updated attribute in BackupPanel

This commit is contained in:
Didier Clermonté 2016-06-13 22:00:48 +02:00
parent 4569913079
commit d93cf69dab
5 changed files with 93 additions and 92 deletions

View File

@ -55,9 +55,9 @@ public class BackupPanel extends JPanel
{
private static final long serialVersionUID = 4714383090458639282L;
static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
public JTextField sourceDirectoryField;
private JTextField textField_1;
static private ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
private JTextField sourceDirectoryField;
private JTextField targetDirectoryField;
/**
* This is the constructor for this panel.
@ -69,15 +69,15 @@ public class BackupPanel extends JPanel
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
setLayout(new BorderLayout(0, 0));
JPanel panel_4 = new JPanel();
add(panel_4, BorderLayout.NORTH);
JPanel helpPanel = new JPanel();
add(helpPanel, BorderLayout.NORTH);
JLabel lblNewLabel_2 = new JLabel(BUNDLE.getString("BackupPanel.lblNewLabel_2.text")); //$NON-NLS-1$
panel_4.add(lblNewLabel_2);
helpPanel.add(lblNewLabel_2);
JPanel panel = new JPanel();
add(panel);
panel.setLayout(new FormLayout(
JPanel choosePanel = new JPanel();
add(choosePanel);
choosePanel.setLayout(new FormLayout(
new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
@ -86,12 +86,12 @@ public class BackupPanel extends JPanel
FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));
JLabel lblSourceDirectory = new JLabel(BUNDLE.getString("BackupPanel.lblSourceDirectory.text")); //$NON-NLS-1$
panel.add(lblSourceDirectory, "2, 2");
choosePanel.add(lblSourceDirectory, "2, 2");
lblSourceDirectory.setHorizontalAlignment(SwingConstants.LEFT);
lblSourceDirectory.setVerticalAlignment(SwingConstants.TOP);
this.sourceDirectoryField = new JTextField();
panel.add(this.sourceDirectoryField, "4, 2");
choosePanel.add(this.sourceDirectoryField, "4, 2");
this.sourceDirectoryField.setColumns(10);
JButton btnNewButton = new JButton(BUNDLE.getString("BackupPanel.btnNewButton.text")); //$NON-NLS-1$
@ -110,16 +110,16 @@ public class BackupPanel extends JPanel
}
});
panel.add(btnNewButton, "6, 2");
choosePanel.add(btnNewButton, "6, 2");
JLabel lblTargetDirectory = new JLabel(BUNDLE.getString("BackupPanel.lblTargetDirectory.text")); //$NON-NLS-1$
panel.add(lblTargetDirectory, "2, 4");
choosePanel.add(lblTargetDirectory, "2, 4");
lblTargetDirectory.setVerticalAlignment(SwingConstants.TOP);
lblTargetDirectory.setHorizontalAlignment(SwingConstants.LEFT);
this.textField_1 = new JTextField();
panel.add(this.textField_1, "4, 4");
this.textField_1.setColumns(10);
this.targetDirectoryField = new JTextField();
choosePanel.add(this.targetDirectoryField, "4, 4");
this.targetDirectoryField.setColumns(10);
JButton btnNewButton_1 = new JButton(BUNDLE.getString("BackupPanel.btnNewButton_1.text")); //$NON-NLS-1$
btnNewButton_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@ -132,25 +132,25 @@ public class BackupPanel extends JPanel
File file = TargetDirectorySelector.showSelectorDialog(null, null);
if (file != null)
{
BackupPanel.this.textField_1.setText(file.getPath());
BackupPanel.this.targetDirectoryField.setText(file.getPath());
}
}
});
panel.add(btnNewButton_1, "6, 4");
choosePanel.add(btnNewButton_1, "6, 4");
btnNewButton_1.setHorizontalAlignment(SwingConstants.RIGHT);
JPanel panel_2 = new JPanel();
JPanel actionPanel = new JPanel();
add(panel_2, BorderLayout.SOUTH);
panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.Y_AXIS));
add(actionPanel, BorderLayout.SOUTH);
actionPanel.setLayout(new BoxLayout(actionPanel, BoxLayout.Y_AXIS));
Component verticalStrut_1 = Box.createVerticalStrut(5);
panel_2.add(verticalStrut_1);
actionPanel.add(verticalStrut_1);
JPanel panel_1 = new JPanel();
panel_2.add(panel_1);
actionPanel.add(panel_1);
panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.X_AXIS));
Component horizontalGlue = Box.createHorizontalGlue();
@ -164,7 +164,7 @@ public class BackupPanel extends JPanel
panel_1.add(horizontalGlue_1);
Component verticalStrut = Box.createVerticalStrut(20);
panel_2.add(verticalStrut);
actionPanel.add(verticalStrut);
btnNewButton_2.addActionListener(new ActionListener()
{
@Override
@ -173,7 +173,7 @@ public class BackupPanel extends JPanel
try
{
File directoryToSave1 = new File(BackupPanel.this.sourceDirectoryField.getText());
File targetDirectory = new File(BackupPanel.this.textField_1.getText());
File targetDirectory = new File(BackupPanel.this.targetDirectoryField.getText());
if (directoryToSave1.exists() && targetDirectory.exists())
{
File output1 = SibaManager.backup(directoryToSave1, targetDirectory);

View File

@ -56,7 +56,7 @@ public class CheckDirectorySelector extends JFileChooser
FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichiers md5", "md5");
setAcceptAllFileFilterUsed(false);
addChoosableFileFilter(filter);
setApproveButtonText(BackupPanel.BUNDLE.getString("BackupPanel.checkFileChooserButton.text"));
setApproveButtonText(BUNDLE.getString("BackupPanel.checkFileChooserButton.text"));
setDialogType(CUSTOM_DIALOG);
}

View File

@ -67,7 +67,7 @@ public class SibaGUI
*/
Locale locale;
private JFrame frmSimpleBackup;
JFrame frmSimpleBackup;
private BackupPanel backupPanel;
/**
@ -100,7 +100,8 @@ public class SibaGUI
message = "An error occured: " + exception.getClass() + "(" + exception.getMessage() + ")";
}
JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(SibaGUI.this.frmSimpleBackup, message, "Error",
JOptionPane.ERROR_MESSAGE);
exception.printStackTrace();
}
});

View File

@ -3,11 +3,11 @@ package org.dclermonte.siba.gui;
import java.awt.Color;
import java.awt.Component;
import java.io.File;
import java.util.ResourceBundle;
import javax.swing.JFileChooser;
import org.apache.commons.lang3.StringUtils;
import java.util.ResourceBundle;
/**
*
@ -18,36 +18,6 @@ public class SourceDirectorySelector extends JFileChooser
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
private static final long serialVersionUID = 3782597353602048214L;
/**
* This method is the main one of the selector.
*
* @param parent
* @return
*/
public static File showSelectorDialog(final Component parent, final File targetFile)
{
File result;
//
SourceDirectorySelector selector = new SourceDirectorySelector(targetFile);
//
if (selector.showDialog(parent, null) == JFileChooser.APPROVE_OPTION)
{
//
result = selector.getSelectedFile();
}
else
{
//
result = null;
}
//
return result;
}
/**
*
*/
@ -77,7 +47,7 @@ public class SourceDirectorySelector extends JFileChooser
setDialogTitle(BUNDLE.getString("SourceDirectorySelector.this.dialogTitle")); //$NON-NLS-1$
setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
setAcceptAllFileFilterUsed(false);
setApproveButtonText(BackupPanel.BUNDLE.getString("BackupPanel.sourceFileChooserButton.text"));
setApproveButtonText(BUNDLE.getString("BackupPanel.sourceFileChooserButton.text"));
setDialogType(CUSTOM_DIALOG);
}
@ -131,4 +101,34 @@ public class SourceDirectorySelector extends JFileChooser
resetChoosableFileFilters();
}
}
/**
* This method is the main one of the selector.
*
* @param parent
* @return
*/
public static File showSelectorDialog(final Component parent, final File targetFile)
{
File result;
//
SourceDirectorySelector selector = new SourceDirectorySelector(targetFile);
//
if (selector.showDialog(parent, null) == JFileChooser.APPROVE_OPTION)
{
//
result = selector.getSelectedFile();
}
else
{
//
result = null;
}
//
return result;
}
}

View File

@ -3,11 +3,11 @@ package org.dclermonte.siba.gui;
import java.awt.Color;
import java.awt.Component;
import java.io.File;
import java.util.ResourceBundle;
import javax.swing.JFileChooser;
import org.apache.commons.lang3.StringUtils;
import java.util.ResourceBundle;
/**
*
@ -18,36 +18,6 @@ public class TargetDirectorySelector extends JFileChooser
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
private static final long serialVersionUID = 3782597353602048214L;
/**
* This method is the main one of the selector.
*
* @param parent
* @return
*/
public static File showSelectorDialog(final Component parent, final File targetFile)
{
File result;
//
TargetDirectorySelector selector = new TargetDirectorySelector(targetFile);
//
if (selector.showDialog(parent, null) == JFileChooser.APPROVE_OPTION)
{
//
result = selector.getSelectedFile();
}
else
{
//
result = null;
}
//
return result;
}
/**
*
*/
@ -77,7 +47,7 @@ public class TargetDirectorySelector extends JFileChooser
setDialogTitle(BUNDLE.getString("TargetDirectorySelector.this.dialogTitle")); //$NON-NLS-1$
setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
setAcceptAllFileFilterUsed(false);
setApproveButtonText(BackupPanel.BUNDLE.getString("BackupPanel.targetFileChooserButton.text"));
setApproveButtonText(BUNDLE.getString("BackupPanel.targetFileChooserButton.text"));
setDialogType(CUSTOM_DIALOG);
}
@ -131,4 +101,34 @@ public class TargetDirectorySelector extends JFileChooser
resetChoosableFileFilters();
}
}
/**
* This method is the main one of the selector.
*
* @param parent
* @return
*/
public static File showSelectorDialog(final Component parent, final File targetFile)
{
File result;
//
TargetDirectorySelector selector = new TargetDirectorySelector(targetFile);
//
if (selector.showDialog(parent, null) == JFileChooser.APPROVE_OPTION)
{
//
result = selector.getSelectedFile();
}
else
{
//
result = null;
}
//
return result;
}
}