org.eclipse.ui.PlatformUI#getWorkbench ( )源码实例Demo

下面列出了org.eclipse.ui.PlatformUI#getWorkbench ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: yang-design-studio   文件: YangSyntax.java
public MessageConsoleStream getMessageStream() {
	MessageConsole myConsole = findConsole("Yang Console"); //calls function to find/create the Yang console
	if (myConsole != null) {

		IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
		IWorkbenchPage page = win.getActivePage();
		String id = IConsoleConstants.ID_CONSOLE_VIEW;
		IConsoleView view;
		try {

			view = (IConsoleView) page.showView(id);
			view.display(myConsole);

			return myConsole.newMessageStream();
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}
	return null;
}
 
源代码2 项目: dsl-devkit   文件: ASMDEditorUtils.java
/** {@inheritDoc} */
public XtextEditor getActiveXtextEditor() {
  IWorkbench workbench = PlatformUI.getWorkbench();
  IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
  if (workbenchWindow == null) {
    return null;
  }
  IWorkbenchPage activePage = workbenchWindow.getActivePage();
  if (activePage == null) {
    return null;
  }
  IEditorPart activeEditor = activePage.getActiveEditor();
  if (activeEditor instanceof XtextEditor) {
    return (XtextEditor) activeEditor;
    // return null;
  }
  // XtextEditor xtextEditor = (XtextEditor) activeEditor.getAdapter(XtextEditor.class);
  // return xtextEditor;
  return null;
}
 
源代码3 项目: tracecompass   文件: SegmentTableTest.java
/**
 * Create the table viewer to test
 *
 * @return the table viewer bot
 */
protected AbstractSegmentStoreTableView openTable() {
    AbstractSegmentStoreTableView tableView = getTableView();
    if (tableView != null) {
        return tableView;
    }
    IViewPart vp = null;
    final IWorkbench workbench = PlatformUI.getWorkbench();
    vp = UIThreadRunnable.syncExec((Result<IViewPart>) () -> {
        try {
            return workbench.getActiveWorkbenchWindow().getActivePage().showView(TestSegmentStoreTableView.ID);
        } catch (PartInitException e) {
            return null;
        }
    });
    assertNotNull(vp);
    assertTrue(vp instanceof TestSegmentStoreTableView);
    TestSegmentStoreTableView testSegmentStoreTableView = (TestSegmentStoreTableView) vp;
    testSegmentStoreTableView.setTest(this);
    fTableView = testSegmentStoreTableView;

    return fTableView;
}
 
源代码4 项目: bonita-studio   文件: BonitaPerspectivesUtils.java
/**
 * Switch to the perspective with id given as parameter
 * 
 * @param perspectiveID
 */
public static synchronized void switchToPerspective(final String perspectiveID) {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window != null) {
        final IWorkbenchPage activePage = window.getActivePage();
        if (activePage != null) {
            final IPerspectiveDescriptor activePerspective = activePage.getPerspective();
            if (activePerspective == null || !activePerspective.getId().equals(perspectiveID)) {
                final IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
                final IWorkbenchPage page = window.getActivePage();
                final IPerspectiveDescriptor desc = registry.findPerspectiveWithId(perspectiveID);
                page.setPerspective(desc);
            }
        }
    }
}
 
源代码5 项目: saros   文件: ViewUtils.java
public static void openSarosView() {
  /*
   * TODO What to do if no WorkbenchWindows are are active?
   */
  final IWorkbench workbench = PlatformUI.getWorkbench();

  if (workbench == null) return;

  final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

  if (window == null) return;

  try {
    window.getActivePage().showView(SarosView.ID, null, IWorkbenchPage.VIEW_CREATE);
  } catch (PartInitException e) {
    log.error("could not open Saros view (id: " + SarosView.ID + ")", e); // $NON-NLS-1$
  }
}
 
源代码6 项目: RDFS   文件: OpenNewMRClassWizardAction.java
public void run(String[] params, ICheatSheetManager manager) {

    if ((params != null) && (params.length > 0)) {
      IWorkbench workbench = PlatformUI.getWorkbench();
      INewWizard wizard = getWizard(params[0]);
      wizard.init(workbench, new StructuredSelection());
      WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench()
          .getActiveWorkbenchWindow().getShell(), wizard);
      dialog.create();
      dialog.open();

      // did the wizard succeed ?
      notifyResult(dialog.getReturnCode() == Window.OK);
    }
  }
 
源代码7 项目: nebula   文件: ExamplesApplication.java
@Override
public void stop() {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench == null) {
		return;
	}
	final Display display = workbench.getDisplay();
	display.syncExec(() -> {
		if (!display.isDisposed()) {
			workbench.close();
		}
	});
}
 
源代码8 项目: dawnsci   文件: H5ValuePage.java
private 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();
}
 
源代码9 项目: n4js   文件: EditorsUtil.java
static private final IWorkbenchPage unsafeGetWorkbenchPage() {
	IWorkbenchPage page = null;
	if (PlatformUI.isWorkbenchRunning()) {
		IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
		page = win.getActivePage();
	}
	return page;
}
 
源代码10 项目: tlaplus   文件: UIHelper.java
/**
 * Switch current perspective
 * 
 * @param perspectiveId
 * @return
 */
public static IWorkbenchPage switchPerspective(String perspectiveId) {
	Assert.isNotNull(perspectiveId, "PerspectiveId is null");
	IWorkbench workbench = PlatformUI.getWorkbench();
	IWorkbenchWindow window = getActiveWindow();
	Assert.isNotNull(workbench, "Workbench is null");
	Assert.isNotNull(window, "Window is null");
	try {
		IWorkbenchPage page = workbench.showPerspective(perspectiveId, window);

		// show intro
		if (InitialPerspective.ID.equals(perspectiveId) && workbench.getIntroManager().hasIntro()) {
			page.resetPerspective();
			// We are no longer showing the Intro view. The following will
			// probably
			// be replaced by something that shows the view we want. 09 Oct
			// 2009
			// workbench.getIntroManager().showIntro(window, false);
			openView(ToolboxWelcomeView.ID);

		}

		return page;
	} catch (WorkbenchException e) {
		Activator.getDefault().logError("Error switching a perspective to " + perspectiveId, e);
	}

	return null;
}
 
源代码11 项目: neoscada   文件: Application.java
public void stop() {
	if (!PlatformUI.isWorkbenchRunning())
		return;
	final IWorkbench workbench = PlatformUI.getWorkbench();
	final Display display = workbench.getDisplay();
	display.syncExec(new Runnable() {
		public void run() {
			if (!display.isDisposed())
				workbench.close();
		}
	});
}
 
源代码12 项目: xtext-eclipse   文件: CreateJavaTypeQuickfixes.java
protected WizardDialog createWizardDialog(NewElementWizard newXtendClassWizard) {
	IWorkbench workbench = PlatformUI.getWorkbench();
	Shell shell = workbench.getActiveWorkbenchWindow().getShell();
	newXtendClassWizard.init(workbench, new StructuredSelection());
	WizardDialog dialog = new WizardDialog(shell, newXtendClassWizard);
	dialog.create();
	return dialog;
}
 
@Test
public void testRunAppEngine_hiddenEvenIfAppEngineProjectFileIsOpen() throws CoreException {
  IProject emptyProject = emptyProjectCreator.getProject();

  // Create an empty file in the App Engine project, and open it in an editor.
  IProject appEngineProject = appEngineProjectCreator.getProject();
  IFile file = appEngineProject.getFile("textfile.txt");
  file.create(new ByteArrayInputStream(new byte[0]), IFile.FORCE, null);

  IWorkbench workbench = PlatformUI.getWorkbench();
  assertNotNull(WorkbenchUtil.openInEditor(workbench, file));

  assertFalse(appEngineMenuExists(emptyProject));
}
 
源代码14 项目: google-cloud-eclipse   文件: WorkbenchStartup.java
@Override
public void earlyStartup() {
  final IWorkbench workbench = PlatformUI.getWorkbench();
  GcpStatusMonitoringService service = workbench.getService(GcpStatusMonitoringService.class);
  if (service != null) {
    service.addStatusChangeListener(
        result -> {
          ICommandService commandService = workbench.getService(ICommandService.class);
          if (commandService != null) {
            commandService.refreshElements(
                "com.google.cloud.tools.eclipse.ui.status.showGcpStatus", null);
          }
        });
  }
}
 
public static IEclipseContext workbenchContext() {
    if (PlatformUI.isWorkbenchRunning()) {
        final Workbench workbench = (Workbench) PlatformUI.getWorkbench();
        if (workbench != null) {
            final IEclipseContext context = workbench.getContext();
            checkNotNull(context, "Workbench eclipse context is null");
            return context;
        }
        throw new IllegalStateException("No workbench available");
    }
    return headlessContext();
}
 
源代码16 项目: tracecompass   文件: TmfViewFactory.java
/**
 * Create a new view. <br>
 * If a view with the corresponding id already exists and no suffix were
 * added the existing view will be given focus.
 *
 * @param viewId
 *            The id of the view to be created. <br>
 *            Format: primary_id[:secondary_id[&uuid]|:uuid]
 * @param generateSuffix
 *            Add or replace a generated suffix id (UUID). This allows
 *            multiple views with the same id to be displayed.
 * @return The view instance, or null if an error occurred.
 */
@NonNullByDefault
public static @Nullable IViewPart newView(String viewId, boolean generateSuffix) {
    IViewPart viewPart = null;
    String primaryId = null;
    String secondaryId = null;

    /* Parse the view id */
    int index = viewId.indexOf(TmfView.VIEW_ID_SEPARATOR);
    if (index != -1) {
        primaryId = viewId.substring(0, index);
        secondaryId = getBaseSecId(viewId.substring(index + 1));
    } else {
        primaryId = viewId;
    }

    if (generateSuffix) {
        if (secondaryId == null) {
            secondaryId = UUID.randomUUID().toString();
        } else {
            secondaryId += INTERNAL_SECONDARY_ID_SEPARATOR + UUID.randomUUID().toString();
        }
    }

    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage page = workbenchWindow.getActivePage();
    try {
        viewPart = page.showView(primaryId, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
        page.activate(viewPart);
    } catch (PartInitException e) {
        /* Simply return null on error */
    }

    return viewPart;
}
 
protected IWorkbench getWorkbench() {
	return PlatformUI.getWorkbench();
}
 
源代码18 项目: gama   文件: WorkbenchHelper.java
public static IWorkbench getWorkbench() {
	return PlatformUI.getWorkbench();
}
 
public void dispose() {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	unhookListeners(workbench);
}
 
源代码20 项目: xds-ide   文件: WorkbenchUtils.java
public static IWorkbenchWindow[] getWorkbenchWindows() {
	IWorkbench workbench = PlatformUI.getWorkbench();
	 return workbench.getWorkbenchWindows();
}