Search in sources :

Example 1 with PyHierarchyView

use of com.python.pydev.ui.hierarchy.PyHierarchyView in project Pydev by fabioz.

the class PyShowHierarchy method perform.

@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(EditorUtils.getShell());
        try {
            IRunnableWithProgress operation = new IRunnableWithProgress() {

                @Override
                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() {

                                @Override
                                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 "";
}
Also used : PyHierarchyView(com.python.pydev.ui.hierarchy.PyHierarchyView) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AsynchronousProgressMonitorDialog(org.python.pydev.shared_ui.utils.AsynchronousProgressMonitorDialog) RefactoringRequest(org.python.pydev.ast.refactoring.RefactoringRequest) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) AsynchronousProgressMonitorDialog(org.python.pydev.shared_ui.utils.AsynchronousProgressMonitorDialog) IPyRefactoring(org.python.pydev.ast.refactoring.IPyRefactoring) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel) IPyRefactoring2(org.python.pydev.ast.refactoring.IPyRefactoring2) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Aggregations

PyHierarchyView (com.python.pydev.ui.hierarchy.PyHierarchyView)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 HierarchyNodeModel (org.python.pydev.ast.refactoring.HierarchyNodeModel)1 IPyRefactoring (org.python.pydev.ast.refactoring.IPyRefactoring)1 IPyRefactoring2 (org.python.pydev.ast.refactoring.IPyRefactoring2)1 RefactoringRequest (org.python.pydev.ast.refactoring.RefactoringRequest)1 AsynchronousProgressMonitorDialog (org.python.pydev.shared_ui.utils.AsynchronousProgressMonitorDialog)1