Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 294894 | Differences between
and this patch

Collapse All | Expand All

(-)schema/propertyPages.exsd (-27 / +41 lines)
Lines 2-10 Link Here
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.ui" xmlns="http://www.w3.org/2001/XMLSchema">
3
<schema targetNamespace="org.eclipse.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
4
<annotation>
5
      <appinfo>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.ui" id="propertyPages" name="Property Pages"/>
6
         <meta.schema plugin="org.eclipse.ui" id="propertyPages" name="Property Pages"/>
7
      </appinfo>
7
      </appInfo>
8
      <documentation>
8
      <documentation>
9
         This extension point is used to add additional property page for objects of a given type.  Once defined, these property pages will appear in the Properties Dialog for objects of that type. 
9
         This extension point is used to add additional property page for objects of a given type.  Once defined, these property pages will appear in the Properties Dialog for objects of that type. 
10
&lt;p&gt;
10
&lt;p&gt;
Lines 24-29 Link Here
24
   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
24
   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
25
25
26
   <element name="extension">
26
   <element name="extension">
27
      <annotation>
28
         <appInfo>
29
            <meta.element />
30
         </appInfo>
31
      </annotation>
27
      <complexType>
32
      <complexType>
28
         <sequence>
33
         <sequence>
29
            <element ref="page" minOccurs="0" maxOccurs="unbounded"/>
34
            <element ref="page" minOccurs="0" maxOccurs="unbounded"/>
Lines 47-55 Link Here
47
               <documentation>
52
               <documentation>
48
                  an optional name of the extension instance
53
                  an optional name of the extension instance
49
               </documentation>
54
               </documentation>
50
               <appinfo>
55
               <appInfo>
51
                  <meta.attribute translatable="true"/>
56
                  <meta.attribute translatable="true"/>
52
               </appinfo>
57
               </appInfo>
53
            </annotation>
58
            </annotation>
54
         </attribute>
59
         </attribute>
55
      </complexType>
60
      </complexType>
Lines 79-87 Link Here
79
               <documentation>
84
               <documentation>
80
                  a translatable name that will be used in the UI for this page
85
                  a translatable name that will be used in the UI for this page
81
               </documentation>
86
               </documentation>
82
               <appinfo>
87
               <appInfo>
83
                  <meta.attribute translatable="true"/>
88
                  <meta.attribute translatable="true"/>
84
               </appinfo>
89
               </appInfo>
85
            </annotation>
90
            </annotation>
86
         </attribute>
91
         </attribute>
87
         <attribute name="icon" type="string">
92
         <attribute name="icon" type="string">
Lines 89-97 Link Here
89
               <documentation>
94
               <documentation>
90
                  a relative path to an icon that will be used in the UI in addition to the page name
95
                  a relative path to an icon that will be used in the UI in addition to the page name
91
               </documentation>
96
               </documentation>
92
               <appinfo>
97
               <appInfo>
93
                  <meta.attribute kind="resource"/>
98
                  <meta.attribute kind="resource"/>
94
               </appinfo>
99
               </appInfo>
95
            </annotation>
100
            </annotation>
96
         </attribute>
101
         </attribute>
97
         <attribute name="objectClass" type="string">
102
         <attribute name="objectClass" type="string">
Lines 101-109 Link Here
101
106
102
&lt;p&gt;Deprecated in Eclipse 3.3. Use the instanceOf or adapt element of the enabledWhen element instead.  If duplicate page definitions were previously used to register the page for multiple objectClass types, these should be combined into one page definition using multiple instanceOf elements combined inside an or element&lt;/p&gt;
107
&lt;p&gt;Deprecated in Eclipse 3.3. Use the instanceOf or adapt element of the enabledWhen element instead.  If duplicate page definitions were previously used to register the page for multiple objectClass types, these should be combined into one page definition using multiple instanceOf elements combined inside an or element&lt;/p&gt;
103
               </documentation>
108
               </documentation>
104
               <appinfo>
109
               <appInfo>
105
                  <meta.attribute kind="java" deprecated="true"/>
110
                  <meta.attribute kind="java" deprecated="true"/>
106
               </appinfo>
111
               </appInfo>
107
            </annotation>
112
            </annotation>
108
         </attribute>
113
         </attribute>
109
         <attribute name="class" type="string" use="required">
114
         <attribute name="class" type="string" use="required">
Lines 111-119 Link Here
111
               <documentation>
116
               <documentation>
112
                  a fully qualified name of the class that implements &lt;tt&gt;org.eclipse.ui.IWorkbenchPropertyPage&lt;/tt&gt;.
117
                  a fully qualified name of the class that implements &lt;tt&gt;org.eclipse.ui.IWorkbenchPropertyPage&lt;/tt&gt;.
113
               </documentation>
118
               </documentation>
114
               <appinfo>
119
               <appInfo>
115
                  <meta.attribute kind="java" basedOn="org.eclipse.ui.dialogs.PropertyPage:org.eclipse.ui.IWorkbenchPropertyPage"/>
120
                  <meta.attribute kind="java" basedOn="org.eclipse.ui.dialogs.PropertyPage:org.eclipse.ui.IWorkbenchPropertyPage"/>
116
               </appinfo>
121
               </appInfo>
117
            </annotation>
122
            </annotation>
118
         </attribute>
123
         </attribute>
119
         <attribute name="nameFilter" type="string">
124
         <attribute name="nameFilter" type="string">
Lines 134-142 Link Here
134
139
135
&lt;strong&gt;NOTE:&lt;/strong&gt; The adaptable attribute will attempt adapt an object to &lt;code&gt;org.eclipse.core.resources.IResource&lt;/code&gt; before referencing the types registered in &lt;code&gt;Platform#getAdaptorManager&lt;/code&gt;. The enabledWhen element has no special case tests for &lt;code&gt;org.eclipse.core.resources.IResource&lt;/code&gt; and uses &lt;code&gt;Platform#getAdaptorManager&lt;/code&gt; to look up adaptable types. These can be registered using the &lt;code&gt;org.eclipse.core.runtime.adaptors&lt;/code&gt; extension point.
140
&lt;strong&gt;NOTE:&lt;/strong&gt; The adaptable attribute will attempt adapt an object to &lt;code&gt;org.eclipse.core.resources.IResource&lt;/code&gt; before referencing the types registered in &lt;code&gt;Platform#getAdaptorManager&lt;/code&gt;. The enabledWhen element has no special case tests for &lt;code&gt;org.eclipse.core.resources.IResource&lt;/code&gt; and uses &lt;code&gt;Platform#getAdaptorManager&lt;/code&gt; to look up adaptable types. These can be registered using the &lt;code&gt;org.eclipse.core.runtime.adaptors&lt;/code&gt; extension point.
136
               </documentation>
141
               </documentation>
137
               <appinfo>
142
               <appInfo>
138
                  <meta.attribute deprecated="true"/>
143
                  <meta.attribute deprecated="true"/>
139
               </appinfo>
144
               </appInfo>
140
            </annotation>
145
            </annotation>
141
         </attribute>
146
         </attribute>
142
         <attribute name="category" type="string">
147
         <attribute name="category" type="string">
Lines 144-152 Link Here
144
               <documentation>
149
               <documentation>
145
                  A path indicating the location of the page in the properties tree. The path may either be a parent node ID or a sequence of IDs separated by &apos;/&apos;, representing the full path from the root node.
150
                  A path indicating the location of the page in the properties tree. The path may either be a parent node ID or a sequence of IDs separated by &apos;/&apos;, representing the full path from the root node.
146
               </documentation>
151
               </documentation>
147
               <appinfo>
152
               <appInfo>
148
                  <meta.attribute kind="identifier" basedOn="org.eclipse.ui.propertyPages/page/@id"/>
153
                  <meta.attribute kind="identifier" basedOn="org.eclipse.ui.propertyPages/page/@id"/>
149
               </appinfo>
154
               </appInfo>
155
            </annotation>
156
         </attribute>
157
         <attribute name="multipleSelection" type="boolean" use="default" value="false">
158
            <annotation>
159
               <documentation>
160
                  This propertyPage is valid for multiple selected items.  All items in the selection must match the applicability / filter criteria.
161
If multipleSelection is true, this propertyPage must extend the abstract class org.eclipse.ui.dialogs.PropertyPage
162
Default: false
163
@since 3.6
164
               </documentation>
150
            </annotation>
165
            </annotation>
151
         </attribute>
166
         </attribute>
152
      </complexType>
167
      </complexType>
Lines 190-198 Link Here
190
               <documentation>
205
               <documentation>
191
                  The id of the keyword being referred to.
206
                  The id of the keyword being referred to.
192
               </documentation>
207
               </documentation>
193
               <appinfo>
208
               <appInfo>
194
                  <meta.attribute kind="identifier" basedOn="org.eclipse.ui.keywords/keyword/@id"/>
209
                  <meta.attribute kind="identifier" basedOn="org.eclipse.ui.keywords/keyword/@id"/>
195
               </appinfo>
210
               </appInfo>
196
            </annotation>
211
            </annotation>
197
         </attribute>
212
         </attribute>
198
      </complexType>
213
      </complexType>
Lines 224-232 Link Here
224
   </element>
239
   </element>
225
240
226
   <annotation>
241
   <annotation>
227
      <appinfo>
242
      <appInfo>
228
         <meta.section type="examples"/>
243
         <meta.section type="examples"/>
229
      </appinfo>
244
      </appInfo>
230
      <documentation>
245
      <documentation>
231
         The following is an example of the property page definition: 
246
         The following is an example of the property page definition: 
232
&lt;p&gt;
247
&lt;p&gt;
Lines 251-259 Link Here
251
   </annotation>
266
   </annotation>
252
267
253
   <annotation>
268
   <annotation>
254
      <appinfo>
269
      <appInfo>
255
         <meta.section type="apiInfo"/>
270
         <meta.section type="apiInfo"/>
256
      </appinfo>
271
      </appInfo>
257
      <documentation>
272
      <documentation>
258
         The attribute &lt;samp&gt;class&lt;/samp&gt; must specify a fully qualified name 
273
         The attribute &lt;samp&gt;class&lt;/samp&gt; must specify a fully qualified name 
259
of the class that implements 
274
of the class that implements 
Lines 262-272 Link Here
262
   </annotation>
277
   </annotation>
263
278
264
279
265
266
   <annotation>
280
   <annotation>
267
      <appinfo>
281
      <appInfo>
268
         <meta.section type="implementation"/>
282
         <meta.section type="implementation"/>
269
      </appinfo>
283
      </appInfo>
270
      <documentation>
284
      <documentation>
271
         Some objects provided by the workbench may have 
285
         Some objects provided by the workbench may have 
272
property pages registered. Plug-ins are allowed 
286
property pages registered. Plug-ins are allowed 
Lines 280-288 Link Here
280
   </annotation>
294
   </annotation>
281
295
282
   <annotation>
296
   <annotation>
283
      <appinfo>
297
      <appInfo>
284
         <meta.section type="copyright"/>
298
         <meta.section type="copyright"/>
285
      </appinfo>
299
      </appInfo>
286
      <documentation>
300
      <documentation>
287
         Copyright (c) 2002, 2006 IBM Corporation and others.&lt;br&gt;
301
         Copyright (c) 2002, 2006 IBM Corporation and others.&lt;br&gt;
288
All rights reserved. This program and the accompanying materials are made
302
All rights reserved. This program and the accompanying materials are made
(-)Eclipse UI/org/eclipse/ui/dialogs/PropertyPage.java (-7 / +30 lines)
Lines 41-50 Link Here
41
 */
41
 */
42
public abstract class PropertyPage extends PreferencePage implements
42
public abstract class PropertyPage extends PreferencePage implements
43
        IWorkbenchPropertyPage {
43
        IWorkbenchPropertyPage {
44
    /**
44
	/**
45
     * The element.
45
	 * The elements.
46
     */
46
	 */
47
    private IAdaptable element;
47
	private IAdaptable[] elements;
48
48
49
    /**
49
    /**
50
     * Creates a new property page.
50
     * Creates a new property page.
Lines 57-72 Link Here
57
     * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
57
     * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
58
     */
58
     */
59
    public IAdaptable getElement() {
59
    public IAdaptable getElement() {
60
        return element;
60
		if (elements == null || elements.length == 0)
61
			return null;
62
		return elements[0];
61
    }
63
    }
62
64
65
	/**
66
	 * Returns an array of elements which open properties to be displayed by
67
	 * this page.
68
	 * 
69
	 * @return IAdaptable[] of elements
70
	 * @since 3.6
71
	 */
72
	public IAdaptable[] getElements() {
73
		return elements;
74
	}
75
63
    /**
76
    /**
64
     * Sets the element that owns properties shown on this page.
77
     * Sets the element that owns properties shown on this page.
65
     * 
66
     * @param element
78
     * @param element
67
     *            the element
79
     *            the element
68
     */
80
     */
69
    public void setElement(IAdaptable element) {
81
    public void setElement(IAdaptable element) {
70
        this.element = element;
82
		this.elements = new IAdaptable[] { element };
71
    }
83
    }
84
85
	/**
86
	 * Sets the elements that own properties shown on this page.
87
	 * 
88
	 * @param elements
89
	 *            the element
90
	 * @since 3.6
91
	 */
92
	public void setElements(IAdaptable[] elements) {
93
		this.elements = elements;
94
	}
72
}
95
}
(-)Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java (-7 / +6 lines)
Lines 100-106 Link Here
100
	 * @param object
100
	 * @param object
101
	 * @return boolean
101
	 * @return boolean
102
	 */
102
	 */
103
	private boolean hasPropertyPagesFor(Object object) {
103
	private boolean hasPropertyPagesFor(IStructuredSelection object) {
104
		return PropertyPageContributorManager.getManager().getApplicableContributors(object).size() != 0;
104
		return PropertyPageContributorManager.getManager().getApplicableContributors(object).size() != 0;
105
	}
105
	}
106
106
Lines 143-149 Link Here
143
	 *         otherwise
143
	 *         otherwise
144
	 */
144
	 */
145
	public boolean isApplicableForSelection(IStructuredSelection selection) {
145
	public boolean isApplicableForSelection(IStructuredSelection selection) {
146
		return selection.size() == 1 && hasPropertyPagesFor(selection.getFirstElement());
146
		return selection.size() > 0 && hasPropertyPagesFor(selection);
147
	}
147
	}
148
148
149
	
149
	
Lines 168-179 Link Here
168
	 */
168
	 */
169
	public PreferenceDialog createDialog() {
169
	public PreferenceDialog createDialog() {
170
170
171
		Object element = getStructuredSelection().getFirstElement();
171
		if (getStructuredSelection().isEmpty())
172
		if (element == null) {
173
			return null;
172
			return null;
174
		}
173
		
175
		return PropertyDialog
174
		return PropertyDialog
176
				.createDialogOn(shellProvider.getShell(), initialPageId, element);
175
				.createDialogOn(shellProvider.getShell(), initialPageId, getStructuredSelection());
177
	}
176
	}
178
177
179
	
178
	
Lines 181-186 Link Here
181
	 * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
180
	 * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
182
	 */
181
	 */
183
	public void selectionChanged(IStructuredSelection selection) {
182
	public void selectionChanged(IStructuredSelection selection) {
184
		setEnabled(selection.size() == 1 && selection.getFirstElement() != null);
183
		setEnabled(selection.size() != 0 && selection.getFirstElement() != null);
185
	}
184
	}
186
}
185
}
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java (-41 / +105 lines)
Lines 30-39 Link Here
30
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.Status;
31
import org.eclipse.jface.preference.PreferenceNode;
31
import org.eclipse.jface.preference.PreferenceNode;
32
import org.eclipse.jface.resource.ImageDescriptor;
32
import org.eclipse.jface.resource.ImageDescriptor;
33
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.IActionFilter;
34
import org.eclipse.ui.IActionFilter;
34
import org.eclipse.ui.IPluginContribution;
35
import org.eclipse.ui.IPluginContribution;
35
import org.eclipse.ui.IWorkbenchPropertyPage;
36
import org.eclipse.ui.IWorkbenchPropertyPage;
36
import org.eclipse.ui.SelectionEnabler;
37
import org.eclipse.ui.SelectionEnabler;
38
import org.eclipse.ui.dialogs.PropertyPage;
37
import org.eclipse.ui.internal.IWorkbenchConstants;
39
import org.eclipse.ui.internal.IWorkbenchConstants;
38
import org.eclipse.ui.internal.LegacyResourceSupport;
40
import org.eclipse.ui.internal.LegacyResourceSupport;
39
import org.eclipse.ui.internal.WorkbenchPlugin;
41
import org.eclipse.ui.internal.WorkbenchPlugin;
Lines 66-71 Link Here
66
68
67
	private boolean adaptable = false;
69
	private boolean adaptable = false;
68
70
71
	/**
72
	 * Flag which indicates if this property page supports multiple selection
73
	 * @since 3.6
74
	 */
75
	private final boolean supportsMultiSelect;
76
69
	private IConfigurationElement pageElement;
77
	private IConfigurationElement pageElement;
70
78
71
	private SoftReference filterProperties;
79
	private SoftReference filterProperties;
Lines 88-93 Link Here
88
						pageElement
96
						pageElement
89
								.getAttribute(PropertyPagesRegistryReader.ATT_ADAPTABLE))
97
								.getAttribute(PropertyPagesRegistryReader.ATT_ADAPTABLE))
90
				.booleanValue();
98
				.booleanValue();
99
		supportsMultiSelect = Boolean
100
				.valueOf(
101
						pageElement
102
								.getAttribute(PropertyPagesRegistryReader.ATT_MULTIPLE_SELECTION))
103
				.booleanValue();
91
		initializeEnablement(element);
104
		initializeEnablement(element);
92
	}
105
	}
93
106
Lines 122-142 Link Here
122
135
123
		ppage.setTitle(getPageName());
136
		ppage.setTitle(getPageName());
124
137
125
		Object adapted = element;
138
		Object[] elements = getObjects(element);
126
		if (adaptable) {
139
		IAdaptable[] adapt = new IAdaptable[elements.length];
127
			adapted = getAdaptedElement(element);
140
128
			if (adapted == null) {
141
		for (int i = 0; i < elements.length; i++) {
129
				String message = "Error adapting selection to Property page " + pageId + " is being ignored"; //$NON-NLS-1$ //$NON-NLS-2$            	
142
			Object adapted = elements[i];
130
				throw new CoreException(new Status(IStatus.ERROR,
143
			if (adaptable) {
131
						WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, message,
144
				adapted = getAdaptedElement(adapted);
132
						null));
145
				if (adapted == null) {
146
					String message = "Error adapting selection to Property page " + pageId + " is being ignored"; //$NON-NLS-1$ //$NON-NLS-2$            	
147
					throw new CoreException(new Status(IStatus.ERROR,
148
							WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR,
149
							message, null));
150
				}
133
			}
151
			}
152
			adapt[i] = (IAdaptable) ((adapted instanceof IAdaptable) ? adapted
153
					: new AdaptableForwarder(adapted));
134
		}
154
		}
135
155
136
		if (adapted instanceof IAdaptable)
156
		if (ppage instanceof PropertyPage)
137
			ppage.setElement((IAdaptable) adapted);
157
			((PropertyPage) ppage).setElements(adapt);
158
		else if (adapt.length > 1)
159
			// Throw exception - if propertPage supports multipleSelection
160
			// then it should extend PropertyPage
161
			throw new CoreException(new Status(IStatus.ERROR,
162
							WorkbenchPlugin.PI_WORKBENCH,
163
							IStatus.ERROR,
164
							"Error: selected element length > 0 but ppage not a PropertyPage", //$NON-NLS-1$
165
							null));
138
		else
166
		else
139
			ppage.setElement(new AdaptableForwarder(adapted));
167
			ppage.setElement(adapt[0]);
140
168
141
		return ppage;
169
		return ppage;
142
	}
170
	}
Lines 209-246 Link Here
209
		if (failsEnablement(object))
237
		if (failsEnablement(object))
210
			return false;
238
			return false;
211
239
240
		Object[] objs = getObjects(object);
241
212
		// Test name filter
242
		// Test name filter
213
		String nameFilter = pageElement
243
		String nameFilter = pageElement
214
				.getAttribute(PropertyPagesRegistryReader.ATT_NAME_FILTER);
244
				.getAttribute(PropertyPagesRegistryReader.ATT_NAME_FILTER);
215
		if (nameFilter != null) {
245
216
			String objectName = object.toString();
246
		for (int i = 0; i < objs.length; i++) {
217
			IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(object, 
247
			object = objs[i];
218
                    IWorkbenchAdapter.class);
248
			if (nameFilter != null) {
219
			if (adapter != null) {
249
				String objectName = object.toString();
220
				String elementName = adapter.getLabel(object);
250
				IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util
221
				if (elementName != null) {
251
						.getAdapter(object, IWorkbenchAdapter.class);
222
					objectName = elementName;
252
				if (adapter != null) {
253
					String elementName = adapter.getLabel(object);
254
					if (elementName != null) {
255
						objectName = elementName;
256
					}
223
				}
257
				}
258
				if (!SelectionEnabler.verifyNameMatch(objectName, nameFilter))
259
					return false;
224
			}
260
			}
225
			if (!SelectionEnabler.verifyNameMatch(objectName, nameFilter))
226
				return false;
227
		}
228
261
229
		// Test custom filter
262
			// Test custom filter
230
		if (getFilterProperties() == null)
263
			if (getFilterProperties() == null)
231
			return true;
264
				return true;
232
		IActionFilter filter = null;
265
			IActionFilter filter = null;
233
266
234
		// Do the free IResource adapting
267
			// Do the free IResource adapting
235
		Object adaptedObject = LegacyResourceSupport.getAdaptedResource(object);
268
			Object adaptedObject = LegacyResourceSupport
236
		if (adaptedObject != null) {
269
					.getAdaptedResource(object);
237
			object = adaptedObject;
270
			if (adaptedObject != null) {
238
		}
271
				object = adaptedObject;
272
			}
239
273
240
        filter = (IActionFilter)Util.getAdapter(object, IActionFilter.class);
274
			filter = (IActionFilter) Util.getAdapter(object,
275
					IActionFilter.class);
241
276
242
		if (filter != null)
277
			if (filter != null && !testCustom(object, filter))
243
			return testCustom(object, filter);
278
				return false;
279
		}
244
280
245
		return true;
281
		return true;
246
	}
282
	}
Lines 252-269 Link Here
252
	 * @return boolean <code>true</code> if it fails the enablement test
288
	 * @return boolean <code>true</code> if it fails the enablement test
253
	 */
289
	 */
254
	private boolean failsEnablement(Object object) {
290
	private boolean failsEnablement(Object object) {
291
		Object[] objs = getObjects(object);
292
		if (objs.length > 1 && !supportsMultiSelect)
293
			return true;
255
		if (enablementExpression == null)
294
		if (enablementExpression == null)
256
			return false;
295
			return false;
257
		try {
296
		try {
258
			EvaluationContext context = new EvaluationContext(null, object);
297
			for (int i = 0; i < objs.length; i++) {
259
			context.setAllowPluginActivation(true);
298
				EvaluationContext context = new EvaluationContext(null, objs[i]);
260
			return enablementExpression.evaluate(
299
				context.setAllowPluginActivation(true);
261
					context).equals(
300
				boolean fails = enablementExpression
262
					EvaluationResult.FALSE);
301
						.evaluate(context).equals(EvaluationResult.FALSE);
302
				if (fails)
303
					return true;
304
			}
263
		} catch (CoreException e) {
305
		} catch (CoreException e) {
264
			WorkbenchPlugin.log(e);
306
			WorkbenchPlugin.log(e);
265
			return false;
266
		}
307
		}
308
		return false;
309
	}
310
311
	/**
312
	 * Returns an object array for the passed in object. If the object is an
313
	 * IStructuredSelection, then return its array otherwise return a 1 element
314
	 * Object[] containing the passed in object
315
	 * 
316
	 * @param obj
317
	 * @return an object array representing the passed in object
318
	 */
319
	private Object[] getObjects(Object obj) {
320
		if (obj instanceof IStructuredSelection)
321
			return ((IStructuredSelection) obj).toArray();
322
		return new Object[] { obj };
267
	}
323
	}
268
324
269
	/**
325
	/**
Lines 404-409 Link Here
404
	}
460
	}
405
461
406
	/**
462
	/**
463
	 * @return boolean indicating if this page supports multiple selection
464
	 * @since 3.6
465
	 */
466
	boolean supportsMultipleSelection() {
467
		return supportsMultiSelect;
468
	}
469
470
	/**
407
	 * @return the configuration element
471
	 * @return the configuration element
408
	 * @since 3.1
472
	 * @since 3.1
409
	 */
473
	 */
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java (-2 / +52 lines)
Lines 16-21 Link Here
16
import java.util.HashMap;
16
import java.util.HashMap;
17
import java.util.Hashtable;
17
import java.util.Hashtable;
18
import java.util.Iterator;
18
import java.util.Iterator;
19
import java.util.LinkedHashSet;
19
import java.util.List;
20
import java.util.List;
20
import java.util.Map;
21
import java.util.Map;
21
22
Lines 24-29 Link Here
24
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
26
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
26
import org.eclipse.jface.preference.PreferenceNode;
27
import org.eclipse.jface.preference.PreferenceNode;
28
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.ui.internal.ObjectContributorManager;
29
import org.eclipse.ui.internal.ObjectContributorManager;
28
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
30
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
29
import org.eclipse.ui.internal.registry.PropertyPagesRegistryReader;
31
import org.eclipse.ui.internal.registry.PropertyPagesRegistryReader;
Lines 66-78 Link Here
66
	 * contributors and sequentially invoke them to contribute to the property
68
	 * contributors and sequentially invoke them to contribute to the property
67
	 * page manager. Matching algorithm will also check subclasses and
69
	 * page manager. Matching algorithm will also check subclasses and
68
	 * implemented interfaces.
70
	 * implemented interfaces.
71
	 * 
72
	 * If object is an IStructuredSelection then attempt to match all the
73
	 * contained objects.
74
	 * 
69
	 * @param manager
75
	 * @param manager
70
	 * @param object
76
	 * @param object
71
	 * @return true if contribution took place, false otherwise.
77
	 * @return true if contribution took place, false otherwise.
72
	 */
78
	 */
73
	public boolean contribute(PropertyPageManager manager, Object object) {
79
	public boolean contribute(PropertyPageManager manager, Object object) {
74
80
75
		List result = getContributors(object);
81
		Collection result = null;
82
		if (object instanceof IStructuredSelection) {
83
			Object[] objs = ((IStructuredSelection) object).toArray();
84
			for (int i = 0; i < objs.length; i++) {
85
				List contribs = getContributors(objs[i]);
86
				if (result == null)
87
					result = new LinkedHashSet(contribs);
88
				else
89
					result.retainAll(contribs);
90
			}
91
		} else
92
			result = getContributors(object);
76
93
77
		if (result == null || result.size() == 0) {
94
		if (result == null || result.size() == 0) {
78
			return false;
95
			return false;
Lines 129-135 Link Here
129
	 * @param nodes
146
	 * @param nodes
130
	 * @return List of CategorizedPageNode
147
	 * @return List of CategorizedPageNode
131
	 */
148
	 */
132
	private List buildNodeList(List nodes) {
149
	private List buildNodeList(Collection nodes) {
133
		Hashtable mapping = new Hashtable();
150
		Hashtable mapping = new Hashtable();
134
		
151
		
135
		Iterator nodesIterator = nodes.iterator();
152
		Iterator nodesIterator = nodes.iterator();
Lines 192-197 Link Here
192
	 * @return Collection of PropertyPageContribution
209
	 * @return Collection of PropertyPageContribution
193
	 */
210
	 */
194
	public Collection getApplicableContributors(Object element) {
211
	public Collection getApplicableContributors(Object element) {
212
		if (element instanceof IStructuredSelection)
213
			return getApplicableContributors((IStructuredSelection) element);
195
		Collection contributors = getContributors(element);
214
		Collection contributors = getContributors(element);
196
		Collection result = new ArrayList();
215
		Collection result = new ArrayList();
197
		for (Iterator iter = contributors.iterator(); iter.hasNext();) {
216
		for (Iterator iter = contributors.iterator(); iter.hasNext();) {
Lines 203-208 Link Here
203
		return result;
222
		return result;
204
	}
223
	}
205
224
225
	/**
226
	 * Get applicable contributors for multiple selection
227
	 * 
228
	 * @param selection
229
	 * @return Collection of applicable property page contributors
230
	 * @since 3.6
231
	 */
232
	public Collection getApplicableContributors(IStructuredSelection selection) {
233
		Iterator it = selection.iterator();
234
		Collection result = null;
235
		while (it.hasNext()) {
236
			Object element = it.next();
237
			Collection collection = getApplicableContributors(element);
238
			if (result == null)
239
				result = new LinkedHashSet(collection);
240
			else
241
				result.retainAll(collection);
242
		}
243
		if (result != null && !result.isEmpty() && selection.size() > 1) {
244
			// only add contributors which can handle multi selection
245
			it = result.iterator();
246
			while (it.hasNext()) {
247
				RegistryPageContributor contrib = (RegistryPageContributor) it
248
						.next();
249
				if (!contrib.supportsMultipleSelection())
250
					it.remove();
251
			}
252
		}
253
		return result;
254
	}
255
206
	/* (non-Javadoc)
256
	/* (non-Javadoc)
207
	 * @see org.eclipse.ui.internal.ObjectContributorManager#getExtensionPointFilter()
257
	 * @see org.eclipse.ui.internal.ObjectContributorManager#getExtensionPointFilter()
208
	 */
258
	 */
(-)Eclipse UI/org/eclipse/ui/internal/registry/PropertyPagesRegistryReader.java (+7 lines)
Lines 41-46 Link Here
41
	 */
41
	 */
42
	public static final String ATT_FILTER_VALUE = "value";//$NON-NLS-1$
42
	public static final String ATT_FILTER_VALUE = "value";//$NON-NLS-1$
43
43
44
	/**
45
	 * Value "<code>multipleSelection</code>".
46
	 * 
47
	 * @since 3.6
48
	 */
49
	public static final String ATT_MULTIPLE_SELECTION = "multipleSelection";//$NON-NLS-1$
50
44
	private static final String TAG_PAGE = "page";//$NON-NLS-1$
51
	private static final String TAG_PAGE = "page";//$NON-NLS-1$
45
52
46
	/**
53
	/**

Return to bug 294894