### Eclipse Workspace Patch 1.0
#P org.eclipse.ui.views.properties.tabbed
Index: src/org/eclipse/ui/internal/views/properties/tabbed/view/TabListContentProvider.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabListContentProvider.java,v
retrieving revision 1.1
diff -u -r1.1 TabListContentProvider.java
--- src/org/eclipse/ui/internal/views/properties/tabbed/view/TabListContentProvider.java 17 Apr 2006 19:03:55 -0000 1.1
+++ src/org/eclipse/ui/internal/views/properties/tabbed/view/TabListContentProvider.java 17 Oct 2006 14:21:51 -0000
@@ -11,8 +11,8 @@
package org.eclipse.ui.internal.views.properties.tabbed.view;
import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IWorkbenchPart;
@@ -41,9 +41,9 @@
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
- Assert.isTrue(inputElement instanceof ISelection);
+ Assert.isTrue(inputElement instanceof IStructuredSelection);
return registry
- .getTabDescriptors(currentPart, (ISelection) inputElement);
+ .getTabDescriptors(currentPart, (IStructuredSelection) inputElement);
}
/**
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.1
diff -u -r1.1 SectionDescriptor.java
--- src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java 17 Apr 2006 19:03:55 -0000 1.1
+++ src/org/eclipse/ui/internal/views/properties/tabbed/view/SectionDescriptor.java 17 Oct 2006 14:21:51 -0000
@@ -19,7 +19,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.IFilter;
-import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
@@ -174,7 +174,7 @@
* @see org.eclipse.ui.views.properties.tabbed.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
- public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
+ public boolean appliesTo(IWorkbenchPart part, IStructuredSelection selection) {
return classFilter.appliesToSelection(this, selection);
}
Index: src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistry.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistry.java,v
retrieving revision 1.2
diff -u -r1.2 TabbedPropertyRegistry.java
--- src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistry.java 29 Aug 2006 13:27:39 -0000 1.2
+++ src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistry.java 17 Oct 2006 14:21:52 -0000
@@ -24,7 +24,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewPlugin;
import org.eclipse.ui.internal.views.properties.tabbed.TabbedPropertyViewStatusCodes;
@@ -32,6 +32,7 @@
import org.eclipse.ui.views.properties.tabbed.IActionProvider;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider;
+import org.eclipse.ui.views.properties.tabbed.ISelectionConverter;
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
/**
@@ -68,6 +69,8 @@
private static final String ATT_LABEL_PROVIDER = "labelProvider"; //$NON-NLS-1$
private static final String ATT_ACTION_PROVIDER = "actionProvider"; //$NON-NLS-1$
+
+ private static final String ATT_SELECTION_CONVERTER = "selectionConverter"; //$NON-NLS-1$
private static final String TOP = "top"; //$NON-NLS-1$
@@ -80,6 +83,8 @@
protected ILabelProvider labelProvider;
protected IActionProvider actionProvider;
+
+ protected ISelectionConverter selectionConverter;
protected ITypeMapper typeMapper;
@@ -117,6 +122,10 @@
typeMapper = (ITypeMapper) configurationElement
.createExecutableExtension(ATT_TYPE_MAPPER);
}
+ if (configurationElement.getAttribute(ATT_SELECTION_CONVERTER) != null) {
+ selectionConverter = (ISelectionConverter) configurationElement
+ .createExecutableExtension(ATT_SELECTION_CONVERTER);
+ }
} catch (CoreException exception) {
handleConfigurationError(id, exception);
}
@@ -234,7 +243,7 @@
* input. The descriptors are sorted using the afterPage attribute.
*/
public TabDescriptor[] getTabDescriptors(IWorkbenchPart part,
- ISelection selection) {
+ IStructuredSelection selection) {
if (selection == null || selection.isEmpty()) {
return EMPTY_DESCRIPTOR_ARRAY;
}
@@ -250,7 +259,7 @@
* given input.
*/
protected TabDescriptor[] filterTabDescriptors(TabDescriptor[] descriptors,
- IWorkbenchPart part, ISelection selection) {
+ IWorkbenchPart part, IStructuredSelection selection) {
List result = new ArrayList();
for (int i = 0; i < descriptors.length; i++) {
TabDescriptor descriptor = adaptDescriptorFor(descriptors[i], part,
@@ -271,7 +280,7 @@
* do not apply to the given input object.
*/
protected TabDescriptor adaptDescriptorFor(TabDescriptor target,
- IWorkbenchPart part, ISelection selection) {
+ IWorkbenchPart part, IStructuredSelection selection) {
List filteredSectionDescriptors = new ArrayList();
List descriptors = target.getSectionDescriptors();
for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
@@ -452,6 +461,15 @@
public IActionProvider getActionProvider() {
return actionProvider;
}
+
+ /**
+ * Gets the structured selection provider for the contributor.
+ *
+ * @return the structured selection provider for the contributor.
+ */
+ public ISelectionConverter getSelectionConverter() {
+ return selectionConverter;
+ }
/**
* Sets the section descriptor provider for the contributor.
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.1
diff -u -r1.1 TabbedPropertyRegistryClassSectionFilter.java
--- src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java 17 Apr 2006 19:03:55 -0000 1.1
+++ src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyRegistryClassSectionFilter.java 17 Oct 2006 14:21:52 -0000
@@ -19,7 +19,6 @@
import java.util.Set;
import org.eclipse.jface.viewers.IFilter;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
@@ -41,19 +40,17 @@
super();
this.typeMapper = typeMapper;
}
-
/**
* Verifies if the property section extension represented by sectionElement
* applies to the given input.
*/
protected boolean appliesToSelection(ISectionDescriptor descriptor,
- ISelection selection) {
+ IStructuredSelection selection) {
- if (selection instanceof IStructuredSelection
- && selection.isEmpty() == false) {
+ if (selection.isEmpty() == false) {
if (descriptor.getEnablesFor() != ISectionDescriptor.ENABLES_FOR_ANY
- && ((IStructuredSelection) selection).size() != descriptor
+ && selection.size() != descriptor
.getEnablesFor()) {
/**
* enablesFor does not match the size of the selection, do not
@@ -65,7 +62,7 @@
IFilter filter = descriptor.getFilter();
if (filter != null) {
- for (Iterator i = ((IStructuredSelection) selection).iterator(); i
+ for (Iterator i = selection.iterator(); i
.hasNext();) {
Object object = i.next();
@@ -85,7 +82,7 @@
Set effectiveTypes = new HashSet();
- for (Iterator i = ((IStructuredSelection) selection).iterator(); i
+ for (Iterator i = selection.iterator(); i
.hasNext();) {
Object object = i.next();
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.1
diff -u -r1.1 ISectionDescriptor.java
--- src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java 30 Jan 2006 21:34:23 -0000 1.1
+++ src/org/eclipse/ui/views/properties/tabbed/ISectionDescriptor.java 17 Oct 2006 14:21:52 -0000
@@ -13,7 +13,7 @@
import java.util.List;
import org.eclipse.jface.viewers.IFilter;
-import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
/**
@@ -80,7 +80,7 @@
* @return true
if this section applies to the current
* selection.
*/
- public boolean appliesTo(IWorkbenchPart part, ISelection selection);
+ public boolean appliesTo(IWorkbenchPart part, IStructuredSelection selection);
/**
* Get the section identifier below which this section is displayed. "top"
Index: src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java,v
retrieving revision 1.7
diff -u -r1.7 TabbedPropertySheetPage.java
--- src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java 29 Aug 2006 13:27:39 -0000 1.7
+++ src/org/eclipse/ui/views/properties/tabbed/TabbedPropertySheetPage.java 17 Oct 2006 14:21:52 -0000
@@ -88,7 +88,7 @@
protected IStructuredContentProvider tabListContentProvider;
- private ISelection currentSelection;
+ private IStructuredSelection currentSelection;
private boolean activePropertySheet;
@@ -539,7 +539,20 @@
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- setInput(part, selection);
+ IStructuredSelection structuredSelection = null;
+ ISelectionConverter selectionConverter = registry.getSelectionConverter();
+ if (selectionConverter != null ) {
+ structuredSelection = selectionConverter.structuredSelection(selection);
+ }
+ else {
+ if (selection instanceof IStructuredSelection) {
+ structuredSelection = (IStructuredSelection) selection;
+ }
+ else {
+ structuredSelection = new StructuredSelection(selection);
+ }
+ }
+ setInput(part, structuredSelection);
}
/**
@@ -591,7 +604,7 @@
/**
* Returns the last known selected tab for the given input.
*/
- private int getLastTabSelection(IWorkbenchPart part, ISelection input) {
+ private int getLastTabSelection(IWorkbenchPart part, IStructuredSelection input) {
TabDescriptor[] descriptors = registry.getTabDescriptors(part, input);
if (descriptors.length != 0) {
for (Iterator iter = selectionQueue.iterator(); iter.hasNext();) {
@@ -661,7 +674,7 @@
return result;
}
- private void setInput(IWorkbenchPart part, ISelection selection) {
+ private void setInput(IWorkbenchPart part, IStructuredSelection selection) {
if (selection.equals(currentSelection)) {
return;
}
@@ -833,7 +846,7 @@
* @param selection
* the current selection in the active workbench part.
*/
- private void validateRegistry(ISelection selection) {
+ private void validateRegistry(IStructuredSelection selection) {
if (selection == null) {
return;
}
Index: schema/propertyContributor.exsd
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.views.properties.tabbed/schema/propertyContributor.exsd,v
retrieving revision 1.2
diff -u -r1.2 propertyContributor.exsd
--- schema/propertyContributor.exsd 29 Aug 2006 13:27:39 -0000 1.2
+++ schema/propertyContributor.exsd 17 Oct 2006 14:21:51 -0000
@@ -81,6 +81,16 @@
+
+ * The selectionConverter will be needed if the selection events given by the property + * sheet page contributor are not IStructuredSelections as is the case for ITextEditors. + *
+ * + * @since 3.3 + * @author Karen Moore + */ + +public interface ISelectionConverter +{ + /** + * Return an IStructuredSelection for the given ISelection + * @param selection + * @return the IStructuredSelection, not null + */ + IStructuredSelection structuredSelection(ISelection selection); +}