Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 35319 Details for
Bug 92601
[Properties] Can't contribute properties page for non IAdaptable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated patch
92601.txt (text/plain), 18.33 KB, created by
Tod Creasey
on 2006-02-24 12:11:05 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Tod Creasey
Created:
2006-02-24 12:11:05 EST
Size:
18.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java,v >retrieving revision 1.24 >diff -u -r1.24 PropertyDialog.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java 2 Aug 2005 17:40:39 -0000 1.24 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java 24 Feb 2006 17:12:24 -0000 >@@ -13,6 +13,7 @@ > import java.util.Iterator; > > import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.PreferenceManager; > import org.eclipse.jface.viewers.ISelection; >@@ -30,25 +31,28 @@ > * type. > */ > public class PropertyDialog extends FilteredPreferenceDialog { >- private ISelection selection; >+ private ISelection selection; > >- //The id of the last page that was selected >- private static String lastPropertyId = null; >+ // The id of the last page that was selected >+ private static String lastPropertyId = null; > >- >- /** >- * Create a new property dialog. >- * >- * @param shell the parent shell >- * @param propertyPageId the property page id >- * @param element the adaptable element >- * @return the property dialog >- */ >- public static PropertyDialog createDialogOn(Shell shell,final String propertyPageId, IAdaptable element){ >+ /** >+ * Create a new property dialog. >+ * >+ * @param shell >+ * the parent shell >+ * @param propertyPageId >+ * the property page id >+ * @param element >+ * the adaptable element >+ * @return the property dialog >+ */ >+ public static PropertyDialog createDialogOn(Shell shell, >+ final String propertyPageId, Object element) { > > PropertyPageManager pageManager = new PropertyPageManager(); > String title = "";//$NON-NLS-1$ >- >+ > if (element == null) > return null; > // load pages for the selection >@@ -60,14 +64,14 @@ > .iterator(); > String name = getName(element); > if (!pages.hasNext()) { >- MessageDialog >- .openInformation( >- shell, >- WorkbenchMessages.PropertyDialog_messageTitle, >- NLS.bind(WorkbenchMessages.PropertyDialog_noPropertyMessage, name)); >+ MessageDialog.openInformation(shell, >+ WorkbenchMessages.PropertyDialog_messageTitle, NLS.bind( >+ WorkbenchMessages.PropertyDialog_noPropertyMessage, >+ name)); > return null; > } >- title = NLS.bind(WorkbenchMessages.PropertyDialog_propertyMessage, name ); >+ title = NLS >+ .bind(WorkbenchMessages.PropertyDialog_propertyMessage, name); > PropertyDialog propertyDialog = new PropertyDialog(shell, pageManager, > new StructuredSelection(element)); > >@@ -81,68 +85,74 @@ > IWorkbenchHelpContextIds.PROPERTY_DIALOG); > > return propertyDialog; >- >- } >- >- /** >+ >+ } >+ >+ /** > * Returns the name of the given element. > * > * @param element > * the element > * @return the name of the element > */ >- private static String getName(IAdaptable element) { >- IWorkbenchAdapter adapter = (IWorkbenchAdapter) element >- .getAdapter(IWorkbenchAdapter.class); >- if (adapter != null) >+ private static String getName(Object element) { >+ IWorkbenchAdapter adapter = null; >+ if (element instanceof IAdaptable) { >+ adapter = (IWorkbenchAdapter) ((IAdaptable) element) >+ .getAdapter(IWorkbenchAdapter.class); >+ } else { >+ adapter = (IWorkbenchAdapter) Platform.getAdapterManager() >+ .getAdapter(element, IWorkbenchAdapter.class); >+ } >+ if (adapter != null) > return adapter.getLabel(element); > return "";//$NON-NLS-1$ > } >- >- /** >- * Create an instance of the receiver. >- * @param parentShell >- * @param mng >- * @param selection >- */ >- public PropertyDialog(Shell parentShell, PreferenceManager mng, >- ISelection selection) { >- super(parentShell, mng); >- setSelection(selection); >- } >- >- /** >- * Returns selection in the "Properties" action context. >- * >- * @return the selection >- */ >- public ISelection getSelection() { >- return selection; >- } >- >- /** >- * Sets the selection that will be used to determine target object. >- * >- * @param newSelection the new selection >- */ >- public void setSelection(ISelection newSelection) { >- selection = newSelection; >- } >- >- /** >- * Get the name of the selected item preference >- */ >- protected String getSelectedNodePreference() { >- return lastPropertyId; >- } >- >- /** >- * Get the name of the selected item preference >- */ >- protected void setSelectedNodePreference(String pageId) { >- lastPropertyId = pageId; >- } >- > >+ /** >+ * Create an instance of the receiver. >+ * >+ * @param parentShell >+ * @param mng >+ * @param selection >+ */ >+ public PropertyDialog(Shell parentShell, PreferenceManager mng, >+ ISelection selection) { >+ super(parentShell, mng); >+ setSelection(selection); >+ } >+ >+ /** >+ * Returns selection in the "Properties" action context. >+ * >+ * @return the selection >+ */ >+ public ISelection getSelection() { >+ return selection; >+ } >+ >+ /** >+ * Sets the selection that will be used to determine target object. >+ * >+ * @param newSelection >+ * the new selection >+ */ >+ public void setSelection(ISelection newSelection) { >+ selection = newSelection; >+ } >+ >+ /** >+ * Get the name of the selected item preference >+ */ >+ protected String getSelectedNodePreference() { >+ return lastPropertyId; >+ } >+ >+ /** >+ * Get the name of the selected item preference >+ */ >+ protected void setSelectedNodePreference(String pageId) { >+ lastPropertyId = pageId; >+ } > > } >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/IPropertyPageContributor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/IPropertyPageContributor.java,v >retrieving revision 1.5 >diff -u -r1.5 IPropertyPageContributor.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/IPropertyPageContributor.java 25 Feb 2005 20:52:32 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/IPropertyPageContributor.java 24 Feb 2006 17:12:24 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.dialogs; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.ui.internal.IObjectContributor; > > /** >@@ -23,9 +22,11 @@ > /** > * Implement this method to add instances of PropertyPage class to the > * property page manager. >+ * @param manager the contributor manager onto which to contribute the >+ * property pages. >+ * @param object the type for which pages should be contributed. > * @return true if pages were added, false if not. > */ >- > public boolean contributePropertyPages(PropertyPageManager manager, >- IAdaptable object); >+ Object object); > } >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java,v >retrieving revision 1.21 >diff -u -r1.21 RegistryPageContributor.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java 29 Mar 2005 00:53:53 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java 24 Feb 2006 17:12:24 -0000 >@@ -67,12 +67,11 @@ > adaptable = Boolean.valueOf(pageElement.getAttribute(PropertyPagesRegistryReader.ATT_ADAPTABLE)).booleanValue(); > } > >- /** >- * Implements the interface by creating property page specified with >- * the configuration element. >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.dialogs.IPropertyPageContributor#contributePropertyPages(org.eclipse.ui.internal.dialogs.PropertyPageManager, java.lang.Object) > */ > public boolean contributePropertyPages(PropertyPageManager mng, >- IAdaptable element) { >+ Object element) { > PropertyPageNode node = new PropertyPageNode(this, element); > > if(getCategory() == null){ >@@ -92,7 +91,7 @@ > * @return the property page > * @throws CoreException thrown if there is a problem creating the apge > */ >- public IWorkbenchPropertyPage createPage(IAdaptable element) >+ public IWorkbenchPropertyPage createPage(Object element) > throws CoreException { > IWorkbenchPropertyPage ppage = null; > ppage = (IWorkbenchPropertyPage) WorkbenchPlugin.createExtension( >@@ -111,7 +110,10 @@ > } > } > >- ppage.setElement((IAdaptable)adapted); >+ if(adapted instanceof IAdaptable) >+ ppage.setElement((IAdaptable) adapted); >+ else >+ ppage.setElement(new AdaptableForwarder(adapted)); > > return ppage; > } >@@ -126,7 +128,7 @@ > if (iconName == null) > return null; > return AbstractUIPlugin.imageDescriptorFromPlugin(pageElement >- .getNamespace(), iconName); >+ .getNamespaceIdentifier(), iconName); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java,v >retrieving revision 1.19 >diff -u -r1.19 PropertyPageContributorManager.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java 28 Mar 2005 21:26:56 -0000 1.19 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java 24 Feb 2006 17:12:24 -0000 >@@ -18,7 +18,6 @@ > import java.util.Iterator; > import java.util.List; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtension; > import org.eclipse.core.runtime.Platform; >@@ -115,10 +114,11 @@ > * contributors and sequentially invoke them to contribute to the property > * page manager. Matching algorithm will also check subclasses and > * implemented interfaces. >- * >+ * @param manager >+ * @param object > * @return true if contribution took place, false otherwise. > */ >- public boolean contribute(PropertyPageManager manager, IAdaptable object) { >+ public boolean contribute(PropertyPageManager manager, Object object) { > > List result = getContributors(object); > >@@ -176,6 +176,7 @@ > /** > * Ideally, shared instance should not be used and manager should be located > * in the workbench class. >+ * @return PropertyPageContributorManager > */ > public static PropertyPageContributorManager getManager() { > if (sharedInstance == null) >@@ -184,13 +185,6 @@ > } > > /** >- * Returns true if contributors exist in the manager for this object. >- */ >- public boolean hasContributorsFor(Object object) { >- return super.hasContributorsFor(object); >- } >- >- /** > * Loads property page contributors from the registry. > */ > private void loadContributors() { >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageNode.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageNode.java,v >retrieving revision 1.16 >diff -u -r1.16 PropertyPageNode.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageNode.java 18 Mar 2005 14:04:38 -0000 1.16 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageNode.java 24 Feb 2006 17:12:24 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.ui.internal.dialogs; > > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.swt.graphics.Image; >@@ -32,7 +31,7 @@ > > private Image icon; > >- private IAdaptable element; >+ private Object element; > > /** > * Create a new instance of the receiver. >@@ -40,7 +39,7 @@ > * @param element > */ > public PropertyPageNode(RegistryPageContributor contributor, >- IAdaptable element) { >+ Object element) { > super(contributor.getPageId(), contributor.getConfigurationElement()); > this.contributor = contributor; > this.element = element; >Index: Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java,v >retrieving revision 1.14 >diff -u -r1.14 PropertyDialogAction.java >--- Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java 24 Mar 2005 19:16:06 -0000 1.14 >+++ Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java 24 Feb 2006 17:12:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2006 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 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.dialogs; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jface.preference.PreferenceDialog; > import org.eclipse.jface.util.Assert; > import org.eclipse.jface.viewers.ISelectionProvider; >@@ -101,8 +100,7 @@ > * @return boolean > */ > private boolean hasPropertyPagesFor(Object object) { >- PropertyPageContributorManager manager = PropertyPageContributorManager.getManager(); >- return manager.hasContributorsFor(object); >+ return PropertyPageContributorManager.getManager().hasContributorsFor(object); > } > > /** >@@ -167,7 +165,7 @@ > */ > public PreferenceDialog createDialog() { > >- IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement(); >+ Object element = getStructuredSelection().getFirstElement(); > if (element == null) > return null; > return PropertyDialog >Index: Eclipse UI/org/eclipse/ui/IWorkbenchPropertyPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPropertyPage.java,v >retrieving revision 1.7 >diff -u -r1.7 IWorkbenchPropertyPage.java >--- Eclipse UI/org/eclipse/ui/IWorkbenchPropertyPage.java 25 Feb 2005 20:52:16 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/IWorkbenchPropertyPage.java 24 Feb 2006 17:12:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * Copyright (c) 2000, 2006 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 >@@ -12,6 +12,7 @@ > > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jface.preference.IPreferencePage; >+import org.eclipse.ui.dialogs.PropertyDialogAction; > > /** > * Interface for workbench property pages. Property pages generally show up in >@@ -43,6 +44,13 @@ > * Sets the object that owns the properties shown in this page. > * The page is expected to store this object and provide it if > * <code>getElement</code> is called. >+ * <p> As of Eclipse 3.2 the org.eclipse.ui.propertyPages extension >+ * point now supports non IAdaptable inputs. An input >+ * that is not an IAdaptable will be wrapped in an >+ * IAdaptable by the workbench before it is forwarded >+ * to this method. >+ * </p> >+ * @see PropertyDialogAction > * > * @param element the object that owns the properties shown in this page > */ >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java >diff -N Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.dialogs; >+ >+import org.eclipse.core.runtime.IAdaptable; >+ >+/** >+ * Class that wraps an object and forwards adapter calls if possible, otherwise >+ * returns the object. This is used to maintain API compatibility with methods that >+ * need an IAdaptable but when the operation supports a broader type. >+ * >+ * @since 3.2 >+ */ >+public class AdaptableForwarder implements IAdaptable { >+ >+ private Object element; >+ >+ /** >+ * Create a new instance of the receiver. >+ * @param element >+ */ >+ public AdaptableForwarder(Object element) { >+ this.element = element; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter(Class adapter) { >+ if(adapter.isInstance(element)) { >+ return element; >+ } >+ if(element instanceof IAdaptable) { >+ return ((IAdaptable)element).getAdapter(adapter); >+ } >+ return null; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92601
:
22809
| 35319 |
35320