|
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 implicitly. |
| 247 |
* |
| 248 |
* @since 3.6 |
| 249 |
*/ |
| 250 |
private boolean fIsCancelImplicit= 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 |
fIsCancelImplicit= 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 |
setViewersInput(); |
| 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-1145
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 |
fEmptyTypesViewer.setText(Messages.format(TypeHierarchyMessages.TypeHierarchyViewPart_nodecl, JavaElementLabels.getElementLabel(fInputElement, JavaElementLabels.ALL_DEFAULT))); |
| 1144 |
setViewerVisibility(false); |
1175 |
setViewerVisibility(false); |
| 1145 |
} |
1176 |
} |
|
Lines 1566-1571
Link Here
|
| 1566 |
} catch (JavaModelException e) { |
1597 |
} catch (JavaModelException e) { |
| 1567 |
return e.getStatus(); |
1598 |
return e.getStatus(); |
| 1568 |
} catch (OperationCanceledException e) { |
1599 |
} catch (OperationCanceledException e) { |
|
|
1600 |
setCanceledViewer(fIsCancelImplicit); |
| 1569 |
return Status.CANCEL_STATUS; |
1601 |
return Status.CANCEL_STATUS; |
| 1570 |
} |
1602 |
} |
| 1571 |
return Status.OK_STATUS; |
1603 |
return Status.OK_STATUS; |
|
Lines 1579-1595
Link Here
|
| 1579 |
private void doRestoreInBackground(final IMemento memento, final IJavaElement hierarchyInput, IProgressMonitor monitor) throws JavaModelException { |
1611 |
private void doRestoreInBackground(final IMemento memento, final IJavaElement hierarchyInput, IProgressMonitor monitor) throws JavaModelException { |
| 1580 |
fHierarchyLifeCycle.doHierarchyRefresh(hierarchyInput, monitor); |
1612 |
fHierarchyLifeCycle.doHierarchyRefresh(hierarchyInput, monitor); |
| 1581 |
final boolean doRestore= !monitor.isCanceled(); |
1613 |
final boolean doRestore= !monitor.isCanceled(); |
| 1582 |
Display.getDefault().asyncExec(new Runnable() { |
1614 |
if (doRestore) { |
| 1583 |
public void run() { |
1615 |
Display.getDefault().asyncExec(new Runnable() { |
| 1584 |
// running async: check first if view still exists |
1616 |
public void run() { |
| 1585 |
if (fPagebook != null && !fPagebook.isDisposed()) { |
1617 |
// running async: check first if view still exists |
| 1586 |
if (doRestore) |
1618 |
if (fPagebook != null && !fPagebook.isDisposed()) { |
| 1587 |
doRestoreState(memento, hierarchyInput); |
1619 |
doRestoreState(memento, hierarchyInput); |
| 1588 |
else |
1620 |
} |
| 1589 |
fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty); |
|
|
| 1590 |
} |
1621 |
} |
| 1591 |
} |
1622 |
}); |
| 1592 |
}); |
1623 |
} |
| 1593 |
} |
1624 |
} |
| 1594 |
|
1625 |
|
| 1595 |
|
1626 |
|
|
Lines 1602-1607
Link Here
|
| 1602 |
} |
1633 |
} |
| 1603 |
|
1634 |
|
| 1604 |
fWorkingSetActionGroup.restoreState(memento); |
1635 |
fWorkingSetActionGroup.restoreState(memento); |
|
|
1636 |
setShowingEmptyViewer(false); |
| 1605 |
setInputElement(input); |
1637 |
setInputElement(input); |
| 1606 |
|
1638 |
|
| 1607 |
Integer viewerIndex= memento.getInteger(TAG_VIEW); |
1639 |
Integer viewerIndex= memento.getInteger(TAG_VIEW); |
|
Lines 1640-1645
Link Here
|
| 1640 |
} |
1672 |
} |
| 1641 |
|
1673 |
|
| 1642 |
/** |
1674 |
/** |
|
|
1675 |
* Sets whether the previous viewer shown was an empty viewer. |
| 1676 |
* |
| 1677 |
* @param isShowingEmptyViewer <code>true</code> if the previous viewer was empty, |
| 1678 |
* <code>false</code> otherwise |
| 1679 |
* |
| 1680 |
* @since 3.6 |
| 1681 |
*/ |
| 1682 |
private void setShowingEmptyViewer(boolean isShowingEmptyViewer) { |
| 1683 |
fIsShowingEmptyViewer= isShowingEmptyViewer; |
| 1684 |
|
| 1685 |
} |
| 1686 |
|
| 1687 |
/** |
| 1643 |
* View part becomes visible. |
1688 |
* View part becomes visible. |
| 1644 |
* |
1689 |
* |
| 1645 |
* @param isVisible <code>true</code> if visible |
1690 |
* @param isVisible <code>true</code> if visible |
|
Lines 1731-1734
Link Here
|
| 1731 |
fNeedRefresh= false; |
1776 |
fNeedRefresh= false; |
| 1732 |
} |
1777 |
} |
| 1733 |
|
1778 |
|
|
|
1779 |
/** |
| 1780 |
* Sets the empty viewer if the user cancels the computation. |
| 1781 |
* |
| 1782 |
* @param isCancelImplicit <code>false</code> when the user cancels the computation explicitly, |
| 1783 |
* <code>true</code> otherwise |
| 1784 |
* |
| 1785 |
* @since 3.6 |
| 1786 |
*/ |
| 1787 |
public void setCanceledViewer(final boolean isCancelImplicit) { |
| 1788 |
if (!isCancelImplicit) { |
| 1789 |
Display.getDefault().asyncExec(new Runnable() { |
| 1790 |
public void run() { |
| 1791 |
clearInput(); |
| 1792 |
setShowingEmptyViewer(true); |
| 1793 |
} |
| 1794 |
}); |
| 1795 |
} |
| 1796 |
} |
| 1797 |
|
| 1798 |
/** |
| 1799 |
* Returns the type hierarchy life cycle. |
| 1800 |
* |
| 1801 |
* @return the type hierarchy life cycle |
| 1802 |
* |
| 1803 |
* @since 3.6 |
| 1804 |
*/ |
| 1805 |
public TypeHierarchyLifeCycle getTypeHierarchyLifeCycle() { |
| 1806 |
return fHierarchyLifeCycle; |
| 1807 |
|
| 1808 |
} |
| 1809 |
|
| 1810 |
/** |
| 1811 |
* Sets the input for all the hierarchy viewers with their respective viewer instances. |
| 1812 |
* |
| 1813 |
* @since 3.6 |
| 1814 |
*/ |
| 1815 |
public void setViewersInput() { |
| 1816 |
for (int i= 0; i < fAllViewers.length; i++) { |
| 1817 |
fAllViewers[i].setInput(fAllViewers[i]); |
| 1818 |
} |
| 1819 |
setShowingEmptyViewer(false); |
| 1820 |
} |
| 1734 |
} |
1821 |
} |