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/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/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/EditorManager.java (-1 / +17 lines)
Lines 31-36 Link Here
31
import org.eclipse.core.runtime.IStatus;
31
import org.eclipse.core.runtime.IStatus;
32
import org.eclipse.core.runtime.MultiStatus;
32
import org.eclipse.core.runtime.MultiStatus;
33
import org.eclipse.core.runtime.Platform;
33
import org.eclipse.core.runtime.Platform;
34
import org.eclipse.core.runtime.SafeRunner;
34
import org.eclipse.core.runtime.Status;
35
import org.eclipse.core.runtime.Status;
35
import org.eclipse.core.runtime.SubProgressMonitor;
36
import org.eclipse.core.runtime.SubProgressMonitor;
36
import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
37
import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
Lines 77-82 Link Here
77
import org.eclipse.ui.IViewPart;
78
import org.eclipse.ui.IViewPart;
78
import org.eclipse.ui.IWorkbenchPage;
79
import org.eclipse.ui.IWorkbenchPage;
79
import org.eclipse.ui.IWorkbenchPart;
80
import org.eclipse.ui.IWorkbenchPart;
81
import org.eclipse.ui.IWorkbenchPart3;
80
import org.eclipse.ui.IWorkbenchPartReference;
82
import org.eclipse.ui.IWorkbenchPartReference;
81
import org.eclipse.ui.IWorkbenchWindow;
83
import org.eclipse.ui.IWorkbenchWindow;
82
import org.eclipse.ui.PartInitException;
84
import org.eclipse.ui.PartInitException;
Lines 1574-1580 Link Here
1574
			return;
1576
			return;
1575
		}
1577
		}
1576
1578
1577
		Platform.run(new SafeRunnable() {
1579
		SafeRunner.run(new SafeRunnable() {
1578
			public void run() {
1580
			public void run() {
1579
				// Get the input.
1581
				// Get the input.
1580
				IEditorInput input = editor.getEditorInput();
1582
				IEditorInput input = editor.getEditorInput();
Lines 1597-1602 Link Here
1597
1599
1598
				editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
1600
				editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
1599
						editorRef.getPartName());
1601
						editorRef.getPartName());
1602
				
1603
				if (editor instanceof IWorkbenchPart3) {
1604
					Map properties = ((IWorkbenchPart3) editor).getPartProperties();
1605
					Iterator i = properties.entrySet().iterator();
1606
					while (i.hasNext()) {
1607
						Map.Entry entry = (Map.Entry) i.next();
1608
						IMemento p = editorMem
1609
								.createChild(IWorkbenchConstants.TAG_PROPERTY);
1610
						p.putString(IWorkbenchConstants.TAG_KEY, (String) entry
1611
								.getKey());
1612
						p.putString(IWorkbenchConstants.TAG_VALUE,
1613
								(String) entry.getValue());
1614
					}
1615
				}
1600
1616
1601
				if (editorRef.isPinned()) {
1617
				if (editorRef.isPinned()) {
1602
					editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
1618
					editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java (+18 lines)
Lines 11-16 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;
Lines 29-34 Link Here
29
import org.eclipse.ui.ISharedImages;
31
import org.eclipse.ui.ISharedImages;
30
import org.eclipse.ui.IWorkbenchPart;
32
import org.eclipse.ui.IWorkbenchPart;
31
import org.eclipse.ui.IWorkbenchPart2;
33
import org.eclipse.ui.IWorkbenchPart2;
34
import org.eclipse.ui.IWorkbenchPart3;
32
import org.eclipse.ui.IWorkbenchPartConstants;
35
import org.eclipse.ui.IWorkbenchPartConstants;
33
import org.eclipse.ui.IWorkbenchPartReference;
36
import org.eclipse.ui.IWorkbenchPartReference;
34
import org.eclipse.ui.IWorkbenchPartSite;
37
import org.eclipse.ui.IWorkbenchPartSite;
Lines 141-146 Link Here
141
144
142
    private String contentDescription;
145
    private String contentDescription;
143
    
146
    
147
    protected Map propertyCache = new HashMap();
148
    
144
    /**
149
    /**
145
     * Used to remember which events have been queued.
150
     * Used to remember which events have been queued.
146
     */
151
     */
Lines 712-715 Link Here
712
        return pinned;
717
        return pinned;
713
    }
718
    }
714
719
720
    /* (non-Javadoc)
721
     * @see org.eclipse.ui.IWorkbenchPartReference#getPartProperty(java.lang.String)
722
     */
723
    public String getPartProperty(String key) {
724
		if (part != null) {
725
			if (part instanceof IWorkbenchPart3) {
726
				return ((IWorkbenchPart3) part).getPartProperty(key);
727
			}
728
		} else {
729
			return (String)propertyCache.get(key);
730
		}
731
		return null;
732
	}
715
}
733
}
(-)Eclipse UI/org/eclipse/ui/IWorkbenchPartConstants.java (+3 lines)
Lines 43-46 Link Here
43
     */
43
     */
44
    int PROP_CONTENT_DESCRIPTION = 0x105;
44
    int PROP_CONTENT_DESCRIPTION = 0x105;
45
45
46
    int PROP_USER_LOW = 0x500;
47
    
48
    int PROP_USER_HI = 0x9FF;
46
}
49
}
(-)Eclipse UI/org/eclipse/ui/IWorkbenchPartReference.java (+12 lines)
Lines 93-96 Link Here
93
     */
93
     */
94
    public boolean isDirty();
94
    public boolean isDirty();
95
    
95
    
96
    /**
97
	 * Return an arbitrary property from the reference. If the part has been
98
	 * instantiated, it just delegates to the part. If not, then it looks in its
99
	 * own cache of properties. If the property is not available or the part has
100
	 * never been instantiated, it can return <code>null</code>.
101
	 * 
102
	 * @param key
103
	 *            The property to return.
104
	 * @return The String property, or <code>null</code>.
105
	 * @since 3.3
106
	 */
107
    public String getPartProperty(String key);
96
}
108
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java (+7 lines)
Lines 351-354 Link Here
351
        }
351
        }
352
    }
352
    }
353
353
354
	/* (non-Javadoc)
355
	 * @see org.eclipse.ui.presentations.IPresentablePart#getPartProperty(java.lang.String)
356
	 */
357
	public String getPartProperty(String key) {
358
		return getPartReference().getPartProperty(key);
359
	}
360
354
}
361
}
(-)Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java (+13 lines)
Lines 226-229 Link Here
226
     */
226
     */
227
    public Control getControl();
227
    public Control getControl();
228
228
229
    /**
230
	 * Get a property other than title or name from a workbench part. These
231
	 * properties are arbitrary properties that the presentation might like
232
	 * access to. It is the part implementation's responsibility to synchronize
233
	 * the property change events which are <code>int</code> with the
234
	 * properties the presentation will request which are <code>String</code>.
235
	 * 
236
	 * @param key
237
	 *            The property key to retrieve. Must not be <code>null</code>.
238
	 * @return the property, or <code>null</code> if that property is not set.
239
	 * @since 3.3
240
	 */
241
	public String getPartProperty(String key);
229
}
242
}
(-)Eclipse (+60 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
/**
17
 * A part can provide arbitrary properties. The properties will be persisted
18
 * between sessions by the part reference, and will be available from the part
19
 * reference as well as the part.
20
 * <p>
21
 * Setting a property must fire a part changed event.
22
 * </p>
23
 * <p>
24
 * It is up to the part to define the arbitrary mapping between its property
25
 * keys and the integer constants used in the property change events. Please use
26
 * integers in the {@link IWorkbenchPartConstants#PROP_USER_LOW} to
27
 * {@link IWorkbenchPartConstants#PROP_USER_HI}.
28
 * </p>
29
 * 
30
 * @since 3.3
31
 */
32
public interface IWorkbenchPart3 extends IWorkbenchPart2 {
33
	/**
34
	 * Return the value for the property key, or <code>null</code>.
35
	 * 
36
	 * @param key
37
	 *            the arbitrary property
38
	 * @return the property value, or <code>null</code>.
39
	 */
40
	public String getPartProperty(String key);
41
42
	/**
43
	 * Set an arbitrary property on the part. It is the implementor's
44
	 * responsibility to fire the corresponding property change event.
45
	 * 
46
	 * @param key
47
	 *            the arbitrary property. Must not be <code>null</code>.
48
	 * @param value
49
	 *            the property value. A <code>null</code> value will remove
50
	 *            that property.
51
	 */
52
	public void setPartProperty(String key, String value);
53
54
	/**
55
	 * Return an unmodifiable map of the properties.
56
	 * 
57
	 * @return A Map of the properties. Must not be <code>null</code>.
58
	 */
59
	public Map getPartProperties();
60
}
(-)src/org/eclipse/ui/tests/performance/presentations/TestPresentablePart.java (+6 lines)
Lines 176-179 Link Here
176
        firePropertyChange(IPresentablePart.PROP_TOOLBAR);
176
        firePropertyChange(IPresentablePart.PROP_TOOLBAR);
177
    }
177
    }
178
    
178
    
179
    /* (non-Javadoc)
180
     * @see org.eclipse.ui.presentations.IPresentablePart#getPartProperty(java.lang.String)
181
     */
182
    public String getPartProperty(String key) {
183
    	return null;
184
    }
179
}
185
}

Return to bug 89834