diff options
Diffstat (limited to 'bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java')
-rw-r--r-- | bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java index 2ef7574d226..cb251190253 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Oakland Software (Francis Upton) <francisu@ieee.org> - bug 219273 + * James Blackburn (Broadcom Corp.) - Bug 294628 multiple selection *******************************************************************************/ package org.eclipse.ui.internal.dialogs; @@ -16,14 +17,15 @@ import java.util.Collection; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; - import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; import org.eclipse.jface.preference.PreferenceNode; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.internal.ObjectContributorManager; import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; import org.eclipse.ui.internal.registry.PropertyPagesRegistryReader; @@ -66,13 +68,28 @@ public class PropertyPageContributorManager extends ObjectContributorManager { * contributors and sequentially invoke them to contribute to the property * page manager. Matching algorithm will also check subclasses and * implemented interfaces. + * + * If object is an IStructuredSelection then attempt to match all the + * contained objects. + * * @param manager * @param object * @return true if contribution took place, false otherwise. */ public boolean contribute(PropertyPageManager manager, Object object) { - List result = getContributors(object); + Collection result = null; + if (object instanceof IStructuredSelection) { + Object[] objs = ((IStructuredSelection) object).toArray(); + for (int i = 0; i < objs.length; i++) { + List contribs = getContributors(objs[i]); + if (result == null) + result = new LinkedHashSet(contribs); + else + result.retainAll(contribs); + } + } else + result = getContributors(object); if (result == null || result.size() == 0) { return false; @@ -129,7 +146,7 @@ public class PropertyPageContributorManager extends ObjectContributorManager { * @param nodes * @return List of CategorizedPageNode */ - private List buildNodeList(List nodes) { + private List buildNodeList(Collection nodes) { Hashtable mapping = new Hashtable(); Iterator nodesIterator = nodes.iterator(); @@ -192,6 +209,8 @@ public class PropertyPageContributorManager extends ObjectContributorManager { * @return Collection of PropertyPageContribution */ public Collection getApplicableContributors(Object element) { + if (element instanceof IStructuredSelection) + return getApplicableContributors((IStructuredSelection) element); Collection contributors = getContributors(element); Collection result = new ArrayList(); for (Iterator iter = contributors.iterator(); iter.hasNext();) { @@ -203,6 +222,37 @@ public class PropertyPageContributorManager extends ObjectContributorManager { return result; } + /** + * Get applicable contributors for multiple selection + * + * @param selection + * @return Collection of applicable property page contributors + * @since 3.7 + */ + public Collection getApplicableContributors(IStructuredSelection selection) { + Iterator it = selection.iterator(); + Collection result = null; + while (it.hasNext()) { + Object element = it.next(); + Collection collection = getApplicableContributors(element); + if (result == null) + result = new LinkedHashSet(collection); + else + result.retainAll(collection); + } + if (result != null && !result.isEmpty() && selection.size() > 1) { + // only add contributors which can handle multi selection + it = result.iterator(); + while (it.hasNext()) { + RegistryPageContributor contrib = (RegistryPageContributor) it + .next(); + if (!contrib.supportsMultipleSelection()) + it.remove(); + } + } + return result; + } + /* (non-Javadoc) * @see org.eclipse.ui.internal.ObjectContributorManager#getExtensionPointFilter() */ |