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 30881 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java (-16 / +135 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-25 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.swt.widgets.Display;
18
17
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.OperationCanceledException;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.jobs.Job;
19
24
20
import org.eclipse.jface.operation.IRunnableContext;
25
import org.eclipse.jface.operation.IRunnableContext;
21
import org.eclipse.jface.operation.IRunnableWithProgress;
26
import org.eclipse.jface.operation.IRunnableWithProgress;
22
27
28
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
29
23
import org.eclipse.jdt.core.ElementChangedEvent;
30
import org.eclipse.jdt.core.ElementChangedEvent;
24
import org.eclipse.jdt.core.IClassFile;
31
import org.eclipse.jdt.core.IClassFile;
25
import org.eclipse.jdt.core.ICompilationUnit;
32
import org.eclipse.jdt.core.ICompilationUnit;
Lines 37-42 Link Here
37
import org.eclipse.jdt.core.JavaModelException;
44
import org.eclipse.jdt.core.JavaModelException;
38
45
39
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
46
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
47
import org.eclipse.jdt.internal.corext.util.Messages;
48
49
import org.eclipse.jdt.ui.JavaElementLabels;
40
50
41
import org.eclipse.jdt.internal.ui.JavaPlugin;
51
import org.eclipse.jdt.internal.ui.JavaPlugin;
42
52
Lines 52-59 Link Here
52
62
53
	private List fChangeListeners;
63
	private List fChangeListeners;
54
64
55
	public TypeHierarchyLifeCycle() {
65
	/**
66
	 * The type hierarchy view part.
67
	 *
68
	 * @since 3.6
69
	 */
70
	private TypeHierarchyViewPart fTypeHierarchyViewPart;
71
72
	/**
73
	 * The job that runs in the background to refresh the type hierarchy.
74
	 *
75
	 * @since 3.6
76
	 */
77
	private Job fRefreshHierarchyJob;
78
79
	/**
80
	 * Creates the type hierarchy life cycle.
81
	 *
82
	 * @param part the type hierarchy view part
83
	 * @since 3.6
84
	 */
85
	public TypeHierarchyLifeCycle(TypeHierarchyViewPart part) {
56
		this(false);
86
		this(false);
87
		fTypeHierarchyViewPart= part;
88
		fRefreshHierarchyJob= null;
57
	}
89
	}
58
90
59
	public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {
91
	public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {
Lines 98-104 Link Here
98
		}
130
		}
99
	}
131
	}
100
132
133
	/**
134
	 * Refreshes the type hierarchy for the java element if it exists.
135
	 *
136
	 * @param element the java element for which the type hierarchy is computed
137
	 * @param context the runnable context
138
	 * @throws InterruptedException thrown from the <code>OperationCanceledException</code> when the monitor is canceled
139
	 * @throws InvocationTargetException thrown from the <code>JavaModelException</code> if the java element does not exist or if an exception occurs while accessing its corresponding resource
140
	 */
101
	public void ensureRefreshedTypeHierarchy(final IJavaElement element, IRunnableContext context) throws InvocationTargetException, InterruptedException {
141
	public void ensureRefreshedTypeHierarchy(final IJavaElement element, IRunnableContext context) throws InvocationTargetException, InterruptedException {
142
		synchronized (this) {
143
			if (fRefreshHierarchyJob != null) {
144
				fRefreshHierarchyJob.cancel();
145
				try {
146
					fRefreshHierarchyJob.join();
147
				} catch (InterruptedException e) {
148
					// ignore
149
				} finally {
150
					fRefreshHierarchyJob= null;
151
				}
152
			}
153
		}
102
		if (element == null || !element.exists()) {
154
		if (element == null || !element.exists()) {
103
			freeHierarchy();
155
			freeHierarchy();
104
			return;
156
			return;
Lines 106-126 Link Here
106
		boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
158
		boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
107
159
108
		if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {
160
		if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {
109
161
			if (fTypeHierarchyViewPart == null) {
110
			IRunnableWithProgress op= new IRunnableWithProgress() {
162
				IRunnableWithProgress op= new IRunnableWithProgress() {
111
				public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
163
					public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
112
					try {
164
						try {
113
						doHierarchyRefresh(element, pm);
165
							doHierarchyRefresh(element, pm);
114
					} catch (JavaModelException e) {
166
						} catch (JavaModelException e) {
115
						throw new InvocationTargetException(e);
167
							throw new InvocationTargetException(e);
116
					} catch (OperationCanceledException e) {
168
						} catch (OperationCanceledException e) {
117
						throw new InterruptedException();
169
							throw new InterruptedException();
170
						}
171
					}
172
				};
173
				fHierarchyRefreshNeeded= true;
174
				context.run(true, true, op);
175
				fHierarchyRefreshNeeded= false;
176
			} else {				
177
				final String label= Messages.format(TypeHierarchyMessages.TypeHierarchyLifeCycle_computeInput, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT));
178
				fRefreshHierarchyJob= new Job(label) {					
179
					/*
180
					 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
181
					 */
182
					public IStatus run(IProgressMonitor pm) {
183
						pm.beginTask(label, LONG);
184
						try {
185
							doHierarchyRefreshBackground(element, pm);
186
						} catch (OperationCanceledException e) {
187
							fTypeHierarchyViewPart.setCanceledViewer(false);
188
							return Status.CANCEL_STATUS;
189
						} catch (JavaModelException e) {
190
							return e.getStatus();
191
						} finally {
192
							fHierarchyRefreshNeeded= true;
193
							pm.done();
194
						}
195
						return Status.OK_STATUS;
118
					}
196
					}
197
				};
198
				fRefreshHierarchyJob.setUser(true);
199
				IWorkbenchSiteProgressService progressService= (IWorkbenchSiteProgressService)fTypeHierarchyViewPart.getSite()
200
														.getAdapter(IWorkbenchSiteProgressService.class);
201
				progressService.schedule(fRefreshHierarchyJob, 0);
202
203
			}
204
		}
205
	}
206
207
	/**
208
	 * Returns <code>true</code> if the refresh job is running, <code>false</code> otherwise.
209
	 * 
210
	 * @return <code>true</code> if the refresh job is running, <code>false</code> otherwise
211
	 * 
212
	 * @since 3.6
213
	 */
214
	public boolean isRefreshJob() {
215
		return fRefreshHierarchyJob != null;
216
	}
217
218
	/**
219
	 * Refreshes the hierarchy in the background and updates the hierarchy viewer asynchronously in
220
	 * the UI thread.
221
	 * 
222
	 * @param element the java element on which the hierarchy is computed
223
	 * @param pm the progress monitor
224
	 * @throws JavaModelException if the java element does not exist or if an exception occurs while
225
	 *             accessing its corresponding resource.
226
	 * 
227
	 * @since 3.6
228
	 */
229
	protected void doHierarchyRefreshBackground(final IJavaElement element, final IProgressMonitor pm) throws JavaModelException {
230
		doHierarchyRefresh(element, pm);
231
		if (!pm.isCanceled()) {
232
			Display.getDefault().asyncExec(new Runnable() {
233
				/*
234
				 * @see java.lang.Runnable#run()
235
				 */
236
				public void run() {
237
					fTypeHierarchyViewPart.setViewerInput();
238
					fTypeHierarchyViewPart.updateViewers();
119
				}
239
				}
120
			};
240
			});
121
			fHierarchyRefreshNeeded= true;
122
			context.run(true, true, op);
123
			fHierarchyRefreshNeeded= false;
124
		}
241
		}
125
	}
242
	}
126
243
Lines 160-166 Link Here
160
	}
277
	}
161
278
162
279
163
	public synchronized void doHierarchyRefresh(IJavaElement element, IProgressMonitor pm) throws JavaModelException {
280
	public void doHierarchyRefresh(IJavaElement element, IProgressMonitor pm) throws JavaModelException {
164
		boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
281
		boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
165
		// to ensure the order of the two listeners always remove / add listeners on operations
282
		// to ensure the order of the two listeners always remove / add listeners on operations
166
		// on type hierarchies
283
		// on type hierarchies
Lines 176-181 Link Here
176
			fInputElement= element;
293
			fInputElement= element;
177
		} else {
294
		} else {
178
			fHierarchy.refresh(pm);
295
			fHierarchy.refresh(pm);
296
			if (pm != null && pm.isCanceled())
297
				throw new OperationCanceledException();
179
		}
298
		}
180
		fHierarchy.addTypeHierarchyChangedListener(this);
299
		fHierarchy.addTypeHierarchyChangedListener(this);
181
		JavaCore.addElementChangedListener(this);
300
		JavaCore.addElementChangedListener(this);
(-)ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyMessages.java (+2 lines)
Lines 60-65 Link Here
60
	public static String SortByDefiningTypeAction_label;
60
	public static String SortByDefiningTypeAction_label;
61
	public static String SortByDefiningTypeAction_tooltip;
61
	public static String SortByDefiningTypeAction_tooltip;
62
	public static String SortByDefiningTypeAction_description;
62
	public static String SortByDefiningTypeAction_description;
63
	public static String TypeHierarchyViewPart_canceled;
63
	public static String TypeHierarchyViewPart_createinput;
64
	public static String TypeHierarchyViewPart_createinput;
64
	public static String TypeHierarchyViewPart_error_title;
65
	public static String TypeHierarchyViewPart_error_title;
65
	public static String TypeHierarchyViewPart_error_message;
66
	public static String TypeHierarchyViewPart_error_message;
Lines 72-77 Link Here
72
	public static String TypeHierarchyViewPart_ws_tooltip;
73
	public static String TypeHierarchyViewPart_ws_tooltip;
73
	public static String TypeHierarchyViewPart_restoreinput;
74
	public static String TypeHierarchyViewPart_restoreinput;
74
	public static String TypeHierarchyViewPart_layout_submenu;
75
	public static String TypeHierarchyViewPart_layout_submenu;
76
	public static String TypeHierarchyLifeCycle_computeInput;
75
	public static String ToggleViewAction_subtypes_label;
77
	public static String ToggleViewAction_subtypes_label;
76
	public static String ToggleViewAction_subtypes_tooltip;
78
	public static String ToggleViewAction_subtypes_tooltip;
77
	public static String ToggleViewAction_subtypes_description;
79
	public static String ToggleViewAction_subtypes_description;
(-)ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties (+2 lines)
Lines 62-69 Link Here
62
SortByDefiningTypeAction_label=Sort by the Defining Type
62
SortByDefiningTypeAction_label=Sort by the Defining Type
63
SortByDefiningTypeAction_tooltip=Sort Methods by the Defining Type
63
SortByDefiningTypeAction_tooltip=Sort Methods by the Defining Type
64
SortByDefiningTypeAction_description=Sort methods by the defining type
64
SortByDefiningTypeAction_description=Sort methods by the defining type
65
TypeHierarchyLifeCycle_computeInput=Computing type hierarchy of ''{0}''...
65
66
66
TypeHierarchyViewPart_error_title=Open Type Hierarchy
67
TypeHierarchyViewPart_error_title=Open Type Hierarchy
68
TypeHierarchyViewPart_canceled=Type Hierarchy computation canceled
67
TypeHierarchyViewPart_createinput=Creating type hierarchy of ''{0}''...
69
TypeHierarchyViewPart_createinput=Creating type hierarchy of ''{0}''...
68
70
69
TypeHierarchyViewPart_error_message=The selected element only exists in the editor.  To perform this operation you have to save the editor first.
71
TypeHierarchyViewPart_error_message=The selected element only exists in the editor.  To perform this operation you have to save the editor first.
(-)ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java (-33 / +132 lines)
Lines 242-247 Link Here
242
242
243
	private OpenAction fOpenAction;
243
	private OpenAction fOpenAction;
244
244
245
	/**
246
	 * Indicates whether the restore job was canceled.
247
	 * 
248
	 * @since 3.6
249
	 */
250
	private boolean fIsRestoreJobCancel= false;
251
252
	/**
253
	 * Indicates whether the current viewer shown is the empty viewer.
254
	 * 
255
	 * @since 3.6
256
	 */
257
	private boolean fIsShowingEmptyViewer= true;
258
245
259
246
	public TypeHierarchyViewPart() {
260
	public TypeHierarchyViewPart() {
247
		fSelectedType= null;
261
		fSelectedType= null;
Lines 251-257 Link Here
251
		fSelectInEditor= true;
265
		fSelectInEditor= true;
252
		fRestoreStateJob= null;
266
		fRestoreStateJob= null;
253
267
254
		fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
268
		fHierarchyLifeCycle= new TypeHierarchyLifeCycle(this);
255
		fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
269
		fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
256
			public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {
270
			public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {
257
				doTypeHierarchyChanged(typeHierarchy, changedTypes);
271
				doTypeHierarchyChanged(typeHierarchy, changedTypes);
Lines 511-516 Link Here
511
		synchronized (this) {
525
		synchronized (this) {
512
			if (fRestoreStateJob != null) {
526
			if (fRestoreStateJob != null) {
513
				fRestoreStateJob.cancel();
527
				fRestoreStateJob.cancel();
528
				fIsRestoreJobCancel= true;
514
				try {
529
				try {
515
					fRestoreStateJob.join();
530
					fRestoreStateJob.join();
516
				} catch (InterruptedException e) {
531
				} catch (InterruptedException e) {
Lines 529-534 Link Here
529
		if (inputElement == null) {
544
		if (inputElement == null) {
530
			clearInput();
545
			clearInput();
531
		} else {
546
		} else {
547
			if (!inputElement.equals(prevInput)) {
548
				for (int i= 0; i < fAllViewers.length; i++) {
549
					fAllViewers[i].setInput(null);
550
				}
551
			}
532
			fInputElement= inputElement;
552
			fInputElement= inputElement;
533
			fNoHierarchyShownLabel.setText(Messages.format(TypeHierarchyMessages.TypeHierarchyViewPart_createinput, JavaElementLabels.getElementLabel(inputElement, JavaElementLabels.ALL_DEFAULT)));
553
			fNoHierarchyShownLabel.setText(Messages.format(TypeHierarchyMessages.TypeHierarchyViewPart_createinput, JavaElementLabels.getElementLabel(inputElement, JavaElementLabels.ALL_DEFAULT)));
534
			try {
554
			try {
Lines 537-570 Link Here
537
			} catch (InvocationTargetException e) {
557
			} catch (InvocationTargetException e) {
538
				ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.TypeHierarchyViewPart_exception_title, TypeHierarchyMessages.TypeHierarchyViewPart_exception_message);
558
				ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.TypeHierarchyViewPart_exception_title, TypeHierarchyMessages.TypeHierarchyViewPart_exception_message);
539
				clearInput();
559
				clearInput();
540
				return;
560
				return;// panic code. This code wont be executed.
541
			} catch (InterruptedException e) {
561
			} catch (InterruptedException e) {
542
				fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
562
				fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
543
				return;
563
				return;// panic code. This code wont be executed.
544
			}
564
			}
545
565
546
			if (inputElement.getElementType() != IJavaElement.TYPE) {
566
			if (inputElement.getElementType() != IJavaElement.TYPE) {
547
				setHierarchyMode(HIERARCHY_MODE_CLASSIC);
567
				setHierarchyMode(HIERARCHY_MODE_CLASSIC);
548
			}
568
			}
549
			// turn off member filtering
569
			updateViewers();
550
			fSelectInEditor= false;
551
			setMemberFilter(null);
552
			internalSelectType(null, false); // clear selection
553
			fIsEnableMemberFilter= false;
554
			if (!inputElement.equals(prevInput)) {
555
				updateHierarchyViewer(true);
556
			}
557
			IType root= getSelectableType(inputElement);
558
			internalSelectType(root, true);
559
			updateMethodViewer(root);
560
			updateToolbarButtons();
561
			updateToolTipAndDescription();
562
			showMembersInHierarchy(false);
563
			fPagebook.showPage(fTypeMethodsSplitter);
564
			fSelectInEditor= true;
565
		}
570
		}
566
	}
571
	}
567
572
573
	/**
574
	 * Updates the viewers, toolbar buttons and tooltip.
575
	 * 
576
	 * @since 3.6
577
	 */
578
	public void updateViewers() {
579
		if (!fHierarchyLifeCycle.isRefreshJob()) {
580
			setViewerInput();
581
		}
582
		setViewerVisibility(true);
583
		// turn off member filtering
584
		fSelectInEditor= false;
585
		setMemberFilter(null);
586
		internalSelectType(null, false); // clear selection
587
		fIsEnableMemberFilter= false;
588
		updateHierarchyViewer(true);
589
		IType root= getSelectableType(fInputElement);
590
		internalSelectType(root, true);
591
		updateMethodViewer(root);
592
		updateToolbarButtons();
593
		updateToolTipAndDescription();
594
		showMembersInHierarchy(false);
595
		fPagebook.showPage(fTypeMethodsSplitter);		
596
		fSelectInEditor= true;		
597
	}
598
568
	private void processOutstandingEvents() {
599
	private void processOutstandingEvents() {
569
		Display display= getDisplay();
600
		Display display= getDisplay();
570
		if (display != null && !display.isDisposed())
601
		if (display != null && !display.isDisposed())
Lines 1086-1092 Link Here
1086
	/*
1117
	/*
1087
	 * Toggles between the empty viewer page and the hierarchy
1118
	 * Toggles between the empty viewer page and the hierarchy
1088
	 */
1119
	 */
1089
	private void setViewerVisibility(boolean showHierarchy) {
1120
	public void setViewerVisibility(boolean showHierarchy) {
1090
		if (showHierarchy) {
1121
		if (showHierarchy) {
1091
			fViewerbook.showPage(getCurrentViewer().getControl());
1122
			fViewerbook.showPage(getCurrentViewer().getControl());
1092
		} else {
1123
		} else {
Lines 1124-1130 Link Here
1124
	 * <code>updateHierarchyViewer<code> brings up the correct view and refreshes
1155
	 * <code>updateHierarchyViewer<code> brings up the correct view and refreshes
1125
	 * the current tree
1156
	 * the current tree
1126
	 */
1157
	 */
1127
	private void updateHierarchyViewer(final boolean doExpand) {
1158
	public void updateHierarchyViewer(final boolean doExpand) {
1128
		if (fInputElement == null) {
1159
		if (fInputElement == null) {
1129
			fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
1160
			fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
1130
			fPagebook.showPage(fNoHierarchyShownLabel);
1161
			fPagebook.showPage(fNoHierarchyShownLabel);
Lines 1139-1147 Link Here
1139
				if (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) {
1170
				if (!isChildVisible(fViewerbook, getCurrentViewer().getControl())) {
1140
					setViewerVisibility(true);
1171
					setViewerVisibility(true);
1141
				}
1172
				}
1142
			} else {
1173
			} else if (!fIsShowingEmptyViewer) {//Show the empty hierarchy viewer till fresh computation is done.
1143
				fEmptyTypesViewer.setText(Messages.format(TypeHierarchyMessages.TypeHierarchyViewPart_nodecl, JavaElementLabels.getElementLabel(fInputElement, JavaElementLabels.ALL_DEFAULT)));
1174
				if (fIsRestoreJobCancel) {
1144
				setViewerVisibility(false);
1175
					setCanceledViewer(false);
1176
					fIsRestoreJobCancel= false;
1177
				} else {
1178
					fEmptyTypesViewer.setText(Messages.format(TypeHierarchyMessages.TypeHierarchyViewPart_nodecl, JavaElementLabels.getElementLabel(fInputElement, JavaElementLabels.ALL_DEFAULT)));
1179
					setViewerVisibility(false);
1180
				}
1145
			}
1181
			}
1146
		}
1182
		}
1147
	}
1183
	}
Lines 1566-1571 Link Here
1566
						} catch (JavaModelException e) {
1602
						} catch (JavaModelException e) {
1567
							return e.getStatus();
1603
							return e.getStatus();
1568
						} catch (OperationCanceledException e) {
1604
						} catch (OperationCanceledException e) {
1605
							setCanceledViewer(true);
1569
							return Status.CANCEL_STATUS;
1606
							return Status.CANCEL_STATUS;
1570
						}
1607
						}
1571
						return Status.OK_STATUS;
1608
						return Status.OK_STATUS;
Lines 1579-1595 Link Here
1579
	private void doRestoreInBackground(final IMemento memento, final IJavaElement hierarchyInput, IProgressMonitor monitor) throws JavaModelException {
1616
	private void doRestoreInBackground(final IMemento memento, final IJavaElement hierarchyInput, IProgressMonitor monitor) throws JavaModelException {
1580
		fHierarchyLifeCycle.doHierarchyRefresh(hierarchyInput, monitor);
1617
		fHierarchyLifeCycle.doHierarchyRefresh(hierarchyInput, monitor);
1581
		final boolean doRestore= !monitor.isCanceled();
1618
		final boolean doRestore= !monitor.isCanceled();
1582
		Display.getDefault().asyncExec(new Runnable() {
1619
		if (doRestore) {
1583
			public void run() {
1620
			Display.getDefault().asyncExec(new Runnable() {
1584
				// running async: check first if view still exists
1621
				public void run() {
1585
				if (fPagebook != null && !fPagebook.isDisposed()) {
1622
					// running async: check first if view still exists
1586
					if (doRestore)
1623
					if (fPagebook != null && !fPagebook.isDisposed()) {
1587
						doRestoreState(memento, hierarchyInput);
1624
						doRestoreState(memento, hierarchyInput);
1588
					else
1625
					}
1589
						fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
1590
				}
1626
				}
1591
			}
1627
			});
1592
		});
1628
		}
1593
	}
1629
	}
1594
1630
1595
1631
Lines 1602-1607 Link Here
1602
		}
1638
		}
1603
1639
1604
		fWorkingSetActionGroup.restoreState(memento);
1640
		fWorkingSetActionGroup.restoreState(memento);
1641
		setShowingEmptyViewer(false);
1605
		setInputElement(input);
1642
		setInputElement(input);
1606
1643
1607
		Integer viewerIndex= memento.getInteger(TAG_VIEW);
1644
		Integer viewerIndex= memento.getInteger(TAG_VIEW);
Lines 1640-1645 Link Here
1640
	}
1677
	}
1641
1678
1642
	/**
1679
	/**
1680
	 * Sets whether the previous viewer shown was an empty viewer.
1681
	 * 
1682
	 * @param isShowingEmptyViewer <code>true</code> if the previous viewer was empty,
1683
	 *            <code>false</code> otherwise
1684
	 * 
1685
	 * @since 3.6
1686
	 */
1687
	private void setShowingEmptyViewer(boolean isShowingEmptyViewer) {
1688
		fIsShowingEmptyViewer= isShowingEmptyViewer;
1689
1690
	}
1691
1692
	/**
1643
	 * View part becomes visible.
1693
	 * View part becomes visible.
1644
	 *
1694
	 *
1645
	 * @param isVisible <code>true</code> if visible
1695
	 * @param isVisible <code>true</code> if visible
Lines 1731-1734 Link Here
1731
		fNeedRefresh= false;
1781
		fNeedRefresh= false;
1732
	}
1782
	}
1733
1783
1784
	/**
1785
	 * Sets the empty viewer after the canceled job in the display thread.
1786
	 * @param isRestoreJob <code>true</code> when restore job is canceled, <code>false</code> otherwise
1787
	 *
1788
	 * @since 3.6
1789
	 */
1790
	public void setCanceledViewer(final boolean isRestoreJob) {
1791
		Display.getDefault().asyncExec(new Runnable() {
1792
			public void run() {
1793
				if (isRestoreJob) {
1794
					fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
1795
				} else {
1796
					setViewerVisibility(false);
1797
					fEmptyTypesViewer.setText(""); //$NON-NLS-1$
1798
					updateMethodViewer(null);
1799
					setContentDescription(TypeHierarchyMessages.TypeHierarchyViewPart_canceled);
1800
					setTitleToolTip(""); //$NON-NLS-1$
1801
					for (int i= 0; i < fViewActions.length; i++) {
1802
						fViewActions[i].setEnabled(false);					
1803
					}
1804
				}
1805
				setShowingEmptyViewer(true);
1806
			}
1807
		});
1808
	}
1809
1810
	/**
1811
	 * Returns the type hierarchy life cycle.
1812
	 *
1813
	 * @return the type hierarchy life cycle
1814
	 *
1815
	 * @since 3.6
1816
	 */
1817
	public TypeHierarchyLifeCycle getTypeHierarchyLifeCycle() {
1818
		return fHierarchyLifeCycle;
1819
1820
	}
1821
1822
	/**
1823
	 * Sets the input for all the hierarchy viewers with their respective viewer instances.
1824
	 * 
1825
	 * @since 3.6
1826
	 */
1827
	public void setViewerInput() {
1828
		for (int i= 0; i < fAllViewers.length; i++) {
1829
			fAllViewers[i].setInput(fAllViewers[i]);
1830
		}
1831
		setShowingEmptyViewer(false);
1832
	}	
1734
}
1833
}

Return to bug 30881