コード例 #1
0
 public SelectedArtifactSelectionManager getSelectedBindingManager() {
   if (selectedBindingManager == null) {
     selectedBindingManager = new SelectedArtifactSelectionManager(IBindingRipper.Utils.ripper());
     selectedBindingManager.addSelectedArtifactSelectionListener(
         new ISelectedBindingListener() {
           @Override
           public void selectionOccured(BindingRipperResult ripperResult) {
             Map<String, Object> context =
                 Maps.makeMap(DisplayCoreConstants.ripperResult, ripperResult);
             IUrlGeneratorMap urlGeneratorMap = getUrlGeneratorMap();
             IUrlGenerator urlGenerator = urlGeneratorMap.get(RepositoryConstants.entityJar);
             String hexDigest = ripperResult.hexDigest;
             String jarUrl = urlGenerator.apply(hexDigest);
             getRepository().getData(RepositoryConstants.entityJar, jarUrl, context);
           }
         });
     IWorkbench workbench = PlatformUI.getWorkbench();
     IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows();
     for (int i = 0; i < workbenchWindows.length; i++) {
       IWorkbenchWindow workbenchWindow = workbench.getWorkbenchWindows()[i];
       ISelectionService selectionService = workbenchWindow.getSelectionService();
       selectionService.addPostSelectionListener(selectedBindingManager);
     }
   }
   return selectedBindingManager;
 }
コード例 #2
0
 @Override
 public void stop(BundleContext context) throws Exception {
   plugin = null;
   if (repository != null) repository.shutdown();
   if (selectedBindingManager != null) {
     IWorkbench workbench = PlatformUI.getWorkbench();
     IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows();
     for (int i = 0; i < workbenchWindows.length; i++) {
       IWorkbenchPage page = workbench.getWorkbenchWindows()[i].getActivePage();
       page.removeSelectionListener(selectedBindingManager);
     }
   }
   super.stop(context);
 }
コード例 #3
0
ファイル: FileSearchQuery.java プロジェクト: sielay/ide_core
  private boolean isAllOpenEditorsOnWorkspace() {
    boolean onlyFilesEditorInput = true;
    IWorkbench workbench = SearchPlugin.getDefault().getWorkbench();
    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
      IWorkbenchPage[] pages = windows[i].getPages();
      for (int x = 0; x < pages.length; x++) {
        IEditorReference[] editorRefs = pages[x].getEditorReferences();
        for (int z = 0; z < editorRefs.length; z++) {
          IEditorPart ep = editorRefs[z].getEditor(false);
          if ((ep instanceof ITextEditor)) { // only dirty editors

            IEditorInput input = ep.getEditorInput();
            if (input instanceof IFileEditorInput) {
              continue;
            }
            if (input instanceof IPathEditorInput) {
              onlyFilesEditorInput = false;
            }
          }
        }
      }
    }
    return onlyFilesEditorInput;
  }
コード例 #4
0
ファイル: NewProjectWiz.java プロジェクト: sleyzerzon/soar
 /**
  * This method is called when 'Finish' button is pressed in the wizard. We will create an
  * operation and run it using wizard as execution context.
  */
 public boolean performFinish() {
   final String fileName = page.getProjectName();
   IRunnableWithProgress op =
       new IRunnableWithProgress() {
         public void run(IProgressMonitor monitor) throws InvocationTargetException {
           try {
             doFinish(fileName, monitor);
           } catch (CoreException e) {
             throw new InvocationTargetException(e);
           } finally {
             monitor.done();
           }
         }
       };
   try {
     getContainer().run(true, false, op);
     workbench.showPerspective(
         "edu.rosehulman.soar.perspective.SoarPerspectiveFactory",
         workbench.getWorkbenchWindows()[0]);
   } catch (InterruptedException e) {
     return false;
   } catch (InvocationTargetException e) {
     Throwable realException = e.getTargetException();
     MessageDialog.openError(getShell(), "Error", realException.getMessage());
     return false;
   } catch (WorkbenchException e) {
     MessageDialog.openError(getShell(), "Error", e.getMessage());
     return false;
   }
   return true;
 }
コード例 #5
0
ファイル: Editor.java プロジェクト: cwi-swat/pdb.ui
  public static void open(final IValue value) {
    if (value == null) {
      return;
    }
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

    if (win == null && wb.getWorkbenchWindowCount() != 0) {
      win = wb.getWorkbenchWindows()[0];
    }

    if (win != null) {
      final IWorkbenchPage page = win.getActivePage();

      if (page != null) {
        Display.getDefault()
            .asyncExec(
                new Runnable() {
                  public void run() {
                    try {
                      page.openEditor(new ValueEditorInput(value, true, 2), Editor.EditorId);
                    } catch (PartInitException e) {
                      PDBUIPlugin.getDefault().logException("failed to open tree editor", e);
                    }
                  }
                });
      }
    }
  }
コード例 #6
0
  public static IWorkbench getMockWorkbench(String file) {

    IWorkbench workbench = mock(IWorkbench.class);
    IWorkbenchWindow window = mock(IWorkbenchWindow.class);
    IWorkbenchPage page = mock(IWorkbenchPage.class);

    ITextEditor editor = mock(ITextEditor.class);

    IDocumentProvider docProvider = mock(IDocumentProvider.class);
    IDocument doc = mock(IDocument.class);

    IPath ipath = mock(IPath.class);
    File afile = mock(File.class);
    IFile inputFile = mock(IFile.class);

    IFileEditorInput editorInput = mock(IFileEditorInput.class);

    when(workbench.getWorkbenchWindows()).thenReturn(new IWorkbenchWindow[] {window});
    when(window.getActivePage()).thenReturn(page);
    when(page.getActiveEditor()).thenReturn(editor);

    when(editor.getEditorInput()).thenReturn(editorInput);
    when(editor.getDocumentProvider()).thenReturn(docProvider);

    when(editorInput.getFile()).thenReturn(inputFile);
    when(docProvider.getDocument(any())).thenReturn(doc);

    when(inputFile.getLocation()).thenReturn(ipath);
    when(inputFile.getName()).thenReturn(file);

    when(ipath.toFile()).thenReturn(afile);
    when(afile.length()).thenReturn(33l);

    return workbench;
  }
コード例 #7
0
  /**
   * Provide the initialization of the listeners additions. The Window, Part, and Document Listener
   * are added. Note that sensor shell should be instantiated before this method is called because
   * <code>processActivity()</code> method uses sensor shell instance.
   */
  private void registerListeners() {
    IWorkbench workbench = EclipseSensorPlugin.getInstance().getWorkbench();

    // :RESOLVED: JULY 1, 2003
    // Supports the multiple window for sensor collection.
    IWorkbenchWindow[] activeWindows = workbench.getWorkbenchWindows();

    // Check if window listener is not added yet. Otherwise multi instances are notified.
    if (this.windowListener == null) {
      this.windowListener = new WindowListenerAdapter();
      workbench.addWindowListener(new WindowListenerAdapter());
    }

    for (int i = 0; i < activeWindows.length; i++) {
      IWorkbenchPage activePage = activeWindows[i].getActivePage();
      activePage.addPartListener(new PartListenerAdapter());
      IEditorPart activeEditorPart = activePage.getActiveEditor();

      // Adds this EclipseSensorPlugin instance to IDocumentListener
      // only when activeEditorPart is the instance of ITextEditor
      // so that null case is also ignored.
      if (activeEditorPart instanceof ITextEditor) {
        // Sets activeTextEditor. Otherwise a first activated file would not be recorded.
        this.activeTextEditor = (ITextEditor) activeEditorPart;
        // Gets opened file since the initial opened file is not notified from IPartListener.
        URI fileResource = EclipseSensor.this.getFileResource(this.activeTextEditor);

        Map<String, String> keyValueMap = new HashMap<String, String>();
        keyValueMap.put(EclipseSensorConstants.SUBTYPE, "Open");
        keyValueMap.put(EclipseSensorConstants.UNIT_TYPE, EclipseSensorConstants.FILE);
        keyValueMap.put(
            EclipseSensorConstants.UNIT_NAME, EclipseSensor.this.extractFileName(fileResource));
        this.addDevEvent(
            EclipseSensorConstants.DEVEVENT_EDIT,
            fileResource,
            keyValueMap,
            "Opened " + fileResource.toString());

        IDocumentProvider provider = this.activeTextEditor.getDocumentProvider();
        IDocument document = provider.getDocument(activeEditorPart.getEditorInput());

        // Initially sets active buffer and threshold buffer.
        // Otherwise a first activated buffer would not be recorded.
        this.activeBufferSize = document.getLength();
        this.thresholdBufferSize = document.getLength();
        document.addDocumentListener(new DocumentListenerAdapter());
      }
    }

    // Handles breakpoint set/unset event.
    IBreakpointManager bpManager = DebugPlugin.getDefault().getBreakpointManager();
    bpManager.addBreakpointListener(new BreakPointerSensor(this));

    // Listens to debug event.
    DebugPlugin.getDefault().addDebugEventListener(new DebugSensor(this));

    // Creates instance to handle build error.
    this.buildErrorSensor = new BuildErrorSensor(this);
  }
コード例 #8
0
 /** Start the manager */
 public void start() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
   for (int i = 0; i < windows.length; i++) {
     instance.windowOpened(windows[i]);
   }
   workbench.addWindowListener(this);
   instance.activewindow = workbench.getActiveWorkbenchWindow();
 }
コード例 #9
0
ファイル: Q7UIPlugin.java プロジェクト: xored/rcptt
 public static IWorkbenchWindow getActiveWindow() {
   IWorkbench workbench = getDefault().getWorkbench();
   IWorkbenchWindow active = workbench.getActiveWorkbenchWindow();
   if (active == null) {
     IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
     if (windows.length == 0)
       throw new RuntimeException(Messages.Q7UIPlugin_NoActiveWindowErrorMsg);
     return windows[0];
   }
   return active;
 }
コード例 #10
0
ファイル: DBeaverUI.java プロジェクト: ralic/dbeaver
 @NotNull
 public static IWorkbenchWindow getActiveWorkbenchWindow() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   if (window != null) {
     return window;
   }
   IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
   if (windows.length > 0) {
     return windows[0];
   }
   throw new IllegalStateException("No workbench window");
 }
コード例 #11
0
ファイル: LejosPlugin.java プロジェクト: jpbonn/lejos_rcx
  private IEditorInput getEditorInput() throws IOException {
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow[] wws = wb.getWorkbenchWindows();
    if (wws.length != 1) throw new IOException("Failed to find workbench window");
    IWorkbenchWindow ww = wws[0];

    IWorkbenchPage[] wps = ww.getPages();
    if (wws.length != 1) throw new IOException("Failed to find workbench page");
    IWorkbenchPage wp = wps[0];

    IEditorPart ep = wp.getActiveEditor();
    if (ep == null) throw new IOException("Failed to find active editor");
    return ep.getEditorInput();
  }
コード例 #12
0
    /**
     * Posts the update code "behind" the running operation.
     *
     * @param runnable the update code
     */
    protected void update(Runnable runnable) {

      if (runnable instanceof SafeChange) {
        fireElementStateChanging(fileEditorInput);
      }

      IWorkbench workbench = PlatformUI.getWorkbench();
      IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
      if (windows != null && windows.length > 0) {
        Display display = windows[0].getShell().getDisplay();
        display.asyncExec(runnable);
      } else {
        runnable.run();
      }
    }
コード例 #13
0
  private IWorkbenchPage getWorkbenchPage() {
    IWorkbench workbench = PlatformUI.getWorkbench();

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
      IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
      if (windows.length == 0) return null;
      window = windows[0];
    }

    IWorkbenchPage page = window.getActivePage();
    if (page == null) return null;

    return page;
  }
コード例 #14
0
ファイル: EditorUtility.java プロジェクト: CODINGLFQ/erlide
 public static Collection<IEditorPart> getAllErlangEditors() {
   final List<IEditorPart> result = Lists.newArrayList();
   final IWorkbench workbench = ErlideUIPlugin.getDefault().getWorkbench();
   for (final IWorkbenchWindow i : workbench.getWorkbenchWindows()) {
     for (final IWorkbenchPage j : i.getPages()) {
       for (final IEditorReference editorReference : j.getEditorReferences()) {
         final IEditorPart editorPart = editorReference.getEditor(false);
         if (editorPart instanceof ErlangEditor) {
           result.add(editorPart);
         }
       }
     }
   }
   return result;
 }
コード例 #15
0
 private static IEditorPart[] getDirtyEditors(String mask) {
   List<IEditorPart> result = new ArrayList<IEditorPart>(0);
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
   for (int i = 0; i < windows.length; i++) {
     IWorkbenchPage[] pages = windows[i].getPages();
     for (int x = 0; x < pages.length; x++) {
       IEditorPart[] editors = pages[x].getDirtyEditors();
       for (int z = 0; z < editors.length; z++) {
         IEditorPart ep = editors[z];
         if (ep.getTitle().indexOf(mask) > 0) {
           result.add(ep);
         }
       }
     }
   }
   return result.toArray(new IEditorPart[result.size()]);
 }
コード例 #16
0
 /**
  * Returns an array of all editors that have an unsaved content. If the identical content is
  * presented in more than one editor, only one of those editor parts is part of the result.
  *
  * @return an array of all dirty editor parts.
  */
 public static IEditorPart[] getDirtyEditors() {
   Set<IEditorInput> inputs = new HashSet<IEditorInput>();
   List<IEditorPart> result = new ArrayList<IEditorPart>(0);
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
   for (int i = 0; i < windows.length; i++) {
     IWorkbenchPage[] pages = windows[i].getPages();
     for (int x = 0; x < pages.length; x++) {
       IEditorPart[] editors = pages[x].getDirtyEditors();
       for (int z = 0; z < editors.length; z++) {
         IEditorPart ep = editors[z];
         IEditorInput input = ep.getEditorInput();
         if (inputs.add(input)) {
           result.add(ep);
         }
       }
     }
   }
   return result.toArray(new IEditorPart[result.size()]);
 }
コード例 #17
0
 /**
  * Returns an array of all editors that have an unsaved content. If the identical content is
  * presented in more than one editor, only one of those editor parts is part of the result.
  *
  * @return an array of all dirty editor parts.
  */
 public static IEditorPart[] getDirtyEditors() {
   Set inputs = new HashSet();
   List result = new ArrayList(0);
   IWorkbench workbench = getDefault().getWorkbench();
   IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
   for (int i = 0; i < windows.length; i++) {
     IWorkbenchPage[] pages = windows[i].getPages();
     for (int x = 0; x < pages.length; x++) {
       IEditorPart[] editors = pages[x].getDirtyEditors();
       for (int z = 0; z < editors.length; z++) {
         IEditorPart ep = editors[z];
         IEditorInput input = ep.getEditorInput();
         if (!inputs.contains(input)) {
           inputs.add(input);
           result.add(ep);
         }
       }
     }
   }
   return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]);
 }
コード例 #18
0
 public void earlyStartup() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   windows = workbench.getWorkbenchWindows();
   workbench.getDisplay().asyncExec(this);
 }