Author: jflesch
Date: 2007-03-14 07:57:03 +0000 (Wed, 14 Mar 2007)
New Revision: 12111
Modified:
trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java
trunk/apps/Thaw/src/thaw/gui/GUIHelper.java
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
Log:
Make informations provided by the PeerMonitor plugin more readable
Modified: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2007-03-13 10:39:02 UTC
(rev 12110)
+++ trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2007-03-14 07:57:03 UTC
(rev 12111)
@@ -261,17 +261,18 @@
if (key == null)
return null;
- if (key.startsWith("KSK@"))
- return key;
+ /* TODO : Being able to compare an USK with a negative rev
+ * with an USK with a positive rev
+ */
- int maxLength = 0;
+ if (key.startsWith("CHK@")) {
+ if (key.length() <= 70)
+ return key.toLowerCase();
- if (key.length() <= 70)
- return key.toLowerCase();
- else
- maxLength = 70;
+ return key.substring(0, 70).toLowerCase();
+ }
- return key.substring(0, maxLength).toLowerCase();
+ return key;
}
}
Modified: trunk/apps/Thaw/src/thaw/gui/GUIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/GUIHelper.java 2007-03-13 10:39:02 UTC (rev
12110)
+++ trunk/apps/Thaw/src/thaw/gui/GUIHelper.java 2007-03-14 07:57:03 UTC (rev
12111)
@@ -68,7 +68,29 @@
}
+ public static String getPrintableTime(final long seconds) {
+ if (seconds == 0)
+ return I18n.getMessage("thaw.common.unknown");
+ if (seconds < 60)
+ return (new Long(seconds)).toString() + " s";
+
+ if (seconds < 3600) {
+ final long min = seconds / 60;
+ return ((new Long(min)).toString() + " min");
+ }
+
+ if (seconds < 86400) {
+ final long hour = seconds / 3600;
+ return ((new Long(hour)).toString() + " h");
+ }
+
+ final long day = seconds / 86400;
+ return ((new Long(day)).toString()) + " day(s)";
+
+ }
+
+
public static String getPrintableSize(final long size) {
if(size == 0)
return I18n.getMessage("thaw.common.unknown");
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-03-13 10:39:02 UTC
(rev 12110)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-03-14 07:57:03 UTC
(rev 12111)
@@ -305,7 +305,7 @@
thaw.plugin.index.loadOnTheFly=Load the index tree on the fly (means less
memory consumption but more CPU usage)
-thaw.plugin.peerMonitor.peerMonitor=Peer management
+thaw.plugin.peerMonitor.peerMonitor=Network status
thaw.plugin.peerMonitor.yourReference=Your reference:
thaw.plugin.peerMonitor.copyReference=Copy your reference to the clipboard
thaw.plugin.peerMonitor.nodeStats=Node informations
@@ -313,5 +313,18 @@
thaw.plugin.peerMonitor.nodeInfos=Node informations:
thaw.plugin.peerMonitor.peerInfos=Informations relative to peer
+thaw.plugin.peerMonitor.infos.peer.lastRoutingBackoffReason=Last back off
reason
+thaw.plugin.peerMonitor.infos.peer.routingBackoffPercent=Backoff percent
+thaw.plugin.peerMonitor.infos.peer.version=Node version
+thaw.plugin.peerMonitor.infos.peer.status=Status
+thaw.plugin.peerMonitor.infos.peer.myName=Node name
+thaw.plugin.peerMonitor.infos.peer.physical.udp=IP address
+thaw.plugin.peerMonitor.infos.peer.averagePingTime=Average ping time
+
+thaw.plugin.peerMonitor.infos.node.overallSize=Datastore size
+thaw.plugin.peerMonitor.infos.node.uptimeSeconds=Uptime
+thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Network size
estimation
+thaw.plugin.peerMonitor.infos.node.myName=Node name
+
thaw.zeroconf.searchingNode=Searching freenet nodes ...
thaw.zeroconf.nodeList=Nodes found:
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-03-13 10:39:02 UTC
(rev 12110)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-03-14 07:57:03 UTC
(rev 12111)
@@ -234,4 +234,6 @@
thaw.plugin.index.addAlreadyExistingIndex=Ajouter un index d?j? pr?sent sur
Freenet
-thaw.plugin.peerMonitor.peerMonitor=Gestion des peers
+thaw.plugin.peerMonitor.peerMonitor=R?seau
+
+
Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
2007-03-13 10:39:02 UTC (rev 12110)
+++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
2007-03-14 07:57:03 UTC (rev 12111)
@@ -70,8 +70,11 @@
private JLabel detailsLabel;
private JPanel detailsPanel;
+ private boolean advanced;
+
public PeerMonitorPanel(Config config) {
+ advanced =
Boolean.valueOf(config.getValue("advancedMode")).booleanValue();
panel = new JPanel(new BorderLayout(10, 10));
@@ -268,6 +271,93 @@
}
+
+ /**
+ * @return null if it must not be displayed ; else an array with two
elements (key translated + value translated)
+ */
+ public String[] getTranslation(String key, String value) {
+
+ /* PEERS */
+
+ if ("volatile.lastRoutingBackoffReason".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.lastRoutingBackoffReason"),
+ value
+ };
+
+ if ("volatile.routingBackoffPercent".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.routingBackoffPercent"),
+ value + "%"
+ };
+
+ if ("version".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.version"),
+ value
+ };
+
+ if ("volatile.status".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.status"),
+ value
+ };
+
+ if ("myName".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.myName"),
+ value
+ };
+
+
+ if ("physical.udp".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.physical.udp"),
+ value
+ };
+
+ if ("volatile.averagePingTime".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.averagePingTime"),
+ Integer.toString(new Float(value).intValue()) +
" ms"
+ };
+
+ /* NODE */
+
+ if ("volatile.overallSize".equals(key))
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.overallSize"),
+ "~" +
thaw.gui.GUIHelper.getPrintableSize(Long.parseLong(value))
+ };
+
+ if ("volatile.uptimeSeconds".equals(key)) {
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.uptimeSeconds"),
+ "~" +
thaw.gui.GUIHelper.getPrintableTime(Long.parseLong(value))
+ };
+ }
+
+ if ("volatile.networkSizeEstimateSession".equals(key)) {
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession"),
+ value
+ };
+ }
+
+ if ("myName".equals(key)) {
+ return new String[] {
+
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.myName"),
+ value
+ };
+ }
+
+ if (advanced)
+ return new String[] { key, value };
+
+ return null;
+ }
+
+
private static JLabel makeInfoLabel(String txt) {
if (txt.length() > STR_INFO_MAX_LNG)
txt = txt.substring(0, STR_INFO_MAX_LNG) + "(...)";
@@ -281,18 +371,30 @@
if (ht == null)
return;
+ Vector v = new Vector();
+
+ for (Enumeration e = ht.keys();
+ e.hasMoreElements(); ) {
+ String key = (String)e.nextElement();
+
+ String[] val = getTranslation(key, (String)ht.get(key));
+
+ if (val != null)
+ v.add(val);
+ }
+
detailsPanel.removeAll();
- detailsPanel.setLayout(new GridLayout(ht.size()+1, 2, 5, 5));
+ detailsPanel.setLayout(new GridLayout(v.size()+1, 2));
detailsLabel.setText(title);
- for (Enumeration e = ht.keys();
- e.hasMoreElements(); ) {
- String key = (String)e.nextElement();
+ for (Iterator i = v.iterator();
+ i.hasNext();) {
+ String[] val = (String[])i.next();
- detailsPanel.add(makeInfoLabel(key + ":"));
- detailsPanel.add(makeInfoLabel((String)ht.get(key)));
+ detailsPanel.add(makeInfoLabel(val[0] + ":"));
+ detailsPanel.add(makeInfoLabel(val[1]));
}
mainPanel.validate();