Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 89834 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/IWorkbenchPartReference.java (+31 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.ui;
12
package org.eclipse.ui;
13
13
14
import org.eclipse.jface.util.IPropertyChangeListener;
14
import org.eclipse.swt.graphics.Image;
15
import org.eclipse.swt.graphics.Image;
15
16
16
/**
17
/**
Lines 93-96 Link Here
93
     */
94
     */
94
    public boolean isDirty();
95
    public boolean isDirty();
95
    
96
    
97
    /**
98
	 * Return an arbitrary property from the reference. If the part has been
99
	 * instantiated, it just delegates to the part. If not, then it looks in its
100
	 * own cache of properties. If the property is not available or the part has
101
	 * never been instantiated, it can return <code>null</code>.
102
	 * 
103
	 * @param key
104
	 *            The property to return. Must not be <code>null</code>.
105
	 * @return The String property, or <code>null</code>.
106
	 * @since 3.3
107
	 */
108
    public String getPartProperty(String key);
109
    
110
    /**
111
	 * Add a listener for changes in the arbitrary properties set.
112
	 * 
113
	 * @param listener
114
	 *            Must not be <code>null</code>.
115
	 * @since 3.3
116
	 */
117
    public void addPartPropertyListener(IPropertyChangeListener listener);
118
    
119
    /**
120
	 * Remove a listener for changes in the arbitrary properties set.
121
	 * 
122
	 * @param listener
123
	 *            Must not be <code>null</code>.
124
	 * @since 3.3
125
	 */
126
    public void removePartPropertyListener(IPropertyChangeListener listener);
96
}
127
}
(-)Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java (+42 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.presentations;
11
package org.eclipse.ui.presentations;
12
12
13
import org.eclipse.jface.util.IPropertyChangeListener;
13
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.graphics.Rectangle;
15
import org.eclipse.swt.graphics.Rectangle;
15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.swt.widgets.Control;
Lines 226-229 Link Here
226
     */
227
     */
227
    public Control getControl();
228
    public Control getControl();
228
229
230
    /**
231
	 * Get a property other than title or name from a workbench part. These
232
	 * properties are arbitrary properties that the presentation might like
233
	 * access to.
234
	 * <p>
235
	 * <b>Note:</b> this is a different set of properties than the ones
236
	 * covered by the PROP_* constants.
237
	 * </p>
238
	 * 
239
	 * @param key
240
	 *            The property key to retrieve. Must not be <code>null</code>.
241
	 * @return the property, or <code>null</code> if that property is not set.
242
	 * @since 3.3
243
	 */
244
	public String getPartProperty(String key);
245
	
246
	/**
247
	 * Add a listener for changes in the arbitrary properties set.
248
	 * <p>
249
	 * <b>Note:</b> this is a different set of properties than the ones covered
250
	 * by the PROP_* constants.
251
	 * </p>
252
	 * 
253
	 * @param listener
254
	 *            Must not be <code>null</code>.
255
	 * @since 3.3
256
	 */
257
	public void addPartPropertyListener(IPropertyChangeListener listener);
258
	
259
	/**
260
	 * Remove a change listener from the arbitrary properties set.
261
	 * <p>
262
	 * <b>Note:</b> this is a different set of properties than the ones covered
263
	 * by the PROP_* constants.
264
	 * </p>
265
	 * 
266
	 * @param listener
267
	 *            Must not be <code>null</code>.
268
	 * @since 3.3
269
	 */
270
	public void removePartPropertyListener(IPropertyChangeListener listener);
229
}
271
}
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java (+66 lines)
Lines 11-22 Link Here
11
package org.eclipse.ui.internal;
11
package org.eclipse.ui.internal;
12
12
13
import java.util.BitSet;
13
import java.util.BitSet;
14
import java.util.HashMap;
15
import java.util.Map;
14
16
15
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.core.runtime.Assert;
16
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.ListenerList;
19
import org.eclipse.core.runtime.ListenerList;
18
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.JFaceResources;
21
import org.eclipse.jface.resource.JFaceResources;
22
import org.eclipse.jface.util.IPropertyChangeListener;
23
import org.eclipse.jface.util.PropertyChangeEvent;
20
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.swt.events.DisposeEvent;
25
import org.eclipse.swt.events.DisposeEvent;
22
import org.eclipse.swt.events.DisposeListener;
26
import org.eclipse.swt.events.DisposeListener;
Lines 29-34 Link Here
29
import org.eclipse.ui.ISharedImages;
33
import org.eclipse.ui.ISharedImages;
30
import org.eclipse.ui.IWorkbenchPart;
34
import org.eclipse.ui.IWorkbenchPart;
31
import org.eclipse.ui.IWorkbenchPart2;
35
import org.eclipse.ui.IWorkbenchPart2;
36
import org.eclipse.ui.IWorkbenchPart3;
32
import org.eclipse.ui.IWorkbenchPartConstants;
37
import org.eclipse.ui.IWorkbenchPartConstants;
33
import org.eclipse.ui.IWorkbenchPartReference;
38
import org.eclipse.ui.IWorkbenchPartReference;
34
import org.eclipse.ui.IWorkbenchPartSite;
39
import org.eclipse.ui.IWorkbenchPartSite;
Lines 137-146 Link Here
137
     */
142
     */
138
    private ListenerList internalPropChangeListeners = new ListenerList();
143
    private ListenerList internalPropChangeListeners = new ListenerList();
139
    
144
    
145
    private ListenerList partChangeListeners = new ListenerList();
146
    
140
    private String partName;
147
    private String partName;
141
148
142
    private String contentDescription;
149
    private String contentDescription;
143
    
150
    
151
    protected Map propertyCache = new HashMap();
152
    
144
    /**
153
    /**
145
     * Used to remember which events have been queued.
154
     * Used to remember which events have been queued.
146
     */
155
     */
Lines 163-168 Link Here
163
        }
172
        }
164
    };
173
    };
165
    
174
    
175
    private IPropertyChangeListener partPropertyChangeListener = new IPropertyChangeListener() {
176
		public void propertyChange(PropertyChangeEvent event) {
177
			partPropertyChanged(event);
178
		}
179
    };
180
    
166
    public WorkbenchPartReference() {
181
    public WorkbenchPartReference() {
167
        //no-op
182
        //no-op
168
    }
183
    }
Lines 283-288 Link Here
283
        	}
298
        	}
284
        }
299
        }
285
    }
300
    }
301
    
302
    protected void partPropertyChanged(PropertyChangeEvent event) {
303
    	firePartPropertyChange(event);
304
    }
286
305
287
    /**
306
    /**
288
     * Refreshes all cached values with the values from the real part 
307
     * Refreshes all cached values with the values from the real part 
Lines 571-576 Link Here
571
                    // object that should dispose this control, and it will remove the listener before it does so.
590
                    // object that should dispose this control, and it will remove the listener before it does so.
572
                    getPane().getControl().addDisposeListener(prematureDisposeListener);
591
                    getPane().getControl().addDisposeListener(prematureDisposeListener);
573
                    part.addPropertyListener(propertyChangeListener);
592
                    part.addPropertyListener(propertyChangeListener);
593
                    if (part instanceof IWorkbenchPart3) {
594
                    	((IWorkbenchPart3)part).addPartPropertyListener(partPropertyChangeListener);
595
                    }
574
596
575
                    refreshFromPart();
597
                    refreshFromPart();
576
                    releaseReferences();
598
                    releaseReferences();
Lines 646-651 Link Here
646
        }
668
        }
647
        
669
        
648
        clearListenerList(internalPropChangeListeners);
670
        clearListenerList(internalPropChangeListeners);
671
        clearListenerList(partChangeListeners);
649
        Image oldImage = image;
672
        Image oldImage = image;
650
        ImageDescriptor oldDescriptor = imageDescriptor;
673
        ImageDescriptor oldDescriptor = imageDescriptor;
651
        image = null;
674
        image = null;
Lines 684-689 Link Here
684
            // Don't let exceptions in client code bring us down. Log them and continue.
707
            // Don't let exceptions in client code bring us down. Log them and continue.
685
            try {
708
            try {
686
                part.removePropertyListener(propertyChangeListener);
709
                part.removePropertyListener(propertyChangeListener);
710
                if (part instanceof IWorkbenchPart3) {
711
                	((IWorkbenchPart3)part).removePartPropertyListener(partPropertyChangeListener);
712
                }
687
                part.dispose();
713
                part.dispose();
688
            } catch (Exception e) {
714
            } catch (Exception e) {
689
                WorkbenchPlugin.log(e);
715
                WorkbenchPlugin.log(e);
Lines 712-715 Link Here
712
        return pinned;
738
        return pinned;
713
    }
739
    }
714
740
741
    /* (non-Javadoc)
742
     * @see org.eclipse.ui.IWorkbenchPartReference#getPartProperty(java.lang.String)
743
     */
744
    public String getPartProperty(String key) {
745
		if (part != null) {
746
			if (part instanceof IWorkbenchPart3) {
747
				return ((IWorkbenchPart3) part).getPartProperty(key);
748
			}
749
		} else {
750
			return (String)propertyCache.get(key);
751
		}
752
		return null;
753
	}
754
    
755
    /* (non-Javadoc)
756
     * @see org.eclipse.ui.IWorkbenchPartReference#addPartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener)
757
     */
758
    public void addPartPropertyListener(IPropertyChangeListener listener) {
759
    	if (isDisposed()) {
760
    		return;
761
    	}
762
    	partChangeListeners.add(listener);
763
    }
764
    
765
    /* (non-Javadoc)
766
     * @see org.eclipse.ui.IWorkbenchPartReference#removePartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener)
767
     */
768
    public void removePartPropertyListener(IPropertyChangeListener listener) {
769
    	if (isDisposed()) {
770
    		return;
771
    	}
772
    	partChangeListeners.remove(listener);
773
    }
774
    
775
    protected void firePartPropertyChange(PropertyChangeEvent event) {
776
    	Object[] l = partChangeListeners.getListeners();
777
    	for (int i = 0; i < l.length; i++) {
778
			((IPropertyChangeListener)l[i]).propertyChange(event);
779
		}
780
    }
715
}
781
}
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+6 lines)
Lines 120-125 Link Here
120
120
121
    public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
121
    public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
122
122
123
    public static final String TAG_PROPERTY = "property"; //$NON-NLS-1$
124
123
    public static final String TAG_PART_TRIMSTATE = "inTrim"; //$NON-NLS-1$
125
    public static final String TAG_PART_TRIMSTATE = "inTrim"; //$NON-NLS-1$
124
126
125
    public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
127
    public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
Lines 328-331 Link Here
328
    //Colors
330
    //Colors
329
    public static final String COLOR_HIGHLIGHT = "org.eclipse.ui.highlight"; //$NON-NLS-1$
331
    public static final String COLOR_HIGHLIGHT = "org.eclipse.ui.highlight"; //$NON-NLS-1$
330
332
333
	public static final String TAG_KEY = "key"; //$NON-NLS-1$
334
335
	public static final String TAG_VALUE = "value"; //$NON-NLS-1$
336
331
}
337
}
(-)Eclipse UI/org/eclipse/ui/internal/PartPane.java (-2 / +30 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.core.runtime.ListenerList;
13
import org.eclipse.core.runtime.ListenerList;
14
import org.eclipse.jface.action.MenuManager;
14
import org.eclipse.jface.action.MenuManager;
15
import org.eclipse.jface.util.IPropertyChangeListener;
16
import org.eclipse.jface.util.PropertyChangeEvent;
15
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.FocusAdapter;
18
import org.eclipse.swt.events.FocusAdapter;
17
import org.eclipse.swt.events.FocusEvent;
19
import org.eclipse.swt.events.FocusEvent;
Lines 50-56 Link Here
50
 * LayoutPart and downcasting. The getPresentablePart() method only applies to PartPanes, and
52
 * LayoutPart and downcasting. The getPresentablePart() method only applies to PartPanes, and
51
 * should be removed from LayoutPart.
53
 * should be removed from LayoutPart.
52
 */
54
 */
53
public abstract class PartPane extends LayoutPart implements IPropertyListener, Listener {
55
public abstract class PartPane extends LayoutPart implements IPropertyListener,
56
		Listener, IPropertyChangeListener {
54
57
55
    public static final String PROP_ZOOMED = "zoomed"; //$NON-NLS-1$
58
    public static final String PROP_ZOOMED = "zoomed"; //$NON-NLS-1$
56
59
Lines 58-63 Link Here
58
61
59
    private MenuManager paneMenuManager;
62
    private MenuManager paneMenuManager;
60
    private ListenerList listeners = new ListenerList();
63
    private ListenerList listeners = new ListenerList();
64
    private ListenerList partListeners = new ListenerList();
61
65
62
    protected IWorkbenchPartReference partReference;
66
    protected IWorkbenchPartReference partReference;
63
67
Lines 135-140 Link Here
135
		}
139
		}
136
140
137
        partReference.addPropertyListener(this);
141
        partReference.addPropertyListener(this);
142
        partReference.addPartPropertyListener(this);
138
        // Create view form.	
143
        // Create view form.	
139
        control = new Composite(parent, SWT.NONE);
144
        control = new Composite(parent, SWT.NONE);
140
        control.setLayout(new FillLayout());
145
        control.setLayout(new FillLayout());
Lines 176-181 Link Here
176
        }
181
        }
177
        
182
        
178
        partReference.removePropertyListener(this);
183
        partReference.removePropertyListener(this);
184
        partReference.removePartPropertyListener(this);
179
    }
185
    }
180
186
181
    /**
187
    /**
Lines 600-607 Link Here
600
            ((IPropertyListener) listeners[i]).propertyChanged(this, propertyId);
606
            ((IPropertyListener) listeners[i]).propertyChanged(this, propertyId);
601
        }
607
        }
602
    }
608
    }
603
609
    
604
    public void propertyChanged(Object source, int propId) {
610
    public void propertyChanged(Object source, int propId) {
605
        firePropertyChange(propId);
611
        firePropertyChange(propId);
606
    }
612
    }
613
    
614
    public void addPartPropertyListener(IPropertyChangeListener listener) {
615
    	partListeners.add(listener);
616
    }
617
    
618
    public void removePartPropertyListener(IPropertyChangeListener listener) {
619
    	partListeners.remove(listener);
620
    }
621
    
622
    public void firePartPropertyChange(PropertyChangeEvent event) {
623
    	Object[] l = partListeners.getListeners();
624
    	for (int i = 0; i < l.length; i++) {
625
			((IPropertyChangeListener)l[i]).propertyChange(event);
626
		}
627
    }
628
    
629
    /* (non-Javadoc)
630
     * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
631
     */
632
    public void propertyChange(PropertyChangeEvent event) {
633
    	firePartPropertyChange(event);
634
    }
607
}
635
}
(-)Eclipse UI/org/eclipse/ui/internal/EditorReference.java (-1 / +8 lines)
Lines 140-146 Link Here
140
        String partName = memento
140
        String partName = memento
141
                .getString(IWorkbenchConstants.TAG_PART_NAME);
141
                .getString(IWorkbenchConstants.TAG_PART_NAME);
142
142
143
        // For compatibility set the part name to the title if not found
143
        IMemento[] props = memento
144
				.getChildren(IWorkbenchConstants.TAG_PROPERTY);
145
		for (int i = 0; i < props.length; i++) {
146
			propertyCache.put(props[i].getString(IWorkbenchConstants.TAG_KEY),
147
					props[i].getString(IWorkbenchConstants.TAG_VALUE));
148
		}
149
150
		// For compatibility set the part name to the title if not found
144
        if (partName == null) {
151
        if (partName == null) {
145
            partName = title;
152
            partName = title;
146
        }
153
        }
(-)Eclipse UI/org/eclipse/ui/internal/EditorManager.java (+15 lines)
Lines 77-82 Link Here
77
import org.eclipse.ui.IViewPart;
77
import org.eclipse.ui.IViewPart;
78
import org.eclipse.ui.IWorkbenchPage;
78
import org.eclipse.ui.IWorkbenchPage;
79
import org.eclipse.ui.IWorkbenchPart;
79
import org.eclipse.ui.IWorkbenchPart;
80
import org.eclipse.ui.IWorkbenchPart3;
80
import org.eclipse.ui.IWorkbenchPartReference;
81
import org.eclipse.ui.IWorkbenchPartReference;
81
import org.eclipse.ui.IWorkbenchWindow;
82
import org.eclipse.ui.IWorkbenchWindow;
82
import org.eclipse.ui.PartInitException;
83
import org.eclipse.ui.PartInitException;
Lines 1600-1605 Link Here
1600
1601
1601
				editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
1602
				editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
1602
						editorRef.getPartName());
1603
						editorRef.getPartName());
1604
				
1605
				if (editor instanceof IWorkbenchPart3) {
1606
					Map properties = ((IWorkbenchPart3) editor).getPartProperties();
1607
					Iterator i = properties.entrySet().iterator();
1608
					while (i.hasNext()) {
1609
						Map.Entry entry = (Map.Entry) i.next();
1610
						IMemento p = editorMem
1611
								.createChild(IWorkbenchConstants.TAG_PROPERTY);
1612
						p.putString(IWorkbenchConstants.TAG_KEY, (String) entry
1613
								.getKey());
1614
						p.putString(IWorkbenchConstants.TAG_VALUE,
1615
								(String) entry.getValue());
1616
					}
1617
				}
1603
1618
1604
				if (editorRef.isPinned()) {
1619
				if (editorRef.isPinned()) {
1605
					editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
1620
					editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java (-3 / +47 lines)
Lines 13-18 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.core.runtime.ListenerList;
17
import org.eclipse.jface.util.IPropertyChangeListener;
18
import org.eclipse.jface.util.PropertyChangeEvent;
16
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.graphics.Rectangle;
Lines 46-51 Link Here
46
49
47
    // Lazily initialized. Use getPropertyListenerProxy() to access.
50
    // Lazily initialized. Use getPropertyListenerProxy() to access.
48
    private IPropertyListener lazyPropertyListenerProxy;
51
    private IPropertyListener lazyPropertyListenerProxy;
52
    
53
    private ListenerList partPropertyChangeListeners = new ListenerList();
54
    
55
    private IPropertyChangeListener lazyPartPropertyChangeListener;
49
56
50
    // Lazily initialized. Use getMenu() to access 
57
    // Lazily initialized. Use getMenu() to access 
51
    private IPartMenu viewMenu;
58
    private IPartMenu viewMenu;
Lines 75-80 Link Here
75
    public PresentablePart(PartPane part, Composite parent) {
82
    public PresentablePart(PartPane part, Composite parent) {
76
        this.part = part;
83
        this.part = part;
77
        getPane().addPropertyListener(getPropertyListenerProxy());
84
        getPane().addPropertyListener(getPropertyListenerProxy());
85
        getPane().addPartPropertyListener(getPartPropertyListenerProxy());
78
    }
86
    }
79
87
80
    public PartPane getPane() {
88
    public PartPane getPane() {
Lines 92-110 Link Here
92
100
93
        return lazyPropertyListenerProxy;
101
        return lazyPropertyListenerProxy;
94
    }
102
    }
103
    
104
    private IPropertyChangeListener getPartPropertyListenerProxy() {
105
		if (lazyPartPropertyChangeListener == null) {
106
			lazyPartPropertyChangeListener = new IPropertyChangeListener() {
107
				public void propertyChange(PropertyChangeEvent event) {
108
					firePartPropertyChange(event);
109
				}
110
			};
111
		}
112
		return lazyPartPropertyChangeListener;
113
	}
95
114
96
    /**
115
    /**
97
     * Detach this PresentablePart from the real part. No further methods should be invoked
116
	 * Detach this PresentablePart from the real part. No further methods should
98
     * on this object.
117
	 * be invoked on this object.
99
     */
118
	 */
100
    public void dispose() {
119
    public void dispose() {
101
        // Ensure that the property listener is detached (necessary to prevent leaks)
120
        // Ensure that the property listener is detached (necessary to prevent leaks)
102
        getPane().removePropertyListener(getPropertyListenerProxy());
121
        getPane().removePropertyListener(getPropertyListenerProxy());
122
        getPane().removePartPropertyListener(getPartPropertyListenerProxy());
103
123
104
        // Null out the various fields to ease garbage collection (optional)
124
        // Null out the various fields to ease garbage collection (optional)
105
        part = null;
125
        part = null;
106
        listeners.clear();
126
        listeners.clear();
107
        listeners = null;
127
        listeners = null;
128
        partPropertyChangeListeners.clear();
129
        partPropertyChangeListeners = null;
108
    }
130
    }
109
131
110
    public void firePropertyChange(int propertyId) {
132
    public void firePropertyChange(int propertyId) {
Lines 121-126 Link Here
121
        listeners.remove(listener);
143
        listeners.remove(listener);
122
    }
144
    }
123
145
146
    public void firePartPropertyChange(PropertyChangeEvent event) {
147
		Object[] l = partPropertyChangeListeners.getListeners();
148
		for (int i = 0; i < l.length; i++) {
149
			((IPropertyChangeListener) l[i]).propertyChange(event);
150
		}
151
	}
152
    
153
    public void addPartPropertyListener(IPropertyChangeListener listener) {
154
    	partPropertyChangeListeners.add(listener);
155
    }
156
    
157
    public void removePartPropertyListener(IPropertyChangeListener listener) {
158
    	partPropertyChangeListeners.remove(listener);
159
    }
160
    
124
    /* (non-Javadoc)
161
    /* (non-Javadoc)
125
     * @see org.eclipse.ui.presentations.IPresentablePart#setBounds(org.eclipse.swt.graphics.Rectangle)
162
     * @see org.eclipse.ui.presentations.IPresentablePart#setBounds(org.eclipse.swt.graphics.Rectangle)
126
     */
163
     */
Lines 351-354 Link Here
351
        }
388
        }
352
    }
389
    }
353
390
391
	/* (non-Javadoc)
392
	 * @see org.eclipse.ui.presentations.IPresentablePart#getPartProperty(java.lang.String)
393
	 */
394
	public String getPartProperty(String key) {
395
		return getPartReference().getPartProperty(key);
396
	}
397
354
}
398
}
(-)Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java (-3 / +67 lines)
Lines 10-31 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.part;
11
package org.eclipse.ui.part;
12
12
13
import com.ibm.icu.text.MessageFormat;
13
import java.util.Collections;
14
import java.util.HashMap;
15
import java.util.Map;
14
16
15
import org.eclipse.core.commands.common.EventManager;
17
import org.eclipse.core.commands.common.EventManager;
16
import org.eclipse.core.runtime.Assert;
18
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IExecutableExtension;
20
import org.eclipse.core.runtime.IExecutableExtension;
21
import org.eclipse.core.runtime.ListenerList;
19
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.jface.resource.ImageDescriptor;
23
import org.eclipse.jface.resource.ImageDescriptor;
21
import org.eclipse.jface.resource.JFaceResources;
24
import org.eclipse.jface.resource.JFaceResources;
25
import org.eclipse.jface.util.IPropertyChangeListener;
26
import org.eclipse.jface.util.PropertyChangeEvent;
22
import org.eclipse.jface.window.Window;
27
import org.eclipse.jface.window.Window;
23
import org.eclipse.swt.graphics.Image;
28
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.widgets.Composite;
29
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.ui.IPropertyListener;
30
import org.eclipse.ui.IPropertyListener;
26
import org.eclipse.ui.ISharedImages;
31
import org.eclipse.ui.ISharedImages;
27
import org.eclipse.ui.IWorkbenchPart;
32
import org.eclipse.ui.IWorkbenchPart;
28
import org.eclipse.ui.IWorkbenchPart2;
33
import org.eclipse.ui.IWorkbenchPart3;
29
import org.eclipse.ui.IWorkbenchPartConstants;
34
import org.eclipse.ui.IWorkbenchPartConstants;
30
import org.eclipse.ui.IWorkbenchPartSite;
35
import org.eclipse.ui.IWorkbenchPartSite;
31
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.PlatformUI;
Lines 34-39 Link Here
34
import org.eclipse.ui.internal.util.Util;
39
import org.eclipse.ui.internal.util.Util;
35
import org.eclipse.ui.plugin.AbstractUIPlugin;
40
import org.eclipse.ui.plugin.AbstractUIPlugin;
36
41
42
import com.ibm.icu.text.MessageFormat;
43
37
/**
44
/**
38
 * Abstract base implementation of all workbench parts.
45
 * Abstract base implementation of all workbench parts.
39
 * <p>
46
 * <p>
Lines 46-52 Link Here
46
 * @see org.eclipse.ui.part.EditorPart
53
 * @see org.eclipse.ui.part.EditorPart
47
 */
54
 */
48
public abstract class WorkbenchPart extends EventManager implements
55
public abstract class WorkbenchPart extends EventManager implements
49
		IWorkbenchPart2, IExecutableExtension, IWorkbenchPartOrientation {
56
		IWorkbenchPart3, IExecutableExtension, IWorkbenchPartOrientation {
50
    private String title = ""; //$NON-NLS-1$
57
    private String title = ""; //$NON-NLS-1$
51
58
52
    private ImageDescriptor imageDescriptor;
59
    private ImageDescriptor imageDescriptor;
Lines 62-67 Link Here
62
    private String partName = ""; //$NON-NLS-1$
69
    private String partName = ""; //$NON-NLS-1$
63
70
64
    private String contentDescription = ""; //$NON-NLS-1$
71
    private String contentDescription = ""; //$NON-NLS-1$
72
    
73
    private ListenerList partChangeListeners = new ListenerList();
65
74
66
    /**
75
    /**
67
     * Creates a new workbench part.
76
     * Creates a new workbench part.
Lines 103-108 Link Here
103
        // should not be notifying anyone after the part
112
        // should not be notifying anyone after the part
104
        // has been disposed.
113
        // has been disposed.
105
        clearListeners();
114
        clearListeners();
115
        partChangeListeners.clear();
106
    }
116
    }
107
117
108
    /**
118
    /**
Lines 462-465 Link Here
462
    	return Window.getDefaultOrientation();
472
    	return Window.getDefaultOrientation();
463
    }
473
    }
464
474
475
    /* (non-Javadoc)
476
     * @see org.eclipse.ui.IWorkbenchPart3#addPartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener)
477
     */
478
    public void addPartPropertyListener(IPropertyChangeListener listener) {
479
    	partChangeListeners.add(listener);
480
    }
481
    
482
    /* (non-Javadoc)
483
     * @see org.eclipse.ui.IWorkbenchPart3#removePartPropertyListener(org.eclipse.jface.util.IPropertyChangeListener)
484
     */
485
    public void removePartPropertyListener(IPropertyChangeListener listener) {
486
    	partChangeListeners.remove(listener);
487
    }
488
    
489
    protected void firePartPropertyChanged(String key, String oldValue, String newValue) {
490
    	final PropertyChangeEvent event = new PropertyChangeEvent(this, key, oldValue, newValue);
491
    	Object[] l = partChangeListeners.getListeners();
492
    	for (int i = 0; i < l.length; i++) {
493
			try {
494
				((IPropertyChangeListener)l[i]).propertyChange(event);
495
			} catch (RuntimeException e) {
496
				WorkbenchPlugin.log(e);
497
			}
498
		}
499
    }
500
    
501
    private Map partProperties = new HashMap();
502
    
503
    /* (non-Javadoc)
504
     * @see org.eclipse.ui.IWorkbenchPart3#setPartProperty(java.lang.String, java.lang.String)
505
     */
506
    public void setPartProperty(String key, String value) {
507
    	String oldValue = (String) partProperties.get(key);
508
    	if (value==null) {
509
    		partProperties.remove(key);
510
    	} else {
511
    		partProperties.put(key, value);
512
    	}
513
    	firePartPropertyChanged(key, oldValue, value);
514
    }
515
    
516
    /* (non-Javadoc)
517
     * @see org.eclipse.ui.IWorkbenchPart3#getPartProperty(java.lang.String)
518
     */
519
    public String getPartProperty(String key) {
520
    	return (String)partProperties.get(key);
521
    }
522
    
523
    /* (non-Javadoc)
524
     * @see org.eclipse.ui.IWorkbenchPart3#getPartProperties()
525
     */
526
    public Map getPartProperties() {
527
    	return Collections.unmodifiableMap(partProperties);
528
    }
465
}
529
}
(-)Eclipse (+80 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui;
13
14
import java.util.Map;
15
16
import org.eclipse.jface.util.IPropertyChangeListener;
17
18
/**
19
 * A part can provide arbitrary properties. The properties will be persisted
20
 * between sessions by the part reference, and will be available from the part
21
 * reference as well as the part.
22
 * <p>
23
 * Setting a property must fire a PropertyChangeEvent.
24
 * </p>
25
 * 
26
 * @since 3.3
27
 */
28
public interface IWorkbenchPart3 extends IWorkbenchPart2 {
29
	/**
30
	 * Add a listener for changes in the arbitrary properties set.
31
	 * <p>
32
	 * <b>Note:</b> this is a different set of properties than the ones covered
33
	 * by the IWorkbenchPartConstants.PROP_* constants.
34
	 * </p>
35
	 * 
36
	 * @param listener
37
	 *            Must not be <code>null</code>.
38
	 */
39
	public void addPartPropertyListener(IPropertyChangeListener listener);
40
41
	/**
42
	 * Remove a change listener from the arbitrary properties set.
43
	 * <p>
44
	 * <b>Note:</b> this is a different set of properties than the ones covered
45
	 * by the IWorkbenchPartConstants.PROP_* constants.
46
	 * </p>
47
	 * 
48
	 * @param listener
49
	 *            Must not be <code>null</code>.
50
	 */
51
	public void removePartPropertyListener(IPropertyChangeListener listener);
52
53
	/**
54
	 * Return the value for the arbitrary property key, or <code>null</code>.
55
	 * 
56
	 * @param key
57
	 *            the arbitrary property. Must not be <code>null</code>.
58
	 * @return the property value, or <code>null</code>.
59
	 */
60
	public String getPartProperty(String key);
61
62
	/**
63
	 * Set an arbitrary property on the part. It is the implementor's
64
	 * responsibility to fire the corresponding PropertyChangeEvent.
65
	 * 
66
	 * @param key
67
	 *            the arbitrary property. Must not be <code>null</code>.
68
	 * @param value
69
	 *            the property value. A <code>null</code> value will remove
70
	 *            that property.
71
	 */
72
	public void setPartProperty(String key, String value);
73
74
	/**
75
	 * Return an unmodifiable map of the arbitrary properties.
76
	 * 
77
	 * @return A Map of the properties. Must not be <code>null</code>.
78
	 */
79
	public Map getPartProperties();
80
}

Return to bug 89834