|
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 |
String label= "Type Hierarchy computation canceled"; //$NON-NLS-1$ |
| 1798 |
fEmptyTypesViewer.setText(""); //$NON-NLS-1$ |
| 1799 |
updateMethodViewer(null); |
| 1800 |
setContentDescription(label); |
| 1801 |
setTitleToolTip(""); //$NON-NLS-1$ |
| 1802 |
for (int i= 0; i < fViewActions.length; i++) { |
| 1803 |
fViewActions[i].setEnabled(false); |
| 1804 |
} |
| 1805 |
} |
| 1806 |
setShowingEmptyViewer(true); |
| 1807 |
} |
| 1808 |
}); |
| 1809 |
} |
| 1810 |
|
| 1811 |
/** |
| 1812 |
* Returns the type hierarchy life cycle. |
| 1813 |
* |
| 1814 |
* @return the type hierarchy life cycle |
| 1815 |
* |
| 1816 |
* @since 3.6 |
| 1817 |
*/ |
| 1818 |
public TypeHierarchyLifeCycle getTypeHierarchyLifeCycle() { |
| 1819 |
return fHierarchyLifeCycle; |
| 1820 |
|
| 1821 |
} |
| 1822 |
|
| 1823 |
/** |
| 1824 |
* Sets the input for all the hierarchy viewers with their respective viewer instances. |
| 1825 |
* |
| 1826 |
* @since 3.6 |
| 1827 |
*/ |
| 1828 |
public void setViewerInput() { |
| 1829 |
for (int i= 0; i < fAllViewers.length; i++) { |
| 1830 |
fAllViewers[i].setInput(fAllViewers[i]); |
| 1831 |
} |
| 1832 |
setShowingEmptyViewer(false); |
| 1833 |
} |
| 1734 |
} |
1834 |
} |