diff --git a/src/org/dclermonte/siba/gui/CheckPanel.java b/src/org/dclermonte/siba/gui/CheckPanel.java index 38a8785..3d931c0 100644 --- a/src/org/dclermonte/siba/gui/CheckPanel.java +++ b/src/org/dclermonte/siba/gui/CheckPanel.java @@ -51,8 +51,8 @@ public class CheckPanel extends JPanel { private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$ private static final long serialVersionUID = -1580485684838045920L; - static File choosenFile; - static JTextField textField; + private JTextField fileToCheckField; + private File choosenFile; /** * This is the constructor for this panel. @@ -78,6 +78,7 @@ public class CheckPanel extends JPanel JButton btnNewButton = new JButton(BUNDLE.getString("CheckPanel.btnNewButton.text")); //$NON-NLS-1$ btnNewButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + File choosenFile; btnNewButton.addActionListener(new ActionListener() { @Override @@ -85,7 +86,7 @@ public class CheckPanel extends JPanel { try { - CheckPanel.choosenFile = choosenDirectory(); + CheckPanel.this.choosenFile = choosenDirectory(); } catch (IOException e1) @@ -101,9 +102,9 @@ public class CheckPanel extends JPanel } }); - CheckPanel.textField = new JTextField(); - add(CheckPanel.textField, "3, 2, fill, default"); - CheckPanel.textField.setColumns(10); + this.fileToCheckField = new JTextField(); + add(this.fileToCheckField, "3, 2, fill, default"); + this.fileToCheckField.setColumns(10); add(btnNewButton, "4, 2, left, top"); JButton btnNewButton_1 = new JButton(BUNDLE.getString("CheckPanel.btnNewButton_1.text")); //$NON-NLS-1$ @@ -115,20 +116,21 @@ public class CheckPanel extends JPanel { try { - if ((CheckPanel.choosenFile != null) && CheckPanel.choosenFile.exists()) + File choosenFile = CheckPanel.this.choosenFile; + if ((choosenFile != null) && choosenFile.exists()) { - boolean check = SibaManager.check(CheckPanel.choosenFile); + boolean check = SibaManager.check(choosenFile); String titre = BUNDLE.getString("CheckPanel.confirmDialogTitle.text"); if (check) { String message = String.format(BUNDLE.getString("CheckPanel.confirmDialogGood.text"), - CheckPanel.choosenFile.getName()); + choosenFile.getName()); JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE); } else { String message = String.format(BUNDLE.getString("CheckPanel.confirmDialogBad.text"), - CheckPanel.choosenFile.getName()); + choosenFile.getName()); JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE); } } @@ -139,11 +141,13 @@ public class CheckPanel extends JPanel JOptionPane.showMessageDialog(null, dataMissing, titleWarning, JOptionPane.INFORMATION_MESSAGE); } } + catch (SibaException exception) { // TODO Auto-generated catch block exception.printStackTrace(); } + } }); add(btnNewButton_1, "3, 4"); @@ -153,11 +157,11 @@ public class CheckPanel extends JPanel { File result; - CheckPanel.choosenFile = CheckDirectorySelector.showSelectorDialog(null, null); - if ((CheckPanel.choosenFile != null) && CheckPanel.choosenFile.exists()) + File choosenFile = CheckDirectorySelector.showSelectorDialog(null, null); + if ((choosenFile != null) && choosenFile.exists()) { - CheckPanel.textField.setText(CheckPanel.choosenFile.getName()); - result = CheckPanel.choosenFile; + this.fileToCheckField.setText(choosenFile.getName()); + result = choosenFile; } else { @@ -165,4 +169,9 @@ public class CheckPanel extends JPanel } return result; } + + public void setFileToCheck(final String sourceDirectory) + { + this.fileToCheckField.setText(sourceDirectory); + } } diff --git a/src/org/dclermonte/siba/gui/SibaGUI.java b/src/org/dclermonte/siba/gui/SibaGUI.java index 1439b3c..3d35b7a 100644 --- a/src/org/dclermonte/siba/gui/SibaGUI.java +++ b/src/org/dclermonte/siba/gui/SibaGUI.java @@ -69,6 +69,7 @@ public class SibaGUI JFrame frmSimpleBackup; private BackupPanel backupPanel; + private CheckPanel checkPanel; /** * This is the constructor of this application. @@ -221,10 +222,10 @@ public class SibaGUI public void actionPerformed(final ActionEvent e) { tabbedPane.setSelectedIndex(1); - CheckPanel.choosenFile = CheckDirectorySelector.showSelectorDialog(null, null); - if ((CheckPanel.choosenFile != null) && CheckPanel.choosenFile.exists()) + File choosenFile = CheckDirectorySelector.showSelectorDialog(null, null); + if ((choosenFile != null) && choosenFile.exists()) { - CheckPanel.textField.setText(CheckPanel.choosenFile.getName()); + SibaGUI.this.checkPanel.setFileToCheck(choosenFile.getName()); } else {