# HG changeset patch # User Mario Torre # Date 1370595277 -7200 # Node ID 3a2501017e913fdc091878dfe5ed9e0a923b17c8 # Parent 9d27da66582c4e123228aaab1e7b63abe8e01303 New tab design for inner component review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-June/007041.html reviewed-by: vanaltj diff -r 9d27da66582c -r 3a2501017e91 client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CleanTabUI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/CleanTabUI.java Fri Jun 07 10:54:37 2013 +0200 @@ -0,0 +1,201 @@ +/* + * 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 + * . + * + * 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 java.awt.Graphics; +import java.awt.Insets; +import java.awt.Rectangle; +import java.lang.reflect.Field; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTabbedPaneUI; + +import com.redhat.thermostat.client.ui.Palette; + +class CleanTabUI extends BasicTabbedPaneUI { + + private Insets cleantabInsets; + + public CleanTabUI() { + cleantabInsets = new Insets(5, 10, 2, 10); + } + + @Override + public void installUI(JComponent c) { + super.installUI(c); + tabPane.setOpaque(true); + } + + @Override + protected void installDefaults() { + super.installDefaults(); + lightHighlight = Palette.EARL_GRAY.getColor(); + contentBorderInsets = new Insets(1, 1, 1, 1); + setTabsOverlap(); + } + + private void setTabsOverlap() { + try { + Field tabsOverlapBorderField = getClass().getSuperclass().getDeclaredField("tabsOverlapBorder"); + tabsOverlapBorderField.setAccessible(true); + tabsOverlapBorderField.set(this, true); + + } catch (IllegalArgumentException | IllegalAccessException | + NoSuchFieldException | SecurityException ignore) {} + } + + @Override + public void paint(Graphics g, JComponent c) { + lightHighlight = Palette.EARL_GRAY.getColor(); + super.paint(g, c); + } + + @Override + protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, + int x, int y, int width, int height, + boolean isSelected) + { + if (!isSelected) { + // TODO: implement for all orientations + g.setColor(Palette.PALE_GRAY.getColor().darker()); + g.drawRect(x, y, width, height); + + g.setColor(lightHighlight); + g.drawLine(x, y + height, x + width + 1, y + height); + + } else { + g.setColor(lightHighlight); + g.drawRect(x, y, width, height - 2); + + g.setColor(Palette.GRANITA_ORANGE.getColor()); + g.fillRect(x, y, width + 1, y + 1); + + g.setColor(Palette.LIGHT_GRAY.getColor()); + g.drawLine(x + 1, y + height - 2, x + width - 1, y + height - 2); + } + } + + // TODO +// protected JButton createScrollButton(int direction) { +// return new JButton(); +// } + + @Override + protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, + int selectedIndex, int x, int y, + int w, int h) + { + g.setColor(lightHighlight); + if (tabPlacement != BOTTOM) { + g.drawLine(x, y + h - 1, x + w, y + h - 1); + } else { + // TODO + } + } + + @Override + protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, + int selectedIndex, int x, int y, + int w, int h) + { + g.setColor(lightHighlight); + if (tabPlacement != LEFT) { + g.drawLine(x, y, x, y + h - 1); + } else { + // TODO + } + } + + @Override + protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, + int selectedIndex, int x, int y, + int w, int h) + { + g.setColor(lightHighlight); + if (tabPlacement != RIGHT) { + g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); + } else { + // TODO + } + } + + @Override + protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, + int selectedIndex, int x, int y, + int w, int h) + { + Rectangle bounds = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); + + g.setColor(lightHighlight); + if (tabPlacement != TOP || bounds == null) { + g.drawLine(x, y, x + w - 1, y); + + } else { + g.drawLine(x, y, bounds.x, y); + g.drawLine(bounds.x + bounds.width, y, x + w - 1, y); + + g.setColor(Palette.LIGHT_GRAY.getColor()); + g.drawLine(bounds.x + 1, y, bounds.x + bounds.width - 1, y); + } + } + + @Override + protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, + int x, int y, int width, int height, + boolean isSelected) + { + g.setColor(Palette.LIGHT_GRAY.getColor()); + int delta = 2; + if (!isSelected) { + delta = 1; + } + g.fillRect(x, y + 1, width, height - delta); + } + + @Override + protected void paintFocusIndicator(Graphics g, int tabPlacement, + Rectangle[] rects, int tabIndex, + Rectangle iconRect, Rectangle textRect, + boolean isSelected) + { + // no-op + } + + @Override + protected Insets getTabInsets(int tabPlacement, int tabIndex) { + return cleantabInsets; + } +} diff -r 9d27da66582c -r 3a2501017e91 client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ThermostatTabbedPane.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ThermostatTabbedPane.java Fri Jun 07 10:54:37 2013 +0200 @@ -0,0 +1,50 @@ +/* + * 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 + * . + * + * 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.JTabbedPane; + +/** + * Simple TabbedPane mainly useful for inner components. + */ +@SuppressWarnings("serial") +public class ThermostatTabbedPane extends JTabbedPane { + + public ThermostatTabbedPane() { + setUI(new CleanTabUI()); + } +} diff -r 9d27da66582c -r 3a2501017e91 thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java --- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java Mon May 27 20:50:48 2013 -0600 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java Fri Jun 07 10:54:37 2013 +0200 @@ -50,6 +50,7 @@ import com.redhat.thermostat.client.swing.ComponentVisibleListener; import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.components.ThermostatTabbedPane; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.shared.locale.LocalizedString; import com.redhat.thermostat.shared.locale.Translate; @@ -144,7 +145,7 @@ } private void setupTopPane() { - topPane = new JTabbedPane(); + topPane = new ThermostatTabbedPane(); topPane.setName("topTabbedPane"); threadTimelineView = new SwingThreadTimelineView(); @@ -157,7 +158,7 @@ } private void setupBottomPane() { - bottomPane = new JTabbedPane(); + bottomPane = new ThermostatTabbedPane(); bottomPane.setName("bottomTabbedPane"); threadTableView = new SwingThreadTableView(); diff -r 9d27da66582c -r 3a2501017e91 vm-heap-analysis/client-swing/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapDetailsSwing.java --- a/vm-heap-analysis/client-swing/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapDetailsSwing.java Mon May 27 20:50:48 2013 -0600 +++ b/vm-heap-analysis/client-swing/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapDetailsSwing.java Fri Jun 07 10:54:37 2013 +0200 @@ -43,6 +43,7 @@ import javax.swing.SwingUtilities; import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.components.ThermostatTabbedPane; import com.redhat.thermostat.shared.locale.LocalizedString; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumpDetailsView; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapHistogramView; @@ -55,7 +56,7 @@ private JPanel visiblePane; - private JTabbedPane tabPane = new JTabbedPane(); + private JTabbedPane tabPane = new ThermostatTabbedPane(); public HeapDetailsSwing() { visiblePane = new JPanel();