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
public void actionPerformed(final ActionEvent e)
{
File file = SourceDirectorySelector.showSelectorDialog(null, null);
File file = SourceDirectorySelector.showSelectorDialog(BackupPanel.this, null);
if (file != null)
{
BackupPanel.this.sourceDirectoryField.setText(file.getPath());
@ -129,7 +129,7 @@ public class BackupPanel extends JPanel
public void actionPerformed(final ActionEvent e)
{
File file = TargetDirectorySelector.showSelectorDialog(null, null);
File file = TargetDirectorySelector.showSelectorDialog(BackupPanel.this, null);
if (file != null)
{
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 titre = BUNDLE.getString("BackupPanel.confirmDialogTitle.text");
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(BackupPanel.this, message, titre,
JOptionPane.INFORMATION_MESSAGE);
}
else
{
String dataMissing = BUNDLE.getString("BackupPanel.dataMissing.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");
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)
{
this.sourceDirectoryField.setText(sourceDirectory);

View File

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

View File

@ -35,6 +35,7 @@ import java.io.File;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
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$
public static final Logger logger = LoggerFactory.getLogger(SibaGUI.class);
private JFrame frmSimpleBackup;
/**
* Launch the application.
*/
Locale locale;
private JFrame frmSimpleBackup;
private BackupPanel backupPanel;
private CheckPanel checkPanel;
@ -172,11 +173,14 @@ public class SibaGUI
this.backupPanel = new BackupPanel();
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.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
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.setForeground(new Color(0, 100, 0));
this.frmSimpleBackup.setBackground(new Color(102, 205, 170));

View File

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