• R/O
  • HTTP
  • SSH
  • HTTPS

importpicture: Commit


Commit MetaInfo

Revision86691f9177309d8f93b8bd07aeeafee87206bd48 (tree)
Time2019-10-11 04:02:15
Authorhaya4 <hayashi.yuu@gmai...>
Commiterhaya4

Log Message

fixed: 対象フォルダが入力されたら次のパネルを有効にする

Change Summary

Incremental Difference

--- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java
+++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java
@@ -39,8 +39,7 @@ public class ParameterPanelFolder extends ParameterPanel implements ActionListen
3939 openButton.setEnabled(f);
4040 }
4141
42- public File getDirectory() throws FileNotFoundException {
43- String path = this.argField.getText();
42+ public File getDirectory(String path) throws FileNotFoundException {
4443 if (path == null) {
4544 throw new FileNotFoundException("Image folder is Not specifiyed yet.");
4645 }
@@ -57,9 +56,14 @@ public class ParameterPanelFolder extends ParameterPanel implements ActionListen
5756 @Override
5857 public void actionPerformed(ActionEvent e) {
5958 if (e.getSource() == openButton){
60- try {
6159 System.out.println("ParameterPanelFolder.actionPerformed(openButton)");
62- File sdir = getDirectory();
60+ File sdir;
61+ try {
62+ sdir = getDirectory(this.argField.getText());
63+ } catch (FileNotFoundException ex) {
64+ sdir = new File(".");
65+ this.argField.setText(sdir.getAbsolutePath());
66+ }
6367 if (sdir.exists()) {
6468 this.fc = new JFileChooser(sdir);
6569 }
@@ -74,9 +78,6 @@ public class ParameterPanelFolder extends ParameterPanel implements ActionListen
7478 File file = this.fc.getSelectedFile();
7579 this.argField.setText(file.getAbsolutePath());
7680 }
77- } catch (FileNotFoundException ex) {
78- this.argField.setText(ex.toString());
79- }
8081 }
8182 }
8283
--- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
+++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
@@ -1,65 +1,71 @@
11 package osm.jp.gpx.matchtime.gui;
22
33 import java.awt.event.ActionEvent;
4-import java.awt.event.ActionListener;
54 import java.io.File;
65 import java.io.FileNotFoundException;
76 import javax.swing.JButton;
87 import javax.swing.JFileChooser;
98
109 @SuppressWarnings("serial")
11-public class ParameterPanelImageFile extends ParameterPanel implements ActionListener {
10+public class ParameterPanelImageFile extends ParameterPanel {
1211 JFileChooser fc;
1312 public JButton openButton;
1413 public ParameterPanelFolder paramDir;
1514
1615 @SuppressWarnings("OverridableMethodCallInConstructor")
17- public ParameterPanelImageFile(String label, String text, ParameterPanelFolder paramDir) {
16+ public ParameterPanelImageFile(
17+ String label, String text,
18+ ParameterPanelFolder paramDir
19+ ) {
1820 super(label, text);
1921
2022 // "選択..."
23+ SelectButtonAction buttonAction = new SelectButtonAction();
2124 openButton = new JButton(i18n.getString("button.select"));
22- openButton.addActionListener(this);
25+ openButton.addActionListener(buttonAction);
2326 this.add(openButton);
2427
2528 //Create a file chooser
2629 this.paramDir = paramDir;
2730 }
2831
29- @SuppressWarnings("override")
30- public void actionPerformed(ActionEvent e) {
31- //Set up the file chooser.
32- File sdir = new File(paramDir.getText());
33- System.out.println(sdir.toPath());
34- if (sdir.isDirectory()) {
35- fc = new JFileChooser(sdir);
36- }
37- else {
38- fc = new JFileChooser();
39- }
32+ class SelectButtonAction implements java.awt.event.ActionListener
33+ {
34+ @SuppressWarnings("override")
35+ public void actionPerformed(ActionEvent e) {
36+ //Set up the file chooser.
37+ File sdir = new File(paramDir.getText());
38+ System.out.println(sdir.toPath());
39+ if (sdir.isDirectory()) {
40+ fc = new JFileChooser(sdir);
41+ }
42+ else {
43+ fc = new JFileChooser();
44+ }
4045
41- //Add a custom file filter and disable the default
42- //(Accept All) file filter.
43- fc.addChoosableFileFilter(new ImageFilter());
44- fc.setAcceptAllFileFilterUsed(false);
46+ //Add a custom file filter and disable the default
47+ //(Accept All) file filter.
48+ fc.addChoosableFileFilter(new ImageFilter());
49+ fc.setAcceptAllFileFilterUsed(false);
4550
46- //Add custom icons for file types.
47- fc.setFileView(new ImageFileView());
51+ //Add custom icons for file types.
52+ fc.setFileView(new ImageFileView());
4853
49- //Add the preview pane.
50- fc.setAccessory(new ImagePreview(fc));
54+ //Add the preview pane.
55+ fc.setAccessory(new ImagePreview(fc));
5156
52- //Show it.
53- int returnVal = fc.showDialog(ParameterPanelImageFile.this, "選択");
57+ //Show it.
58+ int returnVal = fc.showDialog(ParameterPanelImageFile.this, "選択");
5459
55- //Process the results.
56- if (returnVal == JFileChooser.APPROVE_OPTION) {
57- File file = fc.getSelectedFile();
58- this.argField.setText(file.getName());
59- }
60+ //Process the results.
61+ if (returnVal == JFileChooser.APPROVE_OPTION) {
62+ File file = fc.getSelectedFile();
63+ argField.setText(file.getName());
64+ }
6065
61- //Reset the file chooser for the next time it's shown.
62- fc.setSelectedFile(null);
66+ //Reset the file chooser for the next time it's shown.
67+ fc.setSelectedFile(null);
68+ }
6369 }
6470
6571 /**
@@ -72,7 +78,7 @@ public class ParameterPanelImageFile extends ParameterPanel implements ActionLis
7278 String text = this.argField.getText();
7379 if (text != null) {
7480 try {
75- File dir = this.paramDir.getDirectory();
81+ File dir = this.paramDir.getDirectory(text);
7682 File file = new File(dir, text);
7783 if (file.exists() && file.isFile()) {
7884 String name = file.getName().toUpperCase();
--- a/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java
+++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java
@@ -1,8 +1,6 @@
11 package osm.jp.gpx.matchtime.gui.restamp;
22
33 import java.awt.BorderLayout;
4-import java.io.File;
5-import java.io.FileNotFoundException;
64 import javax.swing.BoxLayout;
75 import javax.swing.JLabel;
86 import javax.swing.JPanel;
Show on old repository browser