示例#1
0
  @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() {

              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 "";
  }
示例#2
0
 /**
  * Display gmon results in the GProf View. NOTE: this method has to be called from within the UI
  * thread.
  *
  * @param decoder
  * @param id Secondary id, usually path to gmon file.
  */
 public static GmonView displayGprofView(GmonDecoder decoder, String id) {
   GmonView gmonview = null;
   try {
     IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
     IWorkbenchPage page = window.getActivePage();
     if (id != null) {
       id = id.replace('.', '_');
       id = id.replace(':', '_');
     }
     gmonview = (GmonView) page.showView(ID, id, IWorkbenchPage.VIEW_ACTIVATE);
     if (decoder.getHistogramDecoder().getProfRate() == 0) {
       gmonview.switchSampleTime.setToolTipText(
           "Unable to display time, because profiling rate is null"); //$NON-NLS-1$
       gmonview.switchSampleTime.setEnabled(false);
     }
     gmonview.setInput(decoder);
     GmonView.setHistTitle(decoder, gmonview.label);
     if (!decoder.getHistogramDecoder().hasValues()) {
       gmonview.action1.setChecked(true);
       gmonview.action2.setChecked(false);
       gmonview.action1.run();
     }
   } catch (CoreException e) {
     Status status =
         new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
     Activator.getDefault().getLog().log(status);
   }
   return gmonview;
 }
  /** Open a new Window with the visualization of the selected information. */
  @Override
  public void run() {

    if (window == null) {
      return;
    }

    // get the activate page
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
      return;
    }
    IViewPart view = page.findView(ConstraintView.ID);
    if (view == null) {
      return;
    }

    if (!page.isPartVisible(view)) {
      // use the Resource Manager View id to open up view
      try {
        view = page.showView(ConstraintView.ID);
      } catch (PartInitException e) {
        System.err.println("Failed to open the Constrains View " + e);
      }
    }
    // Refresh the View
    if (view instanceof ConstraintView) ((ConstraintView) view).refresh();

    // Set Focus
    page.activate(view);
  }
  /**
   * The action has been activated. The argument of the method represents the 'real' action sitting
   * in the workbench UI.
   *
   * @see IWorkbenchWindowActionDelegate#run
   */
  public void run(IAction action) {

    try {
      IWorkbenchPage page = window.getActivePage();
      page.showView(SimpleEditor.ID);
    } catch (PartInitException e) {

    }
  }
示例#5
0
  /** If the console view is hidden, it is put to the front and focus is set on it. */
  private void putConsoleToForeground() throws PartInitException {
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

    IWorkbenchPage page = win.getActivePage(); // obtain the active page
    String id = IConsoleConstants.ID_CONSOLE_VIEW;
    IConsoleView view = (IConsoleView) page.showView(id);
    view.display(console);
  }
 /* (non-Javadoc)
  * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
  */
 public void run(IAction action) {
   if (security != null) {
     IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
     try {
       page.showView(
           ChartView.VIEW_ID, String.valueOf(security.getId()), IWorkbenchPage.VIEW_ACTIVATE);
     } catch (PartInitException e) {
       CorePlugin.logException(e);
     }
   }
 }
 public static void openARESConsole() {
   IConsole myConsole = getConsole();
   IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
   String id = IConsoleConstants.ID_CONSOLE_VIEW;
   IConsoleView view;
   try {
     view = (IConsoleView) page.showView(id, null, IWorkbenchPage.VIEW_CREATE);
     view.display(myConsole);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
 public static void show() {
   IWorkbench wb = PlatformUI.getWorkbench();
   IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage();
   if (wbPage != null) {
     try {
       IConsoleView conView = (IConsoleView) wbPage.showView(IConsoleConstants.ID_CONSOLE_VIEW);
       conView.display(getRhinoConsole());
     } catch (PartInitException e) {
       PluginLogger.log("Console.show() - PartInitException: " + e.getMessage());
     }
   }
 }
示例#9
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   IWorkbenchPage page = window.getActivePage();
   try {
     page.showView(PvSearchView.VIEW_ID);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   return null;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  public void run() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
      page.showView(getViewId());

    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      ExceptionHandler.process(e);
    }
  }
 @SuppressWarnings("deprecation")
 public void run(IAction action) {
   try {
     if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
     final IWorkbenchPage page = window.getActivePage();
     page.showView(IPageLayout.ID_RES_NAV);
   } catch (WorkbenchException e) {
     final String message = NLS.bind("Failed to open navigator. \n{0}", e.getMessage());
     MessageDialog.openError(null, "Error", message);
     OPIBuilderPlugin.getLogger().log(Level.WARNING, message, e);
   }
 }
示例#12
0
  /**
   * Shows the view specified
   *
   * @param viewID
   * @return whether the view was shown
   */
  public static boolean showView(String viewID, int mode) {
    IWorkbenchPage activePage = getActivePage();
    if (activePage != null) {
      try {
        return activePage.showView(viewID, null, mode) != null;
      } catch (PartInitException e) {
        return false;
      }
    }

    return false;
  }
  @Test
  public void testFilter() throws CoreException {
    IPerspectiveDescriptor persDescription =
        PlatformUI.getWorkbench()
            .getPerspectiveRegistry()
            .findPerspectiveWithId(JavaUI.ID_PERSPECTIVE);
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    page.setPerspective(persDescription);
    IViewPart arquilliaView = page.showView(ArquillianView.ID);
    try {
      assertTrue(arquilliaView instanceof CommonNavigator);
      PackageExplorerPart packageView = (PackageExplorerPart) page.showView(JavaUI.ID_PACKAGES);
      IProject project = getProject(TEST_PROJECT_NAME);
      packageView.selectAndReveal(project);

      CommonNavigator navigator = (CommonNavigator) arquilliaView;
      CommonViewer viewer = navigator.getCommonViewer();
      TreeItem[] items = viewer.getTree().getItems();
      assertTrue(items.length == 1);
      ViewerFilter[] filters = viewer.getFilters();
      assertTrue(filters.length > 0);
      WorkingSetFilter activeFilter = null;
      List<ViewerFilter> newFilters = new ArrayList<ViewerFilter>();
      int i = 0;
      for (ViewerFilter filter : filters) {
        if (!(filter instanceof ActiveProjectFilter)) {
          newFilters.add(filter);
        }
      }
      newFilters.add(new WorkingSetFilter());
      viewer.setFilters(newFilters.toArray(new ViewerFilter[0]));

      items = viewer.getTree().getItems();
      assertTrue("Invalid filter", items.length == 2);
    } finally {
      if (arquilliaView != null) {
        page.hideView(arquilliaView);
      }
    }
  }
示例#14
0
 /**
  * Display the evaluation result
  *
  * @param result An {@link IWatchExpressionResult}.
  */
 protected void displayResult(IWatchExpressionResult result) {
   IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   if (activeWorkbenchWindow != null) {
     IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
     if (activePage != null) {
       try {
         activePage.showView(IDebugUIConstants.ID_EXPRESSION_VIEW);
       } catch (PartInitException e) {
         PHPDebugEPLPlugin.logError(e.getMessage(), e);
       }
     }
   }
 }
 private void showForgeView() {
   IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   if (workbenchWindow != null) {
     IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
     if (workbenchPage != null) {
       try {
         workbenchPage.showView((ForgeConsoleView.ID));
       } catch (PartInitException e) {
         ForgeUIPlugin.log(e);
       }
     }
   }
 }
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    final IWorkbenchPage page = window.getActivePage();
    try {
      page.showView(ChangelogViewPart.ID);
    } catch (final PartInitException e) {
      e.printStackTrace();
    }
    return null;
  }
示例#17
0
 /**
  * Open the view
  *
  * @return {@link IViewPart} or <code>null</code>
  */
 @SuppressWarnings("nls")
 protected final IViewPart doShowView() {
   final IWorkbench workbench = PlatformUI.getWorkbench();
   final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   try {
     final IWorkbenchPage page = window.getActivePage();
     return page.showView(id);
   } catch (Exception ex) {
     ExceptionDetailsErrorDialog.openError(
         window.getShell(), "Error", "Error opening view '" + id + "'", ex);
   }
   return null;
 }
示例#18
0
 private void openStagingViewLinkClicked() {
   IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
   try {
     StagingView view = (StagingView) workbenchPage.showView(StagingView.VIEW_ID);
     view.reload(repository);
     String message = commitMessageComponent.getCommitMessage();
     if (message != null && message.length() > 0) view.setCommitMessage(message);
     setReturnCode(CANCEL);
     close();
   } catch (PartInitException e) {
     Activator.handleError(UIText.CommitDialog_OpenStagingViewError, e, true);
   }
 }
示例#19
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    ViewData.instance().setModel(null);

    IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
    activePage.hideView(activePage.findView(MainView.ID));
    try {
      activePage.showView(MainView.ID);
    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return null;
  }
 public void open() {
   try {
     IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
     if (activeWorkbenchWindow == null) {
       return;
     }
     IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
     if (activePage == null) {
       return;
     }
     MetamodelBrowserView metamodelBrowserView =
         (MetamodelBrowserView) activePage.showView(MetamodelBrowserView.ID);
     metamodelBrowserView.navigate(myMetamodelElement);
   } catch (PartInitException e) {
     Activator.log(e);
   }
 }
示例#21
0
  private static void basicOpenConsole() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      IWorkbenchPage page = window.getActivePage();
      if (page != null) {
        try {
          IConsole myConsole = findConsole(SQLPLUS_CONSOLE_VIEW);
          String id = IConsoleConstants.ID_CONSOLE_VIEW;
          IConsoleView view = (IConsoleView) page.showView(id);
          view.display(myConsole);

        } catch (PartInitException e) {
          ConsolePlugin.log(e);
        }
      }
    }
  }
示例#22
0
 public void run(IAction action) {
   GrxPluginManager manager_ = Activator.getDefault().manager_;
   GrxJythonPromptView jythonView =
       (GrxJythonPromptView) manager_.getView(GrxJythonPromptView.class, false);
   if (jythonView == null) {
     IWorkbench workbench = PlatformUI.getWorkbench();
     IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
     IWorkbenchPage page = window.getActivePage();
     try {
       page.showView(
           "com.generalrobotix.ui.view.GrxJythonPromptViewPart", null, IWorkbenchPage.VIEW_CREATE);
     } catch (PartInitException e1) {
       e1.printStackTrace();
     }
     jythonView = (GrxJythonPromptView) manager_.getView(GrxJythonPromptView.class, true);
   }
   if (jythonView.getEnabledExecBtn()) jythonView.selectExecBtn();
 }
示例#23
0
 private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IMemberInfo input) {
   IWorkbenchPage page = window.getActivePage();
   try {
     TypeHierarchyViewPart result =
         (TypeHierarchyViewPart) page.findView(X10Constants.ID_TYPE_HIERARCHY);
     if (result != null) {
       result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
     }
     result = (TypeHierarchyViewPart) page.showView(X10Constants.ID_TYPE_HIERARCHY);
     result.setInputElement(input);
     return result;
   } catch (CoreException e) {
     //			ExceptionHandler.handle(e, window.getShell(),
     //				Messages.OpenTypeHierarchyUtil_error_open_view, e.getMessage());
     X10DTUIPlugin.log(e);
   }
   return null;
 }
示例#24
0
 /**
  * Opens the internal HelpView and address it to the given doc url.
  *
  * @param url
  */
 public static void openHelp(String url) {
   IWorkbenchPage page = getActivePage();
   if (page != null) {
     try {
       IViewPart part = page.showView(HELP_VIEW_ID);
       if (part != null) {
         HelpView view = (HelpView) part;
         view.showHelp(url);
       }
     } catch (PartInitException e) {
       IdeLog.logError(UIPlugin.getDefault(), e);
     }
   } else {
     IdeLog.logWarning(
         UIPlugin.getDefault(),
         "Could not open the help view. Active page was null."); //$NON-NLS-1$
   }
 }
示例#25
0
 protected static IViewPart createNewView() {
   IWorkbenchPage activePage =
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
   int nbView = 0;
   for (IViewReference ref : activePage.getViewReferences()) {
     if (ref.getId().startsWith(VIEW_ID)) {
       nbView++;
     }
   }
   // increment to have the second view named #2
   nbView++;
   IViewPart view = null;
   try {
     view = activePage.showView(VIEW_ID, VIEW_ID + "_" + nbView, IWorkbenchPage.VIEW_ACTIVATE);
     // view.
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   return view;
 }
  public void showHistory() throws EmfStoreException {
    if (projectSpace == null) {
      projectSpace =
          WorkspaceManager.getInstance()
              .getCurrentWorkspace()
              .getProjectSpace(ModelUtil.getProject(modelElement));
    }

    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    HistoryBrowserView historyBrowserView = null;
    String viewId =
        "org.eclipse.emf.emfstore.client.ui.views.historybrowserview.HistoryBrowserView";
    try {
      historyBrowserView = (HistoryBrowserView) page.showView(viewId);
    } catch (PartInitException e) {
      EMFStoreMessageDialog.showExceptionDialog(e);
    }
    if (historyBrowserView != null) {
      historyBrowserView.setInput(projectSpace, modelElement);
    }
  }
  // print to stream, lazily instantiating and opening console if necessary
  private void print(final LoggingEvent event) {
    // ensure in UI thread
    assert Display.getCurrent() != null;

    // ensure console view is open
    if (WorkbenchUtil.getView(IConsoleConstants.ID_CONSOLE_VIEW) == null) {
      try {
        IWorkbenchPage activePage = WorkbenchUtil.getActivePage();
        if (activePage != null) {
          activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW);
        }
      } catch (PartInitException pie) {
        // ignore for now
      }
    }

    // lazily instantiate console if necessary
    if (_consoleStream == null) {
      IConsoleManager mgr = ConsolePlugin.getDefault().getConsoleManager();
      MessageConsole logConsole =
          new MessageConsole(
              Activator.getResourceString("MessageConsoleAppender.Log"), // $NON-NLS-1$
              null);
      mgr.addConsoles(new IConsole[] {logConsole});
      mgr.showConsoleView(logConsole);
      _consoleStream = logConsole.newMessageStream();
    }

    // print message
    _consoleStream.print(getLayout().format(event));
    if (getLayout().ignoresThrowable()) {
      String[] lines = event.getThrowableStrRep();
      if (lines != null) {
        for (String line : lines) {
          _consoleStream.println(line);
        }
      }
    }
  }
  public void testSelection() throws Exception {

    structureModelBridge = new EcoreGmfDomainBridge();

    activeContext = ContextCore.getContextManager().getActiveContext();
    assertNotNull(activeContext);

    monitor = new DiagramUiEditingMonitor(structureModelBridge, EcoreDiagramUiBridge.getInstance());
    MonitorUi.getSelectionMonitors().add(monitor);

    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }

    IFile file = getEmfProject().getProject().getFile("model/library.ecorediag");
    assertNotNull(file);

    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
    }

    StructuredSelection selection = new StructuredSelection(file);

    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    ProjectExplorer pe =
        (ProjectExplorer) page.showView("org.eclipse.ui.navigator.ProjectExplorer");
    pe.getCommonViewer().setSelection(selection);
    monitor.handleWorkbenchPartSelection(pe, selection, true);

    //		assertNotNull(activeContext);
    //		assertEquals(activeContext.getAllElements().size(), 1);
    //		//should this be resource type?
    //		assertEquals(activeContext.getAllElements().get(0).getContentType(), "ecore");
    //		assertEquals(activeContext.getAllElements().get(0).getHandleIdentifier(),
    //				"/org.eclipse.mylyn.modeling.tests.ecorediagram/model/library.ecore");
    //		assertTrue(activeContext.getAllElements().get(0).getInterest().isInteresting());
  }
  /** Shows the current selection (if valid) in the transformed data view. */
  private void showSelectionInDataView() {
    InstanceSelection selection = getValidSelection();
    if (selection != null) {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

      // pin the property sheet if possible
      IViewReference ref = page.findViewReference(IPageLayout.ID_PROP_SHEET);
      if (ref != null) {
        IViewPart part = ref.getView(true);
        if (part instanceof PropertySheet) ((PropertySheet) part).setPinned(true);
      }

      // show transformed data view with selection if possible
      try {
        TransformedDataView transformedDataView =
            (TransformedDataView) page.showView(TransformedDataView.ID);
        transformedDataView.showSelection(selection, reportImage);
      } catch (PartInitException e) {
        // if it's not there, we cannot do anything
      }
    }
  }
  @Override
  public void loadPixelPerfectData(IHvDevice device) {
    super.loadPixelPerfectData(device);

    // The windows tab hides the tree tab, so let's bring the tree tab
    // forward.

    IWorkbenchWindow[] windows =
        HierarchyViewerPlugin.getPlugin().getWorkbench().getWorkbenchWindows();
    for (IWorkbenchWindow window : windows) {
      IWorkbenchPage page = window.getActivePage();
      if (page.getPerspective().getId().equals(PixelPerfectPespective.ID)) {
        try {
          IWorkbenchPart part = page.findView(PixelPerfectTreeView.ID);
          if (part != null) {
            page.showView(PixelPerfectTreeView.ID);
          }
        } catch (PartInitException e) {

        }
      }
    }
  }