Java Code Examples for org.eclipse.ui.IWorkbenchWindow

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/handlers/.

Source file: OpenHandler.java

  23 
vote

public Object execute(ExecutionEvent event) throws ExecutionException {
  IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindow(event);
  Drawing drawing=obtainDrawing(window.getShell());
  if (drawing != null) {
    try {
      window.getActivePage().openEditor(new DrawingInput(drawing),DrawingEditor.EDITOR_ID);
      if (drawing.isCenterToOpen())       centerDrawingOnOpen(drawing);
    }
 catch (    PartInitException e) {
      throw new ExecutionException("Can't open the file. Couldn't initialize the editor.",e);
    }
  }
  return null;
}
 

Example 2

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.sdk.ui/src/com/amazonaws/eclipse/sdk/ui/wizard/.

Source file: NewAwsJavaProjectWizard.java

  22 
vote

private IWorkbenchPart getActivePart(){
  IWorkbenchWindow activeWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (activeWindow != null) {
    IWorkbenchPage activePage=activeWindow.getActivePage();
    if (activePage != null) {
      return activePage.getActivePart();
    }
  }
  return null;
}
 

Example 3

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/.

Source file: Activator.java

  22 
vote

/** 
 * Returns the  {@link Shell shell} associated with the editor's activewindow.
 * @return {@link Shell}; may be null
 */
public Shell getShell(){
  IWorkbench workbench=this.getWorkbench();
  IWorkbenchWindow window=workbench.getActiveWorkbenchWindow();
  if (window == null)   return null;
  return window.getShell();
}
 

Example 4

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/launch/.

Source file: BPELLaunchMainTab.java

  22 
vote

public static IWorkbenchPage getActivePage(){
  IWorkbenchWindow w=getActiveWorkbenchWindow();
  if (w != null) {
    return w.getActivePage();
  }
  return null;
}
 

Example 5

From project bundlemaker, under directory /main/org.bundlemaker.core.ui/src/org/bundlemaker/core/ui/internal/.

Source file: Activator.java

  22 
vote

/** 
 * @return the {@link ISelectionService} or null
 */
private ISelectionService getSelectionService(){
  IWorkbenchWindow workbenchWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (workbenchWindow != null) {
    return workbenchWindow.getSelectionService();
  }
  return null;
}
 

Example 6

From project ccw, under directory /ccw.leiningen/src/java/ccw/leiningen/.

Source file: NewLeiningenProjectWizard.java

  22 
vote

private static void openInNewWindow(IPerspectiveDescriptor desc){
  try {
    PlatformUI.getWorkbench().openWorkbenchWindow(desc.getId(),ResourcesPlugin.getWorkspace().getRoot());
  }
 catch (  WorkbenchException e) {
    IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      ErrorDialog.openError(window.getShell(),WINDOW_PROBLEMS_TITLE,e.getMessage(),e.getStatus());
    }
  }
}
 

Example 7

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: Util.java

  22 
vote

public static IWorkbenchPage getActivePage(){
  try {
    IWorkbenchWindow window=getWorkbench().getActiveWorkbenchWindow();
    return window == null ? null : window.getActivePage();
  }
 catch (  IllegalStateException ise) {
    return null;
  }
}
 

Example 8

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/.

Source file: PreferenceGuiAlgorithm.java

  22 
vote

private Shell getParentShell(){
  IWorkbench workbench=PlatformUI.getWorkbench();
  IWorkbenchWindow[] windows=workbench.getWorkbenchWindows();
  IWorkbenchWindow window=windows[0];
  Shell parentShell=window.getShell();
  return parentShell;
}
 

Example 9

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/util/.

Source file: EclipseUtils.java

  22 
vote

/** 
 * @return IWorkbenchPage
 */
public static IWorkbenchPage getActivePage(){
  final IWorkbench bench=PlatformUI.getWorkbench();
  if (bench == null)   return null;
  final IWorkbenchWindow window=bench.getActiveWorkbenchWindow();
  if (window == null)   return null;
  return window.getActivePage();
}
 

Example 10

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.ui/src/main/java/com/isencia/passerelle/workbench/model/ui/utils/.

Source file: EclipseUtils.java

  22 
vote

/** 
 * @return IWorkbenchPage
 */
public static IWorkbenchPage getActivePage(){
  final IWorkbench bench=PlatformUI.getWorkbench();
  if (bench == null)   return null;
  final IWorkbenchWindow window=bench.getActiveWorkbenchWindow();
  if (window == null)   return null;
  return window.getActivePage();
}
 

Example 11

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/ui/internal/.

Source file: SketchUI.java

  22 
vote

@Override public void run(){
  IWorkbenchWindow window=SketchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
  ICommandService service=(ICommandService)window.getService(ICommandService.class);
  if (service != null) {
    service.refreshElements("ca.uvic.chisel.javasketch.packageExplorerFilter",null);
    service.refreshElements(TraceCommandHandler.COMMAND_ID,null);
    service.refreshElements(TraceDurationCommandHandler.COMMAND_ID,null);
  }
}
 

Example 12

From project dolphin, under directory /com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/actions/.

Source file: TomcatProjectAbstractActionDelegate.java

  22 
vote

protected TomcatProject getCurrentSelection(){
  IWorkbenchWindow window=JavaPlugin.getActiveWorkbenchWindow();
  TomcatProject result=null;
  if (window != null) {
    ISelection selection=window.getSelectionService().getSelection();
    if (selection instanceof IStructuredSelection) {
      Object project=((IStructuredSelection)selection).getFirstElement();
      if (project instanceof IProject)       result=TomcatProject.create((IProject)project);
      if (project instanceof IJavaProject)       result=TomcatProject.create((IJavaProject)project);
    }
  }
  return result;
}
 

Example 13

From project dozer, under directory /eclipse-plugin/net.sf.dozer.eclipse.plugin/src/org/dozer/eclipse/plugin/.

Source file: DozerPlugin.java

  22 
vote

public static Shell getActiveWorkbenchShell(){
  IWorkbenchWindow window=getActiveWorkbenchWindow();
  if (window != null) {
    return window.getShell();
  }
  return null;
}
 

Example 14

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/.

Source file: ActionCompletionProcessor.java

  22 
vote

public IEditorPart getEditor(){
  IWorkbench workbench=PlatformUI.getWorkbench();
  if (workbench != null) {
    IWorkbenchWindow workbenchWindow=workbench.getActiveWorkbenchWindow();
    if (workbenchWindow != null) {
      IWorkbenchPage workbenchPage=workbenchWindow.getActivePage();
      if (workbenchPage != null) {
        return workbenchPage.getActiveEditor();
      }
    }
  }
  return null;
}
 

Example 15

From project Eclipse, under directory /com.mobilesorcery.sdk.html5/src/com/mobilesorcery/sdk/html5/ui/.

Source file: ReloadHandler.java

  22 
vote

@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  if (!Html5Plugin.getDefault().shouldFetchRemotely()) {
    IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindow(event);
    MessageDialog.openInformation(window.getShell(),"Cannot refresh","Cannot reload on-device contents.\nTo enable this feature, go to \"Preferences > MoSync Tool > JavaScript On-Device Debug\" and activate \"Load source code and resources from debug server\".");
  }
  ArrayList<ReloadVirtualMachine> vms=new ArrayList<ReloadVirtualMachine>();
  extractVMs(HandlerUtil.getCurrentSelection(event),vms);
  for (  ReloadVirtualMachine vm : vms) {
    vm.reload();
  }
  return null;
}
 

Example 16

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/ui/.

Source file: InstaSearchUI.java

  22 
vote

/** 
 * Checks weather the search view is visible Note: This method must be run from the UI thread
 * @return InstaSearchView
 */
public static boolean isSearchViewVisible(){
  IWorkbenchWindow win=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (win != null && win.getActivePage() != null) {
    IViewPart view=win.getActivePage().findView(InstaSearchView.ID);
    return win.getActivePage().isPartVisible(view);
  }
  return false;
}
 

Example 17

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.tests/src/org/cloudfoundry/ide/eclipse/server/tests/sts/util/.

Source file: StsTestUtil.java

  22 
vote

public static void cleanUpProjects() throws CoreException {
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window != null) {
    IWorkbenchPage page=window.getActivePage();
    if (page != null) {
      page.closeAllEditors(false);
    }
  }
  deleteAllProjects();
}
 

Example 18

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.configurator/src/org/springsource/ide/eclipse/commons/internal/configurator/server/.

Source file: ConfigurableServerExtension.java

  22 
vote

@Override public void postConfiguration(IStatus result){
  if (result.isOK()) {
    IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      try {
        window.getActivePage().showView(ID_SERVERS_VIEW);
      }
 catch (      PartInitException e) {
      }
    }
  }
}
 

Example 19

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.ui/src/org/springsource/ide/eclipse/gradle/ui/actions/.

Source file: GradleProjectActionDelegate.java

  22 
vote

/** 
 * TODO: get rid of this method and replace its uses with a 'user' job.
 */
protected void runInUi(GradleRunnable runnable){
  IWorkbenchWindow context=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  try {
    PlatformUI.getWorkbench().getProgressService().runInUI(context,runnable,ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
  }
 catch (  Exception e) {
    GradleUI.log(e);
    String msg=ExceptionUtil.getMessage(e);
    if (msg != null) {
      MessageDialog.openError(null,runnable.toString() + " Failed",msg);
    }
  }
}
 

Example 20

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/.

Source file: OpenHaskellPerspective.java

  22 
vote

@Override public void run(){
  IWorkbenchWindow window=getWorkbench().getActiveWorkbenchWindow();
  IWorkbenchPage page=window.getActivePage();
  IAdaptable input=(page != null) ? page.getInput() : ResourcesPlugin.getWorkspace().getRoot();
  try {
    String perspectiveId=HaskellUIPlugin.ID_PERSPECTIVE;
    getWorkbench().showPerspective(perspectiveId,window,input);
  }
 catch (  WorkbenchException wbex) {
    handleError(wbex,"Could not open perspective.\nSee error log for details.");
  }
}
 

Example 21

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.tooling.gui/src/org/eclipse/viatra2/emf/incquery/queryexplorer/.

Source file: QueryExplorer.java

  22 
vote

public static QueryExplorer getInstance(){
  IWorkbenchWindow activeWorkbenchWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (activeWorkbenchWindow != null && activeWorkbenchWindow.getActivePage() != null) {
    return (QueryExplorer)activeWorkbenchWindow.getActivePage().findView(ID);
  }
  return null;
}
 

Example 22

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/common/rcp/.

Source file: CommonRCPActivator.java

  22 
vote

public static Shell getActiveWorkbenchShell(){
  IWorkbenchWindow window=getActiveWorkbenchWindow();
  if (window != null) {
    return window.getShell();
  }
  return null;
}
 

Example 23

From project hackergarten-moreunit, under directory /org.moreunit.plugin/src/org/moreunit/util/.

Source file: PluginTools.java

  22 
vote

public static IEditorPart getOpenEditorPart(){
  IWorkbench wb=PlatformUI.getWorkbench();
  IWorkbenchWindow window=wb.getActiveWorkbenchWindow();
  if (window == null)   return null;
  IWorkbenchPage page=window.getActivePage();
  if (page != null)   return page.getActiveEditor();
 else   return null;
}
 

Example 24

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/.

Source file: IvyPlugin.java

  22 
vote

/** 
 * Returns the active workbench shell
 * @return the active workbench shell
 */
public static Shell getActiveWorkbenchShell(){
  IWorkbenchWindow workBenchWindow=getActiveWorkbenchWindow();
  if (workBenchWindow == null) {
    return null;
  }
  return workBenchWindow.getShell();
}
 

Example 25

From project logsaw-app, under directory /net.sf.logsaw.ui/src/net/sf/logsaw/ui/commands/handlers/.

Source file: CopyCellContentsHandler.java

  22 
vote

@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindow(event);
  IWorkbenchPage page=window.getActivePage();
  ILogViewEditor editor=(ILogViewEditor)page.getActiveEditor().getAdapter(ILogViewEditor.class);
  if (editor != null) {
    String text=editor.getFocusCellText();
    if (text.length() > 0) {
      Clipboard cb=new Clipboard(Display.getDefault());
      TextTransfer textTransfer=TextTransfer.getInstance();
      cb.setContents(new Object[]{text},new Transfer[]{textTransfer});
    }
  }
  return null;
}
 

Example 26

From project makegood, under directory /com.piece_framework.makegood.ui/src/com/piece_framework/makegood/ui/.

Source file: ActivePart.java

  22 
vote

/** 
 * @since 1.6.0
 */
public static IWorkbenchPart getActivePart(){
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window == null)   return null;
  IWorkbenchPage page=window.getActivePage();
  if (page == null)   return null;
  return page.getActivePart();
}
 

Example 27

From project mousefeed, under directory /com.mousefeed/src/com/mousefeed/eclipse/commands/.

Source file: ConfigureActionInvocationHandler.java

  22 
vote

public Object execute(final ExecutionEvent event) throws ExecutionException {
  if (getLastAction() == null) {
    return null;
  }
  final IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindowChecked(event);
  final ConfigureActionInvocationDialog dlg=new ConfigureActionInvocationDialog(window.getShell(),getLastAction());
  dlg.open();
  return null;
}
 

Example 28

From project mylyn-mantis, under directory /com.itsolut.mantis.ui/src/com/itsolut/mantis/ui/action/.

Source file: MantisDeleteAttachmentAction.java

  22 
vote

public void run(IAction action){
  String message="";
  for (  ITaskAttachment attachment : attachments)   message+=" - " + attachment.getFileName() + " \n";
  boolean confirm=MessageDialog.openConfirm(null,"Attachment deletion","Please confirm that the following attachments will be deleted:\n\n" + message);
  if (!confirm)   return;
  TaskEditor taskEditor=null;
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  IWorkbenchPage page=window.getActivePage();
  IEditorPart activeEditor=page.getActiveEditor();
  if (activeEditor instanceof TaskEditor)   taskEditor=(TaskEditor)activeEditor;
  final DeleteAttachmentJob job=new DeleteAttachmentJob(attachments,taskEditor);
  job.setUser(true);
  job.schedule();
}
 

Example 29

From project mylyn.builds, under directory /org.eclipse.mylyn.builds.ui/src/org/eclipse/mylyn/builds/ui/.

Source file: BuildsUi.java

  22 
vote

public static void open(IBuildElement element){
  Assert.isNotNull(element);
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window != null) {
    IWorkbenchPage page=window.getActivePage();
    if (page != null) {
      List<EditorHandle> handle=OpenHandler.open(page,Collections.singletonList(element));
      if (handle.get(0).getStatus() != null && handle.get(0).getStatus().isOK()) {
        return;
      }
    }
  }
  BuildsView.openInActivePerspective();
}
 

Example 30

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/rcp/statusbar/.

Source file: StatusBarHelper.java

  21 
vote

/** 
 * This method returns the  {@link IStatusLineManager}. It may return <code>null</code>.
 * @return {@link IStatusLineManager} or <code>null</code>
 */
public static synchronized IStatusLineManager getStatusLineManager(){
  if (manager != null) {
    return manager;
  }
  manager=new NullStatusLineManager();
  IWorkbench wb=PlatformUI.getWorkbench();
  if (wb == null) {
    return manager;
  }
  IWorkbenchWindow win=wb.getActiveWorkbenchWindow();
  if (win == null) {
    return manager;
  }
  IWorkbenchPage page=win.getActivePage();
  if (page == null) {
    return manager;
  }
  IWorkbenchPart part=page.getActivePart();
  if (part == null) {
    return manager;
  }
  IWorkbenchPartSite site=part.getSite();
  if (site == null || !(site instanceof IViewSite)) {
    return manager;
  }
  IViewSite vSite=(IViewSite)site;
  IActionBars actionBars=vSite.getActionBars();
  if (actionBars == null) {
    return manager;
  }
  manager=actionBars.getStatusLineManager();
  return manager;
}
 

Example 31

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/action/.

Source file: CheatSheetAction.java

  21 
vote

public void run(String[] params,ICheatSheetManager manager){
  if (params[0].equals("opencompare")) {
    IWorkbenchWindow dw=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page=dw.getActivePage();
    try {
      page.showView("net.bioclipse.spectrum.views.SpectrumCompareView");
    }
 catch (    PartInitException e) {
      LogUtils.handleException(e,logger);
    }
  }
 else   if (params[0].equals("newspectrum")) {
    NewSpectrumWizard predwiz=new NewSpectrumWizard();
    WizardDialog wd=new WizardDialog(new Shell(),predwiz);
    wd.open();
  }
 else   if (params[0].equals("saveas")) {
    if (WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() instanceof SpectrumEditor) {
      ((SpectrumEditor)WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).doSaveAs();
    }
  }
}
 

Example 32

From project bndtools, under directory /bndtools.core/src/bndtools/editor/contents/.

Source file: GeneralInfoPart.java

  21 
vote

@Override protected List<IContentProposal> doGenerateProposals(String contents,int position){
  final String prefix=contents.substring(0,position);
  final IJavaProject javaProject=getJavaProject();
  if (javaProject == null)   return Collections.emptyList();
  try {
    final List<IContentProposal> result=new ArrayList<IContentProposal>();
    final IRunnableWithProgress runnable=new IRunnableWithProgress(){
      public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          IType activatorType=javaProject.findType(BundleActivator.class.getName());
          if (activatorType != null) {
            ITypeHierarchy hierarchy=activatorType.newTypeHierarchy(javaProject,monitor);
            for (            IType subType : hierarchy.getAllSubtypes(activatorType)) {
              if (!Flags.isAbstract(subType.getFlags()) && subType.getElementName().toLowerCase().contains(prefix.toLowerCase())) {
                result.add(new JavaTypeContentProposal(subType));
              }
            }
          }
        }
 catch (        JavaModelException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
;
    IWorkbenchWindow window=((IFormPage)getManagedForm().getContainer()).getEditorSite().getWorkbenchWindow();
    window.run(false,false,runnable);
    return result;
  }
 catch (  InvocationTargetException e) {
    logger.logError("Error searching for BundleActivator types",e.getTargetException());
    return Collections.emptyList();
  }
catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    return Collections.emptyList();
  }
}
 

Example 33

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/.

Source file: BPMN2Editor.java

  21 
vote

public void showErrorMessage(String msg){
  IWorkbench wb=PlatformUI.getWorkbench();
  IWorkbenchWindow win=wb.getActiveWorkbenchWindow();
  IWorkbenchPage page=win.getActivePage();
  IWorkbenchPart part=page.getActivePart();
  IWorkbenchPartSite site=part.getSite();
  IViewSite vSite=(IViewSite)site;
  IActionBars actionBars=vSite.getActionBars();
  if (actionBars == null)   return;
  IStatusLineManager statusLineManager=actionBars.getStatusLineManager();
  if (statusLineManager == null)   return;
  statusLineManager.setErrorMessage(msg);
  statusLineManager.markDirty();
  statusLineManager.update(true);
}
 

Example 34

From project CBCJVM, under directory /eclipse/CBC/src/cbc/helpers/.

Source file: Helper.java

  21 
vote

public IEditorPart getActiveEditor(){
  IWorkbench iworkbench=PlatformUI.getWorkbench();
  if (iworkbench == null) {
    error("Unable to fetch workbench.");
    return null;
  }
  IWorkbenchWindow iworkbenchwindow=iworkbench.getActiveWorkbenchWindow();
  if (iworkbenchwindow == null) {
    error("Unable to fetch workbench window.");
    return null;
  }
  IWorkbenchPage iworkbenchpage=iworkbenchwindow.getActivePage();
  if (iworkbenchpage == null) {
    error("Unable to fetch workbench page.");
    return null;
  }
  IEditorPart ieditorpart=iworkbenchpage.getActiveEditor();
  if (ieditorpart == null) {
    error("Unable to fetch active editor. You probably have no editors open.");
    return null;
  }
  return ieditorpart;
}
 

Example 35

From project edna-rcp, under directory /org.edna.kernel/src/org/edna/kernel/.

Source file: Launcher.java

  21 
vote

/** 
 * Gets the print stream for the Console if possible
 * @return a valid printStream
 */
private PrintStream getPrintStream(){
  PrintStream ps;
  try {
    MessageConsole myConsole=findConsole(CONSOLE_NAME);
    MessageConsoleStream out=myConsole.newMessageStream();
    ps=new PrintStream(out);
    IWorkbench workBench=Activator.getDefault().getWorkbench();
    if (workBench != null) {
      IWorkbenchWindow activeWindow=workBench.getActiveWorkbenchWindow();
      if (activeWindow != null) {
        IWorkbenchPage page=activeWindow.getActivePage();
        String id=IConsoleConstants.ID_CONSOLE_VIEW;
        IConsoleView view=(IConsoleView)page.showView(id);
        view.display(myConsole);
      }
    }
  }
 catch (  Exception e) {
    ps=new PrintStream(System.out);
  }
  return ps;
}
 

Example 36

From project grails-ide, under directory /org.grails.ide.eclipse.explorer/src/org/grails/ide/eclipse/explorer/internal/actions/.

Source file: ShowInProjectExplorerDelegate.java

  21 
vote

public void run(IAction action){
  if (targetPluginProject == null) {
    return;
  }
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window != null) {
    IWorkbenchPage workbenchPage=window.getActivePage();
    if (workbenchPage != null) {
      try {
        IViewPart viewPart=workbenchPage.showView("org.eclipse.ui.navigator.ProjectExplorer");
        if (viewPart instanceof ISetSelectionTarget) {
          ISetSelectionTarget selectionTarget=(ISetSelectionTarget)viewPart;
          ISelection selection=new StructuredSelection(targetPluginProject);
          selectionTarget.selectReveal(selection);
        }
      }
 catch (      PartInitException pie) {
        GrailsCoreActivator.log(pie);
      }
    }
  }
  targetPluginProject=null;
}
 

Example 37

From project iee, under directory /org.eclipse.iee.editor.monitoring/src/org/eclipse/iee/editor/monitoring/perspectives/.

Source file: EarlyStartup.java

  21 
vote

public void earlyStartup(){
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      final IWorkbenchWindow workbenchWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      if (workbenchWindow != null) {
        workbenchWindow.addPerspectiveListener(new PerspectiveAdapter(){
          @Override public void perspectiveActivated(          IWorkbenchPage page,          IPerspectiveDescriptor perspectiveDescriptor){
            super.perspectiveActivated(page,perspectiveDescriptor);
            System.err.println("--> " + perspectiveDescriptor.getId());
            if (perspectiveDescriptor.getId().indexOf("org.eclipse.iee.editor.monitoring.perspectives.PadsMonitoringPerspective") > -1) {
              if (workbenchWindow.getActivePage() instanceof WorkbenchPage) {
                WorkbenchPage worbenchPage=(WorkbenchPage)workbenchWindow.getActivePage();
                Perspective perspective=worbenchPage.findPerspective(perspectiveDescriptor);
                ArrayList<IActionSetDescriptor> toRemove=new ArrayList<IActionSetDescriptor>();
                if (perspective != null) {
                  for (                  IActionSetDescriptor actionSetDescriptor : perspective.getAlwaysOnActionSets()) {
                    if (actionSetDescriptor.getId().indexOf("org.eclipse.search.searchActionSet") > -1) {
                      toRemove.add(actionSetDescriptor);
                    }
                  }
                  perspective.turnOffActionSets((IActionSetDescriptor[])toRemove.toArray(new IActionSetDescriptor[toRemove.size()]));
                }
              }
            }
          }
        }
);
      }
    }
  }
);
}
 

Example 38

From project interactive-self-assessment, under directory /editbox/src/pm/eclipse/editbox/actions/.

Source file: EditBoxStartup.java

  21 
vote

public void earlyStartup(){
  if (!EditBox.getDefault().isEnabled())   return;
  EditBox.getDefault().setEnabled(false);
  final IWorkbench workbench=PlatformUI.getWorkbench();
  workbench.getDisplay().asyncExec(new Runnable(){
    public void run(){
      ICommandService commandService=(ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
      Command command=commandService.getCommand(EnableEditBox.COMMAND_ID);
      IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      if (window != null) {
        IHandlerService handlerService=(IHandlerService)window.getWorkbench().getService(IHandlerService.class);
        if (handlerService != null)         try {
          handlerService.executeCommand(new ParameterizedCommand(command,null),null);
          toggle(window);
        }
 catch (        Exception e) {
          EditBox.logError(this,"Failed to enable EditBox at startup",e);
        }
      }
    }
  }
);
}
 

Example 39

From project m2eclipse-hudson, under directory /org.sonatype.m2e.hudson.ui/src/main/java/com/sonatype/buildserver/eclipse/ui/.

Source file: StatusLineCLabelContribution.java

  21 
vote

IStatusLineManager getStatusLineManager(){
  if (statusLineManager != null)   return statusLineManager;
  IWorkbenchWindow activeWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (activeWindow == null)   return null;
  try {
    Method method=activeWindow.getClass().getDeclaredMethod("getStatusLineManager",new Class[0]);
    try {
      Object statusLine=method.invoke(activeWindow,new Object[0]);
      if (statusLine instanceof IStatusLineManager) {
        statusLineManager=(IStatusLineManager)statusLine;
        return statusLineManager;
      }
    }
 catch (    InvocationTargetException e) {
      log.error("Could not find getStatusLineManagerMethod",e);
    }
catch (    IllegalAccessException e) {
      log.error("Could not find getStatusLineManagerMethod",e);
    }
  }
 catch (  NoSuchMethodException e) {
    log.error("Could not find getStatusLineManagerMethod",e);
  }
  IWorkbenchPartSite site=activeWindow.getActivePage().getActivePart().getSite();
  if (site instanceof IViewSite) {
    statusLineManager=((IViewSite)site).getActionBars().getStatusLineManager();
  }
 else   if (site instanceof IEditorSite) {
    statusLineManager=((IEditorSite)site).getActionBars().getStatusLineManager();
  }
  return statusLineManager;
}
 

Example 40

From project mwe, under directory /plugins/org.eclipse.emf.mwe.ewm.developer/src/org/eclipse/emf/mwe/ewm/developer/.

Source file: ResetWorkflowLogHandler.java

  21 
vote

public Object execute(ExecutionEvent event) throws ExecutionException {
  IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindow(event);
  IStructuredSelection selection=(IStructuredSelection)window.getSelectionService().getSelection();
  ResourceSet resourceSet=new ResourceSetImpl();
  resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,Boolean.TRUE);
  IFile contextFile=(IFile)selection.getFirstElement();
  URI contextURI=URI.createPlatformResourceURI(contextFile.getFullPath().toString(),false);
  final Resource contextResource=resourceSet.getResource(contextURI,true);
  WorkflowContext context=(WorkflowContext)contextResource.getContents().get(0);
  WorkflowLogResetter resetter=new WorkflowLogResetter(context);
  resetter.doSwitch(context.getWorkflow());
  WorkspaceModifyOperation operation=new WorkspaceModifyOperation(){
    @Override protected void execute(    IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
      try {
        HashMap<String,Object> options=new HashMap<String,Object>();
        options.put(XMLResource.OPTION_EXTENDED_META_DATA,Boolean.TRUE);
        contextResource.save(options);
      }
 catch (      IOException e) {
        throw new InvocationTargetException(e);
      }
    }
  }
;
  try {
    window.run(true,false,operation);
  }
 catch (  InvocationTargetException e) {
    e.printStackTrace();
  }
catch (  InterruptedException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 41

From project mylyn.context, under directory /org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/actions/.

Source file: AbstractInterestManipulationAction.java

  21 
vote

protected IInteractionContext getContext(){
  IWorkbenchWindow activeWorkbenchWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  IInteractionContext context=null;
  if (activeWorkbenchWindow != null && activeWorkbenchWindow.getActivePage() != null) {
    IWorkbenchPage activePage=activeWorkbenchWindow.getActivePage();
    IEditorPart activeEditor=activePage.getActiveEditor();
    if (activeEditor != null && activePage.getActivePart().equals(activeEditor)) {
      context=(IInteractionContext)activeEditor.getEditorInput().getAdapter(IInteractionContext.class);
    }
  }
  if (context == null && ContextCorePlugin.getContextManager().isContextActive()) {
    context=ContextCorePlugin.getContextManager().getActiveContext();
  }
  if (context == null) {
    throw new IllegalStateException("error determining action context");
  }
  return context;
}
 

Example 42

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task.application/src/de/sebastianbenz/task/app/actions/.

Source file: TaskEditorActionBarAdvisor.java

  19 
vote

protected void makeActions(IWorkbenchWindow window){
  registerAsGlobal(ActionFactory.PREFERENCES.create(window));
  registerAsGlobal(ActionFactory.SAVE.create(window));
  registerAsGlobal(ActionFactory.SAVE_AS.create(window));
  registerAsGlobal(ActionFactory.ABOUT.create(window));
  registerAsGlobal(ActionFactory.SAVE_ALL.create(window));
  registerAsGlobal(ActionFactory.UNDO.create(window));
  registerAsGlobal(ActionFactory.REDO.create(window));
  registerAsGlobal(ActionFactory.CUT.create(window));
  registerAsGlobal(ActionFactory.COPY.create(window));
  registerAsGlobal(ActionFactory.PASTE.create(window));
  registerAsGlobal(ActionFactory.SELECT_ALL.create(window));
  registerAsGlobal(ActionFactory.FIND.create(window));
  registerAsGlobal(ActionFactory.CLOSE.create(window));
  registerAsGlobal(ActionFactory.CLOSE_ALL.create(window));
  registerAsGlobal(ActionFactory.CLOSE_ALL_SAVED.create(window));
  registerAsGlobal(ActionFactory.REVERT.create(window));
  registerAsGlobal(ActionFactory.QUIT.create(window));
}
 

Example 43

From project gmc, under directory /src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/.

Source file: ApplicationActionBarAdvisor.java

  19 
vote

protected void makeActions(final IWorkbenchWindow window){
  exitAction=ActionFactory.QUIT.create(window);
  register(exitAction);
  aboutAction=ActionFactory.ABOUT.create(window);
  aboutAction.setText("&About");
  aboutAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID,IImageKeys.HELP_16x16));
  register(aboutAction);
  helpContentsAction=ActionFactory.HELP_CONTENTS.create(window);
  helpContentsAction.setText("&Management Console Help");
  helpContentsAction.setAccelerator(SWT.F1);
  register(helpContentsAction);
}
 

Example 44

From project js4emf, under directory /org.eclipse.emf.js4emf.ui/src/org/eclipse/emf/js4emf/ui/.

Source file: EditJavascriptCommandHandler.java

  19 
vote

private IEditingDomainProvider getEditingDomainProvider(IWorkbenchWindow wbw){
  if (wbw == null || wbw.getActivePage() == null) {
    return null;
  }
  IWorkbenchPart part=wbw.getActivePage().getActivePart();
  return (part instanceof IEditingDomainProvider ? (IEditingDomainProvider)part : null);
}
 

Example 45

From project junithelper, under directory /eclipse-plugin/src/main/java/org/junithelper/plugin/util/.

Source file: ResourceRefreshUtil.java

  19 
vote

public static boolean refreshLocal(IWorkbenchWindow window,String param){
  try {
    IWorkspaceRoot workspaceRoot=ResourcesPlugin.getWorkspace().getRoot();
    IResource resource=workspaceRoot.findMember(param);
    resource.refreshLocal(IResource.DEPTH_INFINITE,monitor);
  }
 catch (  Exception e) {
    e.printStackTrace();
    return false;
  }
  return true;
}