From: yukihane Date: Fri, 5 Aug 2011 03:55:36 +0000 (+0900) Subject: GUIからコンフィグファイルを直接起動できるよう対応 X-Git-Tag: rel20110805_ver0.9.0~5 X-Git-Url: http://git.osdn.net/view?p=coroid%2FNicoBrowser.git;a=commitdiff_plain;h=c5a8729a673459b597fa03103afce8b0772cfb9b GUIからコンフィグファイルを直接起動できるよう対応 --- diff --git a/src/nicobrowser/config/Config.java b/src/nicobrowser/config/Config.java index 03dd226..5296b85 100644 --- a/src/nicobrowser/config/Config.java +++ b/src/nicobrowser/config/Config.java @@ -25,6 +25,7 @@ public final class Config { private static Log log = LogFactory.getLog(Config.class); private static Config instance; + private final PropertiesConfiguration properties; private static final String APPLICATION_NAME = "nicobrowser"; private static final String CONFIG_NAME = APPLICATION_NAME + ".properties"; @@ -310,6 +311,9 @@ public final class Config { public static File getFeedUrlFile() { return FEEDURL_FILE; } + public static File getMylistConfigFile() { + return MYLIST_CONFIG_FILE; + } public static File getAppHome() { return APP_HOME; diff --git a/src/nicobrowser/gui/config/ConfigFrame.form b/src/nicobrowser/gui/config/ConfigFrame.form index 04c82de..5e49a81 100644 --- a/src/nicobrowser/gui/config/ConfigFrame.form +++ b/src/nicobrowser/gui/config/ConfigFrame.form @@ -78,12 +78,12 @@ - + - + @@ -144,18 +144,24 @@ - + - + + + + - + + + + diff --git a/src/nicobrowser/gui/config/ConfigFrame.java b/src/nicobrowser/gui/config/ConfigFrame.java index 183a0d5..62647a7 100644 --- a/src/nicobrowser/gui/config/ConfigFrame.java +++ b/src/nicobrowser/gui/config/ConfigFrame.java @@ -7,6 +7,9 @@ */ package nicobrowser.gui.config; +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; @@ -24,6 +27,7 @@ import org.apache.commons.io.FilenameUtils; */ public class ConfigFrame extends javax.swing.JFrame { + private static final long serialVersionUID = 1L; private final Config config; /** Creates new form ConfigFrame */ @@ -31,6 +35,7 @@ public class ConfigFrame extends javax.swing.JFrame { initComponents(); configFileField.setText(Config.getConfigfile().getAbsolutePath()); feedFileField.setText(Config.getFeedUrlFile().getAbsolutePath()); + mylistFileField.setText(Config.getMylistConfigFile().getAbsolutePath()); config = Config.getInstance(); // ニコニコ動画アカウント @@ -121,11 +126,21 @@ public class ConfigFrame extends javax.swing.JFrame { mylistFileLabel.setText("マイリスト"); - mylistFileField.setEnabled(false); + mylistFileField.setEditable(false); - feedFileEditButton.setText("編集"); + feedFileEditButton.setText("編集..."); + feedFileEditButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + feedFileEditButtonActionPerformed(evt); + } + }); - mylistFileEditButton.setText("編集"); + mylistFileEditButton.setText("編集..."); + mylistFileEditButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mylistFileEditButtonActionPerformed(evt); + } + }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); @@ -139,11 +154,11 @@ public class ConfigFrame extends javax.swing.JFrame { .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() - .add(mylistFileField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE) + .add(mylistFileField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(mylistFileEditButton)) .add(jPanel1Layout.createSequentialGroup() - .add(feedFileField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE) + .add(feedFileField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(feedFileEditButton)) .add(configFileField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE))) @@ -424,12 +439,30 @@ public class ConfigFrame extends javax.swing.JFrame { try { config.updateConfigFile(p); JOptionPane.showMessageDialog(this, Config.getConfigfile().getAbsolutePath() + "\nを更新しました"); - } catch (ConfigurationException ex){ + } catch (ConfigurationException ex) { Logger.getLogger(ConfigFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(this, "保存に失敗しました", "エラー", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_savaButtonActionPerformed + private void feedFileEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_feedFileEditButtonActionPerformed + editConfigFile(Config.getFeedUrlFile()); + }//GEN-LAST:event_feedFileEditButtonActionPerformed + + private void mylistFileEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mylistFileEditButtonActionPerformed + editConfigFile(Config.getMylistConfigFile()); + }//GEN-LAST:event_mylistFileEditButtonActionPerformed + + private void editConfigFile(File file) { + Desktop d = Desktop.getDesktop(); + try { + d.edit(file); + } catch (IOException ex) { + Logger.getLogger(ConfigFrame.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE); + } + } + private void setPathField(JTextField field) { String current = field.getText(); JFileChooser fc = new JFileChooser(current);