Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package IHM;
- import java.awt.Color;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.io.Serializable;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.Vector;
- import java.util.regex.Pattern;
- import javax.swing.GroupLayout;
- import javax.swing.GroupLayout.Alignment;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JCheckBoxMenuItem;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JList;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JSplitPane;
- import javax.swing.JTextPane;
- import javax.swing.LayoutStyle.ComponentPlacement;
- import javax.swing.ListModel;
- import javax.swing.ListSelectionModel;
- import javax.swing.UIManager;
- import javax.swing.filechooser.FileFilter;
- import Fichiers.Enregistrer;
- import Fichiers.Fichier_1;
- import Fichiers.Fichier_2;
- import Fichiers.Fichier_3;
- import Traitement.LSP;
- public class IHM extends JFrame implements Serializable{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- JCheckBox chckbxNewCheckBox;
- Fichier_1 fic1;
- Fichier_2 fic2;
- Fichier_3 fic3;
- int val_fichier3 = 0;
- String file, file2, file3;
- String fichier = "";
- FileFilter filtre_txt;
- // Definition des differentes listes utiles
- ArrayList<String> liste_objet_non_existant= new ArrayList<>();
- ArrayList<String> liste_obj_Doublon = new ArrayList<>();
- ArrayList<String> liste_obj_ecart = new ArrayList<>();
- ArrayList<String> liste_tous_obj = new ArrayList<>();
- ArrayList<String> liste_objet_non_ecart= new ArrayList<>();
- ArrayList<String> liste_objet_3=new ArrayList<>();
- Vector<String> data = new Vector<String>();
- JTextPane textPane, textPane_1;
- JCheckBoxMenuItem chk_btn_debug;
- LSP lsp1, lsp2, lsp3;
- Object item;
- @SuppressWarnings("rawtypes")
- JList list;
- JButton btnCharger, btnEnregistrer, btnSauvegarder;
- JFrame frame;
- // Methode de lecture du fichier
- public String readFile(String file) {
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String ligne;
- StringBuffer fichier = new StringBuffer();
- while((ligne = reader.readLine()) != null){
- fichier.append(ligne);
- fichier.append("\n");
- }
- reader.close();
- return fichier.toString();
- } catch (IOException e) {
- return e.getMessage();
- }
- }
- // Methode de sauvegarde du résultat
- public void saveFile(String contenu, String file) {
- try {
- PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(file)));
- writer.write(contenu);
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public IHM() {
- String fichier = "";
- String fichier2 = "";
- String fichier3 = "";
- frame = new JFrame();
- frame.setBounds(100, 100, 1054, 687);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel panel_button = new JPanel();
- panel_button.setLayout(null);
- JButton button_fic1 = new JButton("Fic.1");
- button_fic1.setBounds(6, 4, 75, 23);
- panel_button.add(button_fic1);
- JButton button_fic2 = new JButton("Fic.2");
- button_fic2.setBounds(74, 4, 75, 23);
- panel_button.add(button_fic2);
- JButton button_fic3 = new JButton("Fic.3");
- button_fic3.setBounds(143, 4, 75, 23);
- panel_button.add(button_fic3);
- JButton button_traiter = new JButton("Traiter");
- button_traiter.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- // Recuperation des chemins des fichiers 1 et 2
- file = fic1.getPath_file();
- file2 = fic2.getPath_file();
- // Si un fichier 3 a ete selectionne
- if( val_fichier3 == 1){
- // Recuperation du chemin du fichier 3
- file3 = fic3.getPath_file();
- lsp3 = new LSP(file3);
- liste_objet_3=lsp3.get_obj_fic3();
- }
- // Traitement
- lsp1 = new LSP(file);
- lsp1.parser();
- lsp2 = new LSP(file2);
- lsp2.parser();
- System.out.println("\nElement manquant\n");
- ArrayList<Traitement.Package> liste_diff_package = lsp1.get_no_existant(lsp2);
- Iterator<Traitement.Package> i = liste_diff_package.iterator();
- while(i.hasNext()){
- Traitement.Package p = i.next();
- if(!liste_objet_non_existant.contains(p.get_nom())){
- liste_objet_non_existant.add(p.get_nom());
- }
- }
- ArrayList<Traitement.Package> liste_diff_package1 = lsp2.get_no_existant(lsp1);
- Iterator<Traitement.Package> i1 = liste_diff_package1.iterator();
- while(i1.hasNext()){
- Traitement.Package p1 = i1.next();
- if(!liste_objet_non_existant.contains(p1.get_nom())){
- liste_objet_non_existant.add(p1.get_nom());
- }
- }
- // Iterator<String> i50 = liste_objet_non_existant.iterator();
- // while(i50.hasNext()){
- // String p50 = i50.next();
- // System.out.println(p50);
- // }
- //DOUBLON
- System.out.println("\nDOUBLON\n");
- ArrayList<String> listeDoublon1=lsp1.get_doublon();
- Iterator<String> i11 = listeDoublon1.iterator();
- while(i11.hasNext()){
- String p11 = i11.next();
- if(!liste_obj_Doublon.contains(p11)){
- liste_obj_Doublon.add(p11);
- }
- }
- //System.out.println(listeDoublon1);
- ArrayList<String> listeDoublon2=lsp2.get_doublon();
- //System.out.println(listeDoublon2);
- Iterator<String> i12 = listeDoublon2.iterator();
- while(i12.hasNext()){
- String p12 = i12.next();
- if(!liste_obj_Doublon.contains(p12)){
- liste_obj_Doublon.add(p12);
- }
- }
- //
- Iterator<String> i13 = liste_obj_Doublon.iterator();
- while(i13.hasNext()){
- String p13 = i13.next();
- System.out.println(p13);
- }
- //
- //
- // //SUPPRESSION DOUBLON
- System.out.println("suppr doublon 1\n");
- lsp1.deleteDoublon();
- System.out.println("suppr doublon 2\n");
- lsp2.deleteDoublon();
- //ELEMENT EN ECART
- System.out.println("\nElement en equart\n");
- ArrayList<Traitement.Package> liste_package_ecart = lsp1.get_obj_ecart(lsp2);
- Iterator<Traitement.Package> i2 = liste_package_ecart.iterator();
- while(i2.hasNext()){
- Traitement.Package p2 = i2.next();
- if(!liste_obj_ecart.contains(p2.get_nom()) && !liste_obj_Doublon.contains(p2.get_nom())){
- liste_obj_ecart.add(p2.get_nom());
- //System.out.println(p2.get_nom());
- }
- }
- ArrayList<Traitement.Package> liste_package_ecart1 = lsp2.get_obj_ecart(lsp1);
- Iterator<Traitement.Package> i3 = liste_package_ecart1.iterator();
- while(i3.hasNext()){
- Traitement.Package p3 = i3.next();
- if(!liste_obj_ecart.contains(p3.get_nom()) && !liste_obj_Doublon.contains(p3.get_nom())){
- liste_obj_ecart.add(p3.get_nom());
- //System.out.println(p3.get_nom());
- }
- }
- //traitement de f3
- if( val_fichier3 == 1){
- System.out.println(fic3.getPath_file());
- //if(fic3.getPath_file() != null){
- Iterator<String> i10 = liste_obj_ecart.iterator();
- while(i10.hasNext()){
- String p10 = i10.next();
- if(liste_objet_3.contains(p10)){
- System.out.println(p10);
- i10.remove();
- }
- }
- }
- System.out.println("\n--\n");
- //liste objet ecart final
- Iterator<String> i15 = liste_obj_ecart.iterator();
- while(i15.hasNext()){
- String p15 = i15.next();
- System.out.println(p15);
- }
- System.out.println("TOUS LES OBJETS\n");
- ArrayList<String> liste_tous_obj1=lsp1.get_liste_objet();
- Iterator<String> i20 = liste_tous_obj1.iterator();
- while(i20.hasNext()){
- String p20 = i20.next();
- if(!liste_tous_obj.contains(p20)){
- liste_tous_obj.add(p20);
- }
- }
- ArrayList<String> liste_tous_obj2=lsp2.get_liste_objet();
- Iterator<String> i21 = liste_tous_obj2.iterator();
- while(i21.hasNext()){
- String p21 = i21.next();
- if(!liste_tous_obj.contains(p21)){
- liste_tous_obj.add(p21);
- }
- }
- //
- // Iterator<String> i22 = liste_tous_obj.iterator();
- // while(i22.hasNext()){
- // String p22 = i22.next();
- //
- // System.out.println(p22);
- //
- // }
- //LISTE OBJET NON ECART
- System.out.println("OBJETS NON ECARTS\n");
- Iterator<String> i30 = liste_tous_obj.iterator();
- while(i30.hasNext()){
- String p30 = i30.next();
- if(!liste_obj_ecart.contains(p30) && !liste_objet_non_existant.contains(p30)){
- liste_objet_non_ecart.add(p30);
- }
- }
- Iterator<String> i40 = liste_objet_non_ecart.iterator();
- while(i40.hasNext()){
- String p40 = i40.next();
- System.out.println(p40);
- }
- JOptionPane.showMessageDialog(null, "Fichiers traités", "Information", JOptionPane.PLAIN_MESSAGE);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- });
- button_traiter.setBounds(212, 4, 91, 23);
- panel_button.add(button_traiter);
- JMenuBar menuBar = new JMenuBar();
- JMenu menu_Fichier = new JMenu("Fichier");
- JMenu menu_Filtre = new JMenu("Filtrer");
- JMenu menu_Outils = new JMenu("Outils");
- JMenu menu_Aide = new JMenu("Aide");
- JMenuItem tous = new JMenuItem("Afficher tous les objets");
- JMenuItem ecart = new JMenuItem("Afficher les objets en écarts");
- JMenuItem non_ecart = new JMenuItem("Afficher les objets non en écarts");
- JMenuItem doublons = new JMenuItem("Afficher les doublons");
- JMenuItem non_existants = new JMenuItem("Afficher les non existants");
- JMenuItem debug = new JMenuItem("Debug");
- JMenuItem informations = new JMenuItem("Informations");
- menu_Filtre.add(tous);
- tous.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- data.clear();
- list.setListData(data);
- Iterator<String> i13 = liste_tous_obj.iterator();
- while(i13.hasNext()){
- String p13 = i13.next();
- //System.out.println(p13);
- data.addElement(""+p13);
- list.setListData(data);
- list.setSelectedIndex(0);
- list.setForeground(new Color(217,38,6));
- }
- }
- });
- menu_Filtre.add(ecart);
- ecart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- data.clear();
- //traitement de f3
- Iterator<String> i10 = liste_obj_ecart.iterator();
- while(i10.hasNext()){
- String p10 = i10.next();
- if(liste_objet_3.contains(p10)){
- //System.out.println(p10);
- liste_obj_ecart.remove(p10);
- }
- }
- //liste objet ecart final
- Iterator<String> i15 = liste_obj_ecart.iterator();
- while(i15.hasNext()){
- @SuppressWarnings("unused")
- String p20 = i15.next();
- //System.out.println(p20);
- }
- list.setListData(data);
- Iterator<String> i13 = liste_obj_ecart.iterator();
- while(i13.hasNext()){
- String p13 = i13.next();
- //System.out.println(p13);
- data.addElement(""+p13);
- list.setListData(data);
- list.setSelectedIndex(0);
- list.setForeground(new Color(217,38,6));
- }
- }
- });
- menu_Filtre.add(non_ecart);
- non_ecart.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- data.clear();
- list.setListData(data);
- Iterator<String> i13 = liste_objet_non_ecart.iterator();
- while(i13.hasNext()){
- String p13 = i13.next();
- //System.out.println(p13);
- data.addElement(""+p13);
- list.setListData(data);
- list.setSelectedIndex(0);
- list.setForeground(new Color(217,38,6));
- }
- }
- });
- menu_Filtre.add(doublons);
- doublons.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- data.clear();
- list.setListData(data);
- Iterator<String> i13 = liste_obj_Doublon.iterator();
- while(i13.hasNext()){
- String p13 = i13.next();
- //System.out.println(p13);
- data.addElement(""+p13);
- list.setListData(data);
- list.setSelectedIndex(0);
- list.setForeground(new Color(217,38,6));
- }
- }
- });
- menu_Filtre.add(non_existants);
- // Existant dans un mais pas l'autre
- non_existants.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- data.clear();
- list.setListData(data);
- Iterator<String> i13 = liste_objet_non_existant.iterator();
- while(i13.hasNext()){
- String p13 = i13.next();
- //System.out.println(p13);
- data.addElement(""+p13);
- list.setListData(data);
- list.setSelectedIndex(0);
- list.setForeground(new Color(217,38,6));
- }
- }
- });
- chk_btn_debug = new JCheckBoxMenuItem("Mode Debug");
- chk_btn_debug.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e) {
- // Etat initial: boutons actifs
- button_fic1.setEnabled(true);
- button_fic2.setEnabled(true);
- button_fic3.setEnabled(true);
- button_traiter.setEnabled(true);
- btnSauvegarder.setEnabled(true);
- btnEnregistrer.setEnabled(true);
- btnCharger.setEnabled(true);
- menuBar.setEnabled(true);
- // Si le bouton est coché
- if(chk_btn_debug.isSelected()){
- // Boutons inactifs
- button_fic1.setEnabled(true);
- button_fic2.setEnabled(true);
- button_fic3.setEnabled(true);
- button_traiter.setEnabled(true);
- btnSauvegarder.setEnabled(true);
- btnEnregistrer.setEnabled(false);
- btnCharger.setEnabled(false);
- menuBar.setEnabled(true);
- }
- }
- });
- menu_Outils.add(chk_btn_debug);
- button_fic1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- fic1 = new Fichier_1(fichier);
- fic1.Chargement_fic1();
- file = fic1.getPath_file();
- textPane.setText("Fichier sélectionné: " +file);
- }
- });
- button_fic2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- fic2 = new Fichier_2(fichier);
- fic2.Chargement_fic2();
- file = fic2.getPath_file();
- textPane_1.setText("Fichier sélectionné: " +file);
- }
- });
- button_fic3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- fic3 = new Fichier_3(fichier3);
- fic3.Chargement_fic3();
- file = fic3.getPath_file();
- val_fichier3 =1;
- //LSP lsp3 = new LSP(fichier3);
- //ArrayList<String> liste_objet_3=lsp3.get_obj_fic3();
- }
- });
- menu_Aide.add(informations);
- informations.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e) {
- Message msg = new Message();
- msg.afficher_msg_info();
- }
- });
- menuBar.add(menu_Fichier);
- JMenu Sous_menu_Ouvrir = new JMenu("Ouvrir");
- menu_Fichier.add(Sous_menu_Ouvrir);
- JMenuItem mntmFichier1 = new JMenuItem("Fichier 1");
- mntmFichier1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Fichier_1 fic1 = new Fichier_1(fichier);
- fic1.Chargement_fic1();
- String file = fic1.getPath_file();
- textPane.setText("Fichier sélectionné: " +file);
- }
- });
- Sous_menu_Ouvrir.add(mntmFichier1);
- JMenuItem mntmFichier2 = new JMenuItem("Fichier 2");
- mntmFichier2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Fichier_2 fic2 = new Fichier_2(fichier2);
- fic2.Chargement_fic2();
- String file = fic2.getPath_file();
- textPane_1.setText("Fichier sélectionné: " +file);
- }
- });
- Sous_menu_Ouvrir.add(mntmFichier2);
- JMenuItem mntmFichier3 = new JMenuItem("Fichier 3");
- mntmFichier3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Fichier_3 fic3 = new Fichier_3(fichier3);
- fic3.Chargement_fic3();
- @SuppressWarnings("unused")
- String file = fic3.getPath_file();
- }
- });
- Sous_menu_Ouvrir.add(mntmFichier3);
- JMenuItem Sous_menu_Sauvegarder = new JMenuItem("Sauvegarder");
- menu_Fichier.add(Sous_menu_Sauvegarder);
- menuBar.add(menu_Filtre);
- menuBar.add(menu_Outils);
- JMenu mnCouleurs = new JMenu("Couleurs");
- menu_Outils.add(mnCouleurs);
- JCheckBoxMenuItem chckbxmntmNewCheckItem = new JCheckBoxMenuItem("Normal");
- chckbxmntmNewCheckItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(UIManager.getColor("Button.background"));
- frame.setBackground(UIManager.getColor("Button.background"));
- }
- });
- mnCouleurs.add(chckbxmntmNewCheckItem);
- JCheckBoxMenuItem chckbxmntmNormal = new JCheckBoxMenuItem("Blanc");
- chckbxmntmNormal.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(new Color(255, 255, 255));
- frame.setBackground(new Color(255, 255, 255));
- }
- });
- mnCouleurs.add(chckbxmntmNormal);
- JCheckBoxMenuItem chckbxmntmBleu = new JCheckBoxMenuItem("Bleu");
- chckbxmntmBleu.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(new Color(30, 144, 255));
- frame.setBackground(new Color(30, 144, 255));
- }
- });
- mnCouleurs.add(chckbxmntmBleu);
- JCheckBoxMenuItem chckbxmntmRouge = new JCheckBoxMenuItem("Rouge");
- chckbxmntmRouge.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(new Color(220, 20, 60));
- frame.setBackground(new Color(220, 20, 60));
- }
- });
- mnCouleurs.add(chckbxmntmRouge);
- JCheckBoxMenuItem chckbxmntmVert = new JCheckBoxMenuItem("Vert");
- chckbxmntmVert.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(new Color(104, 157, 113));
- frame.setBackground(new Color(104, 157, 113));
- }
- });
- mnCouleurs.add(chckbxmntmVert);
- JCheckBoxMenuItem chckbxmntmOrange = new JCheckBoxMenuItem("Orange");
- chckbxmntmOrange.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(new Color(255, 200, 128));
- frame.setBackground(new Color(255, 200, 128));
- }
- });
- mnCouleurs.add(chckbxmntmOrange);
- JCheckBoxMenuItem chckbxmntmGris = new JCheckBoxMenuItem("Gris");
- chckbxmntmGris.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- frame.getContentPane().setBackground(new Color(128, 128, 128));
- frame.setBackground(new Color(128, 128, 128));
- }
- });
- mnCouleurs.add(chckbxmntmGris);
- menuBar.add(menu_Aide);
- JSplitPane splitPane = new JSplitPane();
- splitPane.setResizeWeight(0.5);
- JScrollPane scrollPane_2 = new JScrollPane();
- GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
- groupLayout.setHorizontalGroup(
- groupLayout.createParallelGroup(Alignment.LEADING)
- .addGroup(groupLayout.createSequentialGroup()
- .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
- .addGroup(groupLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(panel_button, GroupLayout.DEFAULT_SIZE, 1044, Short.MAX_VALUE))
- .addComponent(menuBar, GroupLayout.DEFAULT_SIZE, 1050, Short.MAX_VALUE))
- .addGap(4))
- .addGroup(groupLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(scrollPane_2, GroupLayout.PREFERRED_SIZE, 289, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(splitPane, GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
- .addContainerGap())
- );
- groupLayout.setVerticalGroup(
- groupLayout.createParallelGroup(Alignment.LEADING)
- .addGroup(groupLayout.createSequentialGroup()
- .addComponent(menuBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addGap(2)
- .addComponent(panel_button, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
- .addComponent(scrollPane_2, GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
- .addComponent(splitPane, GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE))
- .addContainerGap())
- );
- list = new JList();
- list.setListData(data);
- list.setSelectedIndex(0);
- //ActionJList action = new ActionJList();
- chckbxNewCheckBox = new JCheckBox("Afficher uniquement la différence");
- chckbxNewCheckBox.setBounds(801, 2, 243, 23);
- panel_button.add(chckbxNewCheckBox);
- list.addMouseListener(new MouseListener(){
- @Override
- public void mouseClicked(MouseEvent e) {
- // TODO Auto-generated method stub
- if(e.getClickCount() == 1){
- textPane_1.setText("");
- int index = list.locationToIndex(e.getPoint());
- @SuppressWarnings("rawtypes")
- ListModel dlm = list.getModel();
- String item = (String) dlm.getElementAt(index);
- list.ensureIndexIsVisible(index);
- if(chckbxNewCheckBox.isSelected()){
- ArrayList<String> txt1_val_ecart1=lsp1.get_val_ecart(item);
- ArrayList<String> txt1_val_ecart2=lsp2.get_val_ecart(item);
- textPane.setText("");
- textPane_1.setText("");
- Iterator<String> ite = txt1_val_ecart1.iterator();
- while(ite.hasNext()){
- String str = ite.next();
- textPane.setText(textPane.getText() + str+"\n");
- }
- Iterator<String> ite2 = txt1_val_ecart2.iterator();
- while(ite2.hasNext()){
- String str2 = ite2.next();
- textPane_1.setText(textPane_1.getText() + str2+"\n");
- }
- }else{
- // String txt1_val_ecart1=lsp1.get_val_ecart(item);
- // String txt1_val_ecart2=lsp2.get_val_ecart(item);
- textPane.setText("");
- textPane_1.setText("");
- //recuperer ecarts
- ArrayList<String> txt1_val_ecart1=lsp1.get_val_ecart(item);
- ArrayList<String> txt1_val_ecart2=lsp2.get_val_ecart(item);
- //recuperer balise si ecart sur valeur
- ArrayList<String> txt1_bal_ecart1=lsp2.get_bal_ecart(item);
- ArrayList<String> txt1_bal_ecart2=lsp2.get_bal_ecart(item);
- //pattern ecart
- ArrayList<Pattern> listpat= new ArrayList<Pattern>();
- ArrayList<Pattern> listpat2= new ArrayList<Pattern>();
- ArrayList<Pattern> listpat3= new ArrayList<Pattern>();
- ArrayList<Pattern> listpat4= new ArrayList<Pattern>();
- //mettre ecart fichier 1 dans pattern
- Iterator<String> ite9 = txt1_val_ecart1.iterator();
- while(ite9.hasNext()){
- String str9 = ite9.next();
- listpat.add(Pattern.compile(str9));
- }
- //mettre ecart fichier 2 dans pattern
- Iterator<String> ite2 = txt1_val_ecart2.iterator();
- while(ite2.hasNext()){
- String str2 = ite2.next();
- listpat2.add(Pattern.compile(str2));
- }
- //mettre ecart fichier 1 dans pattern
- Iterator<String> ite10 = txt1_bal_ecart1.iterator();
- while(ite10.hasNext()){
- String str10 = ite10.next();
- listpat3.add(Pattern.compile(str10));
- }
- //mettre ecart fichier 2 dans pattern
- Iterator<String> ite11 = txt1_bal_ecart2.iterator();
- while(ite11.hasNext()){
- String str11 = ite11.next();
- listpat4.add(Pattern.compile(str11));
- }
- //recuperer objet en entier
- ArrayList<String> txt1_full_obj=lsp1.get_full_obj(item);
- ArrayList<String> txt1_full_obj2=lsp2.get_full_obj(item);
- int find=0;
- //parcours de l'objet et comparaison avec pattern
- Iterator<String> ite3 = txt1_full_obj.iterator();
- while(ite3.hasNext()){
- find=0;
- String str3 = ite3.next();
- Iterator<Pattern> itetext1 = listpat.iterator();
- while(itetext1.hasNext()){
- Pattern pat1 = itetext1.next();
- if (pat1.matcher(str3).find()){
- Iterator<Pattern> itetext3 = listpat3.iterator();
- while(itetext3.hasNext()){
- Pattern pat3 = itetext3.next();
- if (pat3.matcher(str3).find()){
- //ligne en rouge
- //str3.setForeground(Color.RED);
- textPane.setText(textPane.getText() + "\n texte en rouguguguguffjjhejhjd");
- find=1;
- }
- }
- }
- }
- if(find==1){
- }else{
- textPane.setText(textPane.getText() + "\n"+str3);
- }
- }
- Iterator<String> ite4 = txt1_full_obj2.iterator();
- while(ite4.hasNext()){
- find=0;
- String str4 = ite4.next();
- Iterator<Pattern> itetext2 = listpat2.iterator();
- while(itetext2.hasNext()){
- Pattern pat1 = itetext2.next();
- if (pat1.matcher(str4).find()){
- Iterator<Pattern> itetext4 = listpat4.iterator();
- while(itetext4.hasNext()){
- Pattern pat4 = itetext4.next();
- if (pat4.matcher(str4).find()){
- //ligne en rouge
- //str3.setForeground(Color.RED);
- textPane_1.setText(textPane_1.getText() + "\n texte en rouguguguguffjjhejhjd");
- find=1;
- }
- }
- }
- }
- if(find==1){
- }else{
- textPane_1.setText(textPane_1.getText() + "\n"+str4);
- }
- }
- // txt1_val_ecart1.drawString("", 10, 30);
- }
- //System.out.println("txt1_full_obj: " +txt1_full_obj);
- }
- }
- @Override
- public void mousePressed(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- });
- list.setValueIsAdjusting(true);
- list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- scrollPane_2.setViewportView(list);
- JScrollPane scrollPane = new JScrollPane();
- splitPane.setLeftComponent(scrollPane);
- textPane = new JTextPane();
- textPane.setForeground(Color.RED);
- scrollPane.setViewportView(textPane);
- JScrollPane scrollPane_1 = new JScrollPane();
- splitPane.setRightComponent(scrollPane_1);
- textPane_1 = new JTextPane();
- scrollPane_1.setViewportView(textPane_1);
- btnCharger = new JButton("Charger");
- btnCharger.setBounds(297, 4, 91, 23);
- panel_button.add(btnCharger);
- btnEnregistrer = new JButton("Enregistrer");
- btnEnregistrer.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- Enregistrer enrg = new Enregistrer();
- try {
- enrg.enreg();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- });
- btnEnregistrer.setBounds(381, 4, 102, 23);
- panel_button.add(btnEnregistrer);
- btnSauvegarder = new JButton("Sauvegarder");
- btnSauvegarder.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- JFileChooser chooser = new JFileChooser();
- chooser.setFileFilter(filtre_txt);
- int returnVal = chooser.showSaveDialog(frame);
- if(returnVal==JFileChooser.APPROVE_OPTION){
- String s = chooser.getSelectedFile().getPath();
- s = s.endsWith(".txt")?s:s+".txt";
- saveFile(textPane_1.getText(), s);
- }
- }
- });
- btnSauvegarder.setBounds(476, 4, 102, 23);
- panel_button.add(btnSauvegarder);
- frame.getContentPane().setLayout(groupLayout);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement