### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java,v retrieving revision 1.293 diff -u -r1.293 CTabFolder.java --- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java 1 Jul 2009 14:49:32 -0000 1.293 +++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java 16 Sep 2009 14:26:19 -0000 @@ -1870,6 +1870,10 @@ } } if (index < 0 || index >= count) return; + while (!items[index].enabled) { + index = index + offset; + if (index < 0 || index >= count) return; + } setSelection (index, true); forceFocus(); } @@ -1932,7 +1936,12 @@ if (selectedIndex >= 0) { redraw(); } else { - setSelection(0, true); + int index = 0; + int count = items.length; + for (index = 0; index < count; index++) { + if (items[index].enabled) break; + } + setSelection(index, true); } } boolean onMnemonic (Event event, boolean doit) { @@ -1956,7 +1965,7 @@ (event.stateMask & SWT.BUTTON3) != 0) return; Event e = new Event(); e.item = getItem(new Point(event.x, event.y)); - if (e.item != null) { + if ((e.item != null) && ((CTabItem)e.item).enabled) { notifyListeners(SWT.DefaultSelection, e); } } @@ -2034,6 +2043,7 @@ } } if (item != null) { + if (!item.enabled) return; if (item.closeRect.contains(x,y)){ item.closeImageState = SELECTED; redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false); @@ -2088,6 +2098,7 @@ CTabItem item = items[i]; close = false; if (item.getBounds().contains(x, y)) { + if (!item.enabled) return; close = true; if (item.closeRect.contains(x, y)) { if (item.closeImageState != SELECTED && item.closeImageState != HOT) { @@ -2184,6 +2195,7 @@ } } if (item != null) { + if (!item.enabled) return; if (item.closeRect.contains(x,y)) { boolean selected = item.closeImageState == SELECTED; item.closeImageState = HOT; @@ -2269,6 +2281,9 @@ } } } + while (!items[index].enabled && index != selectedIndex) { + index = (index + offset + count) % count; + } } setSelection (index, true); } @@ -3220,7 +3235,7 @@ showItem(selection); return; } - + if (!items[index].enabled) return; int oldIndex = selectedIndex; selectedIndex = index; if (oldIndex != -1) { @@ -4022,6 +4037,7 @@ if (showChevron && chevronRect.contains(x, y)) return SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$ CTabItem item = getItem(new Point (x, y)); if (item == null) return null; + if (!item.enabled) return null; if (!item.showing) return null; if ((showClose || item.showClose) && item.closeRect.contains(x, y)) { return SWT.getMessage("SWT_Close"); //$NON-NLS-1$ Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java,v retrieving revision 1.118 diff -u -r1.118 CTabItem.java --- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java 1 Jul 2009 14:49:33 -0000 1.118 +++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java 16 Sep 2009 14:26:21 -0000 @@ -50,6 +50,7 @@ int closeImageState = CTabFolder.NONE; boolean showClose = false; boolean showing = false; + boolean enabled = true; // internal constants static final int TOP_MARGIN = 2; @@ -718,6 +719,24 @@ return disabledImage; } /** + * Returns true if the receiver is enabled, and + * false otherwise. A disabled CTabItem is + * not selectable from the user interface. + * + * @return the receiver's enabled state + * + * @exception SWTException + * + * @since 3.6 + */ +public boolean getEnabled () { + checkWidget(); + return this.enabled; +} +/** * Returns the font that the receiver will use to paint textual information. * * @return the receiver's font @@ -923,6 +942,35 @@ } this.disabledImage = image; } + +/** + * Enables the receiver if the argument is true, and disables + * it otherwise. A disabled CTabItem is not selectable from the user + * interface. When a selected CTabItem is disabled, it is no longer the + * selected tab-item and the selected index changes to -1. + * + * @param enabled the new enabled state + * + * @exception SWTException + * + * @since 3.6 + */ +public void setEnabled (boolean enabled) { + checkWidget(); + if (this.enabled == enabled) return; + + this.enabled = enabled; + if (!enabled && (parent.getSelection() == this)) { + if (control != null) control.setVisible(false); + parent.selectedIndex = -1; + closeImageState = CTabFolder.NONE; + parent.updateItems(); + parent.redrawTabs(); + } +} /** * Sets the font that the receiver will use to paint textual information * for this item to the font specified by the argument, or to the default font