Author: jflesch
Date: 2007-04-29 18:16:10 +0000 (Sun, 29 Apr 2007)
New Revision: 13050

Modified:
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
   trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
Log:
Add a button to specify what identities are the duplicates and what identity is 
the original one

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-04-29 
17:55:41 UTC (rev 13049)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-04-29 
18:16:10 UTC (rev 13050)
@@ -321,7 +321,7 @@

 thaw.plugin.index.sortAlphabetically=Trier par ordre alphab?tique

-thaw.plugin.index.loadOnTheFly=Charger l'arbre d'index ? la vol?e (signifie 
moins de m?moire utilis?e, mais plus de temps CPU consomm?)
+thaw.plugin.index.loadOnTheFly=Charger l'arbre d'indexes ? la vol?e (signifie 
moins de m?moire utilis?e, mais plus de temps CPU consomm?)

 thaw.plugin.index.indexLoading=Chargement d'indexes

@@ -402,6 +402,7 @@

 thaw.plugin.signature.nickname=Pseudo
 thaw.plugin.signature.trustLevel=Status
+thaw.plugin.signature.isDup=Est un duplicata ?

 thaw.plugin.signature.addIdentity=Generer une nouvelle identit?
 thaw.plugin.signature.removeIdentity=Supprimer l'identit? s?lectionn?e

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-04-29 17:55:41 UTC 
(rev 13049)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-04-29 18:16:10 UTC 
(rev 13050)
@@ -406,13 +406,14 @@

 thaw.plugin.signature.nickname=Nickname
 thaw.plugin.signature.trustLevel=Status
+thaw.plugin.signature.isDup=Is a duplicate ?

 thaw.plugin.signature.addIdentity=Generate a new identity
 thaw.plugin.signature.removeIdentity=Delete the selected identity

 thaw.plugin.signature.enterNick=Enter a nickname :

-thaw.plugin.signature.duplicata=DUPLICATA
+thaw.plugin.signature.duplicata=DUPLICATE

 thaw.plugin.signature.trustLevel.trustLevel=Status
 thaw.plugin.signature.trustLevel.dev=MATRIX ARCHITECT
@@ -425,7 +426,9 @@
 thaw.plugin.signature.trustLevel.none=(none)
 thaw.plugin.signature.trustLevel.me=ME

+thaw.plugin.signature.setOriginal=Set as original

+
 thaw.plugin.signature.ignoreLowerThan=Ignore signatures with a status lower 
than

 # ZeroConf

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-04-29 17:55:41 UTC 
(rev 13049)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-04-29 18:16:10 UTC 
(rev 13050)
@@ -321,7 +321,7 @@

 thaw.plugin.index.sortAlphabetically=Trier par ordre alphab\u00e9tique

-thaw.plugin.index.loadOnTheFly=Charger l'arbre d'index \u00e0 la vol\u00e9e 
(signifie moins de m\u00e9moire utilis\u00e9e, mais plus de temps CPU 
consomm\u00e9)
+thaw.plugin.index.loadOnTheFly=Charger l'arbre d'indexes \u00e0 la vol\u00e9e 
(signifie moins de m\u00e9moire utilis\u00e9e, mais plus de temps CPU 
consomm\u00e9)

 thaw.plugin.index.indexLoading=Chargement d'indexes


Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java   2007-04-29 
17:55:41 UTC (rev 13049)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java   2007-04-29 
18:16:10 UTC (rev 13050)
@@ -149,11 +149,7 @@
                }

                if (i < trustLevelInt.length) {
-                       if (!isDup || trustLevelInt[i] < 0)
-                               return trustLevelColor[i];
-                       else {
-                               return Color.ORANGE;
-                       }
+                       return trustLevelColor[i];
                }

                return Color.BLACK;
@@ -193,6 +189,35 @@
        }


+       /**
+        * will put all the other identities with the same nickname as 
duplicata,
+        * and will put this identity as non duplicate
+        */
+       public void setOriginal() {
+               try {
+                       synchronized(db.dbLock) {
+                               PreparedStatement st;
+
+                               st = 
db.getConnection().prepareStatement("UPDATE signatures SET isDup = TRUE "
+                                                                        + 
"WHERE LOWER(nickName) = ?");
+                               st.setString(1, nick.toLowerCase());
+
+                               st.execute();
+
+                               st = 
db.getConnection().prepareStatement("UPDATE signatures SET isDup = FALSE "
+                                                                        + 
"WHERE id = ?");
+                               st.setInt(1, id);
+
+                               st.execute();
+                       }
+               } catch(SQLException e) {
+                       Logger.error(this,
+                                    "SQLException while setting the identity 
as original : "
+                                    +e.toString());
+               }
+       }
+
+
        public boolean mustBeIgnored(Config config) {
                if (x != null)
                        return false;
@@ -231,8 +256,8 @@
                                /* else we must add it, but first we need to 
know if it's a dup */

                                st = 
db.getConnection().prepareStatement("SELECT id FROM signatures "+
-                                                                        "WHERE 
nickName = ? LIMIT 1");
-                               st.setString(1, nick);
+                                                                        "WHERE 
lower(nickName) = ? LIMIT 1");
+                               st.setString(1, nick.toLowerCase());

                                set = st.executeQuery();


Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java       
2007-04-29 17:55:41 UTC (rev 13049)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java       
2007-04-29 18:16:10 UTC (rev 13050)
@@ -161,7 +161,10 @@

                        dialog.getContentPane().setLayout(new BorderLayout(5, 
5));

-                       dialog.getContentPane().add(new 
JLabel(I18n.getMessage("thaw.plugin.signature.dialogTitle.yourIdentities")+" 
:"),
+                       JLabel label = new 
JLabel(I18n.getMessage("thaw.plugin.signature.dialogTitle.yourIdentities")+" 
:");
+                       label.setIcon(IconBox.identity);
+
+                       dialog.getContentPane().add(label,
                                                    BorderLayout.NORTH);

                        list = new JList();
@@ -276,7 +279,8 @@
        protected class IdentityModel extends 
javax.swing.table.AbstractTableModel {
                public String[] columnNames = {
                        I18n.getMessage("thaw.plugin.signature.nickname"),
-                       I18n.getMessage("thaw.plugin.signature.trustLevel")
+                       I18n.getMessage("thaw.plugin.signature.trustLevel"),
+                       I18n.getMessage("thaw.plugin.signature.isDup")
                };

                private Vector identities;
@@ -317,6 +321,10 @@
                        if (column == 1)
                                return 
I18n.getMessage(((Identity)identities.get(row)).getTrustLevelStr());

+                       if (column == 2)
+                               return ((Identity)identities.get(row)).isDup() ?
+                                       "X" : "";
+
                        return null;
                }

@@ -334,7 +342,8 @@

                private JButton close;

-               private Vector statusButtons;
+               private JButton setOriginal;
+               private Vector buttons;


                public  OtherIdentitiesPanel() {
@@ -343,6 +352,11 @@

                        dialog.getContentPane().setLayout(new BorderLayout(5, 
5));

+                       JLabel label = new 
JLabel(I18n.getMessage("thaw.plugin.signature.signatures"));
+                       label.setIcon(IconBox.peers);
+
+                       dialog.getContentPane().add(label, BorderLayout.NORTH);
+
                        model = new IdentityModel();

                        table = new JTable(model);
@@ -352,22 +366,29 @@

                        JPanel eastPanel = new JPanel(new BorderLayout());

-                       JPanel statusButtonsPanel = new JPanel(new 
GridLayout(Identity.trustLevelInt.length -1, 1));
+                       JPanel buttonsPanel = new JPanel(new 
GridLayout(Identity.trustLevelInt.length +1, 1));

-                       statusButtons = new Vector();
+                       buttons = new Vector();

                        for (int i = 0 ; i < Identity.trustLevelInt.length ; 
i++) {
                                if (Identity.trustLevelInt[i] < 100) {
                                        JButton button = new 
JButton(I18n.getMessage(Identity.trustLevelStr[i]));
-                                       statusButtonsPanel.add(button);
-                                       statusButtons.add(button);
+                                       buttonsPanel.add(button);
+                                       buttons.add(button);
                                        button.addActionListener(this);
                                }
                        }

+                       setOriginal = new 
JButton(I18n.getMessage("thaw.plugin.signature.setOriginal"));
+                       buttonsPanel.add(new JLabel(""));
+                       buttonsPanel.add(setOriginal);
+                       buttons.add(setOriginal);
+                       setOriginal.addActionListener(this);
+
+
                        JPanel eastTopPanel = new JPanel();

-                       eastTopPanel.add(statusButtonsPanel);
+                       eastTopPanel.add(buttonsPanel);
                        eastPanel.add(eastTopPanel, BorderLayout.CENTER);

                        JPanel eastBottomPanel = new JPanel();
@@ -383,7 +404,7 @@

                        updateList();

-                       dialog.setSize(500, 300);
+                       dialog.setSize(640, 300);
                        dialog.setVisible(true);
                }

@@ -407,14 +428,24 @@
                        if (target == null)
                                return;

+
+                       if (e.getSource() == setOriginal) {
+                               target.setOriginal();
+
+                               updateList();
+
+                               return;
+                       }
+
+
                        if (e.getSource() instanceof JButton) {
                                JButton bt = (JButton)e.getSource();

                                target.setTrustLevel(bt.getText());

                                updateList();
+                               return;
                        }
-
                }
        }



Reply via email to