Issue#23 Added parent component

This commit is contained in:
Didier Clermonté 2016-06-14 23:23:34 +02:00
parent c01468afd4
commit 35794b0ff1
4 changed files with 31 additions and 15 deletions

View File

@ -101,7 +101,7 @@ public class BackupPanel extends JPanel
@Override @Override
public void actionPerformed(final ActionEvent e) public void actionPerformed(final ActionEvent e)
{ {
File file = SourceDirectorySelector.showSelectorDialog(null, null); File file = SourceDirectorySelector.showSelectorDialog(BackupPanel.this, null);
if (file != null) if (file != null)
{ {
BackupPanel.this.sourceDirectoryField.setText(file.getPath()); BackupPanel.this.sourceDirectoryField.setText(file.getPath());
@ -129,7 +129,7 @@ public class BackupPanel extends JPanel
public void actionPerformed(final ActionEvent e) public void actionPerformed(final ActionEvent e)
{ {
File file = TargetDirectorySelector.showSelectorDialog(null, null); File file = TargetDirectorySelector.showSelectorDialog(BackupPanel.this, null);
if (file != null) if (file != null)
{ {
BackupPanel.this.targetDirectoryField.setText(file.getPath()); BackupPanel.this.targetDirectoryField.setText(file.getPath());
@ -180,13 +180,15 @@ public class BackupPanel extends JPanel
String message = BUNDLE.getString("BackupPanel.confirmDialogMessage.text") + output1.getName(); String message = BUNDLE.getString("BackupPanel.confirmDialogMessage.text") + output1.getName();
String titre = BUNDLE.getString("BackupPanel.confirmDialogTitle.text"); String titre = BUNDLE.getString("BackupPanel.confirmDialogTitle.text");
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(BackupPanel.this, message, titre,
JOptionPane.INFORMATION_MESSAGE);
} }
else else
{ {
String dataMissing = BUNDLE.getString("BackupPanel.dataMissing.text"); String dataMissing = BUNDLE.getString("BackupPanel.dataMissing.text");
String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text"); String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text");
JOptionPane.showMessageDialog(null, dataMissing, titleWarning, JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(BackupPanel.this, dataMissing, titleWarning,
JOptionPane.INFORMATION_MESSAGE);
} }
} }
@ -199,7 +201,8 @@ public class BackupPanel extends JPanel
} }
String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text"); String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text");
JOptionPane.showMessageDialog(null, dataMissing, titleWarning, JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(BackupPanel.this, dataMissing, titleWarning,
JOptionPane.INFORMATION_MESSAGE);
} }
} }
@ -207,6 +210,10 @@ public class BackupPanel extends JPanel
} }
/**
*
* @param sourceDirectory
*/
public void setSourceDirectory(final String sourceDirectory) public void setSourceDirectory(final String sourceDirectory)
{ {
this.sourceDirectoryField.setText(sourceDirectory); this.sourceDirectoryField.setText(sourceDirectory);

View File

@ -125,20 +125,23 @@ public class CheckPanel extends JPanel
{ {
String message = String.format(BUNDLE.getString("CheckPanel.confirmDialogGood.text"), String message = String.format(BUNDLE.getString("CheckPanel.confirmDialogGood.text"),
choosenFile.getName()); choosenFile.getName());
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(CheckPanel.this, message, titre,
JOptionPane.INFORMATION_MESSAGE);
} }
else else
{ {
String message = String.format(BUNDLE.getString("CheckPanel.confirmDialogBad.text"), String message = String.format(BUNDLE.getString("CheckPanel.confirmDialogBad.text"),
choosenFile.getName()); choosenFile.getName());
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(CheckPanel.this, message, titre,
JOptionPane.INFORMATION_MESSAGE);
} }
} }
else else
{ {
String dataMissing = BUNDLE.getString("BackupPanel.dataMissing.text"); String dataMissing = BUNDLE.getString("BackupPanel.dataMissing.text");
String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text"); String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text");
JOptionPane.showMessageDialog(null, dataMissing, titleWarning, JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(CheckPanel.this, dataMissing, titleWarning,
JOptionPane.INFORMATION_MESSAGE);
} }
} }
@ -157,7 +160,7 @@ public class CheckPanel extends JPanel
{ {
File result; File result;
File choosenFile = CheckDirectorySelector.showSelectorDialog(null, null); File choosenFile = CheckDirectorySelector.showSelectorDialog(CheckPanel.this, null);
if ((choosenFile != null) && choosenFile.exists()) if ((choosenFile != null) && choosenFile.exists())
{ {
this.fileToCheckField.setText(choosenFile.getName()); this.fileToCheckField.setText(choosenFile.getName());
@ -170,6 +173,10 @@ public class CheckPanel extends JPanel
return result; return result;
} }
/**
*
* @param sourceDirectory
*/
public void setFileToCheck(final String sourceDirectory) public void setFileToCheck(final String sourceDirectory)
{ {
this.fileToCheckField.setText(sourceDirectory); this.fileToCheckField.setText(sourceDirectory);

View File

@ -35,6 +35,7 @@ import java.io.File;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
@ -62,12 +63,12 @@ public class SibaGUI
{ {
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$ private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
public static final Logger logger = LoggerFactory.getLogger(SibaGUI.class); public static final Logger logger = LoggerFactory.getLogger(SibaGUI.class);
private JFrame frmSimpleBackup;
/** /**
* Launch the application. * Launch the application.
*/ */
Locale locale; Locale locale;
private JFrame frmSimpleBackup;
private BackupPanel backupPanel; private BackupPanel backupPanel;
private CheckPanel checkPanel; private CheckPanel checkPanel;
@ -172,11 +173,14 @@ public class SibaGUI
this.backupPanel = new BackupPanel(); this.backupPanel = new BackupPanel();
this.backupPanel.setBackground(new Color(0, 255, 0)); this.backupPanel.setBackground(new Color(0, 255, 0));
tabbedPane.addTab(BUNDLE.getString("BackupPanel.TitleBackupPanel.text"), null, this.backupPanel, null); //$NON-NLS-1$ tabbedPane.addTab(BUNDLE.getString("BackupPanel.TitleBackupPanel.text"), //$NON-NLS-1$
new ImageIcon(SibaGUI.class.getResource("/org/dclermonte/siba/gui/SibaLogo.png")), this.backupPanel,
null);
CheckPanel checkPanel = new CheckPanel(); CheckPanel checkPanel = new CheckPanel();
checkPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
checkPanel.setBackground(new Color(144, 238, 144)); checkPanel.setBackground(new Color(144, 238, 144));
tabbedPane.addTab(BUNDLE.getString("BackupPanel.TitleCheckPanel.text"), null, checkPanel, null); //$NON-NLS-1$ tabbedPane.addTab(BUNDLE.getString("BackupPanel.TitleCheckPanel.text"), //$NON-NLS-1$
new ImageIcon(SibaGUI.class.getResource("/org/dclermonte/siba/gui/SibaLogo.png")), checkPanel, null);
this.frmSimpleBackup.setFont(new Font("DejaVu Sans", Font.BOLD, 12)); this.frmSimpleBackup.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
this.frmSimpleBackup.setForeground(new Color(0, 100, 0)); this.frmSimpleBackup.setForeground(new Color(0, 100, 0));
this.frmSimpleBackup.setBackground(new Color(102, 205, 170)); this.frmSimpleBackup.setBackground(new Color(102, 205, 170));

View File

@ -165,7 +165,6 @@ public class SibaUtils
{ {
for (File file : directory.listFiles()) for (File file : directory.listFiles())
{ {
if (file.isDirectory()) if (file.isDirectory())
{ {
if (file.listFiles().length == 0) if (file.listFiles().length == 0)
@ -180,7 +179,6 @@ public class SibaUtils
{ {
tarDirectoryTree(file, outputStream, pathLength); tarDirectoryTree(file, outputStream, pathLength);
} }
} }
else else
{ {