1 package osm.jp.gpx.matchtime.gui;
3 import java.awt.event.ActionEvent;
4 import java.awt.event.ActionListener;
7 import javax.swing.JButton;
8 import javax.swing.JCheckBox;
9 import javax.swing.JFileChooser;
10 import osm.jp.gpx.AppParameters;
12 @SuppressWarnings("serial")
13 public class ParameterPanelGpx extends ParameterPanel implements ActionListener
17 public JCheckBox noFirstNode; // CheckBox: "セグメント'trkseg'の最初の1ノードは無視する。"
18 public JCheckBox gpxReuse; // CheckBox: "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする"
25 @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
26 public ParameterPanelGpx(String label, String text) {
30 selectButton = new JButton(
31 i18n.getString("button.select"),
32 AdjustTime.createImageIcon("images/Open16.gif")
34 selectButton.addActionListener(this);
35 this.add(selectButton);
39 public void actionPerformed(ActionEvent e) {
40 if (e.getSource() == selectButton){
41 System.out.println("ParameterPanelGpx.actionPerformed(openButton)");
42 File sdir = new File(this.argField.getText());
44 this.fc = new JFileChooser(sdir);
47 this.fc = new JFileChooser();
49 this.fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
50 this.fc.addChoosableFileFilter(new GpxAndFolderFilter());
51 this.fc.setAcceptAllFileFilterUsed(false);
53 int returnVal = this.fc.showOpenDialog(ParameterPanelGpx.this);
55 if (returnVal == JFileChooser.APPROVE_OPTION) {
56 File file = this.fc.getSelectedFile();
57 this.argField.setText(file.getAbsolutePath());
62 public File getGpxFile() {
64 return new File(getText());
70 * "セグメント'trkseg'の最初の1ノードは無視する。"
74 public void addNoFirstNode(String label, AppParameters params) {
75 boolean selected = false;
76 if (params.getProperty(AppParameters.GPX_NO_FIRST_NODE).equals("true")) {
79 noFirstNode = new JCheckBox(label, selected);
82 public boolean isNoFirstNodeSelected() {
83 return (noFirstNode != null) && noFirstNode.isSelected();
87 * "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする"
91 public void addGpxReuse(String label, AppParameters params) {
92 boolean selected = false;
93 if (params.getProperty(AppParameters.GPX_REUSE).equals("true")) {
96 gpxReuse = new JCheckBox(label, selected);
99 public boolean isGpxReuseSelected() {
100 return (gpxReuse != null) && gpxReuse.isSelected();
104 * このフィールドに有効な値が設定されているかどうか
108 public boolean isEnable() {
109 String text = this.argField.getText();
111 File file = new File(text);
114 String name = file.getName().toUpperCase();
115 if (name.endsWith(".GPX")) {
119 else if (file.isDirectory()) {