View | Details | Raw Unified | Return to bug 55656 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/EditorManager.java (-1 / +10 lines)
Lines 17-22 Link Here
17
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.List;
18
import java.util.List;
19
import java.util.Map;
19
import java.util.Map;
20
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IPath;
Lines 54-59 Link Here
54
import org.eclipse.ui.ISaveablePart;
55
import org.eclipse.ui.ISaveablePart;
55
import org.eclipse.ui.IWorkbenchPage;
56
import org.eclipse.ui.IWorkbenchPage;
56
import org.eclipse.ui.IWorkbenchPart;
57
import org.eclipse.ui.IWorkbenchPart;
58
import org.eclipse.ui.IWorkbenchPart2;
57
import org.eclipse.ui.IWorkbenchWindow;
59
import org.eclipse.ui.IWorkbenchWindow;
58
import org.eclipse.ui.PartInitException;
60
import org.eclipse.ui.PartInitException;
59
import org.eclipse.ui.PlatformUI;
61
import org.eclipse.ui.PlatformUI;
Lines 1080-1085 Link Here
1080
			String id = memento.getString(IWorkbenchConstants.TAG_ID);
1082
			String id = memento.getString(IWorkbenchConstants.TAG_ID);
1081
			String title = memento.getString(IWorkbenchConstants.TAG_TITLE);
1083
			String title = memento.getString(IWorkbenchConstants.TAG_TITLE);
1082
			String tooltip = memento.getString(IWorkbenchConstants.TAG_TOOLTIP);
1084
			String tooltip = memento.getString(IWorkbenchConstants.TAG_TOOLTIP);
1085
			String partName = memento.getString(IWorkbenchConstants.TAG_PART_NAME);
1083
			if (tooltip == null) {
1086
			if (tooltip == null) {
1084
				tooltip = ""; //$NON-NLS-1$
1087
				tooltip = ""; //$NON-NLS-1$
1085
			}
1088
			}
Lines 1093-1099 Link Here
1093
			String location = memento.getString(IWorkbenchConstants.TAG_PATH);	
1096
			String location = memento.getString(IWorkbenchConstants.TAG_PATH);	
1094
			IPath path = location == null ? null : new Path(location);
1097
			IPath path = location == null ? null : new Path(location);
1095
			ImageDescriptor iDesc = findImage(desc, path);
1098
			ImageDescriptor iDesc = findImage(desc, path);
1096
			init(id, title, tooltip, iDesc);
1099
			init(id, title, tooltip, iDesc, partName, null);
1097
			
1100
			
1098
			this.name = memento.getString(IWorkbenchConstants.TAG_NAME);
1101
			this.name = memento.getString(IWorkbenchConstants.TAG_NAME);
1099
			this.pinned = "true".equals(memento.getString(IWorkbenchConstants.TAG_PINNED));  //$NON-NLS-1$
1102
			this.pinned = "true".equals(memento.getString(IWorkbenchConstants.TAG_PINNED));  //$NON-NLS-1$
Lines 1240-1245 Link Here
1240
			restoredInput = (IEditorInput) input;
1243
			restoredInput = (IEditorInput) input;
1241
			return restoredInput;
1244
			return restoredInput;
1242
		}
1245
		}
1246
1243
	}
1247
	}
1244
	protected void restoreEditorState(IMemento editorMem, ArrayList visibleEditors,
1248
	protected void restoreEditorState(IMemento editorMem, ArrayList visibleEditors,
1245
			IEditorPart[] activeEditor, ArrayList errorWorkbooks, MultiStatus result) {
1249
			IEditorPart[] activeEditor, ArrayList errorWorkbooks, MultiStatus result) {
Lines 1315-1320 Link Here
1315
				editorMem.putString(IWorkbenchConstants.TAG_NAME,input.getName());
1319
				editorMem.putString(IWorkbenchConstants.TAG_NAME,input.getName());
1316
				editorMem.putString(IWorkbenchConstants.TAG_ID, editor.getSite().getId());
1320
				editorMem.putString(IWorkbenchConstants.TAG_ID, editor.getSite().getId());
1317
				editorMem.putString(IWorkbenchConstants.TAG_TOOLTIP, editor.getTitleToolTip()); //$NON-NLS-1$
1321
				editorMem.putString(IWorkbenchConstants.TAG_TOOLTIP, editor.getTitleToolTip()); //$NON-NLS-1$
1322
				
1323
				if (editor instanceof IWorkbenchPart2) {
1324
					IWorkbenchPart2 part2 = (IWorkbenchPart2)editor;
1325
					editorMem.putString(IWorkbenchConstants.TAG_PART_NAME, part2.getPartName());
1326
				}
1318
				
1327
				
1319
				if(!site.getReuseEditor())
1328
				if(!site.getReuseEditor())
1320
					editorMem.putString(IWorkbenchConstants.TAG_PINNED,"true"); //$NON-NLS-1$
1329
					editorMem.putString(IWorkbenchConstants.TAG_PINNED,"true"); //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/EditorPane.java (-7 / +13 lines)
Lines 17-22 Link Here
17
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Menu;
21
import org.eclipse.swt.widgets.Menu;
21
import org.eclipse.swt.widgets.MenuItem;
22
import org.eclipse.swt.widgets.MenuItem;
22
import org.eclipse.swt.widgets.Text;
23
import org.eclipse.swt.widgets.Text;
Lines 25-33 Link Here
25
import org.eclipse.ui.IEditorReference;
26
import org.eclipse.ui.IEditorReference;
26
import org.eclipse.ui.IEditorSite;
27
import org.eclipse.ui.IEditorSite;
27
import org.eclipse.ui.IWorkbenchPart;
28
import org.eclipse.ui.IWorkbenchPart;
28
import org.eclipse.ui.internal.presentations.PresentableEditorPart;
29
import org.eclipse.ui.part.EditorPart;
29
import org.eclipse.ui.part.EditorPart;
30
import org.eclipse.ui.presentations.IPresentablePart;
31
import org.eclipse.ui.presentations.StackPresentation;
30
import org.eclipse.ui.presentations.StackPresentation;
32
31
33
/**
32
/**
Lines 35-42 Link Here
35
 * behavior for workbench editors.
34
 * behavior for workbench editors.
36
 */
35
 */
37
public class EditorPane extends PartPane {
36
public class EditorPane extends PartPane {
38
	private PresentableEditorPart presentableAdapter = new PresentableEditorPart(this);	
39
	
40
	private EditorStack workbook;
37
	private EditorStack workbook;
41
38
42
/**
39
/**
Lines 218-227 Link Here
218
		Assert.isTrue(getContainer() == workbook);
215
		Assert.isTrue(getContainer() == workbook);
219
	}
216
	}
220
}
217
}
218
221
/* (non-Javadoc)
219
/* (non-Javadoc)
222
 * @see org.eclipse.ui.internal.LayoutPart#getPresentablePart()
220
 * @see org.eclipse.ui.internal.PartPane#getName()
223
 */
221
 */
224
public IPresentablePart getPresentablePart() {
222
public String getName() {
225
	return presentableAdapter;
223
	return null;
226
}
224
}
225
226
/* (non-Javadoc)
227
 * @see org.eclipse.ui.internal.PartPane#getToolBar()
228
 */
229
public Control getToolBar() {
230
	return null;
231
}
232
227
}
233
}
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+1 lines)
Lines 106-111 Link Here
106
	public static final String TAG_FOLDER = "folder"; //$NON-NLS-1$
106
	public static final String TAG_FOLDER = "folder"; //$NON-NLS-1$
107
	public static final String TAG_INFO = "info"; //$NON-NLS-1$
107
	public static final String TAG_INFO = "info"; //$NON-NLS-1$
108
	public static final String TAG_PART = "part"; //$NON-NLS-1$
108
	public static final String TAG_PART = "part"; //$NON-NLS-1$
109
	public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
109
	public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
110
	public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
110
	public static final String TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$
111
	public static final String TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$
111
	public static final String TAG_RATIO = "ratio"; //$NON-NLS-1$
112
	public static final String TAG_RATIO = "ratio"; //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/PartPane.java (+36 lines)
Lines 26-31 Link Here
26
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.events.TraverseEvent;
27
import org.eclipse.swt.events.TraverseEvent;
28
import org.eclipse.swt.events.TraverseListener;
28
import org.eclipse.swt.events.TraverseListener;
29
import org.eclipse.swt.graphics.Point;
29
import org.eclipse.swt.graphics.Rectangle;
30
import org.eclipse.swt.graphics.Rectangle;
30
import org.eclipse.swt.layout.FillLayout;
31
import org.eclipse.swt.layout.FillLayout;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Composite;
Lines 40-45 Link Here
40
import org.eclipse.ui.IWorkbenchWindow;
41
import org.eclipse.ui.IWorkbenchWindow;
41
import org.eclipse.ui.PlatformUI;
42
import org.eclipse.ui.PlatformUI;
42
import org.eclipse.ui.internal.misc.UIStats;
43
import org.eclipse.ui.internal.misc.UIStats;
44
import org.eclipse.ui.internal.presentations.PresentablePart;
45
import org.eclipse.ui.presentations.IPresentablePart;
43
46
44
/**
47
/**
45
 * Provides the common behavior for both views
48
 * Provides the common behavior for both views
Lines 48-53 Link Here
48
public abstract class PartPane extends LayoutPart
51
public abstract class PartPane extends LayoutPart
49
	implements Listener
52
	implements Listener
50
{
53
{
54
55
	protected PresentablePart presentableAdapter = new PresentablePart(this);
51
	public static final String PROP_ZOOMED = "zoomed"; //$NON-NLS-1$
56
	public static final String PROP_ZOOMED = "zoomed"; //$NON-NLS-1$
52
	private boolean isZoomed = false;
57
	private boolean isZoomed = false;
53
	private MenuManager paneMenuManager;
58
	private MenuManager paneMenuManager;
Lines 497-500 Link Here
497
        setZoomed(false);
502
        setZoomed(false);
498
    super.reparent(newParent);
503
    super.reparent(newParent);
499
}
504
}
505
506
/**
507
 * @return
508
 */
509
public abstract Control getToolBar();
510
511
/**
512
 * @return
513
 */
514
public boolean hasViewMenu() {
515
	return false;
516
}
517
518
/**
519
 * @param location
520
 */
521
public void showViewMenu(Point location) {
522
	
523
}
524
525
public boolean isBusy() {
526
	return false;
527
}
528
529
/* (non-Javadoc)
530
 * @see org.eclipse.ui.internal.LayoutPart#getPresentablePart()
531
 */
532
public IPresentablePart getPresentablePart() {
533
	return presentableAdapter;
534
}
535
500
}
536
}
(-)Eclipse UI/org/eclipse/ui/internal/ViewFactory.java (-8 / +30 lines)
Lines 51-61 Link Here
51
		private String secondaryId;
51
		private String secondaryId;
52
		private boolean create = true;
52
		private boolean create = true;
53
53
54
		public ViewReference(String id) {
54
		public ViewReference(String id, IMemento memento) {
55
			this(id, null);
55
			this(id, null, memento);
56
		}
56
		}
57
		
57
		
58
		public ViewReference(String id, String secondaryId) {
58
		public ViewReference(String id, String secondaryId, IMemento memento) {
59
			ViewDescriptor desc = (ViewDescriptor) viewReg.find(id);
59
			ViewDescriptor desc = (ViewDescriptor) viewReg.find(id);
60
			ImageDescriptor iDesc = null;
60
			ImageDescriptor iDesc = null;
61
			String title = null;
61
			String title = null;
Lines 63-69 Link Here
63
				iDesc = desc.getImageDescriptor();
63
				iDesc = desc.getImageDescriptor();
64
				title = desc.getLabel();
64
				title = desc.getLabel();
65
			}
65
			}
66
			init(id, title, null, iDesc);
66
			
67
			String name = null;
68
			
69
			if (memento != null) {
70
				name = memento.getString(IWorkbenchConstants.TAG_PART_NAME);
71
			}
72
			
73
			init(id, title, null, iDesc, name, null);
67
			this.secondaryId = secondaryId;
74
			this.secondaryId = secondaryId;
68
		}
75
		}
69
		
76
		
Lines 141-146 Link Here
141
		public boolean isFastView() {
148
		public boolean isFastView() {
142
			return page.isFastView(this);
149
			return page.isFastView(this);
143
		}
150
		}
151
		
144
	}
152
	}
145
	
153
	
146
	private ReferenceCounter counter;
154
	private ReferenceCounter counter;
Lines 195-201 Link Here
195
			return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
203
			return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
196
204
197
		final String viewID = ref.getId();
205
		final String viewID = ref.getId();
198
		final IMemento stateMem = (IMemento) mementoTable.get(viewID);
206
		final IMemento stateMem = getViewState(viewID);
199
		mementoTable.remove(viewID);
207
		mementoTable.remove(viewID);
200
208
201
		final boolean resetPart[] = { true };
209
		final boolean resetPart[] = { true };
Lines 321-327 Link Here
321
		String key = getKey(id, secondaryId);
329
		String key = getKey(id, secondaryId);
322
		IViewReference ref = (IViewReference) counter.get(key);
330
		IViewReference ref = (IViewReference) counter.get(key);
323
		if (ref == null) {
331
		if (ref == null) {
324
			ref = new ViewReference(id, secondaryId);
332
			IMemento memento = (IMemento)mementoTable.get(id); 
333
			ref = new ViewReference(id, secondaryId, memento);
325
			counter.put(key, ref);
334
			counter.put(key, ref);
326
		} else {
335
		} else {
327
			counter.addRef(key);
336
			counter.addRef(key);
Lines 484-489 Link Here
484
		final MultiStatus result = res;
493
		final MultiStatus result = res;
485
		final IMemento viewMemento = memento.createChild(IWorkbenchConstants.TAG_VIEW);
494
		final IMemento viewMemento = memento.createChild(IWorkbenchConstants.TAG_VIEW);
486
		viewMemento.putString(IWorkbenchConstants.TAG_ID, ref.getId());
495
		viewMemento.putString(IWorkbenchConstants.TAG_ID, ref.getId());
496
		if (ref instanceof ViewReference) {
497
			viewMemento.putString(IWorkbenchConstants.TAG_PART_NAME, ((ViewReference)ref).getPartName());
498
		}
487
		final IViewReference viewRef = ref;
499
		final IViewReference viewRef = ref;
488
		final IViewPart view = (IViewPart)ref.getPart(false);
500
		final IViewPart view = (IViewPart)ref.getPart(false);
489
		if(view != null) {
501
		if(view != null) {
Lines 499-505 Link Here
499
				}
511
				}
500
			});
512
			});
501
		} else {
513
		} else {
502
			IMemento mem = (IMemento)mementoTable.get(ref.getId());
514
			IMemento mem = getViewState(ref.getId());
503
			if(mem != null) {
515
			if(mem != null) {
504
				IMemento child = viewMemento.createChild(IWorkbenchConstants.TAG_VIEW_STATE);
516
				IMemento child = viewMemento.createChild(IWorkbenchConstants.TAG_VIEW_STATE);
505
				child.putMemento(mem);
517
				child.putMemento(mem);
Lines 511-517 Link Here
511
//	for dynamic UI
523
//	for dynamic UI
512
	public void restoreViewState(IMemento memento){
524
	public void restoreViewState(IMemento memento){
513
		String id = memento.getString(IWorkbenchConstants.TAG_ID);
525
		String id = memento.getString(IWorkbenchConstants.TAG_ID);
514
		mementoTable.put(id, memento.getChild(IWorkbenchConstants.TAG_VIEW_STATE));
526
		mementoTable.put(id, memento);
527
	}
528
	
529
	private IMemento getViewState(String viewId) {
530
		IMemento memento = (IMemento) mementoTable.get(viewId);
531
		
532
		if (memento == null) {
533
			return null;
534
		}
535
		
536
		return memento.getChild(IWorkbenchConstants.TAG_VIEW_STATE);
515
	}
537
	}
516
}
538
}
517
	
539
	
(-)Eclipse UI/org/eclipse/ui/internal/ViewPane.java (-10 / +24 lines)
Lines 36-42 Link Here
36
import org.eclipse.ui.IWorkbenchPart;
36
import org.eclipse.ui.IWorkbenchPart;
37
import org.eclipse.ui.IWorkbenchPartSite;
37
import org.eclipse.ui.IWorkbenchPartSite;
38
import org.eclipse.ui.internal.dnd.DragUtil;
38
import org.eclipse.ui.internal.dnd.DragUtil;
39
import org.eclipse.ui.internal.presentations.PresentableViewPart;
40
import org.eclipse.ui.part.ViewPart;
39
import org.eclipse.ui.part.ViewPart;
41
import org.eclipse.ui.presentations.IPresentablePart;
40
import org.eclipse.ui.presentations.IPresentablePart;
42
import org.eclipse.ui.presentations.StackPresentation;
41
import org.eclipse.ui.presentations.StackPresentation;
Lines 53-60 Link Here
53
 * part.
52
 * part.
54
 */
53
 */
55
public class ViewPane extends PartPane implements IPropertyListener {
54
public class ViewPane extends PartPane implements IPropertyListener {
56
	private PresentableViewPart presentableAdapter = new PresentableViewPart(this);
57
58
	private boolean busy = false;
55
	private boolean busy = false;
59
56
60
	private boolean fast = false;
57
	private boolean fast = false;
Lines 534-546 Link Here
534
	}
531
	}
535
	
532
	
536
	/* (non-Javadoc)
533
	/* (non-Javadoc)
537
	 * @see org.eclipse.ui.internal.LayoutPart#getPresentablePart()
538
	 */
539
	public IPresentablePart getPresentablePart() {
540
		return presentableAdapter;
541
	}
542
	
543
	/* (non-Javadoc)
544
	 * @see org.eclipse.ui.internal.LayoutPart#reparent(org.eclipse.swt.widgets.Composite)
534
	 * @see org.eclipse.ui.internal.LayoutPart#reparent(org.eclipse.swt.widgets.Composite)
545
	 */
535
	 */
546
	public void reparent(Composite newParent) {
536
	public void reparent(Composite newParent) {
Lines 621-624 Link Here
621
    public String getPlaceHolderId() {
611
    public String getPlaceHolderId() {
622
        return ViewFactory.getKey(getViewReference());
612
        return ViewFactory.getKey(getViewReference());
623
    }
613
    }
614
615
	/* (non-Javadoc)
616
	 * @see org.eclipse.ui.internal.PartPane#getToolBar()
617
	 */
618
	public Control getToolBar() {
619
620
		if (!toolbarIsVisible()) {
621
			return null;
622
		}
623
		
624
		ToolBarManager toolbarManager = getToolBarManager();
625
		
626
		if (toolbarManager == null) {
627
			return null;
628
		}
629
		
630
		ToolBar control = toolbarManager.getControl();
631
		
632
		if (control == null || control.isDisposed() ) {
633
			return null;
634
		}		
635
		
636
		return control;
637
	}
624
}
638
}
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java (-11 / +68 lines)
Lines 9-23 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
11
package org.eclipse.ui.internal;
12
import org.eclipse.swt.graphics.Image;
13
14
import org.eclipse.jface.resource.ImageDescriptor;
12
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.jface.util.ListenerList;
13
import org.eclipse.jface.util.ListenerList;
16
14
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.ui.IPropertyListener;
15
import org.eclipse.ui.IPropertyListener;
18
import org.eclipse.ui.IWorkbenchPart;
16
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchPart2;
19
import org.eclipse.ui.IWorkbenchPartReference;
18
import org.eclipse.ui.IWorkbenchPartReference;
20
import org.eclipse.ui.IWorkbenchPartSite;
19
import org.eclipse.ui.IWorkbenchPartSite;
20
import org.eclipse.ui.internal.util.Util;
21
21
22
/**
22
/**
23
 * 
23
 * 
Lines 33-48 Link Here
33
	private Image image;
33
	private Image image;
34
	private ImageDescriptor imageDescriptor;
34
	private ImageDescriptor imageDescriptor;
35
	private ListenerList propChangeListeners = new ListenerList(2);		
35
	private ListenerList propChangeListeners = new ListenerList(2);		
36
	private String partName;
37
	private String contentDescription;
36
	
38
	
37
	public WorkbenchPartReference() {
39
	public WorkbenchPartReference() {
38
	    //no-op
40
	    //no-op
39
	}
41
	}
40
	
42
	
41
	public void init(String id,String title,String tooltip,ImageDescriptor desc) {
43
	public void init(String id,String title,String tooltip,ImageDescriptor desc, String paneName, String contentDescription) {
42
		this.id = id;
44
		this.id = id;
43
		this.title = title;
45
		this.title = title;
44
		this.tooltip = tooltip;
46
		this.tooltip = tooltip;
45
		this.imageDescriptor = desc;
47
		this.imageDescriptor = desc;
48
		this.partName = paneName;
49
		this.contentDescription = contentDescription;
46
	}
50
	}
47
	
51
	
48
	/**
52
	/**
Lines 66-71 Link Here
66
			imageDescriptor = null;
70
			imageDescriptor = null;
67
		}
71
		}
68
		propChangeListeners.clear();
72
		propChangeListeners.clear();
73
		partName = null;
74
		contentDescription = null;
69
	}
75
	}
70
	/**
76
	/**
71
	 * @see IWorkbenchPart
77
	 * @see IWorkbenchPart
Lines 97-115 Link Here
97
	}
103
	}
98
104
99
	public String getTitleToolTip() {
105
	public String getTitleToolTip() {
100
		if(part != null)
106
		String result = tooltip; 
101
			return part.getTitleToolTip();
107
		if(part != null) {
102
		else
108
			result = part.getTitleToolTip();
103
			return tooltip;
109
		}
110
		return Util.safeString(result);
104
	}	
111
	}	
112
	
113
	/**
114
	 * Returns the pane name for the part
115
	 * 
116
	 * @return the pane name for the part
117
	 */
118
	public String getPartName() {
119
		if (part != null) {
120
			if (part instanceof IWorkbenchPart2) {
121
				IWorkbenchPart2 part2 = (IWorkbenchPart2)part;
122
				
123
				return part2.getPartName();
124
			}
125
		}
126
		if (partName != null) {
127
			return partName;
128
		}
129
		
130
		return getRegisteredName();		
131
	}
132
		
133
	/**
134
	 * Returns the content description for this part.
135
	 * 
136
	 * @return the pane name for the part
137
	 */
138
	public String getContentDescription() {
139
		if (part != null) {
140
			if (part instanceof IWorkbenchPart2) {
141
				IWorkbenchPart2 part2 = (IWorkbenchPart2)part;
142
				
143
				return part2.getContentDescription();
144
			}
145
		}
146
		if (contentDescription != null) {
147
			return contentDescription;
148
		}
149
		
150
		return "";		 //$NON-NLS-1$
151
	}
152
	
153
	public boolean isDirty() {
154
		return false;
155
	}
156
		
157
	/**
158
	 * Returns the title for the part.
159
	 * 
160
	 * @return
161
	 */
105
	public String getTitle() {
162
	public String getTitle() {
106
		String result = title;
163
		String result = title;
107
		if(part != null)
164
		if(part != null)
108
			result = part.getTitle();
165
			result = part.getTitle();
109
		if(result == null)
166
		return Util.safeString(result);		
110
			result = new String();
111
		return result;
112
	}
167
	}
168
	
113
	public Image getTitleImage() {
169
	public Image getTitleImage() {
114
		if(part != null)
170
		if(part != null)
115
			return part.getTitleImage();
171
			return part.getTitleImage();
Lines 179-183 Link Here
179
			part.dispose();
235
			part.dispose();
180
		part = null;
236
		part = null;
181
	}	
237
	}	
238
	
182
	public abstract String getRegisteredName();
239
	public abstract String getRegisteredName();
183
}
240
}
(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (+3 lines)
Lines 582-587 Link Here
582
WorkbenchWindow.exceptionMessage = Abnormal Workbench Condition
582
WorkbenchWindow.exceptionMessage = Abnormal Workbench Condition
583
WorkbenchPage.AbnormalWorkbenchCondition = Abnormal Workbench Condition
583
WorkbenchPage.AbnormalWorkbenchCondition = Abnormal Workbench Condition
584
WorkbenchPage.IllegalViewMode = Illegal view mode
584
WorkbenchPage.IllegalViewMode = Illegal view mode
585
WorkbenchPart.AutoTitleFormat={0} ({1})
585
Abnormal_Workbench_Conditi = Abnormal Workbench Condition
586
Abnormal_Workbench_Conditi = Abnormal Workbench Condition
586
WorkbenchPage.ErrorActivatingView = An error has occurred when activating this view
587
WorkbenchPage.ErrorActivatingView = An error has occurred when activating this view
587
WorkbenchPage.oneErrorClosingPage = An error has occurred while closing workbench page: See error log for more details.
588
WorkbenchPage.oneErrorClosingPage = An error has occurred while closing workbench page: See error log for more details.
Lines 708-713 Link Here
708
709
709
# paramter 0 is the feature name, parameter 1 is the version and parameter 2 is the Id
710
# paramter 0 is the feature name, parameter 1 is the version and parameter 2 is the Id
710
SystemSummary.featureVersion= {0} ({1}) "{2}"
711
SystemSummary.featureVersion= {0} ({1}) "{2}"
712
SystemMenuMovePane.PaneName=&Pane
711
713
712
# parameter 0 is the description name, parameter 1 is the version and parameter 2 is the Id
714
# parameter 0 is the description name, parameter 1 is the version and parameter 2 is the Id
713
SystemSummary.descriptorIdVersion= {0} ({1}) "{2}"
715
SystemSummary.descriptorIdVersion= {0} ({1}) "{2}"
Lines 746-751 Link Here
746
DecorationScheduler.UpdateJobName=Update for Decoration Completion
748
DecorationScheduler.UpdateJobName=Update for Decoration Completion
747
DecorationScheduler.CalculationJobName=Decoration Calculation
749
DecorationScheduler.CalculationJobName=Decoration Calculation
748
DecorationScheduler.UpdatingTask=Updating
750
DecorationScheduler.UpdatingTask=Updating
751
DefaultPartPresentation.PaneName=&Pane
749
DecorationScheduler.CalculatingTask=Calculating Decorations
752
DecorationScheduler.CalculatingTask=Calculating Decorations
750
DecorationScheduler.DecoratingSubtask=Decorating {0}
753
DecorationScheduler.DecoratingSubtask=Decorating {0}
751
754
(-)Eclipse UI/org/eclipse/ui/internal/presentations/DefaultPartPresentation.java (-2 / +3 lines)
Lines 471-477 Link Here
471
    }
471
    }
472
	
472
	
473
	protected String getPaneName() {
473
	protected String getPaneName() {
474
		return "&Pane";
474
		return WorkbenchMessages.getString("DefaultPartPresentation.PaneName"); //$NON-NLS-1$
475
	}
475
	}
476
476
477
	/**
477
	/**
Lines 567-572 Link Here
567
	       	if(!getCurrent().equals(part))//Set bold if it does currently have focus
567
	       	if(!getCurrent().equals(part))//Set bold if it does currently have focus
568
				tab.setFont(registry.getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT));
568
				tab.setFont(registry.getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT));
569
	        break;
569
	        break;
570
	     case IPresentablePart.PROP_CONTENT_DESCRIPTION:
570
		 case IPresentablePart.PROP_TOOLBAR:
571
		 case IPresentablePart.PROP_TOOLBAR:
571
		 case IPresentablePart.PROP_PANE_MENU:
572
		 case IPresentablePart.PROP_PANE_MENU:
572
		 case IPresentablePart.PROP_TITLE:
573
		 case IPresentablePart.PROP_TITLE:
Lines 1111-1117 Link Here
1111
    
1112
    
1112
    String getLabelText(IPresentablePart presentablePart,
1113
    String getLabelText(IPresentablePart presentablePart,
1113
            boolean includePath) {
1114
            boolean includePath) {
1114
        String title = presentablePart.getTitle().trim();
1115
        String title = presentablePart.getTitle();
1115
        return title;
1116
        return title;
1116
    }
1117
    }
1117
    
1118
    
(-)Eclipse UI/org/eclipse/ui/internal/presentations/PresentableEditorPart.java (-138 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.eclipse.swt.graphics.Image;
16
import org.eclipse.swt.graphics.Rectangle;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.ui.IEditorReference;
19
import org.eclipse.ui.IPropertyListener;
20
import org.eclipse.ui.internal.EditorPane;
21
import org.eclipse.ui.internal.WorkbenchPartReference;
22
import org.eclipse.ui.internal.util.Util;
23
import org.eclipse.ui.presentations.IPartMenu;
24
import org.eclipse.ui.presentations.IPresentablePart;
25
26
/**
27
 * This is a lightweight wrapper around EditorPane. It adapts an EditorPane into an IPresentablePart.
28
 * All methods here should either redirect directly to EditorPane or do trivial conversions.
29
 */
30
public class PresentableEditorPart implements IPresentablePart {
31
32
    private final List listeners = new ArrayList();
33
34
    private EditorPane pane;
35
36
    private final IPropertyListener propertyListenerProxy = new IPropertyListener() {
37
38
        public void propertyChanged(Object source, int propId) {
39
            for (int i = 0; i < listeners.size(); i++)
40
                ((IPropertyListener) listeners.get(i)).propertyChanged(
41
                        PresentableEditorPart.this, propId);
42
        }
43
    };
44
45
    public PresentableEditorPart(EditorPane pane) {
46
        this.pane = pane;
47
    }
48
49
    public void addPropertyListener(final IPropertyListener listener) {
50
        if (listeners.isEmpty())
51
                getEditorReference().addPropertyListener(propertyListenerProxy);
52
53
        listeners.add(listener);
54
    }
55
56
    private IEditorReference getEditorReference() {
57
        return pane.getEditorReference();
58
    }
59
60
    public String getName() {
61
        WorkbenchPartReference ref = (WorkbenchPartReference) pane
62
                .getPartReference();
63
        return Util.safeString(ref.getRegisteredName());
64
    }
65
66
    public String getTitle() {
67
        return Util.safeString(getEditorReference().getTitle());
68
    }
69
70
    public Image getTitleImage() {
71
        return getEditorReference().getTitleImage();
72
    }
73
74
    public String getTitleToolTip() {
75
        return Util.safeString(getEditorReference().getTitleToolTip());
76
    }
77
78
    public boolean isDirty() {
79
        return getEditorReference().isDirty();
80
    }
81
82
    public void removePropertyListener(final IPropertyListener listener) {
83
        listeners.remove(listener);
84
85
        if (listeners.isEmpty())
86
                getEditorReference().removePropertyListener(
87
                        propertyListenerProxy);
88
    }
89
90
    public void setBounds(Rectangle bounds) {
91
        pane.setBounds(bounds);
92
    }
93
94
    public void setFocus() {
95
        pane.setFocus();
96
    }
97
98
    public void setVisible(boolean isVisible) {
99
        pane.setVisible(isVisible);
100
    }
101
    
102
    /* (non-Javadoc)
103
	 * @see org.eclipse.ui.presentations.IPresentablePart#isBusy()
104
	 */
105
	public boolean isBusy() {
106
		// editors do not support busy currently
107
		return false;
108
	}
109
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
112
	 */
113
	public Control getToolBar() {
114
		return null;
115
	}
116
117
	/* (non-Javadoc)
118
	 * @see org.eclipse.ui.presentations.IPresentablePart#getPartMenu()
119
	 */
120
	public IPartMenu getMenu() {
121
		return null;
122
	}
123
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.ui.presentations.IPresentablePart#getControl()
126
	 */
127
	public Control getControl() {
128
		return pane.getControl();
129
	}
130
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.ui.presentations.IPresentablePart#getTitleStatus()
133
	 */
134
	public String getTitleStatus() {
135
		return new String();
136
	}
137
138
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/PresentableViewPart.java (-197 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.eclipse.jface.action.ToolBarManager;
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.ToolBar;
21
import org.eclipse.ui.IPropertyListener;
22
import org.eclipse.ui.IViewReference;
23
import org.eclipse.ui.internal.ViewPane;
24
import org.eclipse.ui.internal.WorkbenchPartReference;
25
import org.eclipse.ui.internal.util.Util;
26
import org.eclipse.ui.presentations.IPartMenu;
27
import org.eclipse.ui.presentations.IPresentablePart;
28
29
/**
30
 * This is a lightweight wrapper around the ViewPane. It allows a ViewPane to be used as an IPresentablePart.
31
 * All methods here should either redirect directly to ViewPane or do trivial conversions.
32
 */
33
public class PresentableViewPart implements IPresentablePart {
34
35
    private final List listeners = new ArrayList();
36
 
37
    private ViewPane pane;
38
    
39
    private IPartMenu viewMenu = new IPartMenu() {
40
		public void showMenu(Point location) {
41
			pane.showViewMenu(location);
42
		}
43
    };
44
45
    private final IPropertyListener propertyListenerProxy = new IPropertyListener() {
46
47
        public void propertyChanged(Object source, int propId) {
48
            for (int i = 0; i < listeners.size(); i++)
49
                ((IPropertyListener) listeners.get(i)).propertyChanged(
50
                        PresentableViewPart.this, propId);
51
        }
52
    };
53
54
    public PresentableViewPart(ViewPane pane) {
55
        this.pane = pane;
56
    }
57
58
    public void firePropertyChange(int propertyId) {
59
		 for (int i = 0; i < listeners.size(); i++)
60
            ((IPropertyListener) listeners.get(i)).propertyChanged(
61
                    this, propertyId);    	
62
    }
63
    
64
    public void addPropertyListener(final IPropertyListener listener) {
65
        if (listeners.isEmpty())
66
                getViewReference().addPropertyListener(propertyListenerProxy);
67
68
        listeners.add(listener);
69
    }
70
71
    public String getName() {
72
        WorkbenchPartReference ref = (WorkbenchPartReference) pane
73
                .getPartReference();
74
        return Util.safeString(ref.getRegisteredName());
75
    }
76
77
    public String getTitle() {
78
        return Util.safeString(getViewReference().getTitle());
79
    }
80
81
    public Image getTitleImage() {
82
        return getViewReference().getTitleImage();
83
    }
84
85
    public String getTitleToolTip() {
86
        return Util.safeString(getViewReference().getTitleToolTip());
87
    }
88
89
    private IViewReference getViewReference() {
90
        return pane.getViewReference();
91
    }
92
93
    public boolean isDirty() {
94
        return false;
95
    }
96
97
    public void removePropertyListener(final IPropertyListener listener) {
98
        listeners.remove(listener);
99
100
        if (listeners.isEmpty())
101
                getViewReference()
102
                        .removePropertyListener(propertyListenerProxy);
103
    }
104
105
    public void setBounds(Rectangle bounds) {
106
        pane.setBounds(bounds);
107
    }
108
109
    public void setFocus() {
110
        pane.setFocus();
111
    }
112
113
    public void setVisible(boolean isVisible) {
114
        pane.setVisible(isVisible);
115
    }
116
    
117
    /* (non-Javadoc)
118
	 * @see org.eclipse.ui.presentations.IPresentablePart#isBusy()
119
	 */
120
	public boolean isBusy() {
121
		return pane.isBusy();
122
	}
123
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
126
	 */
127
	public Control getToolBar() {
128
		
129
		if (!pane.toolbarIsVisible()) {
130
			return null;
131
		}
132
		
133
		ToolBarManager toolbarManager = pane.getToolBarManager();
134
		
135
		if (toolbarManager == null) {
136
			return null;
137
		}
138
		
139
		ToolBar control = toolbarManager.getControl();
140
		
141
		if (control == null || control.isDisposed() ) {
142
			return null;
143
		}		
144
		
145
		return control;
146
	}
147
148
	/* (non-Javadoc)
149
	 * @see org.eclipse.ui.presentations.IPresentablePart#getPartMenu()
150
	 */
151
	public IPartMenu getMenu() {
152
		if (pane.hasViewMenu()) {
153
			return viewMenu;
154
		}
155
		
156
		return null;
157
	}
158
159
	/* (non-Javadoc)
160
	 * @see org.eclipse.ui.presentations.IPresentablePart#getControl()
161
	 */
162
	public Control getControl() {
163
		return pane.getControl();
164
	}
165
166
	/* (non-Javadoc)
167
	 * @see org.eclipse.ui.presentations.IPresentablePart#getTitleStatus()
168
	 */
169
	public String getTitleStatus() {		
170
		String title = getTitle();
171
		
172
		String name = getName();
173
		
174
		// Return the empty string if the title is unmodified
175
		if (title.equals(name)) {
176
			return Util.ZERO_LENGTH_STRING;
177
		} 
178
179
		if (title.startsWith(name)) {
180
			String substr = title.substring(name.length(), title.length());
181
			
182
			substr = substr.trim();
183
			
184
			if (substr.startsWith("(")) { //$NON-NLS-1$
185
				int end = substr.indexOf(")", 1); //$NON-NLS-1$
186
				
187
				if (end != -1) {
188
					return substr.substring(1, end);
189
				}
190
			}			
191
		}
192
		
193
		return title;
194
	}
195
	
196
	
197
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMovePane.java (-1 / +2 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.jface.action.Action;
13
import org.eclipse.jface.action.Action;
14
import org.eclipse.swt.widgets.Display;
14
import org.eclipse.swt.widgets.Display;
15
import org.eclipse.ui.internal.WorkbenchMessages;
15
import org.eclipse.ui.presentations.IPresentablePart;
16
import org.eclipse.ui.presentations.IPresentablePart;
16
import org.eclipse.ui.presentations.IStackPresentationSite;
17
import org.eclipse.ui.presentations.IStackPresentationSite;
17
18
Lines 24-30 Link Here
24
	
25
	
25
	public SystemMenuMovePane(IStackPresentationSite site) {
26
	public SystemMenuMovePane(IStackPresentationSite site) {
26
		this.site = site;
27
		this.site = site;
27
		setText("&Pane");
28
		setText(WorkbenchMessages.getString("SystemMenuMovePane.PaneName")); //$NON-NLS-1$
28
	}
29
	}
29
	
30
	
30
	/* (non-Javadoc)
31
	/* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/part/EditorPart.java (+28 lines)
Lines 62-67 Link Here
62
 */
62
 */
63
public abstract class EditorPart extends WorkbenchPart implements IEditorPart {
63
public abstract class EditorPart extends WorkbenchPart implements IEditorPart {
64
64
65
	private boolean automaticPartName = true;
66
	
65
	/**
67
	/**
66
	 * Editor input, or <code>null</code> if none.
68
	 * Editor input, or <code>null</code> if none.
67
	 */
69
	 */
Lines 170-173 Link Here
170
protected void setInput(IEditorInput input) {
172
protected void setInput(IEditorInput input) {
171
	editorInput = input;
173
	editorInput = input;
172
}
174
}
175
176
177
/* (non-Javadoc)
178
 * @see org.eclipse.ui.part.WorkbenchPart#setPartName(java.lang.String)
179
 */
180
protected void setPartName(String partName) {
181
	automaticPartName = partName.equals(""); //$NON-NLS-1$
182
	
183
	if (automaticPartName) {
184
		partName = getTitle();
185
	}
186
	
187
	super.setPartName(partName);
188
}
189
190
/* (non-Javadoc)
191
 * @see org.eclipse.ui.part.WorkbenchPart#setTitle(java.lang.String)
192
 */
193
protected void setTitle(String title) {
194
	super.setTitle(title);
195
	
196
	if (automaticPartName) {
197
		super.setPartName(title);
198
	}
199
}
200
173
}
201
}
(-)Eclipse UI/org/eclipse/ui/part/ViewPart.java (-2 / +39 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.part;
11
package org.eclipse.ui.part;
12
12
13
import org.eclipse.jface.util.Assert;
13
import org.eclipse.ui.IMemento;
14
import org.eclipse.ui.IMemento;
14
import org.eclipse.ui.IViewPart;
15
import org.eclipse.ui.IViewPart;
15
import org.eclipse.ui.IViewSite;
16
import org.eclipse.ui.IViewSite;
16
import org.eclipse.ui.PartInitException;
17
import org.eclipse.ui.PartInitException;
18
import org.eclipse.ui.internal.util.Util;
17
19
18
/**
20
/**
19
 * Abstract base implementation of all workbench views.
21
 * Abstract base implementation of all workbench views.
Lines 56-62 Link Here
56
 */
58
 */
57
public abstract class ViewPart extends WorkbenchPart implements IViewPart {
59
public abstract class ViewPart extends WorkbenchPart implements IViewPart {
58
60
59
    
61
private boolean automaticContentDescription = true;
62
	
60
/**
63
/**
61
 * Creates a new view.
64
 * Creates a new view.
62
 */
65
 */
Lines 95-100 Link Here
95
    // do nothing
98
    // do nothing
96
}
99
}
97
100
101
/* (non-Javadoc)
102
 * @see org.eclipse.ui.part.WorkbenchPart#setContentDescription(java.lang.String)
103
 */
104
protected void setContentDescription(String description) {
105
	Assert.isNotNull(description);
106
	
107
	automaticContentDescription = Util.equals(description, "");  //$NON-NLS-1$
108
	
109
	if (automaticContentDescription) {
110
		String title = getTitle();
111
		
112
		if (!title.equals(getPartName())) { 
113
			description = title;
114
		}
115
	}
116
	
117
	super.setContentDescription(description);
118
}
98
119
99
120
/* (non-Javadoc)
121
 * @see org.eclipse.ui.part.WorkbenchPart#setTitle(java.lang.String)
122
 */
123
protected void setTitle(String title) {
124
	title = Util.safeString(title);
125
	super.setTitle(title);
126
	
127
	if (automaticContentDescription) {
128
		
129
		String description = ""; //$NON-NLS-1$
130
		
131
		if (!title.equals(getPartName())) { 
132
			description = title;
133
		}
134
		super.setContentDescription(description);
135
	}
136
}
100
}
137
}
(-)Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java (-17 / +51 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.part;
11
package org.eclipse.ui.part;
12
12
13
import java.text.MessageFormat;
14
13
import org.eclipse.core.runtime.IConfigurationElement;
15
import org.eclipse.core.runtime.IConfigurationElement;
14
import org.eclipse.core.runtime.IExecutableExtension;
16
import org.eclipse.core.runtime.IExecutableExtension;
15
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.core.runtime.Platform;
Lines 22-32 Link Here
22
import org.eclipse.ui.ISharedImages;
24
import org.eclipse.ui.ISharedImages;
23
import org.eclipse.ui.IWorkbenchPart;
25
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.IWorkbenchPart2;
26
import org.eclipse.ui.IWorkbenchPart2;
27
import org.eclipse.ui.IWorkbenchPartConstants;
25
import org.eclipse.ui.IWorkbenchPartSite;
28
import org.eclipse.ui.IWorkbenchPartSite;
26
import org.eclipse.ui.PlatformUI;
29
import org.eclipse.ui.PlatformUI;
27
import org.eclipse.ui.IWorkbenchPartConstants;
28
import org.eclipse.ui.internal.ReferenceCounter;
30
import org.eclipse.ui.internal.ReferenceCounter;
29
import org.eclipse.ui.internal.WorkbenchImages;
31
import org.eclipse.ui.internal.WorkbenchImages;
32
import org.eclipse.ui.internal.WorkbenchMessages;
30
import org.eclipse.ui.internal.misc.Assert;
33
import org.eclipse.ui.internal.misc.Assert;
31
import org.eclipse.ui.internal.util.Util;
34
import org.eclipse.ui.internal.util.Util;
32
import org.eclipse.ui.plugin.AbstractUIPlugin;
35
import org.eclipse.ui.plugin.AbstractUIPlugin;
Lines 52-59 Link Here
52
	private ListenerList propChangeListeners = new ListenerList(2);
55
	private ListenerList propChangeListeners = new ListenerList(2);
53
    
56
    
54
    private String partName = ""; //$NON-NLS-1$
57
    private String partName = ""; //$NON-NLS-1$
55
    private String statusText = ""; //$NON-NLS-1$
58
    private String contentDescription = ""; //$NON-NLS-1$
56
	
59
    
60
    private boolean automaticTitle = true;
61
    
57
/**
62
/**
58
 * Creates a new workbench part.
63
 * Creates a new workbench part.
59
 */
64
 */
Lines 202-210 Link Here
202
	// Save config element.
207
	// Save config element.
203
	configElement = cfig;
208
	configElement = cfig;
204
209
205
	// Part name and title.
210
	// Part name and title.  
206
	partName = Util.safeString(cfig.getAttribute("name"));//$NON-NLS-1$; 
211
	title = Util.safeString(cfig.getAttribute("name"));//$NON-NLS-1$;
207
	title = partName;
212
	setPartName(title);
208
213
209
	// Icon.
214
	// Icon.
210
	String strIcon = cfig.getAttribute("icon");//$NON-NLS-1$
215
	String strIcon = cfig.getAttribute("icon");//$NON-NLS-1$
Lines 250-262 Link Here
250
 * @param title the title, or <code>null</code> to clear
255
 * @param title the title, or <code>null</code> to clear
251
 */
256
 */
252
protected void setTitle(String title) {
257
protected void setTitle(String title) {
253
    title = Util.safeString(title); 
258
	title = Util.safeString(title);
259
	
260
	automaticTitle = (title.equals("")); //$NON-NLS-1$
261
	if (automaticTitle) {
262
		String description = getContentDescription();
263
		String name = getPartName();
264
		
265
		if (Util.equals(description, "")) { //$NON-NLS-1$
266
			title = name;
267
		} else {
268
			title = MessageFormat.format(WorkbenchMessages.getString("WorkbenchPart.AutoTitleFormat"), new String[] {name, description}); //$NON-NLS-1$
269
		}
270
	}
271
	
272
	internalSetTitle(title);
273
}
274
275
private void internalSetTitle(String title) {
276
     
254
	//Do not send changes if they are the same
277
	//Do not send changes if they are the same
255
	if(Util.equals(this.title, title))
278
	if(Util.equals(this.title, title))
256
		return;
279
		return;
257
	this.title = title;
280
	this.title = title;
258
	firePropertyChange(IWorkbenchPart.PROP_TITLE);
281
	firePropertyChange(IWorkbenchPart.PROP_TITLE);	
259
}
282
}
283
260
/**
284
/**
261
 * Sets or clears the title image of this part.
285
 * Sets or clears the title image of this part.
262
 *
286
 *
Lines 322-327 Link Here
322
		return;
346
		return;
323
	this.partName = partName;
347
	this.partName = partName;
324
	firePropertyChange(IWorkbenchPartConstants.PROP_PART_NAME);
348
	firePropertyChange(IWorkbenchPartConstants.PROP_PART_NAME);
349
	
350
	if (automaticTitle) {
351
		setTitle(""); //$NON-NLS-1$
352
	}
325
}
353
}
326
354
327
/* (non-Javadoc)
355
/* (non-Javadoc)
Lines 330-356 Link Here
330
 * @since 3.0
358
 * @since 3.0
331
 */
359
 */
332
public String getContentDescription() {
360
public String getContentDescription() {
333
    return statusText;
361
    return contentDescription;
334
}
362
}
335
363
336
/**
364
/**
337
 * Sets the status text for this part. The status text is typically
365
 * Sets the content description for this part. The content description is typically
338
 * a short string describing the current contents of the part. If parts
366
 * a short string describing the current contents of the part. If parts
339
 * use the setTitle method, their content description may be set automatically.
367
 * use the setTitle method, their content description may be set automatically.
340
 *
368
 *
341
 * @param statusText the status text, or the empty string indicating
369
 * @param description the status text, or the empty string indicating
342
 * that the workbench should manage the status message for this part
370
 * that the workbench should manage the description for this part
343
 * 
371
 * 
344
 * @since 3.0
372
 * @since 3.0
345
 */
373
 */
346
protected void setContentDescription(String statusText) {
374
protected void setContentDescription(String description) {
347
	Assert.isNotNull(statusText);
375
	Assert.isNotNull(description);
348
     
376
	
349
	//Do not send changes if they are the same
377
	//Do not send changes if they are the same
350
	if(Util.equals(this.statusText, statusText))
378
	if(Util.equals(contentDescription, description))
351
		return;
379
		return;
352
	this.statusText = statusText;
380
	this.contentDescription = description;
381
	
353
	firePropertyChange(IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION);
382
	firePropertyChange(IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION);
383
	
384
	if (automaticTitle) {
385
		setTitle(""); //$NON-NLS-1$
386
	}
354
}
387
}
388
355
389
356
}
390
}
(-)Eclipse UI/org/eclipse/ui/presentations/IPresentablePart.java (-5 / +15 lines)
Lines 13-21 Link Here
13
import org.eclipse.swt.graphics.Image;
13
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.graphics.Rectangle;
14
import org.eclipse.swt.graphics.Rectangle;
15
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.ui.IEditorPart;
17
import org.eclipse.ui.IPropertyListener;
16
import org.eclipse.ui.IPropertyListener;
18
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchPartConstants;
19
18
20
/**
19
/**
21
 * This is a skin's interface to the contents of a view or editor. Note that this
20
 * This is a skin's interface to the contents of a view or editor. Note that this
Lines 31-48 Link Here
31
	/**
30
	/**
32
	 * The property id for <code>isDirty</code>.
31
	 * The property id for <code>isDirty</code>.
33
	 */
32
	 */
34
	public static final int PROP_DIRTY = IEditorPart.PROP_DIRTY;
33
	public static final int PROP_DIRTY = IWorkbenchPartConstants.PROP_DIRTY;
35
34
36
	/**
35
	/**
37
	 * The property id for <code>getEditorInput</code>.
36
	 * The property id for <code>getEditorInput</code>.
38
	 */
37
	 */
39
	public static final int PROP_INPUT = IEditorPart.PROP_INPUT;
38
	public static final int PROP_INPUT = IWorkbenchPartConstants.PROP_INPUT;
40
39
41
	/**
40
	/**
42
	 * The property id for <code>getTitle</code>, <code>getTitleImage</code>
41
	 * The property id for <code>getTitle</code>, <code>getTitleImage</code>
43
	 * and <code>getTitleToolTip</code>.
42
	 * and <code>getTitleToolTip</code>.
44
	 */
43
	 */
45
	public static final int PROP_TITLE = IWorkbenchPart.PROP_TITLE;
44
	public static final int PROP_TITLE = IWorkbenchPartConstants.PROP_TITLE;
45
	
46
	/**
47
	 * The property id for <code>IWorkbenchPart2.getContentDescription()</code>
48
	 */
49
	public static final int PROP_CONTENT_DESCRIPTION = IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION;
50
51
	/**
52
	 * The property id for <code>IWorkbenchPart2.getContentDescription()</code>
53
	 */
54
	public static final int PROP_PART_NAME = IWorkbenchPartConstants.PROP_PART_NAME;
55
	
46
	
56
	
47
	/**
57
	/**
48
	 * The property id for <code>isBusy</code>.
58
	 * The property id for <code>isBusy</code>.
(-)Eclipse (+214 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.ui.IPropertyListener;
21
import org.eclipse.ui.internal.PartPane;
22
import org.eclipse.ui.internal.WorkbenchPartReference;
23
import org.eclipse.ui.presentations.IPartMenu;
24
import org.eclipse.ui.presentations.IPresentablePart;
25
26
/**
27
 * This is a lightweight adapter that allows PartPanes to be used by a StackPresentation. All methods
28
 * either redirect directly to PartPane or do trivial type conversions. All listeners registered by
29
 * the presentation are kept here rather than registering them directly on the PartPane. This allows
30
 * us to remove all listeners registered by a presentation that has been disposed, offering some
31
 * protection against memory leaks.
32
 */
33
public class PresentablePart implements IPresentablePart {
34
35
	private PartPane part;
36
	
37
	/**
38
	 * Local listener list -- we use this rather than registering listeners directly on the part
39
	 * in order to protect against memory leaks in badly behaved presentations.
40
	 */
41
	private List listeners = new ArrayList();
42
	
43
	// Lazily initialized. Use getPropertyListenerProxy() to access.
44
    private IPropertyListener lazyPropertyListenerProxy;
45
    
46
    // Lazily initialized. Use getMenu() to access 
47
    private IPartMenu viewMenu;
48
	
49
    /**
50
     * Constructor
51
     * 
52
     * @param part
53
     */
54
	public PresentablePart (PartPane part) {
55
		this.part = part;
56
	}
57
58
	private IPropertyListener getPropertyListenerProxy() {
59
		if (lazyPropertyListenerProxy == null) {
60
			lazyPropertyListenerProxy = new IPropertyListener() {
61
		        public void propertyChanged(Object source, int propId) {
62
		            firePropertyChange(propId);
63
		        }
64
		    };
65
		}
66
		
67
		return lazyPropertyListenerProxy;
68
	}
69
	
70
	private WorkbenchPartReference getPartReference() {
71
		return (WorkbenchPartReference)part.getPartReference();
72
	}
73
	
74
	/**
75
	 * Detach this PresentablePart from the real part. No further methods should be invoked
76
	 * on this object.
77
	 */
78
	public void dispose() {
79
		// Ensure that the property listener is detached (necessary to prevent leaks)
80
		getPartReference().removePropertyListener(getPropertyListenerProxy());
81
		
82
		// Null out the various fields to ease garbage collection (optional)
83
		part = null;
84
		listeners.clear();
85
		listeners = null;
86
	}
87
	
88
	public void firePropertyChange(int propertyId) {
89
		 for (int i = 0; i < listeners.size(); i++) {
90
            ((IPropertyListener) listeners.get(i)).propertyChanged(
91
                    this, propertyId);
92
		 }
93
	}
94
	
95
    public void addPropertyListener(final IPropertyListener listener) {
96
        if (listeners.isEmpty()) {
97
        	getPartReference().addPropertyListener(getPropertyListenerProxy());
98
        }
99
100
        listeners.add(listener);
101
    }
102
    
103
    public void removePropertyListener(final IPropertyListener listener) {
104
        listeners.remove(listener);
105
106
        if (listeners.isEmpty()) {
107
        	getPartReference().removePropertyListener(getPropertyListenerProxy());
108
        }
109
    }
110
	
111
	/* (non-Javadoc)
112
	 * @see org.eclipse.ui.presentations.IPresentablePart#setBounds(org.eclipse.swt.graphics.Rectangle)
113
	 */
114
	public void setBounds(Rectangle bounds) {
115
		part.setBounds(bounds);
116
	}
117
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.ui.presentations.IPresentablePart#setVisible(boolean)
120
	 */
121
	public void setVisible(boolean isVisible) {
122
		part.setVisible(isVisible);
123
	}
124
125
	/* (non-Javadoc)
126
	 * @see org.eclipse.ui.presentations.IPresentablePart#setFocus()
127
	 */
128
	public void setFocus() {
129
		part.setFocus();
130
	}
131
132
	/* (non-Javadoc)
133
	 * @see org.eclipse.ui.presentations.IPresentablePart#getName()
134
	 */
135
	public String getName() {
136
		return getPartReference().getPartName();
137
	}
138
139
	/* (non-Javadoc)
140
	 * @see org.eclipse.ui.presentations.IPresentablePart#getTitle()
141
	 */
142
	public String getTitle() {
143
		return getPartReference().getTitle();
144
	}
145
146
	/* (non-Javadoc)
147
	 * @see org.eclipse.ui.presentations.IPresentablePart#getTitleStatus()
148
	 */
149
	public String getTitleStatus() {
150
		return getPartReference().getContentDescription();
151
	}
152
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.ui.presentations.IPresentablePart#getTitleImage()
155
	 */
156
	public Image getTitleImage() {
157
		return getPartReference().getTitleImage();
158
	}
159
160
	/* (non-Javadoc)
161
	 * @see org.eclipse.ui.presentations.IPresentablePart#getTitleToolTip()
162
	 */
163
	public String getTitleToolTip() {
164
		return getPartReference().getTitleToolTip();
165
	}
166
167
	/* (non-Javadoc)
168
	 * @see org.eclipse.ui.presentations.IPresentablePart#isDirty()
169
	 */
170
	public boolean isDirty() {
171
		return getPartReference().isDirty();
172
	}
173
174
	/* (non-Javadoc)
175
	 * @see org.eclipse.ui.presentations.IPresentablePart#isBusy()
176
	 */
177
	public boolean isBusy() {
178
		return part.isBusy();
179
	}
180
181
	/* (non-Javadoc)
182
	 * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
183
	 */
184
	public Control getToolBar() {
185
		return part.getToolBar();
186
	}
187
188
	/* (non-Javadoc)
189
	 * @see org.eclipse.ui.presentations.IPresentablePart#getMenu()
190
	 */
191
	public IPartMenu getMenu() {
192
		if (!part.hasViewMenu()) {
193
			return null;
194
		}
195
		
196
		if (viewMenu == null) {
197
			viewMenu = new IPartMenu() {
198
				public void showMenu(Point location) {
199
					part.showViewMenu(location);
200
				}
201
		    };
202
		}
203
		
204
		return viewMenu;
205
	}
206
207
	/* (non-Javadoc)
208
	 * @see org.eclipse.ui.presentations.IPresentablePart#getControl()
209
	 */
210
	public Control getControl() {
211
		return part.getControl();
212
	}
213
214
}

Return to bug 55656