View | Details | Raw Unified | Return to bug 156277 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/views/properties/tabbed/view/TabListContentProvider.java (-3 / +3 lines)
Lines 11-18 Link Here
11
package org.eclipse.ui.internal.views.properties.tabbed.view;
11
package org.eclipse.ui.internal.views.properties.tabbed.view;
12
12
13
import org.eclipse.jface.util.Assert;
13
import org.eclipse.jface.util.Assert;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.IStructuredContentProvider;
14
import org.eclipse.jface.viewers.IStructuredContentProvider;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.jface.viewers.Viewer;
17
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchPart;
18
18
Lines 41-49 Link Here
41
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
41
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
42
	 */
42
	 */
43
	public Object[] getElements(Object inputElement) {
43
	public Object[] getElements(Object inputElement) {
44
		Assert.isTrue(inputElement instanceof ISelection);
44
		Assert.isTrue(inputElement instanceof IStructuredSelection);
45
			return registry
45
			return registry
46
			.getTabDescriptors(currentPart, (ISelection) inputElement);
46
			.getTabDescriptors(currentPart, (IStructuredSelection) inputElement);
47
	}
47
	}
48
48
49
	/**
49
	/**
(-)src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java (-2 / +2 lines)
Lines 19-25 Link Here
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.jface.viewers.IFilter;
21
import org.eclipse.jface.viewers.IFilter;
22
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.ui.IWorkbenchPart;
23
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
24
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
25
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
25
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
Lines 174-180 Link Here
174
	 * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart,
174
	 * @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart,
175
	 *      org.eclipse.jface.viewers.ISelection)
175
	 *      org.eclipse.jface.viewers.ISelection)
176
	 */
176
	 */
177
	public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
177
	public boolean appliesTo(IWorkbenchPart part, IStructuredSelection selection) {
178
		return classFilter.appliesToSelection(this, selection);
178
		return classFilter.appliesToSelection(this, selection);
179
	}
179
	}
180
180
(-)src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistry.java (-4 / +22 lines)
Lines 24-30 Link Here
24
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Status;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.jface.viewers.ILabelProvider;
26
import org.eclipse.jface.viewers.ILabelProvider;
27
import org.eclipse.jface.viewers.ISelection;
27
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.ui.IWorkbenchPart;
28
import org.eclipse.ui.IWorkbenchPart;
29
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
29
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
30
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
30
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
Lines 32-37 Link Here
32
import org.eclipse.ui.views.properties.tabbed.IActionProvider;
32
import org.eclipse.ui.views.properties.tabbed.IActionProvider;
33
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
33
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
34
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider;
34
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider;
35
import org.eclipse.ui.views.properties.tabbed.IStructuredSelectionProvider;
35
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
36
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
36
37
37
/**
38
/**
Lines 68-73 Link Here
68
	private static final String ATT_LABEL_PROVIDER = "labelProvider"; //$NON-NLS-1$
69
	private static final String ATT_LABEL_PROVIDER = "labelProvider"; //$NON-NLS-1$
69
70
70
    private static final String ATT_ACTION_PROVIDER = "actionProvider"; //$NON-NLS-1$
71
    private static final String ATT_ACTION_PROVIDER = "actionProvider"; //$NON-NLS-1$
72
    
73
    private static final String ATT_STRUCTURED_SELECTION_PROVIDER = "structuredSelectionProvider"; //$NON-NLS-1$
71
74
72
	private static final String TOP = "top"; //$NON-NLS-1$
75
	private static final String TOP = "top"; //$NON-NLS-1$
73
76
Lines 80-85 Link Here
80
	protected ILabelProvider labelProvider;
83
	protected ILabelProvider labelProvider;
81
84
82
    protected IActionProvider actionProvider;
85
    protected IActionProvider actionProvider;
86
    
87
    protected IStructuredSelectionProvider structuredSelectionProvider;
83
88
84
	protected ITypeMapper typeMapper;
89
	protected ITypeMapper typeMapper;
85
90
Lines 117-122 Link Here
117
					typeMapper = (ITypeMapper) configurationElement
122
					typeMapper = (ITypeMapper) configurationElement
118
						.createExecutableExtension(ATT_TYPE_MAPPER);
123
						.createExecutableExtension(ATT_TYPE_MAPPER);
119
				}
124
				}
125
				if (configurationElement.getAttribute(ATT_STRUCTURED_SELECTION_PROVIDER) != null) {
126
					structuredSelectionProvider = (IStructuredSelectionProvider) configurationElement
127
						.createExecutableExtension(ATT_STRUCTURED_SELECTION_PROVIDER);
128
				}
120
			} catch (CoreException exception) {
129
			} catch (CoreException exception) {
121
				handleConfigurationError(id, exception);
130
				handleConfigurationError(id, exception);
122
			}
131
			}
Lines 234-240 Link Here
234
	 * input. The descriptors are sorted using the afterPage attribute.
243
	 * input. The descriptors are sorted using the afterPage attribute.
235
	 */
244
	 */
236
	public TabDescriptor[] getTabDescriptors(IWorkbenchPart part,
245
	public TabDescriptor[] getTabDescriptors(IWorkbenchPart part,
237
			ISelection selection) {
246
			IStructuredSelection selection) {
238
		if (selection == null || selection.isEmpty()) {
247
		if (selection == null || selection.isEmpty()) {
239
			return EMPTY_DESCRIPTOR_ARRAY;
248
			return EMPTY_DESCRIPTOR_ARRAY;
240
		}
249
		}
Lines 250-256 Link Here
250
	 * given input.
259
	 * given input.
251
	 */
260
	 */
252
	protected TabDescriptor[] filterTabDescriptors(TabDescriptor[] descriptors,
261
	protected TabDescriptor[] filterTabDescriptors(TabDescriptor[] descriptors,
253
			IWorkbenchPart part, ISelection selection) {
262
			IWorkbenchPart part, IStructuredSelection selection) {
254
		List result = new ArrayList();
263
		List result = new ArrayList();
255
		for (int i = 0; i < descriptors.length; i++) {
264
		for (int i = 0; i < descriptors.length; i++) {
256
			TabDescriptor descriptor = adaptDescriptorFor(descriptors[i], part,
265
			TabDescriptor descriptor = adaptDescriptorFor(descriptors[i], part,
Lines 271-277 Link Here
271
	 * do not apply to the given input object.
280
	 * do not apply to the given input object.
272
	 */
281
	 */
273
	protected TabDescriptor adaptDescriptorFor(TabDescriptor target,
282
	protected TabDescriptor adaptDescriptorFor(TabDescriptor target,
274
			IWorkbenchPart part, ISelection selection) {
283
			IWorkbenchPart part, IStructuredSelection selection) {
275
		List filteredSectionDescriptors = new ArrayList();
284
		List filteredSectionDescriptors = new ArrayList();
276
		List descriptors = target.getSectionDescriptors();
285
		List descriptors = target.getSectionDescriptors();
277
		for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
286
		for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
Lines 452-457 Link Here
452
    public IActionProvider getActionProvider() {
461
    public IActionProvider getActionProvider() {
453
        return actionProvider;
462
        return actionProvider;
454
    }
463
    }
464
    
465
    /**
466
     * Gets the structured selection provider for the contributor.
467
     * 
468
     * @return the structured selection provider for the contributor.
469
     */
470
    public IStructuredSelectionProvider getStructuredSelectionProvider() {
471
        return structuredSelectionProvider;
472
    }
455
473
456
	/**
474
	/**
457
	 * Sets the section descriptor provider for the contributor.
475
	 * Sets the section descriptor provider for the contributor.
(-)src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java (-8 / +5 lines)
Lines 19-25 Link Here
19
import java.util.Set;
19
import java.util.Set;
20
20
21
import org.eclipse.jface.viewers.IFilter;
21
import org.eclipse.jface.viewers.IFilter;
22
import org.eclipse.jface.viewers.ISelection;
23
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
24
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
23
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
25
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
24
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
Lines 41-59 Link Here
41
		super();
40
		super();
42
		this.typeMapper = typeMapper;
41
		this.typeMapper = typeMapper;
43
	}
42
	}
44
45
	/**
43
	/**
46
	 * Verifies if the property section extension represented by sectionElement
44
	 * Verifies if the property section extension represented by sectionElement
47
	 * applies to the given input.
45
	 * applies to the given input.
48
	 */
46
	 */
49
	protected boolean appliesToSelection(ISectionDescriptor descriptor,
47
	protected boolean appliesToSelection(ISectionDescriptor descriptor,
50
			ISelection selection) {
48
			IStructuredSelection selection) {
51
49
52
		if (selection instanceof IStructuredSelection
50
		if (selection.isEmpty() == false) {
53
			&& selection.isEmpty() == false) {
54
51
55
			if (descriptor.getEnablesFor() != ISectionDescriptor.ENABLES_FOR_ANY
52
			if (descriptor.getEnablesFor() != ISectionDescriptor.ENABLES_FOR_ANY
56
				&& ((IStructuredSelection) selection).size() != descriptor
53
				&& selection.size() != descriptor
57
					.getEnablesFor()) {
54
					.getEnablesFor()) {
58
				/**
55
				/**
59
				 * enablesFor does not match the size of the selection, do not
56
				 * enablesFor does not match the size of the selection, do not
Lines 65-71 Link Here
65
            IFilter filter = descriptor.getFilter();
62
            IFilter filter = descriptor.getFilter();
66
            
63
            
67
            if (filter != null) {
64
            if (filter != null) {
68
                for (Iterator i = ((IStructuredSelection) selection).iterator(); i
65
                for (Iterator i = selection.iterator(); i
69
                .hasNext();) {
66
                .hasNext();) {
70
                    Object object = i.next();
67
                    Object object = i.next();
71
68
Lines 85-91 Link Here
85
82
86
			Set effectiveTypes = new HashSet();
83
			Set effectiveTypes = new HashSet();
87
84
88
			for (Iterator i = ((IStructuredSelection) selection).iterator(); i
85
			for (Iterator i = selection.iterator(); i
89
				.hasNext();) {
86
				.hasNext();) {
90
87
91
				Object object = i.next();
88
				Object object = i.next();
(-)src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java (-2 / +2 lines)
Lines 13-19 Link Here
13
import java.util.List;
13
import java.util.List;
14
14
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.IStructuredSelection;
17
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchPart;
18
18
19
/**
19
/**
Lines 80-86 Link Here
80
	 * @return <code>true</code> if this section applies to the current
80
	 * @return <code>true</code> if this section applies to the current
81
	 *         selection.
81
	 *         selection.
82
	 */
82
	 */
83
	public boolean appliesTo(IWorkbenchPart part, ISelection selection);
83
	public boolean appliesTo(IWorkbenchPart part, IStructuredSelection selection);
84
84
85
	/**
85
	/**
86
	 * Get the section identifier below which this section is displayed. <code>"top"</code>
86
	 * Get the section identifier below which this section is displayed. <code>"top"</code>
(-)src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java (-5 / +18 lines)
Lines 88-94 Link Here
88
88
89
	protected IStructuredContentProvider tabListContentProvider;
89
	protected IStructuredContentProvider tabListContentProvider;
90
90
91
	private ISelection currentSelection;
91
	private IStructuredSelection currentSelection;
92
92
93
	private boolean activePropertySheet;
93
	private boolean activePropertySheet;
94
94
Lines 539-545 Link Here
539
	 *      org.eclipse.jface.viewers.ISelection)
539
	 *      org.eclipse.jface.viewers.ISelection)
540
	 */
540
	 */
541
	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
541
	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
542
		setInput(part, selection);
542
		IStructuredSelection structuredSelection = null;
543
		IStructuredSelectionProvider selectionProvider = registry.getStructuredSelectionProvider();
544
		if (selectionProvider != null ) {
545
			structuredSelection = selectionProvider.structuredSelection(selection);
546
		}
547
		else {
548
			if (selection instanceof IStructuredSelection) {
549
				structuredSelection = (IStructuredSelection) selection;				
550
			}
551
			else {
552
				structuredSelection = new StructuredSelection(selection);
553
			}
554
		}
555
		setInput(part, structuredSelection);
543
	}
556
	}
544
557
545
	/**
558
	/**
Lines 591-597 Link Here
591
	/**
604
	/**
592
	 * Returns the last known selected tab for the given input.
605
	 * Returns the last known selected tab for the given input.
593
	 */
606
	 */
594
	private int getLastTabSelection(IWorkbenchPart part, ISelection input) {
607
	private int getLastTabSelection(IWorkbenchPart part, IStructuredSelection input) {
595
		TabDescriptor[] descriptors = registry.getTabDescriptors(part, input);
608
		TabDescriptor[] descriptors = registry.getTabDescriptors(part, input);
596
		if (descriptors.length != 0) {
609
		if (descriptors.length != 0) {
597
			for (Iterator iter = selectionQueue.iterator(); iter.hasNext();) {
610
			for (Iterator iter = selectionQueue.iterator(); iter.hasNext();) {
Lines 661-667 Link Here
661
		return result;
674
		return result;
662
	}
675
	}
663
676
664
	private void setInput(IWorkbenchPart part, ISelection selection) {
677
	private void setInput(IWorkbenchPart part, IStructuredSelection selection) {
665
		if (selection.equals(currentSelection)) {
678
		if (selection.equals(currentSelection)) {
666
			return;
679
			return;
667
		}
680
		}
Lines 833-839 Link Here
833
	 * @param selection
846
	 * @param selection
834
	 *            the current selection in the active workbench part.
847
	 *            the current selection in the active workbench part.
835
	 */
848
	 */
836
	private void validateRegistry(ISelection selection) {
849
	private void validateRegistry(IStructuredSelection selection) {
837
		if (selection == null) {
850
		if (selection == null) {
838
			return;
851
			return;
839
		}
852
		}
(-)schema/propertyContributor.exsd (+10 lines)
Lines 81-86 Link Here
81
               </appInfo>
81
               </appInfo>
82
            </annotation>
82
            </annotation>
83
         </attribute>
83
         </attribute>
84
         <attribute name="structuredSelectionProvider" type="string">
85
            <annotation>
86
               <documentation>
87
                  The class that implements the selection provider, i.e. implements &lt;tt&gt;org.eclipse.ui.views.properties.tabbed.IStructuredSelectionProvider&lt;/tt&gt;
88
               </documentation>
89
               <appInfo>
90
                  <meta.attribute kind="java" basedOn="org.eclipse.ui.views.properties.tabbed.IStructuredSelectionProvider"/>
91
               </appInfo>
92
            </annotation>
93
         </attribute>
84
      </complexType>
94
      </complexType>
85
   </element>
95
   </element>
86
96
(-)src/org/eclipse/ui/views/properties/tabbed/IStructuredSelectionProvider.java (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.views.properties.tabbed;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
17
/**
18
 * @since 3.2
19
 *
20
 */
21
public interface IStructuredSelectionProvider
22
{
23
	IStructuredSelection structuredSelection(ISelection selection);
24
}

Return to bug 156277