View | Details | Raw Unified | Return to bug 209867
Collapse All | Expand All

(-)schema/propertySections.exsd (-4 / +29 lines)
Lines 104-117 Link Here
104
         <attribute name="enablesFor" type="string">
104
         <attribute name="enablesFor" type="string">
105
            <annotation>
105
            <annotation>
106
               <documentation>
106
               <documentation>
107
                  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: 
107
                  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: 
108
    &lt;table border=&quot;0&quot; width=&quot;80%&quot;&gt;
108
    &lt;table border=&quot;0&quot; width=&quot;80%&quot;&gt;
109
      &lt;tr&gt;
109
      &lt;tr&gt;
110
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
110
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
111
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;!&lt;/b&gt;&lt;/td&gt;
112
        &lt;td valign=&quot;top&quot;&gt;- 0 items selected&lt;/td&gt;
113
      &lt;/tr&gt;
114
      &lt;tr&gt;
115
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
116
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;?&lt;/b&gt;&lt;/td&gt;
117
        &lt;td valign=&quot;top&quot;&gt;- 0 or 1 items selected&lt;/td&gt;
118
      &lt;/tr&gt;
119
      &lt;tr&gt;
120
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
121
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;+&lt;/b&gt;&lt;/td&gt;
122
        &lt;td valign=&quot;top&quot;&gt;- 1 or more items selected&lt;/td&gt;
123
      &lt;/tr&gt;
124
      &lt;tr&gt;
125
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
126
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;multiple, 2+&lt;/b&gt;&lt;/td&gt;
127
        &lt;td valign=&quot;top&quot;&gt;- 2 or more items selected&lt;/td&gt;
128
      &lt;/tr&gt;
129
      &lt;tr&gt;
130
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
111
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;n&lt;/b&gt;&lt;/td&gt;
131
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;n&lt;/b&gt;&lt;/td&gt;
112
        &lt;td valign=&quot;top&quot;&gt;- a precise number of items selected.&amp;nbsp;
132
        &lt;td valign=&quot;top&quot;&gt;- a precise number of items selected.a precise number of items selected.&amp;nbsp;
113
          For example: enablesFor=&amp;quot; 1&amp;quot; enables the section only when 1
133
          For example: enablesFor=&amp;quot; 4&amp;quot; enables the action only when 4
114
          item is selected&lt;/td&gt;
134
          items are selected&lt;/td&gt;
135
      &lt;/tr&gt;
136
      &lt;tr&gt;
137
 &lt;td valign=&quot;top&quot; width=&quot;25&quot;&gt;&lt;/td&gt;
138
        &lt;td valign=&quot;top&quot; nowrap&gt;&lt;b&gt;*&lt;/b&gt;&lt;/td&gt;
139
        &lt;td valign=&quot;top&quot;&gt;- any number of items selected&lt;/td&gt;
115
      &lt;/tr&gt;
140
      &lt;/tr&gt;
116
    &lt;/table&gt;
141
    &lt;/table&gt;
117
               </documentation>
142
               </documentation>
(-)src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java (+10 lines)
Lines 15-20 Link Here
15
import org.eclipse.jface.viewers.IFilter;
15
import org.eclipse.jface.viewers.IFilter;
16
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchPart;
18
import org.eclipse.ui.SelectionEnabler;
18
19
19
/**
20
/**
20
 * Represents a section descriptor on the tabbed property sections extensions.
21
 * Represents a section descriptor on the tabbed property sections extensions.
Lines 82-91 Link Here
82
	 * ENABLES_FOR_ANY.
83
	 * ENABLES_FOR_ANY.
83
	 * 
84
	 * 
84
	 * @return the value for section enablement.
85
	 * @return the value for section enablement.
86
	 * @deprecated use {@link #getSelectionEnabler()}
85
	 */
87
	 */
86
	public int getEnablesFor();
88
	public int getEnablesFor();
87
89
88
	/**
90
	/**
91
	 * Get a selection enabler that can determine if this section should be
92
	 * visible or not
93
	 * 
94
	 * @return the selection enabler
95
	 */
96
	public SelectionEnabler getSelectionEnabler();
97
98
	/**
89
	 * Determines if this section applies to the selection.
99
	 * Determines if this section applies to the selection.
90
	 * 
100
	 * 
91
	 * @param part
101
	 * @param part
(-)src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java (-3 / +22 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.jface.viewers.IFilter;
20
import org.eclipse.jface.viewers.IFilter;
21
import org.eclipse.ui.SelectionEnabler;
21
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
22
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
22
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
23
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
23
import org.eclipse.ui.internal.views.properties.tabbed.l10n.TabbedPropertyMessages;
24
import org.eclipse.ui.internal.views.properties.tabbed.l10n.TabbedPropertyMessages;
Lines 64-69 Link Here
64
65
65
	private int enablesFor = ENABLES_FOR_ANY;
66
	private int enablesFor = ENABLES_FOR_ANY;
66
67
68
	private SelectionEnabler selectionEnabler;
69
67
	private IConfigurationElement configurationElement;
70
	private IConfigurationElement configurationElement;
68
71
69
	/**
72
	/**
Lines 86-94 Link Here
86
		if (getConfigurationElement().getAttribute(ATT_SECTION_ENABLES_FOR) != null) {
89
		if (getConfigurationElement().getAttribute(ATT_SECTION_ENABLES_FOR) != null) {
87
			String enablesForStr = getConfigurationElement().getAttribute(
90
			String enablesForStr = getConfigurationElement().getAttribute(
88
					ATT_SECTION_ENABLES_FOR);
91
					ATT_SECTION_ENABLES_FOR);
89
			int enablesForTest = Integer.parseInt(enablesForStr);
92
			try{
90
			if (enablesForTest > 0) {
93
				int enablesForTest = Integer.parseInt(enablesForStr);
91
				enablesFor = enablesForTest;
94
				if (enablesForTest > 0) {
95
					enablesFor = enablesForTest;
96
				}
97
			} catch (NumberFormatException nfe) {
98
				enablesFor = ENABLES_FOR_ANY;
92
			}
99
			}
93
		}
100
		}
94
101
Lines 156-167 Link Here
156
	 * 4 items are selected. If not specified, enable for all selections.
163
	 * 4 items are selected. If not specified, enable for all selections.
157
	 * 
164
	 * 
158
	 * @return the value for section enablement.
165
	 * @return the value for section enablement.
166
	 * @deprecated {@link org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getEnablesFor()}
159
	 */
167
	 */
160
	public int getEnablesFor() {
168
	public int getEnablesFor() {
161
		return enablesFor;
169
		return enablesFor;
162
	}
170
	}
163
171
164
	/**
172
	/**
173
	 * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getSelectionEnabler()
174
	 */
175
	public SelectionEnabler getSelectionEnabler() {
176
		if (selectionEnabler == null) {
177
			selectionEnabler = new SelectionEnabler(configurationElement);
178
		}
179
		return selectionEnabler;
180
	}
181
182
	/**
165
	 * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getTargetTab()
183
	 * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#getTargetTab()
166
	 */
184
	 */
167
	public String getTargetTab() {
185
	public String getTargetTab() {
Lines 227-230 Link Here
227
	private IConfigurationElement getConfigurationElement() {
245
	private IConfigurationElement getConfigurationElement() {
228
		return configurationElement;
246
		return configurationElement;
229
	}
247
	}
248
230
}
249
}
(-)src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java (-7 / +1 lines)
Lines 59-71 Link Here
59
		if (selection instanceof IStructuredSelection &&
59
		if (selection instanceof IStructuredSelection &&
60
				selection.isEmpty() == false) {
60
				selection.isEmpty() == false) {
61
61
62
			if (descriptor.getEnablesFor() != ISectionDescriptor.ENABLES_FOR_ANY &&
62
			if (!descriptor.getSelectionEnabler().isEnabledForSelection(selection)) {
63
					((IStructuredSelection) selection).size() != descriptor
64
							.getEnablesFor()) {
65
				/**
66
				 * enablesFor does not match the size of the selection, do not
67
				 * display section.
68
				 */
69
				return false;
63
				return false;
70
			}
64
			}
71
65

Return to bug 209867