1 package osm.surveyor.matchtime.gui;
3 import java.awt.event.ActionEvent;
5 import java.io.FileNotFoundException;
6 import javax.swing.JButton;
7 import javax.swing.JFileChooser;
9 @SuppressWarnings("serial")
10 public class ParameterPanelImageFile extends ParameterPanel {
12 public JButton openButton;
13 public ParameterPanelFolder paramDir;
15 public ParameterPanelImageFile(
16 String label, String text,
17 ParameterPanelFolder paramDir
22 SelectButtonAction buttonAction = new SelectButtonAction();
23 openButton = new JButton(i18n.getString("button.select"));
24 openButton.addActionListener(buttonAction);
27 //Create a file chooser
28 this.paramDir = paramDir;
31 class SelectButtonAction implements java.awt.event.ActionListener
33 public void actionPerformed(ActionEvent e) {
34 selectImage_Action(e);
38 public void selectImage_Action(ActionEvent ev) {
39 File sdir = new File(paramDir.getText());
40 System.out.println(sdir.toPath());
41 if (sdir.isDirectory()) {
42 fc = new JFileChooser(sdir);
45 fc = new JFileChooser();
48 fc.addChoosableFileFilter(new ImageFilter());
49 fc.setAcceptAllFileFilterUsed(false);
50 fc.setFileView(new ImageFileView());
51 fc.setAccessory(new ImagePreview(fc));
54 int returnVal = fc.showDialog(ParameterPanelImageFile.this, i18n.getString("dialog.select"));
55 if (returnVal == JFileChooser.APPROVE_OPTION) {
56 File file = fc.getSelectedFile();
57 this.argField.setText(file.getName());
59 fc.setSelectedFile(null);
62 public File getImageFile() {
63 if (this.paramDir.isEnable()) {
64 String text = this.argField.getText();
67 File dir = this.paramDir.getDirectory();
68 File file = new File(dir, text);
69 if (file.exists() && file.isFile()) {
73 catch (FileNotFoundException e) {
86 public boolean isEnable() {
87 if (this.paramDir.isEnable()) {
88 String text = this.argField.getText();
91 File dir = this.paramDir.getDirectory();
92 File file = new File(dir, text);
93 if (file.exists() && file.isFile()) {
94 String name = file.getName().toUpperCase();
95 if (name.endsWith(".JPG") || name.endsWith(".JPEG")) {
100 catch (FileNotFoundException e) {