OSDN Git Service

ウィンドウのポジションがマイナスになることは普通にある
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / MainFrame.java
index fe11635..316b2d1 100644 (file)
@@ -41,6 +41,7 @@ import javax.swing.GroupLayout;
 import javax.swing.GroupLayout.Alignment;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
+import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JMenu;
@@ -156,6 +157,8 @@ public class MainFrame extends JFrame {
         cbVideoLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
         fldVideo = new JTextField();
         fldVideo.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
+        btnVideo.addActionListener(
+                new FileChooseAction(MainFrame.this, JFileChooser.FILES_ONLY, fldVideo));
         final JLabel lblComment = new JLabel();
 
         fldBackLog.setToolTipText("YYYY/MM/DD hh:mm:ss形式、あるいは1970/01/01からの経過秒を入力します。");
@@ -191,6 +194,8 @@ public class MainFrame extends JFrame {
         });
         fldComment = new JTextField();
         fldComment.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
+        btnComment.addActionListener(
+                new FileChooseAction(MainFrame.this, JFileChooser.FILES_ONLY, fldComment));
         final JLabel lblOutput = new JLabel();
         cbOutputEnable = new JCheckBox();
         fldOutput = new JTextField();
@@ -320,6 +325,10 @@ public class MainFrame extends JFrame {
                     .addComponent(fldComment, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
                     .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
                 )
+                .addGroup(glInputMain.createParallelGroup()
+                    .addComponent(btnVideo)
+                    .addComponent(btnComment)
+                )
                 .addContainerGap()
             )
         );
@@ -338,13 +347,17 @@ public class MainFrame extends JFrame {
                 .addPreferredGap(ComponentPlacement.RELATED)
                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblVideo)
+                    .addComponent(cbVideoLocal)
                     .addComponent(fldVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                    .addComponent(cbVideoLocal))
+                    .addComponent(btnVideo)
+                )
                 .addPreferredGap(ComponentPlacement.RELATED)
                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblComment)
+                    .addComponent(cbCommentLocal)
                     .addComponent(fldComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                    .addComponent(cbCommentLocal))
+                    .addComponent(btnComment)
+                )
                 .addPreferredGap(ComponentPlacement.RELATED)
                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblOutput)
@@ -480,6 +493,7 @@ public class MainFrame extends JFrame {
         );
 
         pack();
+        setMinimumSize(getSize());
 
         /*
          * 画面のサイズや位置を前回終了時のものに設定する
@@ -490,9 +504,10 @@ public class MainFrame extends JFrame {
             setSize(windowWidth, windowHeight);
         }
 
+        // TODO 最大化した状態で終了した場合の考慮
         final int windowPosX = p.getSystemWindowPosX();
         final int windowPosY = p.getSystemWindowPosY();
-        if (windowPosX > 0 && windowPosY > 0) {
+        if (windowPosX > 1024 && windowPosY > 1024) {
             setLocation(windowPosX, windowPosY);
         } else {
             setLocationByPlatform(true);
@@ -599,18 +614,23 @@ public class MainFrame extends JFrame {
 
         final ItemSelectable source = evt.getItemSelectable();
 
+        JButton button;
         JTextField field;
         File dir;
         if (source == cbVideoLocal) {
+            button = btnVideo;
             field = fldVideo;
             dir = new File(p.getVideoDir());
         } else {
+            button = btnComment;
             field = fldComment;
             dir = new File(p.getCommentDir());
         }
 
         final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
 
+        button.setEnabled(useLocal);
+
         String text;
         if (useLocal) {
             final File f = searchFileMatchId(dir, fldId.getText());
@@ -670,8 +690,10 @@ public class MainFrame extends JFrame {
     private final JTextField fldBackLog = new JTextField();
     private final JCheckBox cbVideoLocal;
     private final JTextField fldVideo;
+    private final JButton btnVideo = new JButton("...");
     private final JCheckBox cbCommentLocal;
     private final JTextField fldComment;
+    private final JButton btnComment = new JButton("...");
     private final JCheckBox cbOutputEnable;
     private final JTextField fldOutput;
     // 入力領域 - ffmpeg
@@ -696,17 +718,19 @@ public class MainFrame extends JFrame {
         fldBackLog.setEnabled(false);
         cbBackLog.setEnabled(true);
 
-        final boolean movieLocal = p.getVideoUseLocal();
-        cbVideoLocal.setSelected(movieLocal);
-        if (!movieLocal) {
+        final boolean videoLocal = p.getVideoUseLocal();
+        cbVideoLocal.setSelected(videoLocal);
+        if (!videoLocal) {
             fldVideo.setText(p.getVideoFileNamePattern());
         }
+        btnVideo.setEnabled(videoLocal);
 
         final boolean commentLocal = p.getCommentUseLocal();
         cbCommentLocal.setSelected(commentLocal);
         if (!commentLocal) {
             fldComment.setText(p.getCommentFileNamePattern());
         }
+        btnComment.setEnabled(commentLocal);
 
         final boolean convert = p.getOutputEnable();
         cbOutputEnable.setSelected(convert);