changeset 853:7b05bcaae364

Remove Components class Remove the c.r.t.client.swing.components.Components class. The method header() is available as the class SectionHeader. label() is available as the LabelField class. Modify existing code to use these classes instead. Inline the one-line smallBorder() method which was being used in 2 places. Reviewed-by: vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004707.html
author Omair Majid <omajid@redhat.com>
date Thu, 13 Dec 2012 09:52:03 -0500
parents c78625c43086
children 0e91d4d47781
files client/swing/src/main/java/com/redhat/thermostat/client/swing/components/Components.java client/swing/src/main/java/com/redhat/thermostat/client/swing/views/SummaryPanel.java host-memory/client-swing/src/main/java/com/redhat/thermostat/host/memory/client/swing/internal/HostMemoryPanel.java vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/internal/VmGcPanel.java vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/internal/SimpleTable.java vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/internal/VmOverviewPanel.java
diffstat 6 files changed, 17 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/Components.java	Wed Dec 12 19:39:21 2012 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * 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.client.swing.components;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.SwingConstants;
-import javax.swing.border.Border;
-
-public class Components {
-    public static JLabel header(String text) {
-        JLabel label = new JLabel(HtmlTextBuilder.boldHtml(text));
-        label.setHorizontalAlignment(SwingConstants.LEADING);
-        return label;
-    }
-
-    public static JLabel label(String string) {
-        JLabel label = new JLabel(string);
-        label.setHorizontalAlignment(SwingConstants.TRAILING);
-        return label;
-    }
-
-    public static Border smallBorder() {
-        return BorderFactory.createEmptyBorder(5, 5, 5, 5);
-    }
-}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/views/SummaryPanel.java	Wed Dec 12 19:39:21 2012 -0500
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/views/SummaryPanel.java	Thu Dec 13 09:52:03 2012 -0500
@@ -55,7 +55,7 @@
 import com.redhat.thermostat.client.core.views.SummaryView;
 import com.redhat.thermostat.client.locale.LocaleResources;
 import com.redhat.thermostat.client.swing.SwingComponent;
-import com.redhat.thermostat.client.swing.components.Components;
+import com.redhat.thermostat.client.swing.components.SectionHeader;
 import com.redhat.thermostat.client.swing.components.ValueField;
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
 import com.redhat.thermostat.common.ActionListener;
@@ -75,7 +75,7 @@
     public SummaryPanel() {
         super();
         visiblePanel = new JPanel();
-        JLabel lblHomepanel = Components.header(translator.localize(LocaleResources.HOME_PANEL_SECTION_SUMMARY));
+        JLabel lblHomepanel = new SectionHeader(translator.localize(LocaleResources.HOME_PANEL_SECTION_SUMMARY));
 
         JLabel lblTotalHosts = new JLabel(translator.localize(LocaleResources.HOME_PANEL_TOTAL_MACHINES));
 
@@ -85,7 +85,7 @@
 
         totalMonitoredVms = new ValueField("${TOTAL_MONITORED_VMS}");
 
-        JLabel lblIssues = Components.header(translator.localize(LocaleResources.HOME_PANEL_SECTION_ISSUES));
+        JLabel lblIssues = new SectionHeader(translator.localize(LocaleResources.HOME_PANEL_SECTION_ISSUES));
 
         JScrollPane scrollPane = new JScrollPane();
 
--- a/host-memory/client-swing/src/main/java/com/redhat/thermostat/host/memory/client/swing/internal/HostMemoryPanel.java	Wed Dec 12 19:39:21 2012 -0500
+++ b/host-memory/client-swing/src/main/java/com/redhat/thermostat/host/memory/client/swing/internal/HostMemoryPanel.java	Thu Dec 13 09:52:03 2012 -0500
@@ -64,8 +64,9 @@
 import org.jfree.data.time.TimeSeriesCollection;
 
 import com.redhat.thermostat.client.swing.SwingComponent;
-import com.redhat.thermostat.client.swing.components.Components;
+import com.redhat.thermostat.client.swing.components.LabelField;
 import com.redhat.thermostat.client.swing.components.RecentTimeSeriesChartPanel;
+import com.redhat.thermostat.client.swing.components.SectionHeader;
 import com.redhat.thermostat.client.swing.components.ValueField;
 import com.redhat.thermostat.client.ui.ChartColors;
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
@@ -258,9 +259,9 @@
         JPanel chartPanel = new RecentTimeSeriesChartPanel(new RecentTimeSeriesChartController(chart));
         chartPanel.setOpaque(false);
 
-        JLabel lblMemory = Components.header(translator.localize(LocaleResources.HOST_MEMORY_SECTION_OVERVIEW));
+        JLabel lblMemory = new SectionHeader(translator.localize(LocaleResources.HOST_MEMORY_SECTION_OVERVIEW));
 
-        JLabel totalMemoryLabel = Components.label(translator.localize(LocaleResources.HOST_INFO_MEMORY_TOTAL));
+        JLabel totalMemoryLabel = new LabelField(translator.localize(LocaleResources.HOST_INFO_MEMORY_TOTAL));
 
         memoryCheckBoxPanel.setOpaque(false);
 
--- a/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/internal/VmGcPanel.java	Wed Dec 12 19:39:21 2012 -0500
+++ b/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/internal/VmGcPanel.java	Thu Dec 13 09:52:03 2012 -0500
@@ -45,6 +45,7 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.swing.BorderFactory;
 import javax.swing.JPanel;
 import javax.swing.SwingUtilities;
 
@@ -62,9 +63,9 @@
 import org.jfree.data.xy.IntervalXYDataset;
 
 import com.redhat.thermostat.client.swing.SwingComponent;
-import com.redhat.thermostat.client.swing.components.Components;
 import com.redhat.thermostat.client.swing.components.HeaderPanel;
 import com.redhat.thermostat.client.swing.components.RecentTimeSeriesChartPanel;
+import com.redhat.thermostat.client.swing.components.SectionHeader;
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
 import com.redhat.thermostat.client.ui.RecentTimeSeriesChartController;
 import com.redhat.thermostat.client.ui.SampledDataset;
@@ -133,10 +134,10 @@
 
     private JPanel createCollectorDetailsPanel(IntervalXYDataset collectorData, String title, String units) {
         JPanel detailsPanel = new JPanel();
-        detailsPanel.setBorder(Components.smallBorder());
+        detailsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
         detailsPanel.setLayout(new BorderLayout());
 
-        detailsPanel.add(Components.header(title), BorderLayout.NORTH);
+        detailsPanel.add(new SectionHeader(title), BorderLayout.NORTH);
 
         JFreeChart chart = ChartFactory.createHistogram(
             null,
--- a/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/internal/SimpleTable.java	Wed Dec 12 19:39:21 2012 -0500
+++ b/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/internal/SimpleTable.java	Thu Dec 13 09:52:03 2012 -0500
@@ -57,7 +57,8 @@
 import javax.swing.JTextField;
 import javax.swing.SwingUtilities;
 
-import com.redhat.thermostat.client.swing.components.Components;
+import com.redhat.thermostat.client.swing.components.LabelField;
+import com.redhat.thermostat.client.swing.components.SectionHeader;
 import com.redhat.thermostat.client.swing.components.ValueField;
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
 
@@ -190,10 +191,10 @@
 
         for (Section section : sections) {
             sectionHeaderConstraints.gridy = keyConstraints.gridy = ++valueConstraints.gridy;
-            container.add(Components.header(section.getText()), sectionHeaderConstraints);
+            container.add(new SectionHeader(section.getText()), sectionHeaderConstraints);
             for (TableEntry tableEntry : section.getEntries()) {
                 keyConstraints.gridy = ++valueConstraints.gridy;
-                container.add(Components.label(tableEntry.getKey().getText()), keyConstraints);
+                container.add(new LabelField(tableEntry.getKey().getText()), keyConstraints);
 
                 for (Value value : tableEntry.getValues()) {
                     if (value.getComponent() == null) {
--- a/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/internal/VmOverviewPanel.java	Wed Dec 12 19:39:21 2012 -0500
+++ b/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/internal/VmOverviewPanel.java	Thu Dec 13 09:52:03 2012 -0500
@@ -37,19 +37,14 @@
 package com.redhat.thermostat.vm.overview.client.swing.internal;
 
 import java.awt.Component;
-import java.awt.Point;
-import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.swing.BorderFactory;
 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.SwingComponent;
-import com.redhat.thermostat.client.swing.components.Components;
 import com.redhat.thermostat.client.swing.components.HeaderPanel;
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
 import com.redhat.thermostat.common.ActionListener;
@@ -188,7 +183,7 @@
 
         SimpleTable simpleTable = new SimpleTable();
         JPanel table = simpleTable.createTable(allSections);
-        table.setBorder(Components.smallBorder());
+        table.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
 
         container = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);