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 16394 Details for
Bug 56212
[PropertiesDialog] PropertiesDialogAction should work for objects which do not implement IAdaptable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
patch to allow non-IAdaptables to have property pages
ui-propertypage-adaptable.txt (text/plain), 11.19 KB, created by
Jean-Michel Lemieux
on 2004-12-06 15:22:44 EST
(
hide
)
Description:
patch to allow non-IAdaptables to have property pages
Filename:
MIME Type:
Creator:
Jean-Michel Lemieux
Created:
2004-12-06 15:22:44 EST
Size:
11.19 KB
patch
obsolete
>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.6 >diff -u -r1.6 IWorkbenchPropertyPage.java >--- Eclipse UI/org/eclipse/ui/IWorkbenchPropertyPage.java 8 Jul 2004 20:07:34 -0000 1.6 >+++ Eclipse UI/org/eclipse/ui/IWorkbenchPropertyPage.java 6 Dec 2004 20:19:14 -0000 >@@ -34,6 +34,17 @@ > public interface IWorkbenchPropertyPage extends IPreferencePage { > /** > * Returns the object that owns the properties shown in this page. >+ * <p> >+ * Support has been added to allow non-adaptable objects to accept >+ * property pages. In order to keep this interface compatible the >+ * return value of this method won't be changed. The property manager >+ * will wrap the selected element. You can retrieve the element >+ * from the selection by calling: >+ * <code> >+ * MyNonAdaptable element = (MyNonAdaptable) getElement(). >+ * getAdatable("MyNonAdaptable.class"); >+ * </code> >+ * </p> > * > * @return the object that owns the properties shown in this page > */ >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.7 >diff -u -r1.7 PropertyDialogAction.java >--- Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java 20 Jul 2004 20:06:06 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/dialogs/PropertyDialogAction.java 6 Dec 2004 20:19:14 -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.util.Assert; >@@ -80,14 +81,19 @@ > * the element > * @return the name of the element > */ >- private String getName(IAdaptable element) { >- IWorkbenchAdapter adapter = (IWorkbenchAdapter) element >- .getAdapter(IWorkbenchAdapter.class); >+ private 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); >- } else { >- return "";//$NON-NLS-1$ > } >+ return "";//$NON-NLS-1$ > } > > /** >@@ -152,7 +158,7 @@ > PropertyPageManager pageManager = new PropertyPageManager(); > String title = "";//$NON-NLS-1$ > // get selection >- IAdaptable element = (IAdaptable) getStructuredSelection() >+ Object element = getStructuredSelection() > .getFirstElement(); > if (element == null) > return; >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.4 >diff -u -r1.4 IPropertyPageContributor.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/IPropertyPageContributor.java 8 Jul 2004 20:07:38 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/IPropertyPageContributor.java 6 Dec 2004 20:19:14 -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/PropertyPageContributorManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java,v >retrieving revision 1.13 >diff -u -r1.13 PropertyPageContributorManager.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java 1 Dec 2004 16:37:14 -0000 1.13 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageContributorManager.java 6 Dec 2004 20:19:14 -0000 >@@ -11,12 +11,7 @@ > package org.eclipse.ui.internal.dialogs; > > import java.text.Collator; >-import java.util.Arrays; >-import java.util.Collections; >-import java.util.Comparator; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >+import java.util.*; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.Platform; > import org.eclipse.ui.internal.IWorkbenchConstants; >@@ -88,7 +83,7 @@ > * implemented interfaces. > * @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); > >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.11 >diff -u -r1.11 PropertyPageNode.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageNode.java 8 Jul 2004 20:07:38 -0000 1.11 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyPageNode.java 6 Dec 2004 20:19:14 -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.preference.PreferenceNode; > import org.eclipse.jface.resource.ImageDescriptor; >@@ -34,13 +33,13 @@ > > private Image icon; > >- private IAdaptable element; >+ private Object element; > > /** > * PropertyPageNode constructor. > */ > public PropertyPageNode(RegistryPageContributor contributor, >- IAdaptable element) { >+ Object element) { > super(contributor.getPageId()); > this.contributor = contributor; > this.element = element; >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.13 >diff -u -r1.13 RegistryPageContributor.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java 1 Dec 2004 16:37:14 -0000 1.13 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java 6 Dec 2004 20:19:14 -0000 >@@ -11,21 +11,10 @@ > package org.eclipse.ui.internal.dialogs; > > import java.lang.ref.SoftReference; >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.Map; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >+import java.util.*; >+import org.eclipse.core.runtime.*; > import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.ui.IActionFilter; >-import org.eclipse.ui.IWorkbenchPropertyPage; >-import org.eclipse.ui.SelectionEnabler; >+import org.eclipse.ui.*; > import org.eclipse.ui.internal.LegacyResourceSupport; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.registry.CategorizedPageRegistryReader; >@@ -69,7 +58,7 @@ > * the configuration element. > */ > public boolean contributePropertyPages(PropertyPageManager mng, >- IAdaptable element) { >+ Object element) { > PropertyPageNode node = new PropertyPageNode(this, element); > > if(getCategory() == null){ >@@ -84,7 +73,7 @@ > /** > * Creates the page based on the information in the configuration element. > */ >- public IWorkbenchPropertyPage createPage(IAdaptable element) >+ public IWorkbenchPropertyPage createPage(Object element) > throws CoreException { > IWorkbenchPropertyPage ppage = null; > ppage = (IWorkbenchPropertyPage) WorkbenchPlugin.createExtension( >@@ -103,7 +92,7 @@ > } > } > >- ppage.setElement((IAdaptable)adapted); >+ ppage.setElement(new AdaptableForwarder(element)); > > return ppage; > } >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,39 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 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.1 >+ */ >+public class AdaptableForwarder implements IAdaptable { >+ >+ private Object element; >+ >+ public AdaptableForwarder(Object element) { >+ this.element = element; >+ } >+ >+ 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 Raw
Actions:
View
Attachments on
bug 56212
: 16394