### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.views.properties.tabbed Index: schema/propertySections.exsd =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/schema/propertySections.exsd,v retrieving revision 1.3 diff -u -r1.3 propertySections.exsd --- schema/propertySections.exsd 12 Apr 2007 17:42:41 -0000 1.3 +++ schema/propertySections.exsd 14 Nov 2007 21:44:45 -0000 @@ -104,14 +104,39 @@ - a value indicating the selection count which must be met to enable the section. If specified and the condition is not met, the section is not displayed. If omitted, the section enablement is not affected. The following attribute formats are currently supported: + a value indicating the selection count which must be met to enable the property section If specified and the condition is not met, the property section is disabled. If omitted, the property section enablement state is not affected. The following attribute formats are supported: <table border="0" width="80%"> <tr> <td valign="top" width="25"></td> + <td valign="top" nowrap><b>!</b></td> + <td valign="top">- 0 items selected</td> + </tr> + <tr> + <td valign="top" width="25"></td> + <td valign="top" nowrap><b>?</b></td> + <td valign="top">- 0 or 1 items selected</td> + </tr> + <tr> + <td valign="top" width="25"></td> + <td valign="top" nowrap><b>+</b></td> + <td valign="top">- 1 or more items selected</td> + </tr> + <tr> + <td valign="top" width="25"></td> + <td valign="top" nowrap><b>multiple, 2+</b></td> + <td valign="top">- 2 or more items selected</td> + </tr> + <tr> + <td valign="top" width="25"></td> <td valign="top" nowrap><b>n</b></td> - <td valign="top">- a precise number of items selected.&nbsp; - For example: enablesFor=&quot; 1&quot; enables the section only when 1 - item is selected</td> + <td valign="top">- a precise number of items selected.a precise number of items selected.&nbsp; + For example: enablesFor=&quot; 4&quot; enables the action only when 4 + items are selected</td> + </tr> + <tr> + <td valign="top" width="25"></td> + <td valign="top" nowrap><b>*</b></td> + <td valign="top">- any number of items selected</td> </tr> </table> Index: src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java,v retrieving revision 1.2 diff -u -r1.2 ISectionDescriptor.java --- src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java 29 Aug 2007 20:05:26 -0000 1.2 +++ src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java 14 Nov 2007 21:44:46 -0000 @@ -15,6 +15,7 @@ import org.eclipse.jface.viewers.IFilter; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.SelectionEnabler; /** * Represents a section descriptor on the tabbed property sections extensions. @@ -82,10 +83,19 @@ * ENABLES_FOR_ANY. * * @return the value for section enablement. + * @deprecated use {@link #getSelectionEnabler()} */ public int getEnablesFor(); /** + * Get a selection enabler that can determine if this section should be + * visible or not + * + * @return the selection enabler + */ + public SelectionEnabler getSelectionEnabler(); + + /** * Determines if this section applies to the selection. * * @param part Index: src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java,v retrieving revision 1.2 diff -u -r1.2 SectionDescriptor.java --- src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java 29 Aug 2007 20:05:26 -0000 1.2 +++ src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java 14 Nov 2007 21:44:46 -0000 @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.viewers.IFilter; +import org.eclipse.ui.SelectionEnabler; import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin; import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes; import org.eclipse.ui.internal.views.properties.tabbed.l10n.TabbedPropertyMessages; @@ -64,6 +65,8 @@ private int enablesFor = ENABLES_FOR_ANY; + private SelectionEnabler selectionEnabler; + private IConfigurationElement configurationElement; /** @@ -86,9 +89,13 @@ if (getConfigurationElement().getAttribute(ATT_SECTION_ENABLES_FOR) != null) { String enablesForStr = getConfigurationElement().getAttribute( ATT_SECTION_ENABLES_FOR); - int enablesForTest = Integer.parseInt(enablesForStr); - if (enablesForTest > 0) { - enablesFor = enablesForTest; + try{ + int enablesForTest = Integer.parseInt(enablesForStr); + if (enablesForTest > 0) { + enablesFor = enablesForTest; + } + } catch (NumberFormatException nfe) { + enablesFor = ENABLES_FOR_ANY; } } @@ -156,12 +163,23 @@ * 4 items are selected. If not specified, enable for all selections. * * @return the value for section enablement. + * @deprecated {@link org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getEnablesFor()} */ public int getEnablesFor() { return enablesFor; } /** + * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getSelectionEnabler() + */ + public SelectionEnabler getSelectionEnabler() { + if (selectionEnabler == null) { + selectionEnabler = new SelectionEnabler(configurationElement); + } + return selectionEnabler; + } + + /** * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getTargetTab() */ public String getTargetTab() { @@ -227,4 +245,5 @@ private IConfigurationElement getConfigurationElement() { return configurationElement; } + } Index: src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java,v retrieving revision 1.2 diff -u -r1.2 TabbedPropertyRegistryClassSectionFilter.java --- src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java 29 Aug 2007 20:05:26 -0000 1.2 +++ src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java 14 Nov 2007 21:44:46 -0000 @@ -59,13 +59,7 @@ if (selection instanceof IStructuredSelection && selection.isEmpty() == false) { - if (descriptor.getEnablesFor() != ISectionDescriptor.ENABLES_FOR_ANY && - ((IStructuredSelection) selection).size() != descriptor - .getEnablesFor()) { - /** - * enablesFor does not match the size of the selection, do not - * display section. - */ + if (!descriptor.getSelectionEnabler().isEnabledForSelection(selection)) { return false; }