OSDN Git Service

入力パネルの起動時の初期状態
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / MainFrame.java
index 8ea8227..0fc7e92 100644 (file)
@@ -7,6 +7,7 @@ package yukihane.inqubus.gui;
 
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.Transferable;
+import java.awt.event.ItemEvent;
 import java.io.File;
 import java.util.Collection;
 import java.util.List;
@@ -15,6 +16,7 @@ import java.util.regex.Pattern;
 import javax.swing.TransferHandler;
 import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
+import org.apache.commons.io.FilenameUtils;
 import yukihane.inqubus.conifg.Properties;
 import yukihane.inqubus.model.Target;
 import yukihane.inqubus.model.TargetsTableModel;
@@ -119,18 +121,33 @@ public class MainFrame extends javax.swing.JFrame {
         movieLabel.setText("動画");
 
         useMovieLocalCheckBox.setText("local");
+        useMovieLocalCheckBox.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                useMovieLocalCheckBoxItemStateChanged(evt);
+            }
+        });
 
         movieFileSelectButton.setText("...");
 
         commentLabel.setText("コメント");
 
         useCommentLocalCheckBox.setText("local");
+        useCommentLocalCheckBox.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                useCommentLocalCheckBoxItemStateChanged(evt);
+            }
+        });
 
         commentFileSelectButton.setText("...");
 
         outputLabel.setText("出力");
 
         outputConvertCheckBox.setText("変換");
+        outputConvertCheckBox.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                outputConvertCheckBoxItemStateChanged(evt);
+            }
+        });
 
         outputFileSelectButton.setText("...");
 
@@ -187,11 +204,10 @@ public class MainFrame extends javax.swing.JFrame {
                     .addComponent(movieFileSelectButton)
                     .addComponent(useMovieLocalCheckBox))
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                        .addComponent(commentLabel)
-                        .addComponent(commentFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                        .addComponent(commentFileSelectButton))
+                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(commentLabel)
+                    .addComponent(commentFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(commentFileSelectButton)
                     .addComponent(useCommentLocalCheckBox))
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -250,6 +266,22 @@ public class MainFrame extends javax.swing.JFrame {
         pack();
     }// </editor-fold>//GEN-END:initComponents
 
+private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
+    final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
+    movieFileSelectButton.setEnabled(useLocal);
+}//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
+
+private void useCommentLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useCommentLocalCheckBoxItemStateChanged
+    final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
+    commentFileSelectButton.setEnabled(useLocal);
+}//GEN-LAST:event_useCommentLocalCheckBoxItemStateChanged
+
+private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
+    final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
+    outputFileField.setEnabled(convert);
+    outputFileSelectButton.setEnabled(convert);
+}//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
+
     /**
      * @param args the command line arguments
      */
@@ -304,7 +336,24 @@ public class MainFrame extends javax.swing.JFrame {
     // End of variables declaration//GEN-END:variables
 
     private void initInputPanel() {
-//        Properties.INSTANCE.getUseMovieFileLocal();
+        idField.setText("");
+
+        final Properties p = Properties.INSTANCE;
+
+        final boolean movieLocal = p.getUseMovieFileLocal();
+        useMovieLocalCheckBox.setSelected(movieLocal);
+        movieFileSelectButton.setEnabled(movieLocal);
+
+        final boolean commentLocal = p.getCommentFileLocal();
+        useCommentLocalCheckBox.setSelected(commentLocal);
+        commentFileSelectButton.setEnabled(commentLocal);
+
+        final boolean convert = p.getOutputConvert();
+        outputConvertCheckBox.setSelected(convert);
+        outputFileField.setEnabled(convert);
+        outputFileField.setText(p.getOutputFile().toString());
+        outputFileSelectButton.setEnabled(convert);
+
     }
 
     private class DownloadListTransferHandler extends TransferHandler {