changeset 1112:6640492c1733

PR1439: Missing any info (tooltip) on Notification panel Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-May/006763.html
author Omair Majid <omajid@redhat.com>
date Mon, 27 May 2013 12:27:22 -0400
parents 11fa523a7ba6
children 58d1c5979ddd
files client/swing/src/main/java/com/redhat/thermostat/client/swing/components/DescriptionField.java vm-jmx/client-core/src/main/java/com/redhat/thermostat/vm/jmx/client/core/LocaleResources.java vm-jmx/client-core/src/main/resources/com/redhat/thermostat/vm/jmx/client/core/strings.properties vm-jmx/client-swing/src/main/java/com/redhat/thermostat/vm/jmx/client/swing/internal/JmxNotificationsSwingView.java
diffstat 4 files changed, 95 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/DescriptionField.java	Mon May 27 12:27:22 2013 -0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012, 2013 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.client.swing.components;
+
+import javax.swing.JLabel;
+
+import com.redhat.thermostat.common.locale.LocalizedString;
+
+public class DescriptionField extends JLabel {
+
+    public DescriptionField(LocalizedString text) {
+        super(text.getContents());
+    }
+
+}
--- a/vm-jmx/client-core/src/main/java/com/redhat/thermostat/vm/jmx/client/core/LocaleResources.java	Fri May 24 12:44:17 2013 +0200
+++ b/vm-jmx/client-core/src/main/java/com/redhat/thermostat/vm/jmx/client/core/LocaleResources.java	Mon May 27 12:27:22 2013 -0400
@@ -43,6 +43,12 @@
     NOTIFICATIONS_TITLE,
 
     NOTIFICATIONS_HEADER,
+    NOTIFICATIONS_DESCRIPTION,
+
+    NOTIFICATIONS_ENABLE,
+    NOTIFICATIONS_ENABLE_DESCRIPTION,
+    NOTIFICATIONS_DISABLE,
+    NOTIFICATIONS_DISABLE_DESCRIPTION,
     ;
 
     static final String RESOURCE_BUNDLE = "com.redhat.thermostat.vm.jmx.client.core.strings";
--- a/vm-jmx/client-core/src/main/resources/com/redhat/thermostat/vm/jmx/client/core/strings.properties	Fri May 24 12:44:17 2013 +0200
+++ b/vm-jmx/client-core/src/main/resources/com/redhat/thermostat/vm/jmx/client/core/strings.properties	Mon May 27 12:27:22 2013 -0400
@@ -1,3 +1,9 @@
 NOTIFICATIONS_TITLE=Notifications
 
-NOTIFICATIONS_HEADER=JMX Notifications
\ No newline at end of file
+NOTIFICATIONS_HEADER=JMX Notifications
+NOTIFICATIONS_DESCRIPTION = When enabled, this shows all the JMX notifications emitted by any MBeans active in this JVM
+
+NOTIFICATIONS_ENABLE = Start Monitoring
+NOTIFICATIONS_ENABLE_DESCRIPTION = Start Monitoring Jmx Notifications
+NOTIFICATIONS_DISABLE = Stop Monitoring
+NOTIFICATIONS_DISABLE_DESCRIPTION = Stop Monitoring Jmx Notifications
--- a/vm-jmx/client-swing/src/main/java/com/redhat/thermostat/vm/jmx/client/swing/internal/JmxNotificationsSwingView.java	Fri May 24 12:44:17 2013 +0200
+++ b/vm-jmx/client-swing/src/main/java/com/redhat/thermostat/vm/jmx/client/swing/internal/JmxNotificationsSwingView.java	Mon May 27 12:27:22 2013 -0400
@@ -42,16 +42,22 @@
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
+import javax.swing.ButtonModel;
 import javax.swing.DefaultListModel;
 import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 
 import com.redhat.thermostat.client.swing.ComponentVisibleListener;
 import com.redhat.thermostat.client.swing.IconResource;
 import com.redhat.thermostat.client.swing.SwingComponent;
 import com.redhat.thermostat.client.swing.components.ActionToggleButton;
+import com.redhat.thermostat.client.swing.components.DescriptionField;
 import com.redhat.thermostat.client.swing.components.HeaderPanel;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
@@ -72,16 +78,24 @@
 
     public JmxNotificationsSwingView() {
 
+        DescriptionField description = new DescriptionField(translate.localize(LocaleResources.NOTIFICATIONS_DESCRIPTION));
+        description.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+        JList<String> issuesList = new JList<>(listModel);
+
         JPanel contents = new JPanel();
         contents.setLayout(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 0;
+        c.anchor = GridBagConstraints.FIRST_LINE_START;
+
+        contents.add(description, c);
+
+        c.gridy++;
         c.weightx = 1;
         c.weighty = 1;
         c.fill = GridBagConstraints.BOTH;
-        c.anchor = GridBagConstraints.PAGE_START;
-
-        JList<String> issuesList = new JList<>(listModel);
-
+        c.anchor = GridBagConstraints.FIRST_LINE_START;
         contents.add(new JScrollPane(issuesList), c);
 
         contents.addHierarchyListener(new ComponentVisibleListener() {
@@ -96,8 +110,9 @@
             }
         });
 
-        toolbarButton = new ActionToggleButton(IconResource.RECORD.getIcon(), "");
+        toolbarButton = new ActionToggleButton(IconResource.RECORD.getIcon(), translate.localize(LocaleResources.NOTIFICATIONS_ENABLE).getContents());
         toolbarButton.setName("toggleNotifications");
+        toolbarButton.setToolTipText(translate.localize(LocaleResources.NOTIFICATIONS_ENABLE_DESCRIPTION).getContents());
         toolbarButton.addActionListener(new java.awt.event.ActionListener() {
 
             @Override
@@ -105,6 +120,19 @@
                 fireNotificationAction(NotificationAction.TOGGLE_NOTIFICATIONS);
             }
         });
+        toolbarButton.addChangeListener(new ChangeListener() {
+            @Override
+            public void stateChanged(ChangeEvent e) {
+                ButtonModel model = ((AbstractButton) e.getSource()).getModel();
+                if (model.isSelected()) {
+                    toolbarButton.setText(translate.localize(LocaleResources.NOTIFICATIONS_DISABLE).getContents());
+                    toolbarButton.setToolTipText(translate.localize(LocaleResources.NOTIFICATIONS_DISABLE_DESCRIPTION).getContents());
+                } else {
+                    toolbarButton.setText(translate.localize(LocaleResources.NOTIFICATIONS_ENABLE).getContents());
+                    toolbarButton.setToolTipText(translate.localize(LocaleResources.NOTIFICATIONS_ENABLE_DESCRIPTION).getContents());
+                }
+            }
+        });
 
         visiblePanel = new HeaderPanel(translate.localize(LocaleResources.NOTIFICATIONS_HEADER).getContents());
         visiblePanel.addToolBarButton(toolbarButton);