Author: jflesch
Date: 2007-03-26 00:11:08 +0000 (Mon, 26 Mar 2007)
New Revision: 12374
Modified:
trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
Log:
Add a progress bar showing the memory consumption of Thaw in the plugin
'PeerMonitor'
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-03-25
21:47:47 UTC (rev 12373)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-03-26
00:11:08 UTC (rev 12374)
@@ -334,6 +334,7 @@
thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Estimation de la
taille du r?seau
thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud
thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud
+thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw
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-03-25 21:47:47 UTC
(rev 12373)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-03-26 00:11:08 UTC
(rev 12374)
@@ -327,6 +327,7 @@
thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Network size
estimation
thaw.plugin.peerMonitor.infos.node.myName=Node name
thaw.plugin.peerMonitor.infos.nodeMemory=Node memory
+thaw.plugin.peerMonitor.infos.thawMemory=Thaw memory
thaw.zeroconf.searchingNode=Searching freenet nodes ...
Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
2007-03-25 21:47:47 UTC (rev 12373)
+++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
2007-03-26 00:11:08 UTC (rev 12374)
@@ -31,6 +31,7 @@
import thaw.core.Config;
import thaw.core.I18n;
+import thaw.core.Logger;
import thaw.gui.IconBox;
@@ -78,7 +79,8 @@
private JButton refCopyButton;
private JList peerList;
- private JProgressBar memBar;
+ private JProgressBar thawMemBar;
+ private JProgressBar nodeMemBar;
private JLabel detailsLabel;
private JPanel detailsPanel;
@@ -111,16 +113,24 @@
peerListLabel.setIcon(IconBox.peers);
- memBar = new JProgressBar(0, 100);
+ nodeMemBar = new JProgressBar(0, 100);
+ thawMemBar = new JProgressBar(0, 100);
+ nodeMemBar.setStringPainted(true);
+ thawMemBar.setStringPainted(true);
+
setMemBar(0, 134217728);
- memBar.setStringPainted(true);
peerPanel.add(peerListLabel, BorderLayout.NORTH);
peerPanel.add(new JScrollPane(peerList), BorderLayout.CENTER);
- peerPanel.add(memBar, BorderLayout.SOUTH);
+ JPanel memPanel = new JPanel(new GridLayout(2, 1));
+ memPanel.add(nodeMemBar);
+ memPanel.add(thawMemBar);
+ peerPanel.add(memPanel, BorderLayout.SOUTH);
+
+
mainPanel = new JPanel(new GridLayout(2, 1, 10, 10));
@@ -161,17 +171,41 @@
public void setMemBar(long used, long max) {
int pourcent;
+ /* node mem bar */
+
pourcent = (int)((used * 100) / max);
-
memBar.setString(I18n.getMessage("thaw.plugin.peerMonitor.infos.nodeMemory")+
": "
- + thaw.gui.GUIHelper.getPrintableSize(used)
- + " / "
- + thaw.gui.GUIHelper.getPrintableSize(max)
- + " ("+Integer.toString(pourcent)+"%)");
+
nodeMemBar.setString(I18n.getMessage("thaw.plugin.peerMonitor.infos.nodeMemory")+
": "
+ + thaw.gui.GUIHelper.getPrintableSize(used)
+ + " / "
+ + thaw.gui.GUIHelper.getPrintableSize(max)
+ + " ("+Integer.toString(pourcent)+"%)");
- memBar.setValue(pourcent);
+ nodeMemBar.setValue(pourcent);
+
+
+ /* thaw mem bar */
+
+ max = Runtime.getRuntime().maxMemory();
+
+ if (max == Long.MAX_VALUE) {
+ max = Runtime.getRuntime().totalMemory();
+ }
+
+ used = Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory();
+
+ pourcent = (int)((used * 100) / max);
+
+
thawMemBar.setString(I18n.getMessage("thaw.plugin.peerMonitor.infos.thawMemory")+
": "
+ + thaw.gui.GUIHelper.getPrintableSize(used)
+ + " / "
+ + thaw.gui.GUIHelper.getPrintableSize(max)
+ + " ("+Integer.toString(pourcent)+"%)");
+
+ thawMemBar.setValue(pourcent);
}
+
public void setRef(String ref) {
refArea.setText(ref);
}