<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
- <Component id="mylistFileField" pref="331" max="32767" attributes="0"/>
+ <Component id="mylistFileField" pref="325" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="mylistFileEditButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
- <Component id="feedFileField" pref="331" max="32767" attributes="0"/>
+ <Component id="feedFileField" pref="325" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="feedFileEditButton" min="-2" max="-2" attributes="0"/>
</Group>
</Component>
<Component class="javax.swing.JTextField" name="mylistFileField">
<Properties>
- <Property name="enabled" type="boolean" value="false"/>
+ <Property name="editable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="feedFileEditButton">
<Properties>
- <Property name="text" type="java.lang.String" value="編集"/>
+ <Property name="text" type="java.lang.String" value="編集..."/>
</Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="feedFileEditButtonActionPerformed"/>
+ </Events>
</Component>
<Component class="javax.swing.JButton" name="mylistFileEditButton">
<Properties>
- <Property name="text" type="java.lang.String" value="編集"/>
+ <Property name="text" type="java.lang.String" value="編集..."/>
</Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mylistFileEditButtonActionPerformed"/>
+ </Events>
</Component>
</SubComponents>
</Container>
*/
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;
*/
public class ConfigFrame extends javax.swing.JFrame {
+ private static final long serialVersionUID = 1L;
private final Config config;
/** Creates new form ConfigFrame */
initComponents();
configFileField.setText(Config.getConfigfile().getAbsolutePath());
feedFileField.setText(Config.getFeedUrlFile().getAbsolutePath());
+ mylistFileField.setText(Config.getMylistConfigFile().getAbsolutePath());
config = Config.getInstance();
// ニコニコ動画アカウント
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);
.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)))
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);