OSDN Git Service

enhance: GPXを選択する際に、GPXファイルのみ表示するように変更
authorhayashi <hayashi.yuu@gmail.com>
Sat, 3 Jun 2017 02:21:32 +0000 (11:21 +0900)
committerhayashi <hayashi.yuu@gmail.com>
Sat, 3 Jun 2017 02:21:32 +0000 (11:21 +0900)
importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java
importPicture/src/osm/jp/gpx/matchtime/gui/GpxAndFolderFilter.java [moved from importPicture/src/osm/jp/gpx/matchtime/gui/GpxFilter.java with 91% similarity]
importPicture/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java [new file with mode: 0644]

index 92327fd..db305d8 100644 (file)
@@ -55,7 +55,7 @@ public class AdjustTime extends JFrame
     JCheckBox gpxOverwriteMagvar;      // ソースGPXの<MAGVAR>を無視する
     JCheckBox gpxOutputSpeed;  // GPXに<SPEED>を書き出す
     ParameterPanelFolder arg5_outputFolder;       // EXIF 書き出しフォルダ
-    ParameterPanelFolder arg4_gpxFolder;       // GPXファイル・フォルダ
+    ParameterPanelGpx arg4_gpxFolder;          // GPXファイル・フォルダ
     
     JPanel buttonPanel;                // ボタンパネル   (下部)
     JButton openButton;                // [Fit]ボタン
@@ -262,7 +262,7 @@ public class AdjustTime extends JFrame
         
         JPanel tmpPanel4a = new JPanel();
         tmpPanel4a.setLayout(new BoxLayout(tmpPanel4a, BoxLayout.Y_AXIS));
-        arg4_gpxFolder = new ParameterPanelFolder("GPXフォルダ: ", params.getProperty(AppParameters.IMG_SOURCE_FOLDER), JFileChooser.FILES_AND_DIRECTORIES);
+        arg4_gpxFolder = new ParameterPanelGpx("GPXフォルダ: ", params.getProperty(AppParameters.GPX_SOURCE_FOLDER));
         tmpPanel4a.add(arg4_gpxFolder);
         noFirstNode = new JCheckBox("<trkseg>セグメントの最初の1ノードは無視する。", params.getProperty(AppParameters.GPX_NO_FIRST_NODE).equals("ON"));
         tmpPanel4a.add(noFirstNode);
@@ -3,7 +3,7 @@ package osm.jp.gpx.matchtime.gui;
 import java.io.File;
 import javax.swing.filechooser.*;
 
-public class GpxFilter extends FileFilter {
+public class GpxAndFolderFilter extends FileFilter {
 
     public boolean accept(File f) {
         if (f.isDirectory()) {
diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java b/importPicture/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java
new file mode 100644 (file)
index 0000000..a2dde05
--- /dev/null
@@ -0,0 +1,50 @@
+package osm.jp.gpx.matchtime.gui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+
+@SuppressWarnings("serial")
+public class ParameterPanelGpx extends ParameterPanel implements ActionListener {
+       JFileChooser fc;
+       JButton openButton;
+
+       public ParameterPanelGpx(String label, String text) {
+               super(label, text);
+
+        openButton = new JButton("選択...", AdjustTime.createImageIcon("images/Open16.gif"));
+        openButton.addActionListener(this);
+        this.add(openButton);
+       }
+
+       public void setEnable(boolean f) {
+               super.setEnabled(f);
+               openButton.setEnabled(f);
+       }
+       
+    public void actionPerformed(ActionEvent e) {
+               if (e.getSource() == openButton){
+                       System.out.println("ParameterPanelGpx.actionPerformed(openButton)");
+                       File sdir = new File(this.argField.getText());
+                       if (sdir.exists()) {
+                       this.fc = new JFileChooser(sdir);
+                       }
+                       else {
+                       this.fc = new JFileChooser();
+                       }
+                       this.fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+               this.fc.addChoosableFileFilter(new GpxAndFolderFilter());
+               this.fc.setAcceptAllFileFilterUsed(false);
+                       
+                       int returnVal = this.fc.showOpenDialog(ParameterPanelGpx.this);
+                       
+                       if (returnVal == JFileChooser.APPROVE_OPTION) {
+                           File file = this.fc.getSelectedFile();
+                           this.argField.setText(file.getAbsolutePath());
+                       }
+               }
+    }
+}