Author: jflesch
Date: 2007-04-22 22:00:39 +0000 (Sun, 22 Apr 2007)
New Revision: 12879
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/IndexBrowser.java
trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
Log:
Add a dialog in the config window allowing to change the trust levels
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-22
21:59:13 UTC (rev 12878)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-22
22:00:39 UTC (rev 12879)
@@ -335,8 +335,8 @@
thaw.plugin.index.comment.author=Auteur
thaw.plugin.index.comment.commentList=Commentaires
+thaw.plugin.index.comment.mustSelectIdentity=Vous devez selectionner une
identit?
-
thaw.plugin.peerMonitor.peerMonitor=Connexion
thaw.plugin.peerMonitor.yourReference=Votre r?f?rence:
thaw.plugin.peerMonitor.copyReference=Copier votre r?f?rence vers le
presse-papier
@@ -403,8 +403,8 @@
thaw.plugin.signature.trustLevel.check=VALIDE
thaw.plugin.signature.trustLevel.bad=MAUVAIS
thaw.plugin.signature.trustLevel.evil=DIABOLIQUE
+thaw.plugin.signature.trustLevel.me=MOI
-
# Zeroconf
thaw.zeroconf.searchingNode=Recherche de noeuds Freenet ...
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-22 21:59:13 UTC
(rev 12878)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-22 22:00:39 UTC
(rev 12879)
@@ -339,6 +339,7 @@
thaw.plugin.index.comment.author=Author
thaw.plugin.index.comment.add=Add a comment
+thaw.plugin.index.comment.mustSelectIdentity=You must select an identity
thaw.plugin.peerMonitor.peerMonitor=Connection
thaw.plugin.peerMonitor.yourReference=Your reference:
@@ -401,6 +402,8 @@
thaw.plugin.signature.enterNick=Enter a nickname :
+thaw.plugin.signature.duplicata=DUPLICATA
+
thaw.plugin.signature.trustLevel.trustLevel=Status
thaw.plugin.signature.trustLevel.dev=MATRIX ARCHITECT
thaw.plugin.signature.trustLevel.good=GOOD
@@ -408,8 +411,10 @@
thaw.plugin.signature.trustLevel.check=CHECK
thaw.plugin.signature.trustLevel.bad=BAD
thaw.plugin.signature.trustLevel.evil=EVIL
+thaw.plugin.signature.trustLevel.me=ME
+
# ZeroConf
thaw.zeroconf.searchingNode=Searching freenet nodes ...
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-22 21:59:13 UTC
(rev 12878)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-22 22:00:39 UTC
(rev 12879)
@@ -335,8 +335,8 @@
thaw.plugin.index.comment.author=Auteur
thaw.plugin.index.comment.commentList=Commentaires
+thaw.plugin.index.comment.mustSelectIdentity=Vous devez selectionner une
identit\u00e9
-
thaw.plugin.peerMonitor.peerMonitor=Connexion
thaw.plugin.peerMonitor.yourReference=Votre r\u00e9f\u00e9rence:
thaw.plugin.peerMonitor.copyReference=Copier votre r\u00e9f\u00e9rence vers le
presse-papier
@@ -403,8 +403,8 @@
thaw.plugin.signature.trustLevel.check=VALIDE
thaw.plugin.signature.trustLevel.bad=MAUVAIS
thaw.plugin.signature.trustLevel.evil=DIABOLIQUE
+thaw.plugin.signature.trustLevel.me=MOI
-
# Zeroconf
thaw.zeroconf.searchingNode=Recherche de noeuds Freenet ...
Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2007-04-22 21:59:13 UTC
(rev 12878)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2007-04-22 22:00:39 UTC
(rev 12879)
@@ -55,7 +55,6 @@
hsqldb.registerChild(this);
- /*
if(core.getPluginManager().getPlugin("thaw.plugins.Signatures")
== null) {
Logger.info(this, "Loading signatures plugin");
@@ -68,7 +67,6 @@
signatures =
(Signatures)core.getPluginManager().getPlugin("thaw.plugins.Signatures");
signatures.registerChild(this);
- *//* (don't forget to unregister) */
boolean newDb;
@@ -133,7 +131,7 @@
}
hsqldb.unregisterChild(this);
- //signatures.unregisterChild(this);
+ signatures.unregisterChild(this);
if (configPanel != null)
configPanel.removeTab();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-22 21:59:13 UTC
(rev 12878)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-22 22:00:39 UTC
(rev 12879)
@@ -601,7 +601,7 @@
PreparedStatement st;
st = db.getConnection().prepareStatement("SELECT id
FROM indexComments "+
- "WHERE r = ? AND s = ?
");
+ "WHERE r = ?
AND s = ? ");
st.setBytes(1, r);
st.setBytes(2, s);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-04-22 21:59:13 UTC (rev 12878)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-04-22 22:00:39 UTC (rev 12879)
@@ -1607,8 +1607,15 @@
if (e.getSource() == okButton) {
if (getTarget() instanceof Index) {
+ Identity i =
((Identity)author.getSelectedItem());
+
+ if (i == null) {
+ new
thaw.gui.WarningWindow(null,
I18n.getMessage("thaw.plugin.index.comment.mustSelectIdentity"));
+ return;
+ }
+
((Index)getTarget()).postComment(getQueueManager(),
-
((Identity)author.getSelectedItem()),
+ i,
textArea.getText().trim());
}
Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java 2007-04-22
21:59:13 UTC (rev 12878)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java 2007-04-22
22:00:39 UTC (rev 12879)
@@ -19,6 +19,7 @@
import thaw.core.Core;
import thaw.core.Logger;
+import thaw.core.I18n;
import thaw.plugins.Hsqldb;
@@ -115,28 +116,57 @@
break;
}
- if (i < trustLevelInt.length)
- return trustLevelStr[i];
+ if (i < trustLevelInt.length) {
+ if (!isDup)
+ return trustLevelStr[i];
+ return trustLevelStr[i] +
I18n.getMessage("thaw.plugin.signature.duplicata");
+ }
- return "[?]";
+ if (!isDup)
+ return "[?]";
+ else
+ return "[?]" +
I18n.getMessage("thaw.plugin.signature.duplicata");
}
public Color getTrustLevelColor() {
int i;
+
for (i = 0 ; i < trustLevelInt.length ; i++) {
if (trustLevelInt[i] == trustLevel)
break;
}
- if (i < trustLevelInt.length)
- return trustLevelColor[i];
+ if (i < trustLevelInt.length) {
+ if (!isDup || trustLevelInt[i] < 0)
+ return trustLevelColor[i];
+ else {
+ return Color.ORANGE;
+ }
+ }
return Color.BLACK;
}
+ public void setTrustLevel(int i) {
+ try {
+ synchronized(db.dbLock) {
+ PreparedStatement st;
+
+ st =
db.getConnection().prepareStatement("UPDATE signatures SET trustLevel = ? WHERE
id = ?");
+ st.setInt(1, i);
+ st.setInt(2, id);
+
+ st.execute();
+ }
+ } catch(SQLException e) {
+ Logger.error(this, "Unable to change trust level
because: "+e.toString());
+ }
+ }
+
+
/**
* if the identity doesn't exists, it will be created
*/
Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
2007-04-22 21:59:13 UTC (rev 12878)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
2007-04-22 22:00:39 UTC (rev 12879)
@@ -8,6 +8,12 @@
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JOptionPane;
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
import java.awt.BorderLayout;
import java.awt.GridLayout;
@@ -16,6 +22,8 @@
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
+import java.util.Vector;
+
import thaw.core.I18n;
import thaw.core.ConfigWindow;
@@ -148,13 +156,158 @@
}
+ protected class IdentityModel extends
javax.swing.table.AbstractTableModel {
+ public String[] columnNames = {
+ I18n.getMessage("thaw.plugin.signature.nickname"),
+ I18n.getMessage("thaw.plugin.signature.trustLevel")
+ };
+
+ private Vector identities;
+
+ public IdentityModel() {
+
+ }
+
+ public void setIdentities(Vector i) {
+ identities = i;
+
+ final TableModelEvent event = new TableModelEvent(this);
+ fireTableChanged(event);
+ }
+
+ public int getRowCount() {
+ if (identities == null)
+ return 0;
+
+ return identities.size();
+ }
+
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ public String getColumnName(final int column) {
+ return columnNames[column];
+ }
+
+ public Object getValueAt(int row, int column) {
+ if (identities == null)
+ return null;
+
+ if (column == 0)
+ return
((Identity)identities.get(row)).toString();
+
+ if (column == 1)
+ return
I18n.getMessage(((Identity)identities.get(row)).getTrustLevelStr());
+
+ return null;
+ }
+
+ public Identity getIdentity(int line) {
+ return (Identity)identities.get(line);
+ }
+ }
+
+
protected class OtherIdentitiesPanel implements ActionListener {
+ private JDialog dialog;
+ private IdentityModel model;
+
+ private JTable table;
+
+ private JButton close;
+
+ private Vector statusButtons;
+
+
public OtherIdentitiesPanel() {
+ dialog = new JDialog(configWindow.getFrame(),
+
I18n.getMessage("thaw.plugin.signature.dialogTitle.yourIdentities"));
+ dialog.getContentPane().setLayout(new BorderLayout(5,
5));
+
+ model = new IdentityModel();
+
+ table = new JTable(model);
+
+ dialog.getContentPane().add(new JScrollPane(table),
+ BorderLayout.CENTER);
+
+ JPanel eastPanel = new JPanel(new BorderLayout());
+
+ JPanel statusButtonsPanel = new JPanel(new
GridLayout(Identity.trustLevelInt.length -1, 1));
+
+ statusButtons = 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);
+ button.addActionListener(this);
+ }
+ }
+
+ JPanel eastTopPanel = new JPanel();
+
+ eastTopPanel.add(statusButtonsPanel);
+ eastPanel.add(eastTopPanel, BorderLayout.CENTER);
+
+ JPanel eastBottomPanel = new JPanel();
+
+ close = new JButton(IconBox.minClose);
+ close.addActionListener(this);
+
+ eastBottomPanel.add(close);
+
+ eastPanel.add(eastBottomPanel, BorderLayout.SOUTH);
+
+ dialog.getContentPane().add(eastPanel,
BorderLayout.EAST);
+
+ updateList();
+
+ dialog.setSize(500, 300);
+ dialog.setVisible(true);
}
+ public void updateList() {
+ model.setIdentities(Identity.getOtherIdentities(db));
+ }
+
public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == close) {
+ dialog.setVisible(false);
+ }
+
+ int row = table.getSelectedRow();
+
+ if (row < 0)
+ return;
+
+ Identity target = model.getIdentity(row);
+
+ if (target == null)
+ return;
+
+ if (e.getSource() instanceof JButton) {
+ JButton bt = (JButton)e.getSource();
+
+ int i;
+
+ for (i = 0 ; i < Identity.trustLevelStr.length
; i++) {
+ if
(I18n.getMessage(Identity.trustLevelStr[i]).equals(bt.getText()))
+ break;
+ }
+
+ if (i >= Identity.trustLevelStr.length)
+ return;
+
+ target.setTrustLevel(Identity.trustLevelInt[i]);
+
+ updateList();
+ }
+
}
}