[179292] platform_head ahunter 070416 [TabbedProperties] Need to adapt new forms look
diff --git a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyComposite.java b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyComposite.java
index aab79bf..a51f359 100755
--- a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyComposite.java
+++ b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyComposite.java
@@ -82,6 +82,16 @@
* Create the contents in the main composite.
*/
protected void createMainContents() {
+ if (displayTitle) {
+ title = new TabbedPropertyTitle(mainComposite, factory);
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ title.setLayoutData(data);
+ }
+
leftComposite = factory.createComposite(mainComposite, SWT.NO_FOCUS);
leftComposite.setLayout(new FormLayout());
@@ -92,26 +102,29 @@
FormData formData = new FormData();
formData.left = new FormAttachment(leftComposite, 0);
formData.right = new FormAttachment(100, 0);
- formData.top = new FormAttachment(0, 0);
+ if (displayTitle) {
+ formData.top = new FormAttachment(title, 0);
+ } else {
+ formData.top = new FormAttachment(0, 0);
+ }
formData.bottom = new FormAttachment(100, 0);
scrolledComposite.setLayoutData(formData);
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(scrolledComposite, 0);
- formData.top = new FormAttachment(0, 0);
+ if (displayTitle) {
+ formData.top = new FormAttachment(title, 0);
+ } else {
+ formData.top = new FormAttachment(0, 0);
+ }
formData.bottom = new FormAttachment(100, 0);
leftComposite.setLayoutData(formData);
- final Composite rightComposite = factory.createComposite(scrolledComposite,
- SWT.NO_FOCUS);
- rightComposite.setLayout(new FormLayout());
- FormLayout formLayout = new FormLayout();
- formLayout.marginHeight = 0;
- formLayout.marginWidth = 0;
- rightComposite.setLayout(formLayout);
+ tabComposite = factory.createComposite(scrolledComposite, SWT.NO_FOCUS);
+ tabComposite.setLayout(new FormLayout());
- scrolledComposite.setContent(rightComposite);
+ scrolledComposite.setContent(tabComposite);
scrolledComposite.setAlwaysShowScrollBars(false);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setExpandHorizontal(true);
@@ -124,32 +137,12 @@
formData.bottom = new FormAttachment(100, 0);
listComposite.setLayoutData(formData);
- if (displayTitle) {
- title = new TabbedPropertyTitle(rightComposite, factory);
- }
-
- tabComposite = factory.createComposite(rightComposite, SWT.NO_FOCUS);
- tabComposite.setLayout(new FormLayout());
-
- if (displayTitle) {
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- title.setLayoutData(data);
- }
-
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
- if (displayTitle) {
- data.top = new FormAttachment(title, 0);
- } else {
- data.top = new FormAttachment(0, 0);
- }
+ data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
tabComposite.setLayoutData(data);
-
}
/**
diff --git a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyList.java b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyList.java
index 485af21..ab4b1c5 100755
--- a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyList.java
+++ b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.ui.internal.views.properties.tabbed.view;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.ACC;
import org.eclipse.swt.accessibility.Accessible;
@@ -44,6 +45,7 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.internal.views.properties.tabbed.l10n.TabbedPropertyMessages;
import org.eclipse.ui.views.properties.tabbed.ITabItem;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
@@ -63,8 +65,6 @@
protected static final int INDENT = 7;
- private boolean focus = false;
-
private ListElement[] elements;
private int selectedElementIndex = NONE;
@@ -81,24 +81,40 @@
private int tabsThatFitInComposite = NONE;
- private Color hoverBackground;
+ private Color widgetForeground;
- private Color defaultBackground;
+ private Color widgetBackground;
- private Color defaultForeground;
+ private Color widgetNormalShadow;
- private Color activeBackground;
+ private Color widgetDarkShadow;
- private Color border;
+ private Color listBackground;
- private Color darkShadow;
+ private Color hoverGradientStart;
- private Color textColor;
+ private Color hoverGradientEnd;
+
+ private Color defaultGradientStart;
+
+ private Color defaultGradientEnd;
+
+ private Color indentedDefaultBackground;
+
+ private Color indentedHoverBackground;
+
+ private Color navigationElementShadowStroke;
+
+ private Color bottomNavigationElementShadowStroke1;
+
+ private Color bottomNavigationElementShadowStroke2;
private TabbedPropertySheetWidgetFactory factory;
- public class ListElement
- extends Canvas {
+ /**
+ * One of the tabs in the tabbed property list.
+ */
+ public class ListElement extends Canvas {
private ITabItem tab;
@@ -108,8 +124,17 @@
private boolean hover;
- public ListElement(Composite parent, final ITabItem tab,
- int index) {
+ /**
+ * Constructor for ListElement.
+ *
+ * @param parent
+ * the parent Composite.
+ * @param tab
+ * the tab item for the element.
+ * @param index
+ * the index in the list.
+ */
+ public ListElement(Composite parent, final ITabItem tab, int index) {
super(parent, SWT.NO_FOCUS);
this.tab = tab;
hover = false;
@@ -126,7 +151,7 @@
public void mouseUp(MouseEvent e) {
if (!selected) {
- select(getIndex(ListElement.this), true);
+ select(getIndex(ListElement.this));
/*
* We set focus to the tabbed property composite so that
* focus is moved to the appropriate widget in the
@@ -159,54 +184,60 @@
});
}
+ /**
+ * Set selected value for this element.
+ *
+ * @param selected
+ * the selected value.
+ */
public void setSelected(boolean selected) {
this.selected = selected;
redraw();
}
/**
- * Draws elements and collects element areas.
+ * Paint the element.
+ *
+ * @param e
+ * the paint event.
*/
private void paint(PaintEvent e) {
- e.gc.setBackground(defaultBackground);
- e.gc.setForeground(defaultForeground);
+ /*
+ * draw the top two lines of the tab, same for selected, hover and
+ * default
+ */
Rectangle bounds = getBounds();
- e.gc.fillRectangle(0, 0, bounds.width, bounds.height);
-
- // draw tab
- if (selected) {
- e.gc.setBackground(activeBackground);
- } else if (hover) {
- e.gc.setBackground(hoverBackground);
- } else {
- e.gc.setBackground(defaultBackground);
- }
+ e.gc.setForeground(widgetNormalShadow);
+ e.gc.drawLine(0, 0, bounds.width - 1, 0);
+ e.gc.setForeground(listBackground);
+ e.gc.drawLine(0, 1, bounds.width - 1, 1);
/* draw the fill in the tab */
if (selected) {
- e.gc.fillRectangle(4, 0, bounds.width, bounds.height);
- e.gc.fillRectangle(3, 1, 3, bounds.height);
+ e.gc.setBackground(listBackground);
+ e.gc.fillRectangle(0, 2, bounds.width, bounds.height - 1);
+ } else if (hover && tab.isIndented()) {
+ e.gc.setBackground(indentedHoverBackground);
+ e.gc.fillRectangle(0, 2, bounds.width - 1, bounds.height - 1);
} else if (hover) {
- e.gc.fillRectangle(2, 0, bounds.width - 4, bounds.height);
+ e.gc.setForeground(hoverGradientStart);
+ e.gc.setBackground(hoverGradientEnd);
+ e.gc.fillGradientRectangle(0, 2, bounds.width - 1,
+ bounds.height - 1, true);
+ } else if (tab.isIndented()) {
+ e.gc.setBackground(indentedDefaultBackground);
+ e.gc.fillRectangle(0, 2, bounds.width - 1, bounds.height - 1);
+ } else {
+ e.gc.setForeground(defaultGradientStart);
+ e.gc.setBackground(defaultGradientEnd);
+ e.gc.fillGradientRectangle(0, 2, bounds.width - 1,
+ bounds.height - 1, true);
}
- /* draw the border */
- if (selected) {
- e.gc.setForeground(border);
- e.gc.drawLine(4, 0, bounds.width - 1, 0);
- e.gc.drawPoint(3, 1);
- e.gc.drawPoint(3, bounds.height - 1);
- e.gc.drawLine(2, 2, 2, bounds.height - 2);
- } else {
- e.gc.setForeground(border);
- if (getSelectionIndex() != NONE
- && getSelectionIndex() + 1 == index) {
- e.gc.drawLine(4, 0, bounds.width - 1, 0);
- } else {
- e.gc.drawLine(2, 0, bounds.width - 3, 0);
- }
- e.gc.drawLine(bounds.width - 1, 0, bounds.width - 1,
- bounds.height - 1);
+ if (!selected) {
+ e.gc.setForeground(widgetNormalShadow);
+ e.gc.drawLine(bounds.width - 1, 1, bounds.width - 1,
+ bounds.height + 1);
}
int textIndent = INDENT;
@@ -217,27 +248,41 @@
if (selected && tab.getImage() != null
&& !tab.getImage().isDisposed()) {
/* draw the icon for the selected tab */
- e.gc.drawImage(tab.getImage(), textIndent - 2, textMiddle);
- textIndent = textIndent + 16 + 2;
+ if (tab.isIndented()) {
+ textIndent = textIndent + INDENT;
+ } else {
+ textIndent = textIndent - 3;
+ }
+ e.gc.drawImage(tab.getImage(), textIndent, textMiddle - 1);
+ textIndent = textIndent + 16 + 5;
} else if (tab.isIndented()) {
- /* draw the indent tiny square */
- e.gc.drawRectangle(20, textMiddle + 6, 1, 1);
- textIndent = textIndent + 16 + 4;
+ textIndent = textIndent + INDENT;
}
/* draw the text */
- e.gc.setForeground(textColor);
- e.gc.drawText(tab.getText(), textIndent, textMiddle);
- if (((TabbedPropertyList) getParent()).focus && selected) {
- /* draw a line if the tab has focus */
- Point point = e.gc.textExtent(tab.getText());
- e.gc.drawLine(textIndent, bounds.height - 4, textIndent
- + point.x, bounds.height - 4);
+ e.gc.setForeground(widgetForeground);
+ if (selected) {
+ /* selected tab is bold font */
+ e.gc.setFont(JFaceResources.getFontRegistry().getBold(
+ JFaceResources.DEFAULT_FONT));
+ }
+ e.gc.drawText(tab.getText(), textIndent, textMiddle, true);
+
+ /* draw the bottom line on the tab for selected and default */
+ if (!hover) {
+ e.gc.setForeground(listBackground);
+ e.gc.drawLine(0, bounds.height - 1, bounds.width - 2,
+ bounds.height - 1);
}
}
- public String getText() {
- return tab.getText();
+ /**
+ * Get the tab item.
+ *
+ * @return the tab item.
+ */
+ public ITabItem getTabItem() {
+ return tab;
}
public String toString() {
@@ -245,11 +290,18 @@
}
}
- public class TopNavigationElement
- extends Canvas {
+ /**
+ * The top navigation element in the tabbed property list. It looks like a
+ * scroll button when scrolling is needed or is just a spacer when no
+ * scrolling is required.
+ */
+ public class TopNavigationElement extends Canvas {
/**
+ * Constructor for TopNavigationElement.
+ *
* @param parent
+ * the parent Composite.
*/
public TopNavigationElement(Composite parent) {
super(parent, SWT.NO_FOCUS);
@@ -276,51 +328,67 @@
}
/**
+ * Paint the element.
+ *
* @param e
+ * the paint event.
*/
private void paint(PaintEvent e) {
- e.gc.setBackground(defaultBackground);
- e.gc.setForeground(defaultForeground);
+ e.gc.setBackground(widgetBackground);
+ e.gc.setForeground(widgetForeground);
Rectangle bounds = getBounds();
if (elements.length != 0) {
e.gc.fillRectangle(0, 0, bounds.width, bounds.height);
- e.gc.setForeground(border);
+ e.gc.setForeground(widgetNormalShadow);
e.gc.drawLine(bounds.width - 1, 0, bounds.width - 1,
bounds.height - 1);
} else {
- e.gc.setBackground(activeBackground);
+ e.gc.setBackground(listBackground);
e.gc.fillRectangle(0, 0, bounds.width, bounds.height);
int textIndent = INDENT;
FontMetrics fm = e.gc.getFontMetrics();
int height = fm.getHeight();
int textMiddle = (bounds.height - height) / 2;
- e.gc.setForeground(textColor);
+ e.gc.setForeground(widgetForeground);
String properties_not_available = TabbedPropertyMessages.TabbedPropertyList_properties_not_available;
e.gc.drawText(properties_not_available, textIndent, textMiddle);
}
if (isUpScrollRequired()) {
- e.gc.setForeground(darkShadow);
+ e.gc.setForeground(widgetDarkShadow);
int middle = bounds.width / 2;
e.gc.drawLine(middle + 1, 3, middle + 5, 7);
e.gc.drawLine(middle, 3, middle - 4, 7);
- e.gc.drawLine(middle - 4, 8, middle + 5, 8);
+ e.gc.drawLine(middle - 3, 7, middle + 4, 7);
- e.gc.setForeground(activeBackground);
+ e.gc.setForeground(listBackground);
e.gc.drawLine(middle, 4, middle + 1, 4);
e.gc.drawLine(middle - 1, 5, middle + 2, 5);
e.gc.drawLine(middle - 2, 6, middle + 3, 6);
- e.gc.drawLine(middle - 3, 7, middle + 4, 7);
+
+ e.gc.setForeground(widgetNormalShadow);
+ e.gc.drawLine(0, 0, bounds.width - 2, 0);
+ e.gc.setForeground(navigationElementShadowStroke);
+ e.gc.drawLine(0, 1, bounds.width - 2, 1);
+ e.gc.drawLine(0, bounds.height - 1, bounds.width - 2,
+ bounds.height - 1);
}
}
}
- public class BottomNavigationElement
- extends Canvas {
+ /**
+ * The top navigation element in the tabbed property list. It looks like a
+ * scroll button when scrolling is needed or is just a spacer when no
+ * scrolling is required.
+ */
+ public class BottomNavigationElement extends Canvas {
/**
+ * Constructor for BottomNavigationElement.
+ *
* @param parent
+ * the parent Composite.
*/
public BottomNavigationElement(Composite parent) {
super(parent, SWT.NO_FOCUS);
@@ -347,46 +415,62 @@
}
/**
+ * Paint the element.
+ *
* @param e
+ * the paint event.
*/
private void paint(PaintEvent e) {
- e.gc.setBackground(defaultBackground);
- e.gc.setForeground(defaultForeground);
+ e.gc.setBackground(widgetBackground);
+ e.gc.setForeground(widgetForeground);
Rectangle bounds = getBounds();
if (elements.length != 0) {
e.gc.fillRectangle(0, 0, bounds.width, bounds.height);
- e.gc.setForeground(border);
+ e.gc.setForeground(widgetNormalShadow);
e.gc.drawLine(bounds.width - 1, 0, bounds.width - 1,
- bounds.height - 1);
- if (getSelectionIndex() != NONE && elements.length != 0
- && getSelectionIndex() == elements.length - 1) {
- e.gc.drawLine(4, 0, bounds.width - 1, 0);
- } else {
- e.gc.drawLine(2, 0, bounds.width - 1, 0);
- }
+ bounds.height - 1);
+ e.gc.drawLine(0, 0, bounds.width - 1, 0);
+
+ e.gc.setForeground(bottomNavigationElementShadowStroke1);
+ e.gc.drawLine(0, 1, bounds.width - 2, 1);
+ e.gc.setForeground(bottomNavigationElementShadowStroke2);
+ e.gc.drawLine(0, 2, bounds.width - 2, 2);
} else {
- e.gc.setBackground(activeBackground);
+ e.gc.setBackground(listBackground);
e.gc.fillRectangle(0, 0, bounds.width, bounds.height);
}
if (isDownScrollRequired()) {
- e.gc.setForeground(darkShadow);
+ e.gc.setForeground(widgetDarkShadow);
int middle = bounds.width / 2;
- int bottom = bounds.height - 2;
+ int bottom = bounds.height - 3;
e.gc.drawLine(middle + 1, bottom, middle + 5, bottom - 4);
e.gc.drawLine(middle, bottom, middle - 4, bottom - 4);
- e.gc.drawLine(middle - 4, bottom - 5, middle + 5, bottom - 5);
+ e.gc.drawLine(middle - 3, bottom - 4, middle + 4, bottom - 4);
- e.gc.setForeground(activeBackground);
+ e.gc.setForeground(listBackground);
e.gc.drawLine(middle, bottom - 1, middle + 1, bottom - 1);
e.gc.drawLine(middle - 1, bottom - 2, middle + 2, bottom - 2);
e.gc.drawLine(middle - 2, bottom - 3, middle + 3, bottom - 3);
- e.gc.drawLine(middle - 3, bottom - 4, middle + 4, bottom - 4);
+
+ e.gc.setForeground(widgetNormalShadow);
+ e.gc.drawLine(0, bottom - 7, bounds.width - 2, bottom - 7);
+ e.gc.setForeground(navigationElementShadowStroke);
+ e.gc.drawLine(0, bottom + 2, bounds.width - 2, bottom + 2);
+ e.gc.drawLine(0, bottom - 6, bounds.width - 2, bottom - 6);
}
}
}
+ /**
+ * Constructor for TabbedPropertyList.
+ *
+ * @param parent
+ * the parent widget.
+ * @param factory
+ * the widget factory.
+ */
public TabbedPropertyList(Composite parent,
TabbedPropertySheetWidgetFactory factory) {
super(parent, SWT.NO_FOCUS);
@@ -401,7 +485,6 @@
this.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
- focus = true;
int i = getSelectionIndex();
if (i >= 0) {
elements[i].redraw();
@@ -409,7 +492,6 @@
}
public void focusLost(FocusEvent e) {
- focus = false;
int i = getSelectionIndex();
if (i >= 0) {
elements[i].redraw();
@@ -436,7 +518,7 @@
nCurrent += 1;
nCurrent = Math.min(nCurrent, nMax);
}
- select(nCurrent, true);
+ select(nCurrent);
redraw();
} else {
e.doit = true;
@@ -500,6 +582,8 @@
/**
* Sets the new list elements.
+ *
+ * @param children
*/
public void setElements(Object[] children) {
if (elements != ELEMENTS_EMPTY) {
@@ -511,15 +595,21 @@
} else {
widestLabelIndex = 0;
for (int i = 0; i < children.length; i++) {
- elements[i] = new ListElement(this,
- (ITabItem) children[i], i);
+ elements[i] = new ListElement(this, (ITabItem) children[i], i);
elements[i].setVisible(false);
elements[i].setLayoutData(null);
if (i != widestLabelIndex) {
String label = ((ITabItem) children[i]).getText();
- if (getTextDimension(label).x > getTextDimension(((ITabItem) children[widestLabelIndex])
- .getText()).x) {
+ int width = getTextDimension(label).x;
+ if (((ITabItem) children[i]).getImage() != null) {
+ width = width + 16 + 5;
+ }
+ if (((ITabItem) children[i]).isIndented()) {
+ width = width + INDENT;
+ }
+ if (width > getTextDimension(((ITabItem) children[widestLabelIndex])
+ .getText()).x) {
widestLabelIndex = i;
}
}
@@ -530,9 +620,12 @@
}
/**
- * Selects one for the elements in the list.
+ * Selects one of the elements in the list.
+ *
+ * @param index
+ * the index of the element to select.
*/
- public void select(int index, boolean reveal) {
+ protected void select(int index) {
if (getSelectionIndex() == index) {
/*
* this index is already selected.
@@ -565,7 +658,7 @@
}
/**
- * Selects one for the elements in the list.
+ * Deselects all the elements in the list.
*/
public void deselectAll() {
if (getSelectionIndex() != NONE) {
@@ -578,30 +671,45 @@
return element.index;
}
- /**
- * Computes the size based on the widest string in the list.
- */
public Point computeSize(int wHint, int hHint, boolean changed) {
Point result = super.computeSize(hHint, wHint, changed);
if (widestLabelIndex == -1) {
String properties_not_available = TabbedPropertyMessages.TabbedPropertyList_properties_not_available;
result.x = getTextDimension(properties_not_available).x + INDENT;
} else {
- int width = getTextDimension(elements[widestLabelIndex].getText()).x;
+ ITabItem widestTab = elements[widestLabelIndex].getTabItem();
+ int width = getTextDimension(widestTab.getText()).x + INDENT;
/*
* To anticipate for the icon placement we should always keep the
* space available after the label. So when the active tab includes
* an icon the width of the tab doesn't change.
*/
- result.x = width + 32;
+ if (widestTab.getImage() != null) {
+ width = width + 16 + 4;
+ }
+ if (widestTab.isIndented()) {
+ width = width + 10;
+ }
+ /*
+ * Add 10 pixels to the right of the longest string as a margin.
+ */
+ result.x = width + 10;
}
return result;
}
+ /**
+ * Get the dimensions of the provided string.
+ *
+ * @param text
+ * the string.
+ * @return the dimensions of the provided string.
+ */
private Point getTextDimension(String text) {
Shell shell = new Shell();
GC gc = new GC(shell);
- gc.setFont(getFont());
+ gc.setFont(JFaceResources.getFontRegistry().getBold(
+ JFaceResources.DEFAULT_FONT));
Point point = gc.textExtent(text);
point.x++;
gc.dispose();
@@ -610,42 +718,101 @@
}
/**
- * Initialize the colours used.
+ * Initialize the colours used in the list.
*/
private void initColours() {
- defaultBackground = Display.getCurrent().getSystemColor(
- SWT.COLOR_WIDGET_BACKGROUND);
+ /*
+ * Colour 3 COLOR_LIST_BACKGROUND
+ */
+ listBackground = Display.getCurrent().getSystemColor(
+ SWT.COLOR_LIST_BACKGROUND);
- RGB rgb = defaultBackground.getRGB();
- rgb.blue = Math.min(255, Math.round(rgb.blue * 1.05F));
- rgb.red = Math.min(255, Math.round(rgb.red * 1.05F));
- rgb.green = Math.min(255, Math.round(rgb.green * 1.05F));
- hoverBackground = factory.getColors().createColor(
- "TabbedPropertyList.hoverBackground", rgb); //$NON-NLS-1$
+ /*
+ * Colour 13 COLOR_WIDGET_BACKGROUND
+ */
+ widgetBackground = Display.getCurrent().getSystemColor(
+ SWT.COLOR_WIDGET_BACKGROUND);
- defaultForeground = Display.getCurrent().getSystemColor(
- SWT.COLOR_WIDGET_FOREGROUND);
- activeBackground = Display.getCurrent().getSystemColor(
- SWT.COLOR_LIST_BACKGROUND);
- border = Display.getCurrent().getSystemColor(
- SWT.COLOR_WIDGET_NORMAL_SHADOW);
- darkShadow = Display.getCurrent().getSystemColor(
- SWT.COLOR_WIDGET_DARK_SHADOW);
- textColor = Display.getCurrent().getSystemColor(
- SWT.COLOR_WIDGET_FOREGROUND);
+ /*
+ * Colour 15 COLOR_WIDGET_DARK_SHADOW
+ */
+ widgetDarkShadow = Display.getCurrent().getSystemColor(
+ SWT.COLOR_WIDGET_DARK_SHADOW);
+
+ /*
+ * Colour 16 COLOR_WIDGET_FOREGROUND
+ */
+ widgetForeground = Display.getCurrent().getSystemColor(
+ SWT.COLOR_WIDGET_FOREGROUND);
+
+ /*
+ * Colour 19 COLOR_WIDGET_NORMAL_SHADOW
+ */
+ widgetNormalShadow = Display.getCurrent().getSystemColor(
+ SWT.COLOR_WIDGET_NORMAL_SHADOW);
+
+ RGB infoBackground = Display.getCurrent().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND).getRGB();
+ RGB white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)
+ .getRGB();
+ RGB black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)
+ .getRGB();
+
+ /*
+ * gradient in the default tab: start colour WIDGET_NORMAL_SHADOW 100% +
+ * white 20% + INFO_BACKGROUND 60% end colour WIDGET_NORMAL_SHADOW 100% +
+ * INFO_BACKGROUND 40%
+ */
+ defaultGradientStart = factory.getColors().createColor(
+ "TabbedPropertyList.defaultTabGradientStart", //$NON-NLS-1$
+ FormColors.blend(infoBackground, FormColors.blend(white,
+ widgetNormalShadow.getRGB(), 20), 60));
+ defaultGradientEnd = factory.getColors().createColor(
+ "TabbedPropertyList.defaultTabGradientEnd", //$NON-NLS-1$
+ FormColors.blend(infoBackground, widgetNormalShadow.getRGB(),
+ 40));
+
+ navigationElementShadowStroke = factory.getColors().createColor(
+ "TabbedPropertyList.shadowStroke", //$NON-NLS-1$
+ FormColors.blend(white, widgetNormalShadow.getRGB(), 55));
+ bottomNavigationElementShadowStroke1 = factory.getColors().createColor(
+ "TabbedPropertyList.tabShadowStroke1", //$NON-NLS-1$
+ FormColors.blend(black, widgetBackground.getRGB(), 10));
+ bottomNavigationElementShadowStroke2 = factory.getColors().createColor(
+ "TabbedPropertyList.tabShadowStroke2", //$NON-NLS-1$
+ FormColors.blend(black, widgetBackground.getRGB(), 5));
+
+ /*
+ * gradient in the hover tab: start colour WIDGET_BACKGROUND 100% +
+ * white 20% end colour WIDGET_BACKGROUND 100% + WIDGET_NORMAL_SHADOW
+ * 10%
+ */
+ hoverGradientStart = factory.getColors().createColor(
+ "TabbedPropertyList.hoverBackgroundGradientStart", //$NON-NLS-1$
+ FormColors.blend(white, widgetBackground.getRGB(), 20));
+ hoverGradientEnd = factory.getColors().createColor(
+ "TabbedPropertyList.hoverBackgroundGradientEnd", //$NON-NLS-1$
+ FormColors.blend(widgetNormalShadow.getRGB(), widgetBackground
+ .getRGB(), 10));
+
+ indentedDefaultBackground = factory.getColors().createColor(
+ "TabbedPropertyList.indentedDefaultBackground", //$NON-NLS-1$
+ FormColors.blend(white, widgetBackground.getRGB(), 10));
+ indentedHoverBackground = factory.getColors().createColor(
+ "TabbedPropertyList.indentedHoverBackground", //$NON-NLS-1$
+ FormColors.blend(white, widgetBackground.getRGB(), 75));
}
- /**
- * @see org.eclipse.swt.widgets.Widget#dispose()
- */
public void dispose() {
- hoverBackground.dispose();
- defaultBackground.dispose();
- defaultForeground.dispose();
- activeBackground.dispose();
- border.dispose();
- darkShadow.dispose();
- textColor.dispose();
+ hoverGradientStart.dispose();
+ hoverGradientEnd.dispose();
+ defaultGradientStart.dispose();
+ defaultGradientEnd.dispose();
+ indentedDefaultBackground.dispose();
+ indentedHoverBackground.dispose();
+ navigationElementShadowStroke.dispose();
+ bottomNavigationElementShadowStroke1.dispose();
+ bottomNavigationElementShadowStroke2.dispose();
super.dispose();
}
@@ -670,15 +837,28 @@
return tabHeight;
}
+ /**
+ * Determine if a downward scrolling is required.
+ *
+ * @return true if downward scrolling is required.
+ */
private boolean isDownScrollRequired() {
return elements.length > tabsThatFitInComposite
&& bottomVisibleIndex != elements.length - 1;
}
+ /**
+ * Determine if an upward scrolling is required.
+ *
+ * @return true if upward scrolling is required.
+ */
private boolean isUpScrollRequired() {
return elements.length > tabsThatFitInComposite && topVisibleIndex != 0;
}
+ /**
+ * Based on available space, figure out the top and bottom tabs in the list.
+ */
private void computeTopAndBottomTab() {
computeTabsThatFitInComposite();
if (elements.length == 0) {
@@ -810,13 +990,15 @@
public void getName(AccessibleEvent e) {
if (getSelectionIndex() != NONE) {
- e.result = elements[getSelectionIndex()].getText();
+ e.result = elements[getSelectionIndex()].getTabItem()
+ .getText();
}
}
public void getHelp(AccessibleEvent e) {
if (getSelectionIndex() != NONE) {
- e.result = elements[getSelectionIndex()].getText();
+ e.result = elements[getSelectionIndex()].getTabItem()
+ .getText();
}
}
});
diff --git a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyTitle.java b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyTitle.java
index 9c9fa4c..669f067 100755
--- a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyTitle.java
+++ b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyTitle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,17 +16,16 @@
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
@@ -46,16 +45,8 @@
private static final String BLANK = ""; //$NON-NLS-1$
- /**
- * Width of the margin that will be added around the control.
- */
- public int marginWidth = 4;
-
- /**
- * Height of the margin that will be added around the control.
- */
- public int marginHeight = 4;
-
+ private static final String TITLE_FONT = "org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyTitle"; //$NON-NLS-1$
+
private TabbedPropertySheetWidgetFactory factory;
/**
@@ -88,16 +79,25 @@
setForeground(factory.getColors().getForeground());
FormLayout layout = new FormLayout();
- layout.marginWidth = ITabbedPropertyConstants.HSPACE + 6;
- layout.marginHeight = 5;
+ layout.marginWidth = 1;
+ layout.marginHeight = 2;
setLayout(layout);
+ Font font;
+ if (! JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
+ FontData[] fontData = JFaceResources.getHeaderFont().getFontData();
+ fontData[0].setHeight(10);
+ JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
+ }
+ font = JFaceResources.getFont(TITLE_FONT);
+
label = factory.createCLabel(this, BLANK);
label.setBackground(new Color[] {
- factory.getColors().getColor(FormColors.TB_BG),
- factory.getColors().getColor(FormColors.TB_GBG)}, new int[] {100},
- true);
- label.setFont(JFaceResources.getBannerFont());
+ factory.getColors().getColor(IFormColors.H_GRADIENT_END),
+ factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
+ new int[] { 100 }, true);
+ label.setFont(font);
+ label.setForeground(factory.getColors().getColor(IFormColors.TITLE));
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(0, 0);
@@ -115,50 +115,27 @@
* @param e
*/
protected void drawTitleBackground(PaintEvent e) {
- Color bg = factory.getColors().getColor(FormColors.TB_BG);
- Color gbg = factory.getColors().getColor(FormColors.TB_GBG);
- Color border = factory.getColors().getColor(FormColors.TB_BORDER);
Rectangle bounds = getClientArea();
- Point tsize = null;
- Point labelSize = null;
- int twidth = bounds.width - marginWidth - marginWidth;
- if (label != null) {
- labelSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- }
- if (labelSize != null) {
- twidth -= labelSize.x + 4;
- }
- int tvmargin = 4;
- int theight = getHeight();
- if (tsize != null) {
- theight += Math.max(theight, tsize.y);
- }
- if (labelSize != null) {
- theight = Math.max(theight, labelSize.y);
- }
- theight += tvmargin + tvmargin;
- int midpoint = (theight * 66) / 100;
- int rem = theight - midpoint;
+ label.setBackground(new Color[] {
+ factory.getColors().getColor(IFormColors.H_GRADIENT_END),
+ factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
+ new int[] { 100 }, true);
+ Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END);
+ Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START);
GC gc = e.gc;
gc.setForeground(bg);
gc.setBackground(gbg);
- gc.fillGradientRectangle(marginWidth, marginHeight, bounds.width - 1
- - marginWidth - marginWidth, midpoint - 1, true);
- gc.setForeground(gbg);
- gc.setBackground(getBackground());
- gc.fillGradientRectangle(marginWidth, marginHeight + midpoint - 1,
- bounds.width - 1 - marginWidth - marginWidth, rem - 1, true);
- gc.setForeground(border);
- gc.drawLine(marginWidth, marginHeight + 2, marginWidth, marginHeight
- + theight - 1);
- gc.drawLine(marginWidth, marginHeight + 2, marginWidth + 2,
- marginHeight);
- gc.drawLine(marginWidth + 2, marginHeight, bounds.width - marginWidth
- - 3, marginHeight);
- gc.drawLine(bounds.width - marginWidth - 3, marginHeight, bounds.width
- - marginWidth - 1, marginHeight + 2);
- gc.drawLine(bounds.width - marginWidth - 1, marginHeight + 2,
- bounds.width - marginWidth - 1, marginHeight + theight - 1);
+ gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width,
+ bounds.height, true);
+ // background bottom separator
+ gc.setForeground(factory.getColors().getColor(
+ IFormColors.H_BOTTOM_KEYLINE1));
+ gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1,
+ bounds.height - 2);
+ gc.setForeground(factory.getColors().getColor(
+ IFormColors.H_BOTTOM_KEYLINE2));
+ gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1,
+ bounds.height - 1);
}
/**
@@ -166,6 +143,8 @@
*
* @param text
* the text label.
+ * @param image
+ * the image for the label.
*/
public void setTitle(String text, Image image) {
this.text = text;
@@ -178,19 +157,4 @@
label.setImage(image);
redraw();
}
-
- /**
- * @return the height of the title.
- */
- public int getHeight() {
- Shell shell = new Shell();
- GC gc = new GC(shell);
- gc.setFont(getFont());
- Point point = gc.textExtent(BLANK);
- point.x++;
- int textOrImageHeight = Math.max(point.x, 16);
- gc.dispose();
- shell.dispose();
- return textOrImageHeight + 8;
- }
}
diff --git a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyViewer.java b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyViewer.java
index 5513f64..b0e3898 100755
--- a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyViewer.java
+++ b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,7 +14,7 @@
import java.util.Collections;
import java.util.List;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.widgets.Control;
@@ -34,6 +34,12 @@
protected List elements;
protected IWorkbenchPart part;
+ /**
+ * Constructor for TabbedPropertyViewer.
+ *
+ * @param list
+ * the TabbedPropertyList.
+ */
public TabbedPropertyViewer(TabbedPropertyList list) {
this.list = list;
hookControl(list);
@@ -113,7 +119,7 @@
}
}
Assert.isTrue(index != -1, "Could not set the selected tab in the tabbed property viewer");//$NON-NLS-1$
- list.select(index, reveal);
+ list.select(index);
}
}
@@ -132,11 +138,24 @@
list.setElements(children);
}
+ /**
+ * Set the input for viewer.
+ *
+ * @param part
+ * the workbench part.
+ * @param selection
+ * the selection in the workbench part.
+ */
public void setInput(IWorkbenchPart part, ISelection selection) {
this.part = part;
setInput(selection);
}
-
+
+ /**
+ * Get the current workbench part.
+ *
+ * @return the current workbench part.
+ */
public IWorkbenchPart getWorkbenchPart() {
return part;
}
diff --git a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java
index 1a0972d..3bf1d16 100644
--- a/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java
+++ b/bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,8 +30,6 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
@@ -351,14 +349,6 @@
tabbedPropertyViewer
.addSelectionChangedListener(new SelectionChangedListener());
- tabbedPropertyComposite.getScrolledComposite().addControlListener(
- new ControlAdapter() {
-
- public void controlResized(ControlEvent e) {
- resizeScrolledComposite();
- }
- });
-
/**
* Add a part activation listener.
*/
@@ -561,17 +551,9 @@
if (currentTab != null) {
Composite sizeReference = (Composite) tabToComposite
.get(currentTab);
- currentTabSize.y = (sizeReference != null) ? sizeReference
- .computeSize(SWT.DEFAULT, SWT.DEFAULT).y
- : 0;
- currentTabSize.x = (sizeReference != null) ? sizeReference
- .computeSize(SWT.DEFAULT, SWT.DEFAULT).x
- : 0;
- }
- if (hasTitleBar) {
- int titleHeight = tabbedPropertyComposite.getTitle().computeSize(
- SWT.DEFAULT, SWT.DEFAULT).y;
- currentTabSize.y += titleHeight;
+ if (sizeReference != null) {
+ currentTabSize = sizeReference.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
}
tabbedPropertyComposite.getScrolledComposite().setMinSize(
currentTabSize.x, currentTabSize.y);