1818import java .util .Arrays ;
1919import java .util .Iterator ;
2020import java .util .List ;
21+ import java .util .stream .Stream ;
2122
2223import org .eclipse .help .IContextProvider ;
2324
103104import org .eclipse .ui .part .ViewPart ;
104105import org .eclipse .ui .views .WorkbenchViewerSetup ;
105106
107+ import org .eclipse .jdt .core .ClasspathContainerInitializer ;
106108import org .eclipse .jdt .core .IJavaElement ;
107109import org .eclipse .jdt .core .IMember ;
108110import org .eclipse .jdt .core .IType ;
116118
117119import org .eclipse .jdt .ui .IContextMenuConstants ;
118120import org .eclipse .jdt .ui .ITypeHierarchyViewPart ;
121+ import org .eclipse .jdt .ui .JavaElementLabels ;
119122import org .eclipse .jdt .ui .JavaUI ;
120123import org .eclipse .jdt .ui .PreferenceConstants ;
121124import org .eclipse .jdt .ui .actions .CCPActionGroup ;
@@ -1643,7 +1646,7 @@ private void restoreState(final IMemento memento) {
16431646 int i = 0 ;
16441647 while (elementId != null ) {
16451648 input = JavaCore .create (elementId );
1646- if (input == null || ! input . exists () ) {
1649+ if (input == null ) {
16471650 inputList = null ;
16481651 break ;
16491652 }
@@ -1654,23 +1657,33 @@ private void restoreState(final IMemento memento) {
16541657 doRestoreState (memento , input );
16551658 } else {
16561659 final IJavaElement [] hierarchyInput = inputList .toArray (new IJavaElement [inputList .size ()]);
1657-
16581660 synchronized (this ) {
1659- String label = Messages .format (TypeHierarchyMessages .TypeHierarchyViewPart_restoreinput , HistoryAction .getElementLabel (hierarchyInput ));
1661+ long flags = JavaElementLabels .M_APP_TYPE_PARAMETERS | JavaElementLabels .M_PARAMETER_TYPES | JavaElementLabels .ALL_POST_QUALIFIED | JavaElementLabels .ALL_POST_QUALIFIED | JavaElementLabels .P_COMPRESSED ;
1662+ String label = Messages .format (TypeHierarchyMessages .TypeHierarchyViewPart_restoreinput , HistoryAction .getElementLabel (hierarchyInput , flags ));
16601663 fNoHierarchyShownLabel .setText (label );
16611664
16621665 fRestoreStateJob = new Job (label ) {
16631666 @ Override
16641667 protected IStatus run (IProgressMonitor monitor ) {
16651668 try {
1666- doRestoreInBackground (memento , hierarchyInput , monitor );
1669+ Job .getJobManager ().join (ClasspathContainerInitializer .class , monitor );
1670+ IJavaElement [] exsistingHierarchyInput = Stream .of (hierarchyInput ).filter (IJavaElement ::exists ).toArray (length -> new IJavaElement [length ]);
1671+ if (exsistingHierarchyInput .length == 0 ) {
1672+ PlatformUI .getWorkbench ().getDisplay ().asyncExec (() -> {
1673+ doRestoreState (memento , new IJavaElement [0 ]);
1674+ });
1675+ } else {
1676+ doRestoreInBackground (memento , exsistingHierarchyInput , monitor );
1677+ }
16671678 } catch (JavaModelException e ) {
16681679 return e .getStatus ();
16691680 } catch (OperationCanceledException e ) {
16701681 if (fRestoreJobCanceledExplicitly ) {
16711682 showEmptyViewer ();
16721683 }
16731684 return Status .CANCEL_STATUS ;
1685+ } catch (InterruptedException e ) {
1686+ Thread .currentThread ().interrupt ();
16741687 }
16751688 return Status .OK_STATUS ;
16761689 }
0 commit comments