From 6a37764ca1e8a88c336999ea46b32c681cbe9638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clermont=C3=A9?= Date: Mon, 6 Jun 2016 19:33:02 +0200 Subject: [PATCH] added method setSourceDirectory in BackupPanel --- src/org/dclermonte/siba/gui/BackupPanel.java | 19 +++++++++++++------ src/org/dclermonte/siba/gui/SibaGUI.java | 9 +++++---- .../dclermonte/siba/model/SibaManager.java | 10 ++++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/org/dclermonte/siba/gui/BackupPanel.java b/src/org/dclermonte/siba/gui/BackupPanel.java index eec6b7c..8a02bec 100644 --- a/src/org/dclermonte/siba/gui/BackupPanel.java +++ b/src/org/dclermonte/siba/gui/BackupPanel.java @@ -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); + } + } diff --git a/src/org/dclermonte/siba/gui/SibaGUI.java b/src/org/dclermonte/siba/gui/SibaGUI.java index 31bd605..a40e05f 100644 --- a/src/org/dclermonte/siba/gui/SibaGUI.java +++ b/src/org/dclermonte/siba/gui/SibaGUI.java @@ -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); diff --git a/src/org/dclermonte/siba/model/SibaManager.java b/src/org/dclermonte/siba/model/SibaManager.java index 2473429..96b6652 100644 --- a/src/org/dclermonte/siba/model/SibaManager.java +++ b/src/org/dclermonte/siba/model/SibaManager.java @@ -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; }