# HG changeset patch # User Mario Torre # Date 1372079338 -7200 # Node ID 9683c9b7bd614ff133de0c045bda5b44295ff489 # Parent 66b8b266a5dd13a60a1ab5ab6eaae93e677d8019 Add buttons to ThermostatTab when scrolling is needed review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-June/007079.html reviewed-by: vanaltj diff -r 66b8b266a5dd -r 9683c9b7bd61 client/swing/src/main/java/com/redhat/thermostat/client/swing/IconResource.java --- 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) { diff -r 66b8b266a5dd -r 9683c9b7bd61 client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CleanTabUI.java --- 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, diff -r 66b8b266a5dd -r 9683c9b7bd61 client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ToolbarButtonBorder.java --- 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 diff -r 66b8b266a5dd -r 9683c9b7bd61 client/swing/src/main/resources/arrow-left.png Binary file client/swing/src/main/resources/arrow-left.png has changed diff -r 66b8b266a5dd -r 9683c9b7bd61 client/swing/src/main/resources/arrow-right.png Binary file client/swing/src/main/resources/arrow-right.png has changed