updated check
This commit is contained in:
parent
3472d2d032
commit
3a1d366474
@ -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
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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;index<file.length()+3;index++){
|
||||
fileToCheck[index-36]= (char) fileReader.read();
|
||||
}
|
||||
fileNameToString= String.copyValueOf(fileToCheck);
|
||||
File fileToCheck1 = new File(fileNameToString);
|
||||
fileReader.close();
|
||||
byte[] bytedirectoryToSave = new byte[(int) fileToCheck.length] ;
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
for ( int index1 = 0 ;index1< fileNameToString.length();index1++)
|
||||
{
|
||||
bytedirectoryToSave[index1] = (byte) fileInputStream.read();
|
||||
}
|
||||
|
||||
|
||||
byte[] hash = null;
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
||||
hash = messageDigest.digest(bytedirectoryToSave);
|
||||
if (messageDigest.isEqual(hash, md5byte)){
|
||||
System.out.println("gagné");}
|
||||
else {
|
||||
System.out.println("Perdu");
|
||||
}
|
||||
final void check() throws IOException, NoSuchAlgorithmException
|
||||
{
|
||||
File file = new File(this.textField.getText());
|
||||
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; index < (file.length() + 3); index++)
|
||||
{
|
||||
fileToCheck[index - 36] = (char) fileReader.read();
|
||||
}
|
||||
fileNameToString = String.copyValueOf(fileToCheck);
|
||||
fileReader.close();
|
||||
byte[] bytedirectoryToSave = new byte[fileToCheck.length];
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
for (int index1 = 0; index1 < fileNameToString.length(); index1++)
|
||||
{
|
||||
bytedirectoryToSave[index1] = (byte) fileInputStream.read();
|
||||
}
|
||||
fileInputStream.close();
|
||||
byte[] hash = null;
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
||||
hash = messageDigest.digest(bytedirectoryToSave);
|
||||
if (MessageDigest.isEqual(hash, md5byte))
|
||||
{
|
||||
System.out.println("gagné");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Perdu");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
final void repertoireChoisi() throws IOException, NoSuchAlgorithmException
|
||||
{
|
||||
final JFileChooser fc = new JFileChooser();
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichiers md5", "md5");
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
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();
|
||||
this.textField.setText(file.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import javax.swing.JPopupMenu;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.Dimension;
|
||||
|
||||
|
||||
public class SibaGUI
|
||||
@ -60,6 +61,7 @@ public class SibaGUI
|
||||
private void initialize()
|
||||
{
|
||||
frmSimpleBackup = new JFrame();
|
||||
frmSimpleBackup.setMinimumSize(new Dimension(600, 400));
|
||||
frmSimpleBackup.getContentPane().setBackground(new Color(173, 255, 47));
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
|
@ -1,12 +1,13 @@
|
||||
#Field ResourceBundle: BUNDLE
|
||||
#Mon Apr 04 22:42:06 CEST 2016
|
||||
#Thu Apr 07 21:33:48 CEST 2016
|
||||
BackupPanel.btnNewButton.text=\u2026
|
||||
BackupPanel.btnNewButton_1.text=\u2026
|
||||
BackupPanel.btnNewButton_2.text=Backup
|
||||
BackupPanel.lblLeRepertoire.text=- le repertoire \u00E0 compresser
|
||||
BackupPanel.lblNewLabel.text=Source Directory\:
|
||||
BackupPanel.lblNewLabel_1.text=Date Format
|
||||
BackupPanel.lblNewLabel_2.text=Choisissez \:
|
||||
BackupPanel.lblNewLabel_2.text=<html>Choisissez \:<br/>\nblabla<br/>\n</html>
|
||||
BackupPanel.lblRpertoireDeDestination.text=Target Directory\:
|
||||
BackupPanel.rdbtnNewRadioButton.text=(iso8601) YYYY-MM-dd
|
||||
BackupPanel.rdbtnNewRadioButton_1.text=Human
|
||||
BackupPanel.targetFileChooserButton.text=Target Directory
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user