Mercurial > hg > release > thermostat-1.0
changeset 1323:2dea7ac8e42c
More UI cleanups
review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-November/008711.html
reviewed-by: omajid
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/Palette.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/Palette.java Thu Nov 14 18:17:49 2013 +0100 @@ -44,44 +44,49 @@ */ public enum Palette { - THERMOSTAT_BLU(new Color(74, 93, 117)), - THERMOSTAT_RED(new Color(226, 46, 42)), + WHITE(Color.WHITE), - RED(new Color(192, 0, 0)), - PALE_RED(new Color(192, 80, 77)), + LIGHT_GRAY(new Color(242, 242, 242)), + PALE_GRAY(new Color(235, 235, 235)), + GRAY(new Color(216, 216, 216)), + DARK_GRAY(new Color(168, 172, 168)), + EARL_GRAY(new Color(128, 128, 128)), + + ELEGANT_BLACK(new Color(0x34313A)), + ROYAL_BLACK(new Color(0x2E2B33)), - SKY_BLUE(new Color(79, 129, 189)), - AZUREUS(new Color(0, 176, 190)), - EGYPTIAN_BLUE(new Color(74, 144, 217)), - DIRTY_CYAN(new Color(75, 172, 198)), - PRUSSIAN_BLUE(new Color(0, 49, 83)), + DROID_GRAY(new Color(0x272627)), + DROID_BLACK(new Color(0x161616)), + + DARK_BLUE(new Color(0x030A0C)), + BLACK(Color.BLACK), + PALE_RED(new Color(192, 80, 77)), + THERMOSTAT_RED(new Color(226, 46, 42)), + RED(new Color(192, 0, 0)), + + GRANITA_ORANGE(new Color(247,150,70)), + GREEN(new Color(146, 208, 80)), TUNDRA_GREEN(new Color(155, 187, 89)), - POMP_AND_POWER_VIOLET(new Color(128, 100, 162)), - VIOLET(new Color(112, 48, 160)), + AZUREUS(new Color(0, 176, 190)), + DIRTY_CYAN(new Color(75, 172, 198)), + + ELEGANT_CYAN(new Color(0x39CAFF)), - EARL_GRAY(new Color(128, 128, 128)), - - PALE_GRAY(new Color(235, 235, 235)), - LIGHT_GRAY(new Color(242, 242, 242)), - GRAY(new Color(216, 216, 216)), - DARK_GRAY(new Color(168, 172, 168)), + CLEAN_BLU(new Color(0x007AFF)), + EGYPTIAN_BLUE(new Color(74, 144, 217)), - GRANITA_ORANGE(new Color(247,150,70)), + ADWAITA_BLU(new Color(0x3980CB)), + SKY_BLUE(new Color(79, 129, 189)), + + THERMOSTAT_BLU(new Color(74, 93, 117)), + PRUSSIAN_BLUE(new Color(0, 49, 83)), + ROYAL_BLUE(new Color(0x0A242D)), - BLACK(Color.BLACK), - WHITE(Color.WHITE), - - DARK_BLUE(new Color(0x030A0C)), - ROYAL_BLUE(new Color(0x0A242D)), - ELEGANT_CYAN(new Color(0x39CAFF)), - ELEGANT_BLACK(new Color(0x34313A)), - ROYAL_BLACK(new Color(0x2E2B33)), - - DROID_BLACK(new Color(0x161616)), - DROID_GRAY(new Color(0x272627)), + VIOLET(new Color(112, 48, 160)), + POMP_AND_POWER_VIOLET(new Color(128, 100, 162)), /* END */ ;
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/host/swing/DeadHostIconDecorator.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/host/swing/DeadHostIconDecorator.java Thu Nov 14 18:17:49 2013 +0100 @@ -36,9 +36,11 @@ package com.redhat.thermostat.client.filter.host.swing; +import java.awt.Paint; + +import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.client.swing.components.FontAwesomeIcon; import com.redhat.thermostat.client.swing.components.Icon; -import com.redhat.thermostat.client.ui.Palette; import com.redhat.thermostat.client.ui.PlatformIcon; import com.redhat.thermostat.client.ui.ReferenceFieldIconDecorator; import com.redhat.thermostat.storage.core.HostRef; @@ -47,15 +49,32 @@ public class DeadHostIconDecorator implements ReferenceFieldIconDecorator { - public static final Icon UNCONNECTED = new FontAwesomeIcon('\uf127', 12, Palette.THERMOSTAT_RED.getColor()); - public static final Icon UNCONNECTED_SELECTED = new FontAwesomeIcon('\uf127', 12, Palette.THERMOSTAT_RED.getColor()); + private static Icon UNCONNECTED; + private static Icon UNCONNECTED_SELECTED; - private HostInfoDAO dao; + private static HostInfoDAO dao; + + private static DeadHostIconDecorator theInstance; - public DeadHostIconDecorator(HostInfoDAO dao) { - this.dao = dao; + public static synchronized DeadHostIconDecorator getInstance(HostInfoDAO dao, UIDefaults uiDefaults) { + + if (theInstance == null) { + DeadHostIconDecorator.dao = dao; + + int size = uiDefaults.getIconDecorationSize(); + Paint color = uiDefaults.getDecorationIconColor(); + + UNCONNECTED = new FontAwesomeIcon('\uf127', size, color); + UNCONNECTED_SELECTED = new FontAwesomeIcon('\uf127', size, color); + + theInstance = new DeadHostIconDecorator(); + } + + return theInstance; } + private DeadHostIconDecorator() {} + @Override public int getOrderValue() { return ORDER_FIRST + 100;
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/host/swing/HostIconDecorator.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/host/swing/HostIconDecorator.java Thu Nov 14 18:17:49 2013 +0100 @@ -36,7 +36,10 @@ package com.redhat.thermostat.client.filter.host.swing; +import java.awt.Paint; + import com.redhat.thermostat.client.swing.IconResource; +import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.client.swing.components.CompositeIcon; import com.redhat.thermostat.client.swing.components.Icon; import com.redhat.thermostat.client.ui.PlatformIcon; @@ -46,9 +49,30 @@ public class HostIconDecorator implements ReferenceFieldIconDecorator { - private static final Icon ICON = IconUtils.resizeIcon(IconResource.HOST_24.getIcon(), 32); - private static final Icon SELECTED = CompositeIcon.createDefaultComposite(ICON, true); + private static Icon ICON; + private static Icon SELECTED; + private static HostIconDecorator theInstance; + public static synchronized HostIconDecorator getInstance(UIDefaults uiDefaults) { + + if (theInstance == null) { + int size = uiDefaults.getReferenceFieldDefaultIconSize(); + Paint fg = uiDefaults.getReferenceFieldIconColor(); + Paint selected = uiDefaults.getReferenceFieldIconSelectedColor(); + + Icon hostIcon = IconUtils.resizeIcon(IconResource.HOST_24.getIcon(), size); + + ICON = CompositeIcon.createDefaultComposite(hostIcon, fg); + SELECTED = CompositeIcon.createDefaultComposite(hostIcon, selected); + + theInstance = new HostIconDecorator(); + } + + return theInstance; + } + + private HostIconDecorator() {} + @Override public int getOrderValue() { return ORDER_FIRST;
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMIconDecorator.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMIconDecorator.java Thu Nov 14 18:17:49 2013 +0100 @@ -36,10 +36,12 @@ package com.redhat.thermostat.client.filter.vm.swing; +import java.awt.Paint; + import com.redhat.thermostat.client.filter.host.swing.IconUtils; +import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.client.swing.components.FontAwesomeIcon; import com.redhat.thermostat.client.swing.components.Icon; -import com.redhat.thermostat.client.ui.Palette; import com.redhat.thermostat.client.ui.PlatformIcon; import com.redhat.thermostat.client.ui.ReferenceFieldIconDecorator; import com.redhat.thermostat.storage.core.Ref; @@ -50,16 +52,35 @@ public class DeadVMIconDecorator implements ReferenceFieldIconDecorator { - public static final Icon DEAD = new FontAwesomeIcon('\uf00d', 12, Palette.THERMOSTAT_RED.getColor()); - public static final Icon DEAD_SELECTED = new FontAwesomeIcon('\uf00d', 12, Palette.THERMOSTAT_RED.getColor()); + private static VmInfoDAO vmDao; + private static HostInfoDAO hostDao; + + public static Icon DEAD; + public static Icon DEAD_SELECTED; + + private static DeadVMIconDecorator theInstance; + + public static synchronized DeadVMIconDecorator getInstance(VmInfoDAO vmDao, + HostInfoDAO hostDao, + UIDefaults uiDefaults) + { + if (theInstance == null) { + DeadVMIconDecorator.vmDao = vmDao; + DeadVMIconDecorator.hostDao = hostDao; - private VmInfoDAO vmDao; - private HostInfoDAO hostDao; + int size = uiDefaults.getIconDecorationSize(); + Paint color = uiDefaults.getDecorationIconColor(); + + DEAD = new FontAwesomeIcon('\uf00d', size, color); + DEAD_SELECTED = new FontAwesomeIcon('\uf00d', size, color); + + theInstance = new DeadVMIconDecorator(); + } + + return theInstance; + } - public DeadVMIconDecorator(VmInfoDAO vmDao, HostInfoDAO hostDao) { - this.vmDao = vmDao; - this.hostDao = hostDao; - } + private DeadVMIconDecorator() {} @Override public int getOrderValue() {
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java Thu Nov 14 18:17:49 2013 +0100 @@ -51,12 +51,15 @@ import com.redhat.thermostat.client.filter.host.swing.DeadHostIconDecorator; import com.redhat.thermostat.client.filter.host.swing.HostIconDecorator; import com.redhat.thermostat.client.filter.host.swing.HostLabelDecorator; + import com.redhat.thermostat.client.swing.ReferenceFieldDecoratorLayout; +import com.redhat.thermostat.client.swing.UIDefaults; + import com.redhat.thermostat.client.ui.ReferenceFieldIconDecorator; import com.redhat.thermostat.client.ui.ReferenceFieldLabelDecorator; -import com.redhat.thermostat.common.Constants; + import com.redhat.thermostat.common.MultipleServiceTracker; -import com.redhat.thermostat.storage.core.VmRef; + import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; @@ -76,6 +79,7 @@ VmInfoDAO.class, HostInfoDAO.class, NetworkInterfaceInfoDAO.class, + UIDefaults.class, }; tracker = new MultipleServiceTracker(context, services, new MultipleServiceTracker.Action() { @@ -94,6 +98,8 @@ public void dependenciesAvailable(Map<String, Object> services) { ServiceRegistration registration = null; + UIDefaults uiDefaults = (UIDefaults) services.get(UIDefaults.class.getName()); + VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); HostInfoDAO hostDao = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); @@ -119,7 +125,7 @@ hostLabelDecorator, decoratorProperties); registeredServices.add(registration); - HostIconDecorator hostIconDecorator = new HostIconDecorator(); + HostIconDecorator hostIconDecorator = HostIconDecorator.getInstance(uiDefaults); decoratorProperties = new Hashtable<>(); decoratorProperties.put(ReferenceFieldIconDecorator.ID, ReferenceFieldDecoratorLayout.ICON_MAIN.name()); @@ -127,7 +133,7 @@ hostIconDecorator, decoratorProperties); registeredServices.add(registration); - DeadHostIconDecorator deadHostIconDecorator = new DeadHostIconDecorator(hostDao); + DeadHostIconDecorator deadHostIconDecorator = DeadHostIconDecorator.getInstance(hostDao, uiDefaults); decoratorProperties = new Hashtable<>(); decoratorProperties.put(ReferenceFieldIconDecorator.ID, ReferenceFieldDecoratorLayout.ICON_MAIN.name()); @@ -135,7 +141,7 @@ deadHostIconDecorator, decoratorProperties); registeredServices.add(registration); - VMIconDecorator livingVMIconDecorator = new VMIconDecorator(); + VMIconDecorator livingVMIconDecorator = VMIconDecorator.getInstance(uiDefaults); decoratorProperties = new Hashtable<>(); decoratorProperties.put(ReferenceFieldIconDecorator.ID, ReferenceFieldDecoratorLayout.ICON_MAIN.name()); @@ -143,7 +149,7 @@ livingVMIconDecorator, decoratorProperties); registeredServices.add(registration); - DeadVMIconDecorator deadVMIconDecorator = new DeadVMIconDecorator(vmDao, hostDao); + DeadVMIconDecorator deadVMIconDecorator = DeadVMIconDecorator.getInstance(vmDao, hostDao, uiDefaults); decoratorProperties = new Hashtable<>(); decoratorProperties.put(ReferenceFieldIconDecorator.ID, ReferenceFieldDecoratorLayout.ICON_MAIN.name());
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMIconDecorator.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMIconDecorator.java Thu Nov 14 18:17:49 2013 +0100 @@ -36,8 +36,11 @@ package com.redhat.thermostat.client.filter.vm.swing; +import java.awt.Paint; + import com.redhat.thermostat.client.filter.host.swing.IconUtils; import com.redhat.thermostat.client.swing.IconResource; +import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.client.swing.components.CompositeIcon; import com.redhat.thermostat.client.swing.components.Icon; import com.redhat.thermostat.client.ui.PlatformIcon; @@ -47,9 +50,30 @@ public class VMIconDecorator implements ReferenceFieldIconDecorator { - private static final Icon ICON = IconUtils.resizeIcon(IconResource.JAVA_APPLICATION_24.getIcon(), 32); - private static final Icon SELECTED = CompositeIcon.createDefaultComposite(ICON, true); + private static Icon ICON; + private static Icon SELECTED; + private static VMIconDecorator theInstance; + public static synchronized VMIconDecorator getInstance(UIDefaults uiDefaults) { + + if (theInstance == null) { + int size = uiDefaults.getReferenceFieldDefaultIconSize(); + Paint fg = uiDefaults.getReferenceFieldIconColor(); + Paint selected = uiDefaults.getReferenceFieldIconSelectedColor(); + + Icon vmIcon = IconUtils.resizeIcon(IconResource.JAVA_APPLICATION_24.getIcon(), size); + + ICON = CompositeIcon.createDefaultComposite(vmIcon, fg); + SELECTED = CompositeIcon.createDefaultComposite(vmIcon, selected); + + theInstance = new VMIconDecorator(); + } + + return theInstance; + } + + private VMIconDecorator() {} + @Override public int getOrderValue() { return ORDER_FIRST;
--- a/client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java Thu Nov 14 18:17:49 2013 +0100 @@ -38,12 +38,14 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import org.junit.Test; import com.redhat.thermostat.client.filter.host.swing.DeadHostIconDecorator; import com.redhat.thermostat.client.filter.host.swing.HostIconDecorator; import com.redhat.thermostat.client.filter.host.swing.HostLabelDecorator; +import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.client.ui.ReferenceFieldIconDecorator; import com.redhat.thermostat.client.ui.ReferenceFieldLabelDecorator; import com.redhat.thermostat.storage.dao.HostInfoDAO; @@ -62,10 +64,14 @@ VmInfoDAO vmDao = mock(VmInfoDAO.class); HostInfoDAO hostDao = mock(HostInfoDAO.class); NetworkInterfaceInfoDAO netDao = mock(NetworkInterfaceInfoDAO.class); + UIDefaults uiDefaults = mock(UIDefaults.class); + when(uiDefaults.getReferenceFieldDefaultIconSize()).thenReturn(1); + ctx.registerService(VmInfoDAO.class, vmDao, null); ctx.registerService(HostInfoDAO.class, hostDao, null); ctx.registerService(NetworkInterfaceInfoDAO.class, netDao, null); + ctx.registerService(UIDefaults.class, uiDefaults, null); assertTrue(ctx.isServiceRegistered(ReferenceFieldLabelDecorator.class.getName(), VMLabelDecorator.class)); assertTrue(ctx.isServiceRegistered(ReferenceFieldLabelDecorator.class.getName(), HostLabelDecorator.class)); @@ -74,7 +80,5 @@ assertTrue(ctx.isServiceRegistered(ReferenceFieldIconDecorator.class.getName(), VMIconDecorator.class)); assertTrue(ctx.isServiceRegistered(ReferenceFieldIconDecorator.class.getName(), DeadVMIconDecorator.class)); - - } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/ReferenceFieldDecoratorLayout.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/ReferenceFieldDecoratorLayout.java Thu Nov 14 18:17:49 2013 +0100 @@ -36,6 +36,7 @@ package com.redhat.thermostat.client.swing; +import com.redhat.thermostat.client.swing.components.Icon; import com.redhat.thermostat.client.ui.Decorator; import com.redhat.thermostat.client.ui.PlatformIcon; import com.redhat.thermostat.client.ui.ReferenceFieldIconDecorator; @@ -62,7 +63,7 @@ * * <br /><br /> * - * An example use for this field is the name of the target reference. + * An example use for this field is the name of the target reference. */ LABEL_MAIN, @@ -90,6 +91,17 @@ * * This icon is the main icon characterising the component being shown, * for example representing a particular application or device. + * + * <br /><br /> + * + * Decorators registered for this entry point can cast PlatformIcon into + * {@link Icon}. + * + * <br /><br /> + * + * <strong>Note</strong>: since this client doesn't provide a default icon, + * plugins that apply for this decoration should check for a + * <code>null</code> PlatformIcon before using the input parameter. */ ICON_MAIN, }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/UIDefaults.java Thu Nov 14 18:17:49 2013 +0100 @@ -0,0 +1,128 @@ +/* + * 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; + +import java.awt.Color; +import java.awt.Paint; + +import com.redhat.thermostat.annotations.Service; + +/** + * Returns the default UI defaults used by this Thermostat client. + */ +@Service +public interface UIDefaults { + + /** + * Returns the foreground colour for components that are + * selected, like text or entries in the reference field panel. + */ + Paint getSelectedComponentFGColor(); + + /** + * Returns the foreground colour for components. + */ + Paint getComponentFGColor(); + + /** + * Returns the suggested background colour for components that are + * selected. + */ + Paint getSelectedComponentBGColor(); + + /** + * Returns the default background colour for UI components. + */ + Paint getComponentBGColor(); + + /** + * Returns the suggested foreground colour for components that want to + * differentiate their text from other components. This is used, for example, + * in the side panel for {@link ReferenceFieldDecoratorLayout#LABEL_INFO} + * components. + */ + Paint getComponentSecondaryFGColor(); + + /** + * Returns the suggested size for the + * {@link ReferenceFieldDecoratorLayout#ICON_MAIN} icons. + * + * <br /><br /> + * + * <strong>Note</strong>: by default the side panel is not annotated + * with icons, this is a suggested value for plugins that want to provide + * an ReferenceFieldDecoratorLayout main icon decoration and + * indicates the full space of the icon (not the actual drawn area). + */ + int getReferenceFieldDefaultIconSize(); + + /** + * Returns the suggested size for the icon decorations, where applicable. + */ + int getIconDecorationSize(); + + /** + * Returns the suggested size for icons to be used in Thermostat views and + * components. + */ + int getIconSize(); + + /** + * Returns the suggested color for icons to be used in Thermostat views and + * components. + */ + Color getIconColor(); + + /** + * Returns the suggested color for icons to be used as + * {@link ReferenceFieldDecoratorLayout#ICON_MAIN} entry point. + */ + Paint getReferenceFieldIconColor(); + + /** + * Returns the suggested color for icons to be used as + * {@link ReferenceFieldDecoratorLayout#ICON_MAIN} entry point when + * selected. + */ + Paint getReferenceFieldIconSelectedColor(); + + /** + * Returns the suggested color for icons decorations to be used in + * Thermostat views and components. + */ + Paint getDecorationIconColor(); +}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/UIResources.java Thu Nov 14 11:50:48 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* - * 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; - -import com.redhat.thermostat.client.ui.IconDescriptor; -import java.awt.Color; -import java.awt.Font; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.UIManager; -import javax.swing.plaf.ColorUIResource; - -/** - * Encapsulates a standard selection of colors and fonts. - */ -public class UIResources { - - private static final UIResources resource = new UIResources(); - - private static final ColorUIResource hyperLinkColor; - private static final ColorUIResource hyperLinkActiveColor; - - private static final ColorUIResource selectionColor; - - private static final Font standard; - - private static IconDescriptor logo = null; - - static { - Color color = UIManager.getColor("Button.darkShadow"); - if (color == null) { - color = Color.BLUE; - } - hyperLinkColor = new ColorUIResource(color); - - color = UIManager.getColor("Button.focus"); - if (color == null) { - color = Color.BLUE; - } - hyperLinkActiveColor = new ColorUIResource(color); - selectionColor = hyperLinkActiveColor; - - Font font = UIManager.getFont("Label.font"); - if (font == null) { - font = Font.decode(Font.DIALOG); - } - standard = font; - try { - logo = IconDescriptor.loadIcon(UIResources.class.getClassLoader(), "/icons/thermostat.png"); - } catch (IOException ex) { - Logger.getLogger(UIResources.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); - } - } - - private static final Font header = standard.deriveFont(Font.BOLD); - - // TODO: check when size is too small - private static final Font footer = standard.deriveFont(Font.PLAIN, standard.getSize() - 2); - - private UIResources() { /* nothing to do */ } - - // colors - - public static UIResources getInstance() { - return resource; - } - - public ColorUIResource hyperlinkColor() { - return hyperLinkColor; - } - - public ColorUIResource hyperlinkActiveColor() { - return hyperLinkActiveColor; - } - - public ColorUIResource getSelectionColor() { - return selectionColor; - } - - // font resources - - public Font footerFont() { - return footer; - } - - public Font headerFont() { - return header; - } - - public Font standardFont() { - return standard; - } - - // miscellaneous - - public IconDescriptor getLogo() { - return logo; - } -} -
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/BaseIcon.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/BaseIcon.java Thu Nov 14 18:17:49 2013 +0100 @@ -36,26 +36,21 @@ package com.redhat.thermostat.client.swing.components; -import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Paint; -import java.awt.image.BufferedImage; -import java.beans.Transient; import com.redhat.thermostat.client.swing.GraphicsUtils; -import com.redhat.thermostat.client.swing.internal.vmlist.UIDefaults; @SuppressWarnings("serial") class BaseIcon extends Icon { - private boolean selected; + private Paint paint; private Icon source; - public BaseIcon(boolean selected, Icon source) { - this.selected = selected; + public BaseIcon(Paint paint, Icon source) { + this.paint = paint; this.source = source; } @@ -63,7 +58,7 @@ public synchronized void paintIcon(Component c, Graphics g, int x, int y) { GraphicsUtils utils = GraphicsUtils.getInstance(); Graphics2D graphics = utils.createAAGraphics(g); - graphics.setPaint(getPaint()); + graphics.setPaint(paint); graphics.fillRect(x, y, getIconWidth(), getIconHeight()); graphics.dispose(); } @@ -77,13 +72,4 @@ public int getIconWidth() { return source.getIconWidth(); } - - private Paint getPaint() { - UIDefaults palette = UIDefaults.getInstance(); - Color color = palette.getComponentFGColor(); - if (selected) { - color = palette.getSelectedComponentFGColor(); - } - return color; - } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CompositeIcon.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CompositeIcon.java Thu Nov 14 18:17:49 2013 +0100 @@ -41,6 +41,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; +import java.awt.Paint; import java.awt.image.BufferedImage; import java.beans.Transient; @@ -97,7 +98,7 @@ * Creates a default composite icon suitable for highlight. * The default colours are defined based on the underlying look and feel. */ - public static Icon createDefaultComposite(Icon source, boolean selected) { - return new CompositeIcon(source, new BaseIcon(true, source)); + public static Icon createDefaultComposite(Icon source, Paint paint) { + return new CompositeIcon(source, new BaseIcon(paint, source)); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/FontAwesomeIcon.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/FontAwesomeIcon.java Thu Nov 14 18:17:49 2013 +0100 @@ -44,6 +44,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; +import java.awt.Paint; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.IOException; @@ -67,7 +68,7 @@ private Font font; - private Color color; + private Paint color; static { try { @@ -97,7 +98,7 @@ } /** - * Creates a new {@link FontAwesomeIcon} painted in the given {@link Color}. + * Creates a new {@link FontAwesomeIcon} painted in the given {@link Paint}. * * <br /><br /> * @@ -108,7 +109,7 @@ * * @see {@link http://fortawesome.github.io/Font-Awesome/cheatsheet/} */ - public FontAwesomeIcon(char iconID, int size, Color color) { + public FontAwesomeIcon(char iconID, int size, Paint color) { this.iconID = iconID; this.size = size; font = awesome.deriveFont(Font.PLAIN, size); @@ -129,7 +130,7 @@ RenderingHints.VALUE_RENDER_QUALITY); graphics.setFont(font); - graphics.setColor(color); + graphics.setPaint(color); FontMetrics metrics = graphics.getFontMetrics(font); int width = metrics.charWidth(iconID);
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/AboutDialog.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/AboutDialog.java Thu Nov 14 18:17:49 2013 +0100 @@ -59,7 +59,6 @@ import javax.swing.border.TitledBorder; import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.swing.UIResources; import com.redhat.thermostat.common.ApplicationInfo; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.shared.locale.Translate;
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java Thu Nov 14 18:17:49 2013 +0100 @@ -50,7 +50,9 @@ import com.redhat.thermostat.client.core.views.ClientConfigurationView; import com.redhat.thermostat.client.locale.LocaleResources; +import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.client.swing.internal.views.ClientConfigurationSwing; +import com.redhat.thermostat.client.swing.internal.vmlist.UIDefaultsImpl; import com.redhat.thermostat.client.ui.ClientConfigReconnector; import com.redhat.thermostat.client.ui.ClientConfigurationController; import com.redhat.thermostat.common.ApplicationService; @@ -115,6 +117,11 @@ public void run() { ThemeManager themeManager = ThemeManager.getInstance(); themeManager.setLAF(); + + // this needs to be done after setting the laf, otherwise + // we will not get consistent colours + UIDefaults uiDefaults = UIDefaultsImpl.getInstance(); + context.registerService(UIDefaults.class, uiDefaults, null); } });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UIResources.java Thu Nov 14 18:17:49 2013 +0100 @@ -0,0 +1,136 @@ +/* + * 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.internal; + +import com.redhat.thermostat.client.ui.IconDescriptor; +import java.awt.Color; +import java.awt.Font; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; + +/** + * Encapsulates a standard selection of colors and fonts. + */ +class UIResources { + + private static final UIResources resource = new UIResources(); + + private static final ColorUIResource hyperLinkColor; + private static final ColorUIResource hyperLinkActiveColor; + + private static final ColorUIResource selectionColor; + + private static final Font standard; + + private static IconDescriptor logo = null; + + static { + Color color = UIManager.getColor("Button.darkShadow"); + if (color == null) { + color = Color.BLUE; + } + hyperLinkColor = new ColorUIResource(color); + + color = UIManager.getColor("Button.focus"); + if (color == null) { + color = Color.BLUE; + } + hyperLinkActiveColor = new ColorUIResource(color); + selectionColor = hyperLinkActiveColor; + + Font font = UIManager.getFont("Label.font"); + if (font == null) { + font = Font.decode(Font.DIALOG); + } + standard = font; + try { + logo = IconDescriptor.loadIcon(UIResources.class.getClassLoader(), "/icons/thermostat.png"); + } catch (IOException ex) { + Logger.getLogger(UIResources.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); + } + } + + private static final Font header = standard.deriveFont(Font.BOLD); + + // TODO: check when size is too small + private static final Font footer = standard.deriveFont(Font.PLAIN, standard.getSize() - 2); + + private UIResources() { /* nothing to do */ } + + // colors + + public static UIResources getInstance() { + return resource; + } + + public ColorUIResource hyperlinkColor() { + return hyperLinkColor; + } + + public ColorUIResource hyperlinkActiveColor() { + return hyperLinkActiveColor; + } + + public ColorUIResource getSelectionColor() { + return selectionColor; + } + + // font resources + + public Font footerFont() { + return footer; + } + + public Font headerFont() { + return header; + } + + public Font standardFont() { + return standard; + } + + // miscellaneous + + public IconDescriptor getLogo() { + return logo; + } +} +
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Thu Nov 14 18:17:49 2013 +0100 @@ -46,6 +46,7 @@ import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.client.core.views.SummaryViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; + import com.redhat.thermostat.client.swing.internal.GUIClientCommand; import com.redhat.thermostat.client.swing.internal.Main; import com.redhat.thermostat.client.swing.internal.views.SwingAgentInformationViewProvider; @@ -53,11 +54,14 @@ import com.redhat.thermostat.client.swing.internal.views.SwingHostInformationViewProvider; import com.redhat.thermostat.client.swing.internal.views.SwingSummaryViewProvider; import com.redhat.thermostat.client.swing.internal.views.SwingVmInformationViewProvider; + import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; + import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; + import com.redhat.thermostat.utils.keyring.Keyring; public class ThermostatActivator implements BundleActivator {
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/sidepane/ExpanderComponent.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/sidepane/ExpanderComponent.java Thu Nov 14 18:17:49 2013 +0100 @@ -60,7 +60,7 @@ setLayout(new BorderLayout()); final Icon mainIcon = new FontAwesomeIcon('\uf101', ICON_WIDTH, TopSidePane.FG_COLOR); - final Icon hover = new FontAwesomeIcon('\uf101', ICON_WIDTH, ThermostatSidePanel.FG_TEXT_COLOR); + final Icon hover = new FontAwesomeIcon('\uf101', ICON_WIDTH, TopSidePane.ICON_BG_COLOR); final JLabel expander = new JLabel(mainIcon); expander.setHorizontalTextPosition(SwingConstants.LEFT);
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/sidepane/ThermostatSidePanel.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/sidepane/ThermostatSidePanel.java Thu Nov 14 18:17:49 2013 +0100 @@ -49,7 +49,7 @@ @SuppressWarnings("serial") public class ThermostatSidePanel extends JPanel { - public static final Color BG_COLOR = Palette.DROID_GRAY.getColor(); + public static final Color BG_COLOR = Palette.DROID_GRAY.getColor(); public static final Color FG_COLOR = Palette.EARL_GRAY.getColor(); public static final Color FG_TEXT_COLOR = Palette.LIGHT_GRAY.getColor();
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/sidepane/TopSidePane.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/sidepane/TopSidePane.java Thu Nov 14 18:17:49 2013 +0100 @@ -52,6 +52,8 @@ import com.redhat.thermostat.client.swing.components.FontAwesomeIcon; import com.redhat.thermostat.client.swing.components.Icon; +import com.redhat.thermostat.client.swing.internal.vmlist.UIDefaultsImpl; + @SuppressWarnings("serial") class TopSidePane extends JPanel { @@ -59,7 +61,7 @@ static int ICON_WIDTH = 24; - static Color ICON_BG_COLOR = ThermostatSidePanel.FG_TEXT_COLOR; + static Color ICON_BG_COLOR = UIDefaultsImpl.getInstance().getReferenceFieldIconColor(); static Color FG_COLOR = ThermostatSidePanel.FG_COLOR; private Color currentFGColor = ThermostatSidePanel.FG_COLOR; @@ -67,7 +69,7 @@ public TopSidePane() { setBackground(Color.WHITE); setLayout(new BorderLayout()); - + final Icon mainIcon = new FontAwesomeIcon('\uf100', ICON_WIDTH, FG_COLOR); final Icon hover = new FontAwesomeIcon('\uf100', ICON_WIDTH, ICON_BG_COLOR);
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/ReferenceComponent.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/ReferenceComponent.java Thu Nov 14 18:17:49 2013 +0100 @@ -139,7 +139,7 @@ } private void setState() { - UIDefaults palette = UIDefaults.getInstance(); + UIDefaultsImpl palette = UIDefaultsImpl.getInstance(); if (selected) { mainLabel.setForeground(palette.getSelectedComponentFGColor()); infoLabel.setForeground(palette.getSelectedComponentFGColor());
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/ReferenceComponentPainter.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/ReferenceComponentPainter.java Thu Nov 14 18:17:49 2013 +0100 @@ -49,17 +49,17 @@ @Override public Color getSelectedForeground() { - return UIDefaults.getInstance().getSelectedComponentFGColor(); + return UIDefaultsImpl.getInstance().getSelectedComponentFGColor(); } @Override public Color getUnselectedForeground() { - return UIDefaults.getInstance().getComponentFGColor(); + return UIDefaultsImpl.getInstance().getComponentFGColor(); } @Override public void paint(Graphics2D g, AccordionComponent component, int width, int height) { - UIDefaults palette = UIDefaults.getInstance(); + UIDefaultsImpl palette = UIDefaultsImpl.getInstance(); GraphicsUtils utils = GraphicsUtils.getInstance(); Graphics2D graphics = utils.createAAGraphics(g);
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/UIDefaults.java Thu Nov 14 11:50:48 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * 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.internal.vmlist; - -import java.awt.Color; - -import javax.swing.UIManager; - -import com.redhat.thermostat.client.ui.Palette; - -/** - * - */ -public class UIDefaults { - private static final UIDefaults palette = new UIDefaults(); - public static UIDefaults getInstance() { - return palette; - } - - public Color getSelectedComponentFGColor() { - Color color = (Color) UIManager.get("thermostat-selection-fg-color"); - return color != null ? color : Palette.LIGHT_GRAY.getColor(); - } - - public Color getComponentFGColor() { - Color color = (Color) UIManager.get("thermostat-fg-color"); - return color != null ? color : Palette.DROID_BLACK.getColor(); - } - - public Color getSelectedComponentBGColor() { - Color color = (Color) UIManager.get("thermostat-selection-bg-color"); - return color != null ? color : Palette.THERMOSTAT_BLU.getColor(); - } - - public Color getComponentSecondaryFGColor() { - return Palette.DARK_GRAY.getColor(); - } - - public int getIconSize() { - return 32; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/UIDefaultsImpl.java Thu Nov 14 18:17:49 2013 +0100 @@ -0,0 +1,111 @@ +/* + * 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.internal.vmlist; + +import java.awt.Color; + +import javax.swing.UIManager; + +import com.redhat.thermostat.client.ui.Palette; + +public class UIDefaultsImpl implements com.redhat.thermostat.client.swing.UIDefaults { + + private static final UIDefaultsImpl palette = new UIDefaultsImpl(); + public static UIDefaultsImpl getInstance() { + return palette; + } + + public Color getSelectedComponentFGColor() { + Color color = (Color) UIManager.get("thermostat-selection-fg-color"); + return color != null ? color : Palette.LIGHT_GRAY.getColor(); + } + + public Color getComponentFGColor() { + Color color = (Color) UIManager.get("thermostat-fg-color"); + return color != null ? color : Palette.DROID_BLACK.getColor(); + } + + public Color getSelectedComponentBGColor() { + Color color = (Color) UIManager.get("thermostat-selection-bg-color"); + return color != null ? color : Palette.THERMOSTAT_BLU.getColor(); + } + + public Color getComponentSecondaryFGColor() { + return Palette.DARK_GRAY.getColor(); + } + + @Override + public int getIconSize() { + return 16; + } + + @Override + public Color getComponentBGColor() { + Color color = (Color) UIManager.get("thermostat-bg-color"); + return color != null ? color : Palette.LIGHT_GRAY.getColor(); + } + + @Override + public int getReferenceFieldDefaultIconSize() { + return 32; + } + + @Override + public int getIconDecorationSize() { + return 12; + } + + @Override + public Color getDecorationIconColor() { + return Palette.THERMOSTAT_RED.getColor(); + } + + @Override + public Color getIconColor() { + return Palette.EARL_GRAY.getColor(); + } + + @Override + public Color getReferenceFieldIconColor() { + return getSelectedComponentBGColor(); + } + + @Override + public Color getReferenceFieldIconSelectedColor() { + return getSelectedComponentFGColor(); + } +}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/controller/DecoratorManager.java Thu Nov 14 11:50:48 2013 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/vmlist/controller/DecoratorManager.java Thu Nov 14 18:17:49 2013 +0100 @@ -95,10 +95,7 @@ } private void setIcons(final ReferenceComponent component) { - Icons icons = new Icons(); - icons.main = component.getIcon(); - icons.selected = component.getSelectedIcon(); - icons = createComponentIcon(iconDecorator, component.getReference(), icons); + Icons icons = createComponentIcon(iconDecorator, component.getReference()); component.setIcon(icons.main, icons.selected); } @@ -108,9 +105,10 @@ } private <R extends Ref> Icons createComponentIcon(DecoratorListener<ReferenceFieldIconDecorator> listener, - R reference, - Icons originalIcons) + R reference) { + Icons originalIcons = new Icons(); + for (ReferenceFieldIconDecorator decorator : listener.getDecorators()) { originalIcons.main = (Icon) decorator.getIcon(originalIcons.main, reference); originalIcons.selected = (Icon) decorator.getSelectedIcon(originalIcons.selected, reference);
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/UIResourcesTest.java Thu Nov 14 11:50:48 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -/* - * 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; - -import java.awt.Color; -import java.awt.Font; - -import javax.swing.LookAndFeel; -import javax.swing.UIDefaults; -import javax.swing.UIManager; -import javax.swing.plaf.basic.BasicLookAndFeel; - -import junit.framework.Assert; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.redhat.thermostat.test.Bug; - -@Bug(id="976", - summary="About dialog creashes with GTK look and feel", - url="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=976") -public class UIResourcesTest { - - private static LookAndFeel originalLaf; - - @BeforeClass - public static void setUp() throws Exception { - final Object [] uiDefaults = new Object[] { - "Button.darkShadow", null, - "Button.focus", null, - "Label.font", null - }; - - originalLaf = UIManager.getLookAndFeel(); - UIManager.setLookAndFeel(new BasicLookAndFeel() { - - @Override - protected void initClassDefaults(UIDefaults table) { - super.initClassDefaults(table); - table.putDefaults(uiDefaults); - } - - @Override - protected void initSystemColorDefaults(UIDefaults table) { - super.initSystemColorDefaults(table); - table.putDefaults(uiDefaults); - } - - @Override - protected void initComponentDefaults(UIDefaults table) { - super.initComponentDefaults(table); - table.putDefaults(uiDefaults); - } - - @Override - public boolean isSupportedLookAndFeel() { - return true; - } - - @Override - public boolean isNativeLookAndFeel() { - return false; - } - - @Override - public String getName() { - return "fluff"; - } - - @Override - public String getID() { - return "fluff"; - } - - @Override - public String getDescription() { - return "fluff"; - } - }); - } - - @Test - public void testHyperlinkColor() { - Assert.assertEquals(Color.BLUE, UIResources.getInstance().hyperlinkColor()); - } - - @Test - public void testHyperlinkActiveColor() { - Assert.assertEquals(Color.BLUE, UIResources.getInstance().hyperlinkActiveColor()); - } - - @Test - public void testStandardFont() { - Assert.assertEquals(Font.DIALOG, UIResources.getInstance().standardFont().getName()); - } - - @AfterClass - public static void tearDown() throws Exception { - if (originalLaf != null) { - UIManager.setLookAndFeel(originalLaf); - } else { - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - } - } -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/UIResourcesTest.java Thu Nov 14 18:17:49 2013 +0100 @@ -0,0 +1,142 @@ +/* + * 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.internal; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.LookAndFeel; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicLookAndFeel; + +import junit.framework.Assert; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.redhat.thermostat.test.Bug; + +@Bug(id="976", + summary="About dialog creashes with GTK look and feel", + url="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=976") +public class UIResourcesTest { + + private static LookAndFeel originalLaf; + + @BeforeClass + public static void setUp() throws Exception { + final Object [] uiDefaults = new Object[] { + "Button.darkShadow", null, + "Button.focus", null, + "Label.font", null + }; + + originalLaf = UIManager.getLookAndFeel(); + UIManager.setLookAndFeel(new BasicLookAndFeel() { + + @Override + protected void initClassDefaults(UIDefaults table) { + super.initClassDefaults(table); + table.putDefaults(uiDefaults); + } + + @Override + protected void initSystemColorDefaults(UIDefaults table) { + super.initSystemColorDefaults(table); + table.putDefaults(uiDefaults); + } + + @Override + protected void initComponentDefaults(UIDefaults table) { + super.initComponentDefaults(table); + table.putDefaults(uiDefaults); + } + + @Override + public boolean isSupportedLookAndFeel() { + return true; + } + + @Override + public boolean isNativeLookAndFeel() { + return false; + } + + @Override + public String getName() { + return "fluff"; + } + + @Override + public String getID() { + return "fluff"; + } + + @Override + public String getDescription() { + return "fluff"; + } + }); + } + + @Test + public void testHyperlinkColor() { + Assert.assertEquals(Color.BLUE, UIResources.getInstance().hyperlinkColor()); + } + + @Test + public void testHyperlinkActiveColor() { + Assert.assertEquals(Color.BLUE, UIResources.getInstance().hyperlinkActiveColor()); + } + + @Test + public void testStandardFont() { + Assert.assertEquals(Font.DIALOG, UIResources.getInstance().standardFont().getName()); + } + + @AfterClass + public static void tearDown() throws Exception { + if (originalLaf != null) { + UIManager.setLookAndFeel(originalLaf); + } else { + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + } + } +} +