public class PyShowHierarchy extends PyRefactorAction {
@Override
protected String perform(IAction action, IProgressMonitor monitor) throws Exception {
try {
final PyHierarchyView view;
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
view = (PyHierarchyView) page.showView("com.python.pydev.ui.hierarchy.PyHierarchyView", null,
IWorkbenchPage.VIEW_VISIBLE);
ProgressMonitorDialog monitorDialog = new AsynchronousProgressMonitorDialog(PyAction.getShell());
try {
IRunnableWithProgress operation = new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
try {
final HierarchyNodeModel model;
//set whatever is needed for the hierarchy
IPyRefactoring pyRefactoring = AbstractPyRefactoring.getPyRefactoring();
if (pyRefactoring instanceof IPyRefactoring2) {
RefactoringRequest refactoringRequest = getRefactoringRequest(monitor);
IPyRefactoring2 r2 = (IPyRefactoring2) pyRefactoring;
model = r2.findClassHierarchy(refactoringRequest, false);
if (monitor.isCanceled()) {
return;
}
Runnable r = new Runnable() {
public void run() {
if (!monitor.isCanceled()) {
view.setHierarchy(model);
}
}
};
Display.getDefault().asyncExec(r);
}