added method setSourceDirectory in BackupPanel

This commit is contained in:
Didier Clermonté 2016-06-06 19:33:02 +02:00
parent dfa6b2dcf6
commit 6a37764ca1
3 changed files with 22 additions and 16 deletions

View File

@ -61,7 +61,7 @@ public class BackupPanel extends JPanel
*
*/
static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
static JTextField textField;
public JTextField sourceDirectoryField;
private JTextField textField_1;
/**
@ -70,6 +70,7 @@ public class BackupPanel extends JPanel
public BackupPanel() throws SibaException
{
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
setLayout(new BorderLayout(0, 0));
@ -94,9 +95,9 @@ public class BackupPanel extends JPanel
lblSourceDirectory.setHorizontalAlignment(SwingConstants.LEFT);
lblSourceDirectory.setVerticalAlignment(SwingConstants.TOP);
this.textField = new JTextField();
panel.add(this.textField, "4, 2");
this.textField.setColumns(10);
this.sourceDirectoryField = new JTextField();
panel.add(this.sourceDirectoryField, "4, 2");
this.sourceDirectoryField.setColumns(10);
JButton btnNewButton = new JButton(BUNDLE.getString("BackupPanel.btnNewButton.text")); //$NON-NLS-1$
btnNewButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@ -108,10 +109,11 @@ public class BackupPanel extends JPanel
File file = SourceDirectorySelector.showSelectorDialog(null, null);
if (!(file == null))
{
BackupPanel.this.textField.setText(file.getPath());
BackupPanel.this.sourceDirectoryField.setText(file.getPath());
}
}
});
panel.add(btnNewButton, "6, 2");
@ -175,7 +177,7 @@ public class BackupPanel extends JPanel
{
try
{
File directoryToSave1 = new File(BackupPanel.this.textField.getText());
File directoryToSave1 = new File(BackupPanel.this.sourceDirectoryField.getText());
File targetDirectory = new File(BackupPanel.this.textField_1.getText());
if (directoryToSave1.exists() && targetDirectory.exists())
{
@ -210,4 +212,9 @@ public class BackupPanel extends JPanel
}
public void setSourceDirectory(final String sourceDirectory)
{
this.sourceDirectoryField.setText(sourceDirectory);
}
}

View File

@ -69,6 +69,7 @@ public class SibaGUI
Locale locale;
private JFrame frmSimpleBackup;
private JPanel backupPanel;
/**
* This is the constructor of this application.
@ -168,10 +169,10 @@ public class SibaGUI
tabbedPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
this.frmSimpleBackup.getContentPane().add(tabbedPane, BorderLayout.CENTER);
JPanel panel = new BackupPanel();
panel.setBackground(new Color(0, 255, 0));
this.backupPanel = new BackupPanel();
this.backupPanel.setBackground(new Color(0, 255, 0));
String backup = BackupPanel.BUNDLE.getString("BackupPanel.TitleBackupPanel.text");
tabbedPane.addTab(backup, null, panel, null);
tabbedPane.addTab(backup, null, this.backupPanel, null);
JPanel panel_1 = new CheckPanel();
panel_1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
@ -208,7 +209,7 @@ public class SibaGUI
File file = SourceDirectorySelector.showSelectorDialog(null, null);
if (!(file == null))
{
BackupPanel.textField.setText(file.getPath());
((BackupPanel) SibaGUI.this.backupPanel).setSourceDirectory(file.getPath());
}
// panel.setVisible(true);

View File

@ -20,7 +20,6 @@
package org.dclermonte.siba.model;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -109,7 +108,6 @@ public class SibaManager
out.close();
fileWithMD5(result, target + "/" + outputFileNameWithoutExtension + ".tgz.md5");
}
}
catch (IOException ioExceptionBackup)
{
@ -122,7 +120,6 @@ public class SibaManager
finally
{
IOUtils.closeQuietly(out);
IOUtils.closeQuietly(gzipOutputStream);
}
//
@ -167,7 +164,7 @@ public class SibaManager
/**
*
* This method generate ArchiveEntry.
* This method generates ArchiveEntry.
*
* @param directory
* @param outputStream
@ -247,8 +244,8 @@ public class SibaManager
if (choosenFile.exists() && (choosenFile.length() > 32))
{
FileReader fileReader = new FileReader(choosenFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line = bufferedReader.readLine();
// BufferedReader bufferedReader = new BufferedReader(fileReader);
// String line = bufferedReader.readLine();
char[] fileToCheck = new char[(int) (choosenFile.length()) - 32];
fileReader.read();
fileReader.skip(32);
@ -271,6 +268,7 @@ public class SibaManager
}
}
//
return result;
}