|
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 |
} |