Example #1
0
 public boolean performFinish() {
   try {
     String perspId = selection.getAttribute("perspectiveId"); // $NON-NLS-1$
     IWorkbenchPage page = PDEPlugin.getActivePage();
     if (perspId != null && switchPerspective) {
       PlatformUI.getWorkbench().showPerspective(perspId, page.getWorkbenchWindow());
     }
     SampleOperation op =
         new SampleOperation(selection, namesPage.getProjectNames(), new ImportOverwriteQuery());
     getContainer().run(true, true, op);
     IFile sampleManifest = op.getSampleManifest();
     if (selectRevealEnabled) {
       selectReveal(getShell());
     }
     if (activitiesEnabled) enableActivities();
     if (sampleEditorNeeded && sampleManifest != null) IDE.openEditor(page, sampleManifest, true);
   } catch (InvocationTargetException e) {
     PDEPlugin.logException(e);
     return false;
   } catch (InterruptedException e) {
     // PDEPlugin.logException(e);
     return false;
   } catch (CoreException e) {
     PDEPlugin.logException(e);
     return false;
   } catch (OperationCanceledException e) {
     return false;
   }
   return true;
 }
Example #2
0
  @Override
  public void init(ICommonActionExtensionSite extensionSite) {
    this.extensionSite = extensionSite;
    ICommonViewerSite viewSite = extensionSite.getViewSite();
    if (viewSite instanceof ICommonViewerWorkbenchSite) {
      page = ((ICommonViewerWorkbenchSite) viewSite).getPage();
      IWorkbenchWindow window = page.getWorkbenchWindow();

      showDlgAction = ActionFactory.NEW.create(window);

      CDOCheckoutContentProvider contentProvider = getContentProvider();
      IWizardRegistry wrapperRegistry = new WizardRegistryWrapper(contentProvider);

      newWizardActionGroup =
          new WizardActionGroup(
              window,
              wrapperRegistry,
              WizardActionGroup.TYPE_NEW,
              extensionSite.getContentService());

      viewer = (TreeViewer) extensionSite.getStructuredViewer();
      viewer.addSelectionChangedListener(this);
      updateSelectedObject(viewer.getSelection());
    }
  }
 /**
  * Returns the evaluation context for the given part, or <code>null</code> if none. The evaluation
  * context corresponds to the selected stack frame in the following priority order:
  *
  * <ol>
  *   <li>stack frame in the same page
  *   <li>stack frame in the same window
  *   <li>stack frame in active page of other window
  *   <li>stack frame in page of other windows
  * </ol>
  *
  * @param part the part that the evaluation action was invoked from
  * @return the stack frame that supplies an evaluation context, or <code>null</code> if none
  */
 public IJavaScriptStackFrame getEvaluationContext(IWorkbenchPart part) {
   IWorkbenchPage page = part.getSite().getPage();
   IJavaScriptStackFrame frame = getContext(page);
   if (frame == null) {
     return getEvaluationContext(page.getWorkbenchWindow());
   }
   return frame;
 }
  /**
   * Performs this action.
   *
   * @param action the action proxy that handles the presentation portion of the action
   */
  @Override
  public void run(IAction action) {
    IPathEditorInput originalInput = (IPathEditorInput) editor.getEditorInput();
    IEditorInput input = createEditorInput(originalInput.getPath().toString());

    // check if text editor plug-in is loaded
    if (Platform.getBundle(IOperationsConstants.ID_TEXT_EDITOR_PLUGIN) != null) {
      try {
        page.closeEditor(editor, true);
        page.openEditor(input, IOperationsConstants.ID_TEXT_EDITOR, true);
      } catch (PartInitException e) {
        MessageDialog.openWarning(
            page.getWorkbenchWindow().getShell(),
            Messages.OpenInTextEditorAction_0,
            Messages.OpenInTextEditorAction_1);
      }
    } else {
      MessageDialog.openError(
          page.getWorkbenchWindow().getShell(),
          Messages.OpenInTextEditorAction_0,
          Messages.OpenInTextEditorAction_2);
    }
  }
Example #5
0
    /*
     * (non-Javadoc)
     * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime .IProgressMonitor)
     */
    public IStatus runInUIThread(IProgressMonitor monitor) {
      ISourceLookupResult result = null;
      IWorkbenchPage page = null;
      synchronized (this) {
        result = fResult;
        page = fPage;
        setDisplayInfo(null, null);
      }
      if (!monitor.isCanceled() && result != null && page != null) {
        if (result.getEditorInput() == null) {
          MessageDialog.openError(
              page.getWorkbenchWindow().getShell(),
              Messages.getString("SourceDisplayAdapter.Error_Opening_Source"), // $NON-NLS-1$
              MessageFormat.format(
                  Messages.getString("SourceDisplayAdapter.Source_Not_Located"), // $NON-NLS-1$
                  JSDebugUIPlugin.getDefault()
                      .getModelPresentation()
                      .getText(result.getArtifact())));
          return Status.CANCEL_STATUS;
        }
        // Workaround for http://support.aptana.com/asap/browse/STU-3818
        if (result.getArtifact() instanceof ISourceLink) {
          boolean oldReuseValue =
              DebugUIPlugin.getDefault()
                  .getPreferenceStore()
                  .getBoolean(IDebugUIConstants.PREF_REUSE_EDITOR);
          DebugUIPlugin.getDefault()
              .getPreferenceStore()
              .setValue(IDebugUIConstants.PREF_REUSE_EDITOR, false);
          DebugUITools.displaySource(result, page);
          DebugUIPlugin.getDefault()
              .getPreferenceStore()
              .setValue(IDebugUIConstants.PREF_REUSE_EDITOR, oldReuseValue);
        } else {
          DebugUITools.displaySource(result, page);
        }
        if (result.getArtifact() instanceof IJSScriptElement) {
          int lineNumber = ((IJSScriptElement) result.getArtifact()).getBaseLine();
          IEditorInput editorInput = result.getEditorInput();
          if (editorInput != null && lineNumber > 0) {
            IEditorPart editorPart = SourceDisplayUtil.findEditor(editorInput);
            if (editorPart != null) {
              SourceDisplayUtil.revealLineInEditor(editorPart, lineNumber);
            }
          }
        }
      }

      return Status.OK_STATUS;
    }
Example #6
0
 public SourceDisplayListener() {
   IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   fPage = window.getActivePage();
   fPage.addPartListener(this);
   fPage
       .getWorkbenchWindow()
       .getShell()
       .getDisplay()
       .asyncExec(
           new Runnable() {
             public void run() {
               partBroughtToTop(fPage.getActiveEditor());
             }
           });
 }
  private void asyncDrop(DropTargetEvent event, IWorkbenchPage page) {

    if (event.data == null) {
      event.detail = DND.DROP_NONE;
      return;
    }
    if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
      String[] fileNames = (String[]) event.data;
      if (fileNames.length == 0) {
        event.detail = DND.DROP_NONE;
        return;
      }
      File file = new File(fileNames[0]);
      if (!file.exists()) return;
      ParseFileAction pfa = (ParseFileAction) ParseFileAction.create(page.getWorkbenchWindow());
      pfa.parseFile(file);
      pfa.dispose();
    }
  }
  /**
   * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.IWorkbenchPage,
   *     org.eclipse.jface.viewers.IStructuredSelection)
   */
  public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) {
    // no selection
    if (aSelection == null || aSelection.isEmpty()) {
      return;
    }
    ISelectionService selectService = aPage.getWorkbenchWindow().getSelectionService();
    ISelection selection = selectService.getSelection();

    // test if the selection come the tree viewer in order to avoid  cycle: Diagram -> tree->
    // diagram
    // if the diagram has been selected the selection is not a TreeSelection
    if (selection instanceof ITreeSelection) {
      try {
        ISashWindowsContainer windowsContainer =
            ServiceUtilsForWorkbenchPage.getInstance().getISashWindowsContainer(aPage);

        Iterator<IEditorPart> iterPart = windowsContainer.getVisibleIEditorParts().iterator();

        while (iterPart.hasNext()) {
          IEditorPart diagramEditor = iterPart.next();
          if (diagramEditor instanceof IRevealSemanticElement) {
            if (aSelection instanceof IStructuredSelection) {
              Iterator<?> selectionIterator = aSelection.iterator();
              ArrayList<Object> semanticElementList = new ArrayList<Object>();
              while (selectionIterator.hasNext()) {
                Object currentSelection = selectionIterator.next();
                Object semanticElement = EMFHelper.getEObject(currentSelection);
                if (semanticElement != null) {
                  semanticElementList.add(semanticElement);
                }
              }
              ((IRevealSemanticElement) diagramEditor).revealSemanticElement(semanticElementList);
            }
          }
        }
      } catch (ServiceException ex) {
        // We cannot access the service registry. The PapyrusEditor is probably closed.
      } catch (Exception ex) {
        Activator.log.error("Impossible to acces to windows Container", ex); // $NON-NLS-1$
      }
    }
  }
  private void selectAndReveal(final ISelection selection) {
    // validate the input
    IWorkbenchPage page = fSite.getPage();
    if (page == null) return;

    // get all the view and editor parts
    List parts = new ArrayList();
    IWorkbenchPartReference refs[] = page.getViewReferences();
    for (int i = 0; i < refs.length; i++) {
      IWorkbenchPart part = refs[i].getPart(false);
      if (part != null) parts.add(part);
    }
    refs = page.getEditorReferences();
    for (int i = 0; i < refs.length; i++) {
      if (refs[i].getPart(false) != null) parts.add(refs[i].getPart(false));
    }

    Iterator itr = parts.iterator();
    while (itr.hasNext()) {
      IWorkbenchPart part = (IWorkbenchPart) itr.next();

      // get the part's ISetSelectionTarget implementation
      ISetSelectionTarget target = null;
      if (part instanceof ISetSelectionTarget) target = (ISetSelectionTarget) part;
      else target = (ISetSelectionTarget) part.getAdapter(ISetSelectionTarget.class);

      if (target != null) {
        // select and reveal resource
        final ISetSelectionTarget finalTarget = target;
        page.getWorkbenchWindow()
            .getShell()
            .getDisplay()
            .asyncExec(
                new Runnable() {
                  public void run() {
                    finalTarget.selectReveal(selection);
                  }
                });
      }
    }
  }
  private IEditorPart openFileInEditorWithProblemsViewOpened(String filePath) throws Exception {
    InputStream inputStream =
        MarkersRemoverValidatorIT.class.getClassLoader().getResourceAsStream(filePath);
    final IFile fileWithoutContext =
        fuseProject
            .getProject()
            .getFile(filePath.startsWith("/") ? filePath.substring(1) : filePath);
    fileWithoutContext.create(inputStream, true, new NullProgressMonitor());
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    page.closeAllPerspectives(false, false);
    PlatformUI.getWorkbench().showPerspective(FusePerspective.ID, page.getWorkbenchWindow());

    readAndDispatch(20);
    this.problemView =
        PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow()
            .getActivePage()
            .showView("org.eclipse.ui.views.ProblemView");
    readAndDispatch(20);
    IEditorPart editor = IDE.openEditor(page, fileWithoutContext, true);
    page.activate(editor);
    readAndDispatch(20);
    return editor;
  }