public void registerCommands(CompilationUnitEditor editor) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    ICommandService commandService = (ICommandService) workbench.getAdapter(ICommandService.class);
    IHandlerService handlerService = (IHandlerService) workbench.getAdapter(IHandlerService.class);
    if (commandService == null || handlerService == null) {
      return;
    }

    if (fCorrectionHandlerActivations != null) {
      JavaPlugin.logErrorMessage("correction handler activations not released"); // $NON-NLS-1$
    }
    fCorrectionHandlerActivations = new ArrayList();

    Collection definedCommandIds = commandService.getDefinedCommandIds();
    for (Iterator iter = definedCommandIds.iterator(); iter.hasNext(); ) {
      String id = (String) iter.next();
      if (id.startsWith(COMMAND_PREFIX)) {
        boolean isAssist = id.endsWith(ASSIST_SUFFIX);
        CorrectionCommandHandler handler = new CorrectionCommandHandler(editor, id, isAssist);
        IHandlerActivation activation =
            handlerService.activateHandler(
                id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
        fCorrectionHandlerActivations.add(activation);
      }
    }
  }
  public static StatusLineContributionItem getStatusLineCItem(final String statusLineId) {
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

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

    if (page == null) return null;
    IWorkbenchPart part = page.getActivePart();
    if (part == null) return null;
    IWorkbenchPartSite site = part.getSite();

    IViewSite vSite = (IViewSite) site;

    IActionBars actionBars = vSite.getActionBars();

    if (actionBars == null) return null;

    IStatusLineManager statusLineManager = actionBars.getStatusLineManager();

    if (statusLineManager == null) return null;

    StatusLineContributionItem StatusLineCItem =
        (StatusLineContributionItem) statusLineManager.find(statusLineId);
    return StatusLineCItem;
  }
 /** @generated */
 private static boolean openEditor(IWorkbench workbench, URI fileURI) {
   IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
   IWorkbenchPage page = workbenchWindow.getActivePage();
   IEditorDescriptor editorDescriptor =
       workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
   if (editorDescriptor == null) {
     MessageDialog.openError(
         workbenchWindow.getShell(),
         Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorTitle,
         NLS.bind(
             Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorMessage,
             fileURI.toFileString()));
     return false;
   } else {
     try {
       page.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());
     } catch (PartInitException exception) {
       MessageDialog.openError(
           workbenchWindow.getShell(),
           Messages.DiagramEditorActionBarAdvisor_DefaultEditorOpenErrorTitle,
           exception.getMessage());
       return false;
     }
   }
   return true;
 }
 public void hookOnViewer(final String viewerId) {
   IWorkbench workbench = PlatformUI.getWorkbench();
   if (viewerId != null && workbench != null && workbench.getDisplay() != null) {
     Display display = workbench.getDisplay();
     Thread displayThread = display.getThread();
     if (workbench.isStarting() || !Thread.currentThread().equals(displayThread)) {
       // while workbench is starting defer hooking until later
       UIJob job =
           new UIJob(display, "viewer hooker") {
             @Override
             public IStatus runInUIThread(IProgressMonitor monitor) {
               hookOnViewer(viewerId);
               return Status.OK_STATUS;
             }
           };
       job.schedule(250);
     } else if (viewerId != null) {
       CommonNavigator navigator =
           (CommonNavigator) eu.fittest.eclipse.gui.utils.Viewer.getView(viewerId);
       if (navigator != null) {
         CommonViewer viewer = navigator.getCommonViewer();
         if (viewer != null) {
           if (this.viewer != null) {
             this.viewer.removeSelectionChangedListener(this);
           }
           requestRefresh();
           viewer.addSelectionChangedListener(this);
           this.viewer = viewer;
         }
       }
     }
   }
 }
Exemplo n.º 5
0
 @Override
 public void earlyStartup() {
   IEclipsePreferences pref = ConfigurationScope.INSTANCE.getNode(this.getClass().getName());
   if (pref.getBoolean(CFG_SHOW_PERSPECTIVE_KEY, true)) {
     pref.putBoolean(CFG_SHOW_PERSPECTIVE_KEY, false);
     try {
       pref.flush();
     } catch (BackingStoreException e) {
       Activator.error(e);
     }
     final IWorkbench workbench = PlatformUI.getWorkbench();
     workbench
         .getDisplay()
         .asyncExec(
             new Runnable() {
               public void run() {
                 IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
                 if (window != null && window.getActivePage() != null) {
                   IPerspectiveDescriptor desc =
                       PlatformUI.getWorkbench()
                           .getPerspectiveRegistry()
                           .findPerspectiveWithId(TYPESCRIPT_PERSPECTIVE_ID);
                   window.getActivePage().setPerspective(desc);
                 }
               }
             });
   }
 }
 private static ISelection getSelection() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
   ISelectionService selectionService = workbenchWindow.getSelectionService();
   ISelection selection = selectionService.getSelection();
   return selection;
 }
Exemplo n.º 7
0
 /** @see ActionDelegate#run(IAction) */
 public void run(IAction action) {
   if (this.selection instanceof StructuredSelection) {
     StructuredSelection selection = (StructuredSelection) this.selection;
     if (!selection.isEmpty()) {
       IWorkbench workbench = PlatformUI.getWorkbench();
       Shell shell = workbench.getActiveWorkbenchWindow().getShell();
       IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
       InputDialog inputDialog =
           new InputDialog(
               Activator.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell(),
               "Ingreso de version",
               "Ingrese la version a generar",
               "",
               null);
       int manual = inputDialog.open();
       if (manual == 0) {
         String value = inputDialog.getValue();
         IFolder folder = (IFolder) selection.getFirstElement();
         try {
           IFolder folder1 = folder.getFolder(new Path(value));
           folder1.create(true, false, new NullProgressMonitor());
           IFile file = folder1.getFile(new Path("000_db_version_insert.sql"));
           file.create(
               new ByteArrayInputStream(VERSION_SCRIPT.replace("DBVERSION", value).getBytes()),
               true,
               new NullProgressMonitor());
         } catch (CoreException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
         }
       }
     }
   }
 }
Exemplo n.º 8
0
  /** Hides the warning view. */
  public static void closeWarningView() {
    final IWorkbench workbench = PlatformUI.getWorkbench();

    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    final IViewPart theView = window.getActivePage().findView(warningViewID);
    window.getActivePage().hideView(theView);
  }
  private GradleProject getContext() {
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
    IWorkbenchPage page = win == null ? null : win.getActivePage();

    if (page != null) {
      ISelection selection = page.getSelection();
      if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        if (!ss.isEmpty()) {
          Object obj = ss.getFirstElement();
          if (obj instanceof IResource) {
            IResource rsrc = (IResource) obj;
            IProject prj = rsrc.getProject();
            if (prj != null) {
              return GradleCore.create(prj);
            }
          }
        }
      }
      IEditorPart part = page.getActiveEditor();
      if (part != null) {
        IEditorInput input = part.getEditorInput();
        IResource rsrc = (IResource) input.getAdapter(IResource.class);
        if (rsrc != null) {
          IProject prj = rsrc.getProject();
          if (prj != null) {
            return GradleCore.create(prj);
          }
        }
      }
    }
    return null;
  }
  private IPerspectiveDescriptor[] load() {
    Preferences store = createSessionScope();
    String[] keys;
    IPerspectiveDescriptor[] result = null;

    IWorkbench workbench = PlatformUI.getWorkbench();
    IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();

    try {
      keys = store.keys();
      result = new IPerspectiveDescriptor[keys.length];
      for (int i = 0; i < keys.length; i++) {
        String perspectiveId = keys[i];

        int pos = store.getInt(perspectiveId, 0);
        if (pos <= perspectiveList.size()) {
          perspectiveList.add(pos, perspectiveId);
        } else {
          perspectiveList.add(perspectiveId);
        }
      }
      for (int i = 0; i < perspectiveList.size(); i++) {
        String id = (String) perspectiveList.get(i);
        result[i] = registry.findPerspectiveWithId(id);
      }

    } catch (BackingStoreException e) {
      e.printStackTrace();
    }
    return result;
  }
 @Test
 public void testWorkbenchRunningPredicateFalse() {
   IWorkbench wb = mock(IWorkbench.class);
   when(wb.isClosing()).thenReturn(false);
   sut = new WorkbenchRunningPredicate(wb);
   assertTrue(sut.apply(status));
 }
Exemplo n.º 12
0
  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;
  }
Exemplo n.º 13
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;
  }
Exemplo n.º 14
0
 /** {@inheritDoc} */
 public Object executeImpl(ExecutionEvent event) {
   DirectoryDialog directoryDialog = createDirectoryDialog();
   genPath = directoryDialog.open();
   if (genPath != null) {
     org.eclipse.jubula.client.ui.rcp.utils.Utils.storeLastDirPath(
         directoryDialog.getFilterPath());
     File directory = new File(genPath);
     if (directory.list().length == 0) {
       InputDialog inputDialog =
           new InputDialog(
               getActiveShell(),
               Messages.InputDialogName,
               Messages.InputDialogMessage,
               StringConstants.EMPTY,
               new PackageNameValidator());
       if (inputDialog.open() == Window.OK) {
         genPackage = inputDialog.getValue();
         IWorkbench workbench = PlatformUI.getWorkbench();
         try {
           workbench.getProgressService().run(true, true, new ConvertProjectOperation());
         } catch (InvocationTargetException | InterruptedException e) {
           LOG.error(Messages.ErrorWhileConverting, e);
         }
       }
     } else {
       ErrorHandlingUtil.createMessageDialog(MessageIDs.E_NON_EMPTY_DIRECTORY);
     }
   }
   return null;
 }
Exemplo n.º 15
0
 protected IWorkbenchWindow getActiveWorkbenchWindow() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   if (workbench != null) {
     return workbench.getActiveWorkbenchWindow();
   }
   return null;
 }
Exemplo n.º 16
0
  /** User clicks Finish */
  @Override
  public boolean performFinish() {
    try {
      // Create file object
      IFile file = doCreateNew(new NullProgressMonitor());
      if (file == null) {
        // that's ok, as it just didn't create a file (but maybe a folder)...
        return true;
      }

      // Scroll to file in package explorer
      BasicNewResourceWizard.selectAndReveal(file, workbench.getActiveWorkbenchWindow());

      // Open editor on new file.
      IWorkbenchWindow dw = workbench.getActiveWorkbenchWindow();
      try {
        if (dw != null) {
          IWorkbenchPage page = dw.getActivePage();
          if (page != null) {
            IEditorPart openEditor = IDE.openEditor(page, file, true);
            afterEditorCreated(openEditor);
          }
        }
      } catch (PartInitException e) {
        Log.log(e);
        return false;
      }
    } catch (Exception e) {
      Log.log(e);
      return false;
    }
    return true;
  }
Exemplo n.º 17
0
 /**
  * Runs task in Eclipse progress dialog. NOTE: this call can't be canceled if it will block in IO
  */
 public static void runInProgressDialog(final DBRRunnableWithProgress runnable)
     throws InvocationTargetException {
   try {
     IRunnableContext runnableContext;
     IWorkbench workbench = PlatformUI.getWorkbench();
     IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
     if (workbenchWindow != null) {
       runnableContext =
           new ProgressMonitorDialog(workbench.getActiveWorkbenchWindow().getShell());
     } else {
       runnableContext = workbench.getProgressService();
     }
     runnableContext.run(
         true,
         true,
         new IRunnableWithProgress() {
           @Override
           public void run(IProgressMonitor monitor)
               throws InvocationTargetException, InterruptedException {
             runnable.run(RuntimeUtils.makeMonitor(monitor));
           }
         });
   } catch (InterruptedException e) {
     // do nothing
   }
 }
  /* (non-Javadoc)
   * @see PerspectiveMenu#run(IPerspectiveDescriptor)
   */
  protected void run(IPerspectiveDescriptor desc) {
    //        IPreferenceStore store = PrefUtil.getInternalPreferenceStore();
    //        int mode = store.getInt(IPreferenceConstants.OPEN_PERSP_MODE);
    int mode = IPreferenceConstants.OPM_ACTIVE_PAGE;
    IWorkbenchPage page = getWindow().getActivePage();
    IPerspectiveDescriptor persp = null;
    if (page != null) {
      persp = page.getPerspective();
    }

    // Only open a new window if user preference is set and the window
    // has an active perspective.
    if (IPreferenceConstants.OPM_NEW_WINDOW == mode && persp != null) {
      try {
        IWorkbench workbench = getWindow().getWorkbench();
        IAdaptable input = ((Workbench) workbench).getDefaultPageInput();
        workbench.openWorkbenchWindow(desc.getId(), input);
      } catch (WorkbenchException e) {
        handleWorkbenchException(e);
      }
    } else {
      if (page != null) {
        page.setPerspective(desc);
      } else {
        try {
          IWorkbench workbench = getWindow().getWorkbench();
          IAdaptable input = ((Workbench) workbench).getDefaultPageInput();
          getWindow().openPage(desc.getId(), input);
        } catch (WorkbenchException e) {
          handleWorkbenchException(e);
        }
      }
    }
  }
Exemplo n.º 19
0
  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);
                    }
                  }
                });
      }
    }
  }
  @Override
  public void build() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    workbenchWindow.addPerspectiveListener(perspectiveAdapter);

    IPerspectiveDescriptor[] descriptors = load();
    for (int i = 0; i < descriptors.length; i++) {
      createPerspectiveButton(descriptors[i]);
    }

    // Button for the perspective dialog
    Composite otherBg = new Composite(background, SWT.NONE);
    otherBg.setLayout(new FormLayout());
    otherButton = new Button(otherBg, SWT.PUSH | SWT.FLAT);
    FormData fdOther = new FormData();
    otherButton.setLayoutData(fdOther);
    fdOther.left = new FormAttachment(0, left.getBounds().width);
    FormData buttonPos = getLayoutSet().getPosition(ILayoutSetConstants.PERSP_BUTTON_POS);
    fdOther.top = buttonPos.top;
    otherButton.setData(RWT.CUSTOM_VARIANT, "perspective"); // $NON-NLS-1$
    otherButton.setText(Messages.get().PerspectiveSwitcherBuilder_Other);
    IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();
    final IWorkbenchAction perspectiveAction =
        ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(activeWindow);
    otherButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            perspectiveAction.run();
          }
        });
  }
Exemplo n.º 21
0
 /**
  * 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;
 }
Exemplo n.º 22
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;
 }
  /**
   * 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);
  }
Exemplo n.º 24
0
 private DartKeyBindingPersistence getBindingPersist() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IActivityManager act = workbench.getActivitySupport().getActivityManager();
   IBindingService bind = (IBindingService) workbench.getService(IBindingService.class);
   ICommandService cmd = (ICommandService) workbench.getService(ICommandService.class);
   DartKeyBindingPersistence persist = new DartKeyBindingPersistence(act, bind, cmd);
   return persist;
 }
 /** 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();
 }
Exemplo n.º 26
0
 public void dispose() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
   workbenchWindow.removePerspectiveListener(perspectiveAdapter);
   Composite parent = getParent();
   if (parent != null && !parent.isDisposed()) {
     parent.dispose();
   }
 }
 @Override
 public void run() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
   IEditorPart editorPart = page.getActiveEditor();
   if (editorPart instanceof MultiPageTalendEditor) {
     ((MultiPageTalendEditor) editorPart).showCodePage();
   }
 }
 private void switchPerspective(final String perspectiveId) {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   try {
     workbench.showPerspective(perspectiveId, window);
   } catch (WorkbenchException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 29
0
 public void openStackAnalyzer() {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   try {
     workbench.showPerspective(PerspectiveStackAnalyzer.ID, window);
   } catch (WorkbenchException e) {
     System.out.println("Unable to open Perspective: " + PerspectiveStackAnalyzer.ID);
   }
 }
Exemplo n.º 30
0
 /** Called when the action is executed. */
 public void run(IAction action) {
   wizard = new P5ExportWizard();
   IWorkbench wb = PlatformUI.getWorkbench();
   wizard.init(wb, null);
   Shell shell = wb.getActiveWorkbenchWindow().getShell();
   WizardDialog wd = new WizardDialog(shell, wizard);
   wd.open();
   // System.err.println("WIZARD="+wizard);
 }