changeset 554:6ca85a6f23c7

Add support for localization in Thread Monitor review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-August/002835.html reviewed-by: vanaltj
author Mario Torre <neugens.limasoftware@gmail.com>
date Tue, 21 Aug 2012 09:45:24 +0200
parents e7413ea27f17
children f7f315bd6a53
files thread/client-common/pom.xml thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTableView.java thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/ThreadAliveDaemonTimelinePanel.java thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/ThreadMainPanel.java thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/VMCapsSummaryPanel.java
diffstat 8 files changed, 129 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/thread/client-common/pom.xml	Mon Aug 20 16:03:04 2012 +0200
+++ b/thread/client-common/pom.xml	Tue Aug 21 09:45:24 2012 +0200
@@ -103,6 +103,7 @@
             <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor>
             <Export-Package>
               com.redhat.thermostat.thread.client.common,
+              com.redhat.thermostat.thread.client.common.locale,
               com.redhat.thermostat.thread.client.common.chart,
             </Export-Package>
             <!-- Do not autogenerate uses clauses in Manifests -->
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java	Tue Aug 21 09:45:24 2012 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.thread.client.common.locale;
+
+import com.redhat.thermostat.common.locale.Translate;
+
+public enum LocaleResources {
+
+    NAME,
+    ID,
+    START,
+    STOP,
+    WAIT_COUNT,
+    BLOCK_COUNT,
+    RUNNING,
+    WAITING,
+    
+    START_RECORDING,
+    RECORDING,
+    
+    VM_CAPABILITIES,
+    TABLE,
+    
+    LIVE_THREADS,
+    DAEMON_THREADS,
+    
+    THREAD_CONTROL_PANEL,
+    THREAD_DUMP,
+    
+    MISSING_INFO;
+
+    public static final String RESOURCE_BUNDLE =
+            "com.redhat.thermostat.thread.client.common.locale.strings";
+    
+    public static Translate createLocalizer() {
+        return new Translate(RESOURCE_BUNDLE);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties	Tue Aug 21 09:45:24 2012 +0200
@@ -0,0 +1,21 @@
+MISSING_INFO = Missing Information
+
+NAME = Name
+ID = ID
+START = Started
+STOP = Stopped
+WAIT_COUNT = Wait Count
+BLOCK_COUNT = Blocked Count
+RUNNING = Running %
+WAITING = Waiting %
+
+START_RECORDING = Start Recording
+RECORDING = Recording probes...
+VM_CAPABILITIES = VM Capabilities
+TABLE = Table
+
+LIVE_THREADS = Live Threads
+DAEMON_THREADS = Daemon Threads
+
+THREAD_CONTROL_PANEL = Thread Control Panel
+THREAD_DUMP = Thread Dump
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTableView.java	Mon Aug 20 16:03:04 2012 +0200
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTableView.java	Tue Aug 21 09:45:24 2012 +0200
@@ -49,6 +49,8 @@
 
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
 import com.redhat.thermostat.client.ui.SwingComponent;
+import com.redhat.thermostat.thread.client.common.locale.LocaleResources;
+import com.redhat.thermostat.common.locale.Translate;
 import com.redhat.thermostat.thread.client.common.ThreadTableBean;
 import com.redhat.thermostat.thread.client.common.ThreadTableView;
 
@@ -59,6 +61,8 @@
     private JTable table;
     private ThreadTable tablePanel;
     
+    private static final Translate t = LocaleResources.createLocalizer();
+    
     public SwingThreadTableView() {
         tablePanel = new ThreadTable();
         tablePanel.addHierarchyListener(new ComponentVisibleListener() {
@@ -141,9 +145,15 @@
     @SuppressWarnings("serial")
     private class ThreadViewTableModel extends DefaultTableModel {
 
-        // TODO: localize
         private String [] columns = {
-                "Name", "ID", "Start", "Stop", "Wait Count", "Blocked Count", "Running %", "Waiting %"//, "Heap", "CPU Time", "User CPU Time"
+                t.localize(LocaleResources.NAME),
+                t.localize(LocaleResources.ID),
+                t.localize(LocaleResources.START),
+                t.localize(LocaleResources.STOP),
+                t.localize(LocaleResources.WAIT_COUNT),
+                t.localize(LocaleResources.BLOCK_COUNT),
+                t.localize(LocaleResources.RUNNING),
+                t.localize(LocaleResources.WAITING), //, "Heap", "CPU Time", "User CPU Time"
         };
         
         private List<ThreadTableBean> infos;
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java	Mon Aug 20 16:03:04 2012 +0200
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java	Tue Aug 21 09:45:24 2012 +0200
@@ -47,6 +47,7 @@
 
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
 import com.redhat.thermostat.client.ui.SwingComponent;
+import com.redhat.thermostat.common.locale.Translate;
 import com.redhat.thermostat.swing.ChartPanel;
 
 import com.redhat.thermostat.thread.client.common.ThreadTableView;
@@ -54,6 +55,7 @@
 import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView;
 
 import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart;
+import com.redhat.thermostat.thread.client.common.locale.LocaleResources;
 
 public class SwingThreadView extends ThreadView implements SwingComponent {
     
@@ -63,6 +65,8 @@
     private SwingThreadTableView threadTable;
     private SwingVMThreadCapabilitiesView vmCapsView;
     
+    private static final Translate t = LocaleResources.createLocalizer();
+
     public SwingThreadView() {
         
         panel = new ThreadMainPanel();
@@ -83,17 +87,17 @@
             }
         });
         
-        panel.getLiveRecording().setText("Start Recording");
+        panel.getLiveRecording().setText(t.localize(LocaleResources.START_RECORDING));
         panel.getLiveRecording().addItemListener(new ItemListener() {
             @Override
             public void itemStateChanged(ItemEvent e) {
                 ThreadAction action = null;
                 if (e.getStateChange() == ItemEvent.SELECTED) {
                     action = ThreadAction.START_LIVE_RECORDING;
-                    panel.getLiveRecording().setText("Recording probes...");
+                    panel.getLiveRecording().setText(t.localize(LocaleResources.RECORDING));
                 } else {
                     action = ThreadAction.STOP_LIVE_RECORDING;
-                    panel.getLiveRecording().setText("Start Recording");
+                    panel.getLiveRecording().setText(t.localize(LocaleResources.START_RECORDING));
                 }
                 final ThreadAction toNotify = action;
                 SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
@@ -112,10 +116,10 @@
         
         vmCapsView = new SwingVMThreadCapabilitiesView();
         JTabbedPane pane = new JTabbedPane();
-        pane.addTab("Capabilites", vmCapsView.getUiComponent());
+        pane.addTab(t.localize(LocaleResources.VM_CAPABILITIES), vmCapsView.getUiComponent());
         
         threadTable = new SwingThreadTableView();
-        pane.addTab("Table", threadTable.getUiComponent());
+        pane.addTab(t.localize(LocaleResources.TABLE), threadTable.getUiComponent());
         
         panel.getSplitPane().setBottomComponent(pane);
     }
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/ThreadAliveDaemonTimelinePanel.java	Mon Aug 20 16:03:04 2012 +0200
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/ThreadAliveDaemonTimelinePanel.java	Tue Aug 21 09:45:24 2012 +0200
@@ -44,8 +44,14 @@
 import javax.swing.JLabel;
 import javax.swing.SwingConstants;
 
+import com.redhat.thermostat.common.locale.Translate;
+import com.redhat.thermostat.thread.client.common.locale.LocaleResources;
+
 @SuppressWarnings("serial")
 class ThreadAliveDaemonTimelinePanel extends JPanel {
+
+    private static final Translate t = LocaleResources.createLocalizer();
+    
     private JLabel liveThreads;
     private JLabel daemonThreads;
     private JPanel timelinePanel;
@@ -82,9 +88,9 @@
                     .addGap(3))
         );
         
-        JLabel liveThreadsLabel = new JLabel("Live Threads:");
+        JLabel liveThreadsLabel = new JLabel(t.localize(LocaleResources.LIVE_THREADS) + ":");
         
-        JLabel daemonThreadsLabel = new JLabel("Daemon Threads:");
+        JLabel daemonThreadsLabel = new JLabel(t.localize(LocaleResources.DAEMON_THREADS) + ":");
         
         liveThreads = new JLabel("-");
         liveThreads.setHorizontalAlignment(SwingConstants.RIGHT);
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/ThreadMainPanel.java	Mon Aug 20 16:03:04 2012 +0200
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/ThreadMainPanel.java	Tue Aug 21 09:45:24 2012 +0200
@@ -47,11 +47,15 @@
 import javax.swing.JToggleButton;
 import javax.swing.LayoutStyle.ComponentPlacement;
 
+import com.redhat.thermostat.common.locale.Translate;
 import com.redhat.thermostat.swing.HeaderPanel;
+import com.redhat.thermostat.thread.client.common.locale.LocaleResources;
 
 @SuppressWarnings("serial")
 class ThreadMainPanel extends JPanel {
 
+    private static final Translate t = LocaleResources.createLocalizer();
+    
     private JToggleButton liveRecording;
     private JButton snapshot;
     private JSplitPane splitPane;
@@ -60,7 +64,7 @@
         setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
         
         HeaderPanel headerPanel = new HeaderPanel();
-        headerPanel.setHeader("Thread Control Panel");
+        headerPanel.setHeader(t.localize(LocaleResources.THREAD_CONTROL_PANEL));
         
         JPanel content = new JPanel();
         headerPanel.setContent(content);
@@ -91,7 +95,7 @@
                     .addContainerGap())
         );
         
-        snapshot = new JButton("Thread Dump");
+        snapshot = new JButton(t.localize(LocaleResources.THREAD_DUMP));
         
         liveRecording = new JToggleButton();
         
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/VMCapsSummaryPanel.java	Mon Aug 20 16:03:04 2012 +0200
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/VMCapsSummaryPanel.java	Tue Aug 21 09:45:24 2012 +0200
@@ -42,7 +42,6 @@
 import javax.swing.DefaultListModel;
 import javax.swing.JList;
 import javax.swing.JPanel;
-import javax.swing.border.TitledBorder;
 
 import com.redhat.thermostat.swing.models.NullSelectionModel;
 
@@ -62,7 +61,6 @@
         
         JPanel panel = new JPanel();
         panel.setLayout(new GridLayout(0, 1, 0, 0));
-        panel.setBorder(new TitledBorder(null, "VM Capabilities", TitledBorder.RIGHT, TitledBorder.TOP, null, null));
         panel.setOpaque(false);
         
         add(panel);