From 3a1d3664749ac21e1003b37c59e0abe9188bad50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clermont=C3=A9?= Date: Sat, 9 Apr 2016 11:33:15 +0200 Subject: [PATCH] updated check --- .settings/org.eclipse.jdt.core.prefs | 4 +- .settings/org.eclipse.jdt.ui.prefs | 61 +++++- src/org/dclermonte/siba/gui/BackupPanel.java | 5 +- src/org/dclermonte/siba/gui/CheckPanel.java | 197 +++++++++++------- src/org/dclermonte/siba/gui/SibaGUI.java | 2 + .../dclermonte/siba/gui/messages.properties | 5 +- .../siba/gui/messages_fr_FR.properties | 3 +- 7 files changed, 193 insertions(+), 84 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 34ce075..939eb9a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -59,7 +59,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=false org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true @@ -89,7 +89,7 @@ org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs index 55229af..4559912 100644 --- a/.settings/org.eclipse.jdt.ui.prefs +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -58,5 +58,64 @@ cleanup.use_type_arguments=false cleanup_profile=org.eclipse.jdt.ui.default.eclipse_clean_up_profile cleanup_settings_version=2 eclipse.preferences.version=1 -formatter_profile=_Didier +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Siba formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=true +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=true +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=true +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false diff --git a/src/org/dclermonte/siba/gui/BackupPanel.java b/src/org/dclermonte/siba/gui/BackupPanel.java index ae20045..7d7691f 100644 --- a/src/org/dclermonte/siba/gui/BackupPanel.java +++ b/src/org/dclermonte/siba/gui/BackupPanel.java @@ -64,7 +64,8 @@ public class BackupPanel extends JPanel FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, - FormSpecs.DEFAULT_COLSPEC,}, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC,}, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, @@ -91,7 +92,7 @@ public class BackupPanel extends JPanel public void mouseClicked(MouseEvent e) { final JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int returnVal = fc.showDialog(BackupPanel.this,"Répertoire à sauvegarder"); + int returnVal = fc.showDialog(BackupPanel.this,BUNDLE.getString("BackupPanel.targetFileChooserButton.text")); if (returnVal == JFileChooser.APPROVE_OPTION){ File file = fc.getSelectedFile(); textField.setText(file.getPath()); diff --git a/src/org/dclermonte/siba/gui/CheckPanel.java b/src/org/dclermonte/siba/gui/CheckPanel.java index 4a675f8..f83879b 100644 --- a/src/org/dclermonte/siba/gui/CheckPanel.java +++ b/src/org/dclermonte/siba/gui/CheckPanel.java @@ -1,32 +1,36 @@ package org.dclermonte.siba.gui; -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JButton; -import javax.swing.JFileChooser; - +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileFilter; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import com.jgoodies.forms.layout.FormLayout; -import com.jgoodies.forms.layout.ColumnSpec; -import com.jgoodies.forms.layout.FormSpecs; -import com.jgoodies.forms.layout.RowSpec; -import com.jgoodies.forms.layout.Sizes; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.filechooser.FileNameExtensionFilter; +import com.jgoodies.forms.layout.ColumnSpec; +import com.jgoodies.forms.layout.FormLayout; +import com.jgoodies.forms.layout.FormSpecs; +import com.jgoodies.forms.layout.RowSpec; +import com.jgoodies.forms.layout.Sizes; + +/** + * + * @author papa + */ public class CheckPanel extends JPanel { + private static final long serialVersionUID = -1580485684838045920L; private JTextField textField; /** @@ -34,24 +38,29 @@ public class CheckPanel extends JPanel */ public CheckPanel() { - setLayout(new FormLayout(new ColumnSpec[] { - ColumnSpec.decode("2dlu"), - new ColumnSpec(ColumnSpec.LEFT, Sizes.bounded(Sizes.PREFERRED, Sizes.constant("50dlu", true), Sizes.constant("60dlu", true)), 1), - new ColumnSpec(ColumnSpec.LEFT, Sizes.bounded(Sizes.PREFERRED, Sizes.constant("50dlu", true), Sizes.constant("100dlu", true)), 1), - ColumnSpec.decode("30dlu"),}, - new RowSpec[] { - FormSpecs.LINE_GAP_ROWSPEC, - RowSpec.decode("25px"), - FormSpecs.RELATED_GAP_ROWSPEC, - FormSpecs.DEFAULT_ROWSPEC,})); - + setLayout(new FormLayout( + new ColumnSpec[] { ColumnSpec.decode("2dlu"), + new ColumnSpec(ColumnSpec.LEFT, + Sizes.bounded(Sizes.PREFERRED, Sizes.constant("50dlu", true), + Sizes.constant("60dlu", true)), + 1), + new ColumnSpec(ColumnSpec.LEFT, + Sizes.bounded(Sizes.PREFERRED, Sizes.constant("50dlu", true), + Sizes.constant("100dlu", true)), + 1), + ColumnSpec.decode("30dlu"), }, + new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("25px"), FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, })); + JLabel lblNewLabel = new JLabel("Sauvegarde à vérifier"); add(lblNewLabel, "2, 2, left, center"); - + JButton btnNewButton = new JButton("..."); - btnNewButton.addMouseListener(new MouseAdapter() { + btnNewButton.addMouseListener(new MouseAdapter() + { @Override - public void mouseClicked(MouseEvent e) { + public void mouseClicked(final MouseEvent e) + { try { repertoireChoisi(); @@ -68,62 +77,98 @@ public class CheckPanel extends JPanel } } }); - - textField = new JTextField(); - add(textField, "3, 2, fill, default"); - textField.setColumns(10); + + this.textField = new JTextField(); + add(this.textField, "3, 2, fill, default"); + this.textField.setColumns(10); add(btnNewButton, "4, 2, left, top"); - + JButton btnNewButton_1 = new JButton("Check"); + btnNewButton_1.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(final ActionEvent arg0) + { + try + { + check(); + } + catch (NoSuchAlgorithmException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); add(btnNewButton_1, "3, 4"); } - final void repertoireChoisi() throws IOException, NoSuchAlgorithmException { - final JFileChooser fc = new JFileChooser(); - FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichiers md5","md5"); - fc.addChoosableFileFilter(filter); - fc.setFileSelectionMode(JFileChooser.FILES_ONLY); - - int returnVal = fc.showDialog(CheckPanel.this,"Sauvegarde à vérifier"); - if (returnVal == JFileChooser.APPROVE_OPTION){ - File file = fc.getSelectedFile(); - textField.setText(file.getPath()); - FileReader fileReader = new FileReader(file); - char[] md5 = new char[32]; - byte[] md5byte = new byte[32]; - char[] fileToCheck = new char[(int) (file.length())-32]; - for (int index=0;index<32;index++){ - md5[index]= (char) fileReader.read(); - md5byte[index]=(byte) md5[index] ; - } - fileReader.read(); - String fileNameToString = new String(); - for (int index=36;indexChoisissez \:
\nblabla
\n BackupPanel.lblRpertoireDeDestination.text=Target Directory\: BackupPanel.rdbtnNewRadioButton.text=(iso8601) YYYY-MM-dd BackupPanel.rdbtnNewRadioButton_1.text=Human +BackupPanel.targetFileChooserButton.text=Target Directory diff --git a/src/org/dclermonte/siba/gui/messages_fr_FR.properties b/src/org/dclermonte/siba/gui/messages_fr_FR.properties index 41ebf0b..76cfd9f 100644 --- a/src/org/dclermonte/siba/gui/messages_fr_FR.properties +++ b/src/org/dclermonte/siba/gui/messages_fr_FR.properties @@ -1,5 +1,5 @@ #Field ResourceBundle: BUNDLE -#Fri Apr 01 15:52:27 CEST 2016 +#Thu Apr 07 21:33:48 CEST 2016 BackupPanel.btnNewButton.text=\u2026 BackupPanel.btnNewButton_1.text=... BackupPanel.btnNewButton_2.text=Backup @@ -8,3 +8,4 @@ BackupPanel.lblNewLabel_1.text=Date Format BackupPanel.lblRpertoireDeDestination.text=Target Directory\: BackupPanel.rdbtnNewRadioButton.text=(iso8601) YYYY-MM-dd BackupPanel.rdbtnNewRadioButton_1.text=Human +BackupPanel.targetFileChooserButton.text=Target Directory