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 56930 Details for
Bug 89834
[Presentations] Allow for unanticipated parameters for part appearance and behavior
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]
part Properties v02
partProperties-v02.txt (text/plain), 26.55 KB, created by
Paul Webster
on 2007-01-15 15:17:07 EST
(
hide
)
Description:
part Properties v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2007-01-15 15:17:07 EST
Size:
26.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/IWorkbenchPartReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPartReference.java,v >retrieving revision 1.13 >diff -u -r1.13 IWorkbenchPartReference.java >--- Eclipse UI/org/eclipse/ui/IWorkbenchPartReference.java 8 May 2006 20:55:31 -0000 1.13 >+++ Eclipse UI/org/eclipse/ui/IWorkbenchPartReference.java 15 Jan 2007 20:06:20 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.ui; > >+import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.swt.graphics.Image; > > /** >@@ -93,4 +94,34 @@ > */ > public boolean isDirty(); > >+ /** >+ * Return an arbitrary property from the reference. If the part has been >+ * instantiated, it just delegates to the part. If not, then it looks in its >+ * own cache of properties. If the property is not available or the part has >+ * never been instantiated, it can return <code>null</code>. >+ * >+ * @param key >+ * The property to return. Must not be <code>null</code>. >+ * @return The String property, or <code>null</code>. >+ * @since 3.3 >+ */ >+ public String getPartProperty(String key); >+ >+ /** >+ * Add a listener for changes in the arbitrary properties set. >+ * >+ * @param listener >+ * Must not be <code>null</code>. >+ * @since 3.3 >+ */ >+ public void addPartPropertyListener(IPropertyChangeListener listener); >+ >+ /** >+ * Remove a listener for changes in the arbitrary properties set. >+ * >+ * @param listener >+ * Must not be <code>null</code>. >+ * @since 3.3 >+ */ >+ public void removePartPropertyListener(IPropertyChangeListener listener); > } >Index: Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java,v >retrieving revision 1.19 >diff -u -r1.19 IPresentablePart.java >--- Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java 8 May 2006 20:55:49 -0000 1.19 >+++ Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java 15 Jan 2007 20:06:20 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ui.presentations; > >+import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Control; >@@ -226,4 +227,45 @@ > */ > public Control getControl(); > >+ /** >+ * Get a property other than title or name from a workbench part. These >+ * properties are arbitrary properties that the presentation might like >+ * access to. >+ * <p> >+ * <b>Note:</b> this is a different set of properties than the ones >+ * covered by the PROP_* constants. >+ * </p> >+ * >+ * @param key >+ * The property key to retrieve. Must not be <code>null</code>. >+ * @return the property, or <code>null</code> if that property is not set. >+ * @since 3.3 >+ */ >+ public String getPartProperty(String key); >+ >+ /** >+ * Add a listener for changes in the arbitrary properties set. >+ * <p> >+ * <b>Note:</b> this is a different set of properties than the ones covered >+ * by the PROP_* constants. >+ * </p> >+ * >+ * @param listener >+ * Must not be <code>null</code>. >+ * @since 3.3 >+ */ >+ public void addPartPropertyListener(IPropertyChangeListener listener); >+ >+ /** >+ * Remove a change listener from the arbitrary properties set. >+ * <p> >+ * <b>Note:</b> this is a different set of properties than the ones covered >+ * by the PROP_* constants. >+ * </p> >+ * >+ * @param listener >+ * Must not be <code>null</code>. >+ * @since 3.3 >+ */ >+ public void removePartPropertyListener(IPropertyChangeListener listener); > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java,v >retrieving revision 1.43 >diff -u -r1.43 WorkbenchPartReference.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java 20 Dec 2006 02:38:11 -0000 1.43 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java 15 Jan 2007 20:06:20 -0000 >@@ -11,12 +11,16 @@ > package org.eclipse.ui.internal; > > import java.util.BitSet; >+import java.util.HashMap; >+import java.util.Map; > > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.ListenerList; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.events.DisposeEvent; > import org.eclipse.swt.events.DisposeListener; >@@ -29,6 +33,7 @@ > import org.eclipse.ui.ISharedImages; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchPart2; >+import org.eclipse.ui.IWorkbenchPart3; > import org.eclipse.ui.IWorkbenchPartConstants; > import org.eclipse.ui.IWorkbenchPartReference; > import org.eclipse.ui.IWorkbenchPartSite; >@@ -137,10 +142,14 @@ > */ > private ListenerList internalPropChangeListeners = new ListenerList(); > >+ private ListenerList partChangeListeners = new ListenerList(); >+ > private String partName; > > private String contentDescription; > >+ protected Map propertyCache = new HashMap(); >+ > /** > * Used to remember which events have been queued. > */ >@@ -163,6 +172,12 @@ > } > }; > >+ private IPropertyChangeListener partPropertyChangeListener = new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ partPropertyChanged(event); >+ } >+ }; >+ > public WorkbenchPartReference() { > //no-op > } >@@ -283,6 +298,10 @@ > } > } > } >+ >+ protected void partPropertyChanged(PropertyChangeEvent event) { >+ firePartPropertyChange(event); >+ } > > /** > * Refreshes all cached values with the values from the real part >@@ -571,6 +590,9 @@ > // object that should dispose this control, and it will remove the listener before it does so. > getPane().getControl().addDisposeListener(prematureDisposeListener); > part.addPropertyListener(propertyChangeListener); >+ if (part instanceof IWorkbenchPart3) { >+ ((IWorkbenchPart3)part).addPartPropertyListener(partPropertyChangeListener); >+ } > > refreshFromPart(); > releaseReferences(); >@@ -646,6 +668,7 @@ > } > > clearListenerList(internalPropChangeListeners); >+ clearListenerList(partChangeListeners); > Image oldImage = image; > ImageDescriptor oldDescriptor = imageDescriptor; > image = null; >@@ -684,6 +707,9 @@ > // Don't let exceptions in client code bring us down. Log them and continue. > try { > part.removePropertyListener(propertyChangeListener); >+ if (part instanceof IWorkbenchPart3) { >+ ((IWorkbenchPart3)part).removePartPropertyListener(partPropertyChangeListener); >+ } > part.dispose(); > } catch (Exception e) { > WorkbenchPlugin.log(e); >@@ -712,4 +738,44 @@ > return pinned; > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPartReference#getPartProperty(java.lang.String) >+ */ >+ public String getPartProperty(String key) { >+ if (part != null) { >+ if (part instanceof IWorkbenchPart3) { >+ return ((IWorkbenchPart3) part).getPartProperty(key); >+ } >+ } else { >+ return (String)propertyCache.get(key); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPartReference#addPartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener) >+ */ >+ public void addPartPropertyListener(IPropertyChangeListener listener) { >+ if (isDisposed()) { >+ return; >+ } >+ partChangeListeners.add(listener); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPartReference#removePartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener) >+ */ >+ public void removePartPropertyListener(IPropertyChangeListener listener) { >+ if (isDisposed()) { >+ return; >+ } >+ partChangeListeners.remove(listener); >+ } >+ >+ protected void firePartPropertyChange(PropertyChangeEvent event) { >+ Object[] l = partChangeListeners.getListeners(); >+ for (int i = 0; i < l.length; i++) { >+ ((IPropertyChangeListener)l[i]).propertyChange(event); >+ } >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java,v >retrieving revision 1.75 >diff -u -r1.75 IWorkbenchConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 10 Nov 2006 12:51:44 -0000 1.75 >+++ Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 15 Jan 2007 20:06:20 -0000 >@@ -120,6 +120,8 @@ > > public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$ > >+ public static final String TAG_PROPERTY = "property"; //$NON-NLS-1$ >+ > public static final String TAG_PART_TRIMSTATE = "inTrim"; //$NON-NLS-1$ > > public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$ >@@ -328,4 +330,8 @@ > //Colors > public static final String COLOR_HIGHLIGHT = "org.eclipse.ui.highlight"; //$NON-NLS-1$ > >+ public static final String TAG_KEY = "key"; //$NON-NLS-1$ >+ >+ public static final String TAG_VALUE = "value"; //$NON-NLS-1$ >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/PartPane.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartPane.java,v >retrieving revision 1.86 >diff -u -r1.86 PartPane.java >--- Eclipse UI/org/eclipse/ui/internal/PartPane.java 11 Dec 2006 04:39:37 -0000 1.86 >+++ Eclipse UI/org/eclipse/ui/internal/PartPane.java 15 Jan 2007 20:06:20 -0000 >@@ -12,6 +12,8 @@ > > import org.eclipse.core.runtime.ListenerList; > import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.FocusAdapter; > import org.eclipse.swt.events.FocusEvent; >@@ -50,7 +52,8 @@ > * LayoutPart and downcasting. The getPresentablePart() method only applies to PartPanes, and > * should be removed from LayoutPart. > */ >-public abstract class PartPane extends LayoutPart implements IPropertyListener, Listener { >+public abstract class PartPane extends LayoutPart implements IPropertyListener, >+ Listener, IPropertyChangeListener { > > public static final String PROP_ZOOMED = "zoomed"; //$NON-NLS-1$ > >@@ -58,6 +61,7 @@ > > private MenuManager paneMenuManager; > private ListenerList listeners = new ListenerList(); >+ private ListenerList partListeners = new ListenerList(); > > protected IWorkbenchPartReference partReference; > >@@ -135,6 +139,7 @@ > } > > partReference.addPropertyListener(this); >+ partReference.addPartPropertyListener(this); > // Create view form. > control = new Composite(parent, SWT.NONE); > control.setLayout(new FillLayout()); >@@ -176,6 +181,7 @@ > } > > partReference.removePropertyListener(this); >+ partReference.removePartPropertyListener(this); > } > > /** >@@ -600,8 +606,30 @@ > ((IPropertyListener) listeners[i]).propertyChanged(this, propertyId); > } > } >- >+ > public void propertyChanged(Object source, int propId) { > firePropertyChange(propId); > } >+ >+ public void addPartPropertyListener(IPropertyChangeListener listener) { >+ partListeners.add(listener); >+ } >+ >+ public void removePartPropertyListener(IPropertyChangeListener listener) { >+ partListeners.remove(listener); >+ } >+ >+ public void firePartPropertyChange(PropertyChangeEvent event) { >+ Object[] l = partListeners.getListeners(); >+ for (int i = 0; i < l.length; i++) { >+ ((IPropertyChangeListener)l[i]).propertyChange(event); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) >+ */ >+ public void propertyChange(PropertyChangeEvent event) { >+ firePartPropertyChange(event); >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/EditorReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java,v >retrieving revision 1.21 >diff -u -r1.21 EditorReference.java >--- Eclipse UI/org/eclipse/ui/internal/EditorReference.java 20 Dec 2006 15:16:47 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/internal/EditorReference.java 15 Jan 2007 20:06:20 -0000 >@@ -140,7 +140,14 @@ > String partName = memento > .getString(IWorkbenchConstants.TAG_PART_NAME); > >- // For compatibility set the part name to the title if not found >+ IMemento[] props = memento >+ .getChildren(IWorkbenchConstants.TAG_PROPERTY); >+ for (int i = 0; i < props.length; i++) { >+ propertyCache.put(props[i].getString(IWorkbenchConstants.TAG_KEY), >+ props[i].getString(IWorkbenchConstants.TAG_VALUE)); >+ } >+ >+ // For compatibility set the part name to the title if not found > if (partName == null) { > partName = title; > } >Index: Eclipse UI/org/eclipse/ui/internal/EditorManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java,v >retrieving revision 1.124 >diff -u -r1.124 EditorManager.java >--- Eclipse UI/org/eclipse/ui/internal/EditorManager.java 12 Jan 2007 20:21:37 -0000 1.124 >+++ Eclipse UI/org/eclipse/ui/internal/EditorManager.java 15 Jan 2007 20:06:20 -0000 >@@ -77,6 +77,7 @@ > import org.eclipse.ui.IViewPart; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchPart3; > import org.eclipse.ui.IWorkbenchPartReference; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PartInitException; >@@ -1600,6 +1601,20 @@ > > editorMem.putString(IWorkbenchConstants.TAG_PART_NAME, > editorRef.getPartName()); >+ >+ if (editor instanceof IWorkbenchPart3) { >+ Map properties = ((IWorkbenchPart3) editor).getPartProperties(); >+ Iterator i = properties.entrySet().iterator(); >+ while (i.hasNext()) { >+ Map.Entry entry = (Map.Entry) i.next(); >+ IMemento p = editorMem >+ .createChild(IWorkbenchConstants.TAG_PROPERTY); >+ p.putString(IWorkbenchConstants.TAG_KEY, (String) entry >+ .getKey()); >+ p.putString(IWorkbenchConstants.TAG_VALUE, >+ (String) entry.getValue()); >+ } >+ } > > if (editorRef.isPinned()) { > editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java,v >retrieving revision 1.10 >diff -u -r1.10 PresentablePart.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java 24 Oct 2005 19:06:49 -0000 1.10 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java 15 Jan 2007 20:06:20 -0000 >@@ -13,6 +13,9 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >@@ -46,6 +49,10 @@ > > // Lazily initialized. Use getPropertyListenerProxy() to access. > private IPropertyListener lazyPropertyListenerProxy; >+ >+ private ListenerList partPropertyChangeListeners = new ListenerList(); >+ >+ private IPropertyChangeListener lazyPartPropertyChangeListener; > > // Lazily initialized. Use getMenu() to access > private IPartMenu viewMenu; >@@ -75,6 +82,7 @@ > public PresentablePart(PartPane part, Composite parent) { > this.part = part; > getPane().addPropertyListener(getPropertyListenerProxy()); >+ getPane().addPartPropertyListener(getPartPropertyListenerProxy()); > } > > public PartPane getPane() { >@@ -92,19 +100,33 @@ > > return lazyPropertyListenerProxy; > } >+ >+ private IPropertyChangeListener getPartPropertyListenerProxy() { >+ if (lazyPartPropertyChangeListener == null) { >+ lazyPartPropertyChangeListener = new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ firePartPropertyChange(event); >+ } >+ }; >+ } >+ return lazyPartPropertyChangeListener; >+ } > > /** >- * Detach this PresentablePart from the real part. No further methods should be invoked >- * on this object. >- */ >+ * Detach this PresentablePart from the real part. No further methods should >+ * be invoked on this object. >+ */ > public void dispose() { > // Ensure that the property listener is detached (necessary to prevent leaks) > getPane().removePropertyListener(getPropertyListenerProxy()); >+ getPane().removePartPropertyListener(getPartPropertyListenerProxy()); > > // Null out the various fields to ease garbage collection (optional) > part = null; > listeners.clear(); > listeners = null; >+ partPropertyChangeListeners.clear(); >+ partPropertyChangeListeners = null; > } > > public void firePropertyChange(int propertyId) { >@@ -121,6 +143,21 @@ > listeners.remove(listener); > } > >+ public void firePartPropertyChange(PropertyChangeEvent event) { >+ Object[] l = partPropertyChangeListeners.getListeners(); >+ for (int i = 0; i < l.length; i++) { >+ ((IPropertyChangeListener) l[i]).propertyChange(event); >+ } >+ } >+ >+ public void addPartPropertyListener(IPropertyChangeListener listener) { >+ partPropertyChangeListeners.add(listener); >+ } >+ >+ public void removePartPropertyListener(IPropertyChangeListener listener) { >+ partPropertyChangeListeners.remove(listener); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.ui.presentations.IPresentablePart#setBounds(org.eclipse.swt.graphics.Rectangle) > */ >@@ -351,4 +388,11 @@ > } > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.presentations.IPresentablePart#getPartProperty(java.lang.String) >+ */ >+ public String getPartProperty(String key) { >+ return getPartReference().getPartProperty(key); >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java,v >retrieving revision 1.51 >diff -u -r1.51 WorkbenchPart.java >--- Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java 11 Jan 2007 15:28:10 -0000 1.51 >+++ Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java 15 Jan 2007 20:06:20 -0000 >@@ -10,22 +10,27 @@ > *******************************************************************************/ > package org.eclipse.ui.part; > >-import com.ibm.icu.text.MessageFormat; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Map; > > import org.eclipse.core.commands.common.EventManager; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExecutableExtension; >+import org.eclipse.core.runtime.ListenerList; > import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.jface.window.Window; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.IPropertyListener; > import org.eclipse.ui.ISharedImages; > import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.IWorkbenchPart2; >+import org.eclipse.ui.IWorkbenchPart3; > import org.eclipse.ui.IWorkbenchPartConstants; > import org.eclipse.ui.IWorkbenchPartSite; > import org.eclipse.ui.PlatformUI; >@@ -34,6 +39,8 @@ > import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.plugin.AbstractUIPlugin; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * Abstract base implementation of all workbench parts. > * <p> >@@ -46,7 +53,7 @@ > * @see org.eclipse.ui.part.EditorPart > */ > public abstract class WorkbenchPart extends EventManager implements >- IWorkbenchPart2, IExecutableExtension, IWorkbenchPartOrientation { >+ IWorkbenchPart3, IExecutableExtension, IWorkbenchPartOrientation { > private String title = ""; //$NON-NLS-1$ > > private ImageDescriptor imageDescriptor; >@@ -62,6 +69,8 @@ > private String partName = ""; //$NON-NLS-1$ > > private String contentDescription = ""; //$NON-NLS-1$ >+ >+ private ListenerList partChangeListeners = new ListenerList(); > > /** > * Creates a new workbench part. >@@ -103,6 +112,7 @@ > // should not be notifying anyone after the part > // has been disposed. > clearListeners(); >+ partChangeListeners.clear(); > } > > /** >@@ -462,4 +472,58 @@ > return Window.getDefaultOrientation(); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPart3#addPartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener) >+ */ >+ public void addPartPropertyListener(IPropertyChangeListener listener) { >+ partChangeListeners.add(listener); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPart3#removePartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener) >+ */ >+ public void removePartPropertyListener(IPropertyChangeListener listener) { >+ partChangeListeners.remove(listener); >+ } >+ >+ protected void firePartPropertyChanged(String key, String oldValue, String newValue) { >+ final PropertyChangeEvent event = new PropertyChangeEvent(this, key, oldValue, newValue); >+ Object[] l = partChangeListeners.getListeners(); >+ for (int i = 0; i < l.length; i++) { >+ try { >+ ((IPropertyChangeListener)l[i]).propertyChange(event); >+ } catch (RuntimeException e) { >+ WorkbenchPlugin.log(e); >+ } >+ } >+ } >+ >+ private Map partProperties = new HashMap(); >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPart3#setPartProperty(java.lang.String, java.lang.String) >+ */ >+ public void setPartProperty(String key, String value) { >+ String oldValue = (String) partProperties.get(key); >+ if (value==null) { >+ partProperties.remove(key); >+ } else { >+ partProperties.put(key, value); >+ } >+ firePartPropertyChanged(key, oldValue, value); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPart3#getPartProperty(java.lang.String) >+ */ >+ public String getPartProperty(String key) { >+ return (String)partProperties.get(key); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPart3#getPartProperties() >+ */ >+ public Map getPartProperties() { >+ return Collections.unmodifiableMap(partProperties); >+ } > } >Index: Eclipse UI/org/eclipse/ui/IWorkbenchPart3.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/IWorkbenchPart3.java >diff -N Eclipse UI/org/eclipse/ui/IWorkbenchPart3.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/IWorkbenchPart3.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui; >+ >+import java.util.Map; >+ >+import org.eclipse.jface.util.IPropertyChangeListener; >+ >+/** >+ * A part can provide arbitrary properties. The properties will be persisted >+ * between sessions by the part reference, and will be available from the part >+ * reference as well as the part. >+ * <p> >+ * Setting a property must fire a PropertyChangeEvent. >+ * </p> >+ * >+ * @since 3.3 >+ */ >+public interface IWorkbenchPart3 extends IWorkbenchPart2 { >+ /** >+ * Add a listener for changes in the arbitrary properties set. >+ * <p> >+ * <b>Note:</b> this is a different set of properties than the ones covered >+ * by the IWorkbenchPartConstants.PROP_* constants. >+ * </p> >+ * >+ * @param listener >+ * Must not be <code>null</code>. >+ */ >+ public void addPartPropertyListener(IPropertyChangeListener listener); >+ >+ /** >+ * Remove a change listener from the arbitrary properties set. >+ * <p> >+ * <b>Note:</b> this is a different set of properties than the ones covered >+ * by the IWorkbenchPartConstants.PROP_* constants. >+ * </p> >+ * >+ * @param listener >+ * Must not be <code>null</code>. >+ */ >+ public void removePartPropertyListener(IPropertyChangeListener listener); >+ >+ /** >+ * Return the value for the arbitrary property key, or <code>null</code>. >+ * >+ * @param key >+ * the arbitrary property. Must not be <code>null</code>. >+ * @return the property value, or <code>null</code>. >+ */ >+ public String getPartProperty(String key); >+ >+ /** >+ * Set an arbitrary property on the part. It is the implementor's >+ * responsibility to fire the corresponding PropertyChangeEvent. >+ * >+ * @param key >+ * the arbitrary property. Must not be <code>null</code>. >+ * @param value >+ * the property value. A <code>null</code> value will remove >+ * that property. >+ */ >+ public void setPartProperty(String key, String value); >+ >+ /** >+ * Return an unmodifiable map of the arbitrary properties. >+ * >+ * @return A Map of the properties. Must not be <code>null</code>. >+ */ >+ public Map getPartProperties(); >+}
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 89834
:
56661
|
56930
|
56982
|
56997