OSDN Git Service

fixed: Restampからダイアログが表示できない
authorhaya4 <hayashi.yuu@gmail.com>
Mon, 14 Oct 2019 03:31:03 +0000 (12:31 +0900)
committerhaya4 <hayashi.yuu@gmail.com>
Mon, 14 Oct 2019 03:31:03 +0000 (12:31 +0900)
src/i18n.properties
src/i18n_ja_JP.properties
src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java
src/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java
src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java

index 7bdf409..9603e80 100644 (file)
@@ -13,6 +13,7 @@ button.previous=Previous
 button.execute=Execute
 button.select=Selection...
 button.update=Update...
+button.reset=Reset...
 
 tab.100=1. Source image Folder
 label.100=<html><p>1. Select image source folder.</p><ul><li>If you perform a copy operation, the file update time may be rewritten to the time the copy was executed. It is recommended to directly specify the folder in the camera SD card.</li></ul>
index e0cb33c..e5c58c1 100644 (file)
@@ -13,6 +13,7 @@ button.previous=\u623b\u308b
 button.execute=\u51e6\u7406\u5b9f\u884c
 button.select=\u9078\u629e...
 button.update=\u5909\u66f4...
+button.reset=\u518d\u8a2d\u5b9a...
 
 tab.100=1. \u753b\u50cf\u5143\u306e\u30d5\u30a1\u30a4\u30eb\u30d5\u30a9\u30eb\u30c0
 label.100=<html><p>1. \u4f4d\u7f6e\u60c5\u5831\u3092\u4ed8\u52a0\u3057\u305f\u3044\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002</p><ul><li>\u30b3\u30d4\u30fc\u52d5\u4f5c\u3092\u884c\u3046\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u66f4\u65b0\u6642\u523b\u304c\u30b3\u30d4\u30fc\u3092\u5b9f\u884c\u3057\u305f\u6642\u523b\u306b\u66f8\u304d\u63db\u308f\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u30ab\u30e1\u30e9SD\u30ab\u30fc\u30c9\u5185\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u76f4\u63a5\u6307\u5b9a\u3059\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002</li></ul>
index 100db25..28cbabf 100644 (file)
@@ -2,8 +2,10 @@ package osm.jp.gpx.matchtime.gui;
 
 import java.awt.Dialog;
 import java.awt.event.ActionEvent;
+import java.io.File;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import javax.swing.JButton;
 import osm.jp.gpx.matchtime.gui.restamp.DialogCorectTime;
 
@@ -12,9 +14,11 @@ import osm.jp.gpx.matchtime.gui.restamp.DialogCorectTime;
  * この1インスタンスで、1パラメータをあらわす。
  */
 public class ParameterPanelTime extends ParameterPanel {
+    static final String TIME_PATTERN = "yyyy.MM.dd HH:mm:ss z";
     SimpleDateFormat sdf = (SimpleDateFormat)DateFormat.getDateTimeInstance();
     ParameterPanelImageFile imageFile;
     public JButton updateButton;
+    public JButton resetButton;
     Dialog owner;
 
     @SuppressWarnings("OverridableMethodCallInConstructor")
@@ -31,12 +35,19 @@ public class ParameterPanelTime extends ParameterPanel {
         updateButton = new JButton(i18n.getString("button.update"));
         updateButton.addActionListener(buttonAction);
         this.add(updateButton);
+        
+        // "ボタン[再設定...]"
+        ResetButtonAction resetAction = new ResetButtonAction(this);
+        resetButton = new JButton(i18n.getString("button.reset"));
+        resetButton.addActionListener(resetAction);
+        resetButton.setVisible(false);
+        this.add(resetButton);
     }
     
     public ParameterPanelTime setOwner(Dialog owner) {
         this.owner = owner;
         return this;
-    } 
+    }
     
     /**
      * ボタンのアクション
@@ -55,6 +66,31 @@ public class ParameterPanelTime extends ParameterPanel {
         }
     }
     
+    /**
+     * ボタンのアクション
+     */
+    class ResetButtonAction implements java.awt.event.ActionListener
+    {
+        ParameterPanelTime param;
+        
+        public ResetButtonAction(ParameterPanelTime param) {
+            this.param = param;
+        }
+        
+        @SuppressWarnings("override")
+        public void actionPerformed(ActionEvent e) {
+            if (param.imageFile.isEnable()) {
+                File file = param.imageFile.getImageFile();
+                long lastModified = file.lastModified();
+                sdf.applyPattern(TIME_PATTERN);
+                param.argField.setText(sdf.format(new Date(lastModified)));
+            }
+            else {
+                param.argField.setText("");
+            }
+        }
+    }
+    
     public ParameterPanelImageFile getImageFile() {
         return this.imageFile;
     }
@@ -65,7 +101,7 @@ public class ParameterPanelTime extends ParameterPanel {
             String text = this.argField.getText();
             if (text != null) {
                 try {
-                    sdf.applyPattern("yyyy.MM.dd HH:mm:ss z");
+                    sdf.applyPattern(TIME_PATTERN);
                     sdf.parse(text);
                     return true;
                 }
index 95f107c..d66443c 100644 (file)
@@ -3,6 +3,7 @@ package osm.jp.gpx.matchtime.gui.restamp;
 import java.awt.BorderLayout;
 import java.awt.Dialog;
 import java.awt.GridLayout;
+import java.awt.Rectangle;
 import javax.swing.BoxLayout;
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -21,8 +22,9 @@ import osm.jp.gpx.matchtime.gui.ParameterPanelTime;
  */
 public class DialogCorectTime extends JDialog implements PanelAction {
     public JPanel mainPanel;
-    JPanel argsPanel;          // パラメータ設定パネル       (上部)
     ParameterPanelTime arg_basetime;   // 開始画像の基準時刻:
+    ParameterPanelTime basetime;       // 開始画像の基準時刻:
+    java.awt.Button closeButton;
     
     /**
      * コンストラクタ
@@ -31,33 +33,48 @@ public class DialogCorectTime extends JDialog implements PanelAction {
      */
     public DialogCorectTime(ParameterPanelTime arg3_basetime, Dialog owner) {
         super(owner, AdjustTime.i18n.getString("tab.restamp.300"), false);
+        this.arg_basetime = arg3_basetime;
         
-        argsPanel = new JPanel();
-        argsPanel.setLayout(new GridLayout(2, 1));
-        
+        // INIT_CONTROLS
+        setLayout(new BorderLayout());
+        setSize(
+            getInsets().left + getInsets().right + 720,
+            getInsets().top + getInsets().bottom + 480
+        );
+
         //---- CENTER -----
         JPanel centerPanel = new JPanel();
         centerPanel.setLayout(new BorderLayout());
         add(centerPanel, BorderLayout.CENTER);
 
+        //---- CENTER.NORTH -----
+        JPanel argsPanel;              // パラメータ設定パネル       (上部)
+        argsPanel = new JPanel();
+        argsPanel.setLayout(new GridLayout(2, 1));
+        
         // 3. 正確な撮影時刻を入力してください。
         //    カメラの時計が正確ならば、設定を変更する必要はありません。
         JLabel label3 = new JLabel();
         label3.setText(i18n.getString("label.300"));
         argsPanel.add(label3);
 
-        // 基準時刻:
-        this.arg_basetime = arg3_basetime;
-        //arg3_basetime.setLabel(String.format("  %s: ", i18n.getString("label.310")));
-        //arg3_basetime.setLabel(ImportPicture.TIME_FORMAT_STRING);
-        //argsPanel.add(arg3_basetime);
-        //centerPanel.add(argsPanel, BorderLayout.NORTH);
+        basetime = new ParameterPanelTime(
+                arg3_basetime.argLabel.getText(),
+                "",
+                arg3_basetime.getImageFile()
+        );
+        basetime.updateButton.setVisible(false);
+        basetime.resetButton.setVisible(true);
+        argsPanel.add(basetime);
+        centerPanel.add(argsPanel, BorderLayout.NORTH);
 
+        //---- CENTER.CENTER -----
         // 参考画像
         JLabel imageLabel = new JLabel();
         JScrollPane imageSPane = new JScrollPane(imageLabel);
         centerPanel.add(imageSPane, BorderLayout.CENTER);
 
+        //---- CENTER.SOUTH -----
         // 画像ファイル選択ダイアログを起動するボタン
         JPanel buttonPanel = new JPanel();
         buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
@@ -68,6 +85,61 @@ public class DialogCorectTime extends JDialog implements PanelAction {
         JButton zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif"));
         buttonPanel.add(zoomOutButton);
         centerPanel.add(buttonPanel, BorderLayout.SOUTH);
+        
+        //---- SOUTH -----
+        closeButton = new java.awt.Button();
+        closeButton.setLabel(i18n.getString("button.close") );
+        closeButton.setBounds(145,65,66,27);
+        add(closeButton, BorderLayout.SOUTH);
+
+        //{{REGISTER_LISTENERS
+        SymWindow aSymWindow = new SymWindow();
+        this.addWindowListener(aSymWindow);
+        SymAction lSymAction = new SymAction();
+        closeButton.addActionListener(lSymAction);
+        //}}
+    }
+    
+    class SymWindow extends java.awt.event.WindowAdapter
+    {
+        @Override
+        public void windowClosing(java.awt.event.WindowEvent event) {
+            Object object = event.getSource();
+            if (object == DialogCorectTime.this) {
+                dialog_WindowClosing();
+            }
+        }
+    }
+    
+    class SymAction implements java.awt.event.ActionListener
+    {
+        @Override
+        public void actionPerformed(java.awt.event.ActionEvent event) {
+            Object object = event.getSource();
+            if (object == closeButton) {
+                dialog_WindowClosing();
+            }
+        }
+    }
+
+    /**
+     * ダイアログが閉じられるときのアクション
+     */
+    void dialog_WindowClosing() {
+        String workStr = basetime.getText();
+        arg_basetime.setText(workStr);
+        dispose();
+    }
+
+    @Override
+    public void setVisible(boolean b) {
+        if(b) {
+            Rectangle bounds = getParent().getBounds();
+            Rectangle abounds = getBounds();
+            setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
+            bounds.y + (bounds.height - abounds.height)/2);
+        }
+        super.setVisible(b);
     }
 
     @Override
index bc72d08..81640aa 100644 (file)
@@ -57,7 +57,7 @@ public class RestampDialog extends Dialog implements Observer
         public void windowClosing(java.awt.event.WindowEvent event) {
             Object object = event.getSource();
             if (object == RestampDialog.this) {
-                AboutDialog_WindowClosing(event);
+                dispose();
             }
         }
     }
@@ -68,7 +68,7 @@ public class RestampDialog extends Dialog implements Observer
         public void actionPerformed(java.awt.event.ActionEvent event) {
             Object object = event.getSource();
             if (object == closeButton) {
-                closeButton_Clicked(event);
+                dispose();
             }
             else if (object == arg2_baseTimeImg.argField) {
                imageView_Action(event);
@@ -259,17 +259,6 @@ public class RestampDialog extends Dialog implements Observer
         super.setVisible(b);
     }
 
-    void AboutDialog_WindowClosing(java.awt.event.WindowEvent event) {
-        dispose();
-    }
-
-    void closeButton_Clicked(java.awt.event.ActionEvent event) {
-        //{{CONNECTION
-        // Clicked from okButton Hide the Dialog
-        dispose();
-        //}}
-    }
-    
     ImageIcon refImage;
 
     /**