changeset 1143:9683c9b7bd61

Add buttons to ThermostatTab when scrolling is needed review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-June/007079.html reviewed-by: vanaltj
author Mario Torre <neugens.limasoftware@gmail.com>
date Mon, 24 Jun 2013 15:08:58 +0200
parents 66b8b266a5dd
children e34e65e36bc9
files client/swing/src/main/java/com/redhat/thermostat/client/swing/IconResource.java client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CleanTabUI.java client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ToolbarButtonBorder.java client/swing/src/main/resources/arrow-left.png client/swing/src/main/resources/arrow-right.png
diffstat 5 files changed, 39 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/IconResource.java	Mon Jun 24 13:50:44 2013 +0200
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/IconResource.java	Mon Jun 24 15:08:58 2013 +0200
@@ -61,12 +61,12 @@
     public static final IconResource CLEAN = new IconResource("clean.png");
     public static final IconResource TRASH = new IconResource("trash.png");
     
+    public static final IconResource ARROW_LEFT = new IconResource("arrow-left.png");
+    public static final IconResource ARROW_RIGHT = new IconResource("arrow-right.png");
+
     // TODO: add a proper one for this
     public static final IconResource HISTORY = RECORD;
 
-    // TODO: those should either go into appropriate modules or be converted into internal icons 
-    public static final IconResource ARROW_RIGHT = new IconResource(ICON_PREFIX + "48x48/actions/go-next.png", true);
-
     private final String path;
 
     private IconResource(String descriptor) {
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CleanTabUI.java	Mon Jun 24 13:50:44 2013 +0200
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CleanTabUI.java	Mon Jun 24 15:08:58 2013 +0200
@@ -40,15 +40,32 @@
 import java.awt.Rectangle;
 import java.lang.reflect.Field;
 
+import javax.swing.JButton;
 import javax.swing.JComponent;
+import javax.swing.SwingConstants;
+import javax.swing.plaf.UIResource;
 import javax.swing.plaf.basic.BasicTabbedPaneUI;
 
+import com.redhat.thermostat.client.swing.IconResource;
 import com.redhat.thermostat.client.ui.Palette;
 
 class CleanTabUI extends BasicTabbedPaneUI {
     
     private Insets cleantabInsets;
     
+    @SuppressWarnings("serial")
+    private class ArrowButton extends ActionButton implements UIResource, SwingConstants {
+
+        public ArrowButton(Icon icon) {
+            super(icon);
+            setRequestFocusEnabled(false);
+        }
+
+        public boolean isFocusTraversable() {
+            return false;
+        }
+    }
+    
     public CleanTabUI() {
         cleantabInsets = new Insets(5, 10, 2, 10);
     }
@@ -108,10 +125,24 @@
         }
     }
     
-    // TODO
-//    protected JButton createScrollButton(int direction) {
-//        return new JButton();
-//    }
+    protected JButton createScrollButton(int direction) {
+
+        IconResource resource = IconResource.ARROW_LEFT;
+        switch (direction) {
+        case EAST:
+        case NORTH:
+            resource = IconResource.ARROW_RIGHT;
+            break;
+
+        case WEST:
+        case SOUTH:
+        default:
+            resource = IconResource.ARROW_LEFT;
+            break;
+        }
+        
+        return new ArrowButton(resource.getIcon());
+    }
     
     @Override
     protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ToolbarButtonBorder.java	Mon Jun 24 13:50:44 2013 +0200
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ToolbarButtonBorder.java	Mon Jun 24 15:08:58 2013 +0200
@@ -51,7 +51,7 @@
 import com.redhat.thermostat.client.ui.Palette;
 
 @SuppressWarnings("serial")
-public class ToolbarButtonBorder extends DebugBorder implements UIResource, Serializable {
+class ToolbarButtonBorder extends DebugBorder implements UIResource, Serializable {
 
     public ToolbarButtonBorder(ToolbarButton button) {
         // TODO Auto-generated constructor stub
Binary file client/swing/src/main/resources/arrow-left.png has changed
Binary file client/swing/src/main/resources/arrow-right.png has changed