< prev index next >

src/share/classes/sun/tools/jconsole/MemoryTab.java

Print this page
rev 1501 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: mchung, mfang

*** 36,52 **** import javax.accessibility.*; import javax.management.*; import javax.management.openmbean.CompositeData; import javax.swing.*; import javax.swing.border.*; - import javax.swing.text.*; - import sun.management.*; import static sun.tools.jconsole.Formatter.*; - import static sun.tools.jconsole.OverviewPanel.*; - import static sun.tools.jconsole.Resources.*; import static sun.tools.jconsole.Utilities.*; @SuppressWarnings("serial") class MemoryTab extends Tab implements ActionListener, ItemListener { JComboBox plotterChoice; --- 36,48 ----
*** 65,87 **** private static final String usedKey = "used"; private static final String committedKey = "committed"; private static final String maxKey = "max"; private static final String thresholdKey = "threshold"; - - private static final String usedName = Resources.getText("Used"); - private static final String committedName = Resources.getText("Committed"); - private static final String maxName = Resources.getText("Max"); - private static final String thresholdName = Resources.getText("Threshold"); - private static final Color usedColor = Plotter.defaultColor; private static final Color committedColor = null; private static final Color maxColor = null; private static final Color thresholdColor = Color.red; - private static final String infoLabelFormat = "MemoryTab.infoLabelFormat"; - /* Hierarchy of panels and layouts for this tab: MemoryTab (BorderLayout) --- 61,75 ----
*** 103,113 **** East: poolChart */ public static String getTabName() { ! return getText("Memory"); } public MemoryTab(VMPanel vmPanel) { super(vmPanel, getTabName()); --- 91,101 ---- East: poolChart */ public static String getTabName() { ! return Messages.MEMORY; } public MemoryTab(VMPanel vmPanel) { super(vmPanel, getTabName());
*** 125,158 **** topPanel.add(controlPanel, BorderLayout.CENTER); // Plotter choice plotterChoice = new JComboBox(); plotterChoice.addItemListener(this); ! controlPanel.add(new LabeledComponent(getText("Chart:"), ! getMnemonicInt("Chart:"), plotterChoice)); // Range control timeComboBox = new TimeComboBox(); ! controlPanel.add(new LabeledComponent(getText("Time Range:"), ! getMnemonicInt("Time Range:"), timeComboBox)); ! gcButton = new JButton(getText("Perform GC")); ! gcButton.setMnemonic(getMnemonicInt("Perform GC")); gcButton.addActionListener(this); ! gcButton.setToolTipText(getText("Perform GC.toolTip")); JPanel topRightPanel = new JPanel(); topRightPanel.setBorder(new EmptyBorder(0, 65-8, 0, 70)); topRightPanel.add(gcButton); topPanel.add(topRightPanel, BorderLayout.AFTER_LINE_ENDS); ! bottomPanel.setBorder(new CompoundBorder(new TitledBorder(getText("Details")), new EmptyBorder(10, 10, 10, 10))); details = new HTMLPane(); ! setAccessibleName(details, getText("Details")); bottomPanel.add(new JScrollPane(details), BorderLayout.CENTER); poolChart = new PoolChart(); bottomPanel.add(poolChart, BorderLayout.AFTER_LINE_ENDS); } --- 113,146 ---- topPanel.add(controlPanel, BorderLayout.CENTER); // Plotter choice plotterChoice = new JComboBox(); plotterChoice.addItemListener(this); ! controlPanel.add(new LabeledComponent(Messages.CHART_COLON, ! Resources.getMnemonicInt(Messages.CHART_COLON), plotterChoice)); // Range control timeComboBox = new TimeComboBox(); ! controlPanel.add(new LabeledComponent(Messages.TIME_RANGE_COLON, ! Resources.getMnemonicInt(Messages.TIME_RANGE_COLON), timeComboBox)); ! gcButton = new JButton(Messages.PERFORM_GC); ! gcButton.setMnemonic(Resources.getMnemonicInt(Messages.PERFORM_GC)); gcButton.addActionListener(this); ! gcButton.setToolTipText(Messages.PERFORM_GC_TOOLTIP); JPanel topRightPanel = new JPanel(); topRightPanel.setBorder(new EmptyBorder(0, 65-8, 0, 70)); topRightPanel.add(gcButton); topPanel.add(topRightPanel, BorderLayout.AFTER_LINE_ENDS); ! bottomPanel.setBorder(new CompoundBorder(new TitledBorder(Messages.DETAILS), new EmptyBorder(10, 10, 10, 10))); details = new HTMLPane(); ! setAccessibleName(details, Messages.DETAILS); bottomPanel.add(new JScrollPane(details), BorderLayout.CENTER); poolChart = new PoolChart(); bottomPanel.add(poolChart, BorderLayout.AFTER_LINE_ENDS); }
*** 163,197 **** ProxyClient proxyClient = vmPanel.getProxyClient(); heapPlotter = new Plotter(Plotter.Unit.BYTES) { public String toString() { ! return Resources.getText("Heap Memory Usage"); } }; proxyClient.addWeakPropertyChangeListener(heapPlotter); nonHeapPlotter = new Plotter(Plotter.Unit.BYTES) { public String toString() { ! return Resources.getText("Non-Heap Memory Usage"); } }; setAccessibleName(heapPlotter, ! getText("MemoryTab.heapPlotter.accessibleName")); setAccessibleName(nonHeapPlotter, ! getText("MemoryTab.nonHeapPlotter.accessibleName")); proxyClient.addWeakPropertyChangeListener(nonHeapPlotter); ! heapPlotter.createSequence(usedKey, usedName, usedColor, true); ! heapPlotter.createSequence(committedKey, committedName, committedColor, false); ! heapPlotter.createSequence(maxKey, maxName, maxColor, false); ! ! nonHeapPlotter.createSequence(usedKey, usedName, usedColor, true); ! nonHeapPlotter.createSequence(committedKey, committedName, committedColor, false); ! nonHeapPlotter.createSequence(maxKey, maxName, maxColor, false); plotterList.add(heapPlotter); plotterList.add(nonHeapPlotter); // Now add memory pools --- 151,185 ---- ProxyClient proxyClient = vmPanel.getProxyClient(); heapPlotter = new Plotter(Plotter.Unit.BYTES) { public String toString() { ! return Messages.HEAP_MEMORY_USAGE; } }; proxyClient.addWeakPropertyChangeListener(heapPlotter); nonHeapPlotter = new Plotter(Plotter.Unit.BYTES) { public String toString() { ! return Messages.NON_HEAP_MEMORY_USAGE; } }; setAccessibleName(heapPlotter, ! Messages.MEMORY_TAB_HEAP_PLOTTER_ACCESSIBLE_NAME); setAccessibleName(nonHeapPlotter, ! Messages.MEMORY_TAB_NON_HEAP_PLOTTER_ACCESSIBLE_NAME); proxyClient.addWeakPropertyChangeListener(nonHeapPlotter); ! heapPlotter.createSequence(usedKey, Messages.USED, usedColor, true); ! heapPlotter.createSequence(committedKey, Messages.COMMITTED, committedColor, false); ! heapPlotter.createSequence(maxKey, Messages.MAX, maxColor, false); ! ! nonHeapPlotter.createSequence(usedKey, Messages.USED, usedColor, true); ! nonHeapPlotter.createSequence(committedKey, Messages.COMMITTED, committedColor, false); ! nonHeapPlotter.createSequence(maxKey, Messages.MAX, maxColor, false); plotterList.add(heapPlotter); plotterList.add(nonHeapPlotter); // Now add memory pools
*** 200,210 **** ObjectName[] objectNames = keys.toArray(new ObjectName[keys.size()]); ArrayList<PoolPlotter> nonHeapPlotters = new ArrayList<PoolPlotter>(2); for (ObjectName objectName : objectNames) { String type = objectName.getKeyProperty("type"); if (type.equals("MemoryPool")) { ! String name = getText("MemoryPoolLabel", objectName.getKeyProperty("name")); // Heap or non-heap? boolean isHeap = false; AttributeList al = proxyClient.getAttributes(objectName, --- 188,198 ---- ObjectName[] objectNames = keys.toArray(new ObjectName[keys.size()]); ArrayList<PoolPlotter> nonHeapPlotters = new ArrayList<PoolPlotter>(2); for (ObjectName objectName : objectNames) { String type = objectName.getKeyProperty("type"); if (type.equals("MemoryPool")) { ! String name = Resources.format(Messages.MEMORY_POOL_LABEL, objectName.getKeyProperty("name")); // Heap or non-heap? boolean isHeap = false; AttributeList al = proxyClient.getAttributes(objectName,
*** 213,226 **** isHeap = MemoryType.HEAP.name().equals(((Attribute)al.get(0)).getValue()); } PoolPlotter poolPlotter = new PoolPlotter(objectName, name, isHeap); proxyClient.addWeakPropertyChangeListener(poolPlotter); ! poolPlotter.createSequence(usedKey, usedName, usedColor, true); ! poolPlotter.createSequence(committedKey, committedName, committedColor, false); ! poolPlotter.createSequence(maxKey, maxName, maxColor, false); ! poolPlotter.createSequence(thresholdKey, thresholdName, thresholdColor, false); poolPlotter.setUseDashedTransitions(thresholdKey, true); if (isHeap) { plotterList.add(poolPlotter); } else { --- 201,214 ---- isHeap = MemoryType.HEAP.name().equals(((Attribute)al.get(0)).getValue()); } PoolPlotter poolPlotter = new PoolPlotter(objectName, name, isHeap); proxyClient.addWeakPropertyChangeListener(poolPlotter); ! poolPlotter.createSequence(usedKey, Messages.USED, usedColor, true); ! poolPlotter.createSequence(committedKey, Messages.COMMITTED, committedColor, false); ! poolPlotter.createSequence(maxKey, Messages.MAX, maxColor, false); ! poolPlotter.createSequence(thresholdKey, Messages.THRESHOLD, thresholdColor, false); poolPlotter.setUseDashedTransitions(thresholdKey, true); if (isHeap) { plotterList.add(poolPlotter); } else {
*** 284,294 **** used = new long[n]; committed = new long[n]; max = new long[n]; threshold = new long[n]; timeStamp = System.currentTimeMillis(); - int poolCount = 0; for (int i = 0; i < n; i++) { Plotter plotter = plotterList.get(i); MemoryUsage mu = null; used[i] = -1L; --- 272,281 ----
*** 398,423 **** } //long time = plotter.getLastTimeStamp(); long time = System.currentTimeMillis(); String timeStamp = formatDateTime(time); ! text += newRow(getText("Time"), timeStamp); long used = plotter.getLastValue(usedKey); long committed = plotter.getLastValue(committedKey); long max = plotter.getLastValue(maxKey); long threshold = plotter.getLastValue(thresholdKey); ! text += newRow(getText("Used"), formatKBytes(used)); if (committed > 0L) { ! text += newRow(getText("Committed"), formatKBytes(committed)); } if (max > 0L) { ! text += newRow(getText("Max"), formatKBytes(max)); } if (threshold > 0L) { ! text += newRow(getText("Usage Threshold"), formatKBytes(threshold)); } try { Collection<GarbageCollectorMXBean> garbageCollectors = proxyClient.getGarbageCollectorMXBeans(); --- 385,410 ---- } //long time = plotter.getLastTimeStamp(); long time = System.currentTimeMillis(); String timeStamp = formatDateTime(time); ! text += newRow(Messages.TIME, timeStamp); long used = plotter.getLastValue(usedKey); long committed = plotter.getLastValue(committedKey); long max = plotter.getLastValue(maxKey); long threshold = plotter.getLastValue(thresholdKey); ! text += newRow(Messages.USED, formatKBytes(used)); if (committed > 0L) { ! text += newRow(Messages.COMMITTED, formatKBytes(committed)); } if (max > 0L) { ! text += newRow(Messages.MAX, formatKBytes(max)); } if (threshold > 0L) { ! text += newRow(Messages.USAGE_THRESHOLD, formatKBytes(threshold)); } try { Collection<GarbageCollectorMXBean> garbageCollectors = proxyClient.getGarbageCollectorMXBeans();
*** 425,439 **** boolean descPrinted = false; for (GarbageCollectorMXBean garbageCollectorMBean : garbageCollectors) { String gcName = garbageCollectorMBean.getName(); long gcCount = garbageCollectorMBean.getCollectionCount(); long gcTime = garbageCollectorMBean.getCollectionTime(); ! String str = getText("GC time details", justify(formatTime(gcTime), 14), gcName, String.format("%,d",gcCount)); if (!descPrinted) { ! text += newRow(getText("GC time"), str); descPrinted = true; } else { text += newRow(null, str); } } --- 412,426 ---- boolean descPrinted = false; for (GarbageCollectorMXBean garbageCollectorMBean : garbageCollectors) { String gcName = garbageCollectorMBean.getName(); long gcCount = garbageCollectorMBean.getCollectionCount(); long gcTime = garbageCollectorMBean.getCollectionTime(); ! String str = Resources.format(Messages.GC_TIME_DETAILS, justify(formatTime(gcTime), 14), gcName, String.format("%,d",gcCount)); if (!descPrinted) { ! text += newRow(Messages.GC_TIME, str); descPrinted = true; } else { text += newRow(null, str); } }
*** 463,473 **** this.objectName = objectName; this.name = name; this.isHeap = isHeap; setAccessibleName(this, ! getText("MemoryTab.poolPlotter.accessibleName", name)); } public String toString() { --- 450,460 ---- this.objectName = objectName; this.name = name; this.isHeap = isHeap; setAccessibleName(this, ! Resources.format(Messages.MEMORY_TAB_POOL_PLOTTER_ACCESSIBLE_NAME, name)); } public String toString() {
*** 625,635 **** g.setColor(heapColor); g.fillRect(heapRect.x + 1, heapRect.y + 1, heapRect.width - 1, heapRect.height - 1); g.setColor(nonHeapColor); g.fillRect(nonHeapRect.x + 1, nonHeapRect.y + 1, nonHeapRect.width - 1, nonHeapRect.height - 1); ! String str = getText("Heap"); int stringWidth = fm.stringWidth(str); int x = heapRect.x + (heapRect.width - stringWidth) / 2; int y = heapRect.y + heapRect.height - 6; g.setColor(Color.white); g.drawString(str, x-1, y-1); --- 612,622 ---- g.setColor(heapColor); g.fillRect(heapRect.x + 1, heapRect.y + 1, heapRect.width - 1, heapRect.height - 1); g.setColor(nonHeapColor); g.fillRect(nonHeapRect.x + 1, nonHeapRect.y + 1, nonHeapRect.width - 1, nonHeapRect.height - 1); ! String str = Messages.HEAP; int stringWidth = fm.stringWidth(str); int x = heapRect.x + (heapRect.width - stringWidth) / 2; int y = heapRect.y + heapRect.height - 6; g.setColor(Color.white); g.drawString(str, x-1, y-1);
*** 637,647 **** g.drawString(str, x-1, y+1); g.drawString(str, x+1, y+1); g.setColor(Color.black); g.drawString(str, x, y); ! str = getText("Non-Heap"); stringWidth = fm.stringWidth(str); x = nonHeapRect.x + (nonHeapRect.width - stringWidth) / 2; y = nonHeapRect.y + nonHeapRect.height - 6; g.setColor(Color.white); g.drawString(str, x-1, y-1); --- 624,634 ---- g.drawString(str, x-1, y+1); g.drawString(str, x+1, y+1); g.setColor(Color.black); g.drawString(str, x, y); ! str = Messages.NON_HEAP; stringWidth = fm.stringWidth(str); x = nonHeapRect.x + (nonHeapRect.width - stringWidth) / 2; y = nonHeapRect.y + nonHeapRect.height - 6; g.setColor(Color.white); g.drawString(str, x-1, y-1);
*** 726,754 **** return accessibleContext; } protected class AccessiblePoolChart extends AccessibleJPanel { public String getAccessibleName() { ! String name = getText("MemoryTab.poolChart.accessibleName"); String keyValueList = ""; for (PoolPlotter poolPlotter : poolPlotters) { String value = (poolPlotter.value * 100 / poolPlotter.max) + "%"; // Assume format string ends with newline keyValueList += ! getText("Plotter.accessibleName.keyAndValue", poolPlotter.toString(), value); if (poolPlotter.threshold > 0L) { String threshold = (poolPlotter.threshold * 100 / poolPlotter.max) + "%"; if (poolPlotter.value > poolPlotter.threshold) { keyValueList += ! getText("MemoryTab.poolChart.aboveThreshold", threshold); } else { keyValueList += ! getText("MemoryTab.poolChart.belowThreshold", threshold); } } } --- 713,741 ---- return accessibleContext; } protected class AccessiblePoolChart extends AccessibleJPanel { public String getAccessibleName() { ! String name = Messages.MEMORY_TAB_POOL_CHART_ACCESSIBLE_NAME; String keyValueList = ""; for (PoolPlotter poolPlotter : poolPlotters) { String value = (poolPlotter.value * 100 / poolPlotter.max) + "%"; // Assume format string ends with newline keyValueList += ! Resources.format(Messages.PLOTTER_ACCESSIBLE_NAME_KEY_AND_VALUE, poolPlotter.toString(), value); if (poolPlotter.threshold > 0L) { String threshold = (poolPlotter.threshold * 100 / poolPlotter.max) + "%"; if (poolPlotter.value > poolPlotter.threshold) { keyValueList += ! Resources.format(Messages.MEMORY_TAB_POOL_CHART_ABOVE_THRESHOLD, threshold); } else { keyValueList += ! Resources.format(Messages.MEMORY_TAB_POOL_CHART_BELOW_THRESHOLD, threshold); } } }
*** 765,779 **** return new OverviewPanel[] { overviewPanel }; } private static class MemoryOverviewPanel extends OverviewPanel { MemoryOverviewPanel() { ! super(getText("Heap Memory Usage"), usedKey, usedName, Plotter.Unit.BYTES); } private void updateMemoryInfo(long used, long committed, long max) { ! getInfoLabel().setText(getText(infoLabelFormat, formatBytes(used, true), formatBytes(committed, true), formatBytes(max, true))); } } --- 752,766 ---- return new OverviewPanel[] { overviewPanel }; } private static class MemoryOverviewPanel extends OverviewPanel { MemoryOverviewPanel() { ! super(Messages.HEAP_MEMORY_USAGE, usedKey, Messages.USED, Plotter.Unit.BYTES); } private void updateMemoryInfo(long used, long committed, long max) { ! getInfoLabel().setText(Resources.format(Messages.MEMORY_TAB_INFO_LABEL_FORMAT, formatBytes(used, true), formatBytes(committed, true), formatBytes(max, true))); } }
< prev index next >