-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathPyShowHierarchy.java
More file actions
96 lines (82 loc) · 3.91 KB
/
PyShowHierarchy.java
File metadata and controls
96 lines (82 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Eclipse Public License (EPL).
* Please see the license.txt included with this distribution for details.
* Any modifications to this file must keep this entire header intact.
*/
package com.python.pydev.actions;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.python.pydev.core.log.Log;
import org.python.pydev.core.uiutils.AsynchronousProgressMonitorDialog;
import org.python.pydev.editor.actions.PyAction;
import org.python.pydev.editor.actions.refactoring.PyRefactorAction;
import org.python.pydev.editor.refactoring.AbstractPyRefactoring;
import org.python.pydev.editor.refactoring.HierarchyNodeModel;
import org.python.pydev.editor.refactoring.IPyRefactoring;
import org.python.pydev.editor.refactoring.IPyRefactoring2;
import org.python.pydev.editor.refactoring.RefactoringRequest;
import com.python.pydev.ui.hierarchy.PyHierarchyView;
/**
*
* Based on
* org.eclipse.jdt.ui.actions.OpenTypeHierarchyAction
* org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil
* @author fabioz
*
*/
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);
}
} catch (Exception e) {
Log.log(e);
}
}
};
boolean fork = true;
monitorDialog.run(fork, true, operation);
} catch (Throwable e) {
Log.log(e);
}
} catch (Exception e) {
Log.log(e);
}
return "";
}
}