org.eclipse.ui.internal.WorkbenchPage Java Examples

The following examples show how to use org.eclipse.ui.internal.WorkbenchPage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GdtPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds the new wizards to the current perspective displayed in <code>activeWorkbenchWindow</code>, if they've not
 * been added already. Adds listeners on the window so that the same is done whenever the user switches perspectives
 * in the window.
 *
 * Note: This method can only be called once the workbench has been started.
 */
private void maybeAddNewWizardActionsToWindow(IWorkbenchWindow activeWorkbenchWindow) {
  if (activeWorkbenchWindow == null) {
    return;
  }

  activeWorkbenchWindow.addPerspectiveListener(perspectiveListener);

  WorkbenchPage activePage = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
  if (activePage == null) {
    return;
  }

  IPerspectiveDescriptor perspectiveDesc = activePage.getPerspective();
  maybeAddNewWizardActionsToPerspective(activePage, perspectiveDesc);
}
 
Example #2
Source File: ResetSimulationPerspective.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
	final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
	if (activeWorkbenchWindow != null) {
		final WorkbenchPage page = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
		if (page != null) {
			final IPerspectiveDescriptor descriptor = page.getPerspective();
			if (descriptor != null) {
				final String message =
						"Resetting the perspective will reload the current experiment. Do you want to proceed ?";
				final boolean result = MessageDialog.open(MessageDialog.QUESTION, activeWorkbenchWindow.getShell(),
						"Reset experiment perspective", message, SWT.SHEET);
				if (!result) { return null; }
				page.resetPerspective();
				GAMA.reloadFrontmostExperiment();
			}

		}
	}

	return null;

}
 
Example #3
Source File: BonitaStudioWorkbenchWindowAdvisor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Register to selection service to update button enablement
 * Register the Automatic Perspective switch part listener
 */
@Override
public void postWindowOpen() {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
    configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
    configurer.addEditorAreaTransfer(FileTransfer.getInstance());
    configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());
    configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
            configurer.getWindow()));

    final MWindow model = ((WorkbenchPage) window.getActivePage()).getWindowModel();
    model.getContext().get(EPartService.class).addPartListener(new AutomaticSwitchPerspectivePartListener());
    final Object widget = model.getWidget();
    if (widget instanceof Shell) {
        ((Widget) widget).setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_MAIN_SHELL);
    }
    // Replace ObjectActionContributorManager with filtered actions
    CustomObjectActionContributorManager.getManager();
}
 
Example #4
Source File: CppStyleHandler.java    From CppStyle with MIT License 5 votes vote down vote up
@Override
protected EvaluationResult evaluate(IEvaluationContext context) {

	IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
	// no window? not active
	if (window == null)
		return EvaluationResult.FALSE;
	WorkbenchPage page = (WorkbenchPage) window.getActivePage();

	// no page? not active
	if (page == null)
		return EvaluationResult.FALSE;

	// get saveable part
	ISaveablePart saveablePart = getSaveablePart(context);
	if (saveablePart == null)
		return EvaluationResult.FALSE;

	if (saveablePart instanceof ISaveablesSource) {
		ISaveablesSource modelSource = (ISaveablesSource) saveablePart;
		if (SaveableHelper.needsSave(modelSource))
			return EvaluationResult.TRUE;
		return EvaluationResult.FALSE;
	}

	if (saveablePart != null && saveablePart.isDirty())
		return EvaluationResult.TRUE;

	return EvaluationResult.FALSE;
}
 
Example #5
Source File: EmacsPlusUtils.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
public static IEditorReference[] getSortedEditors(IWorkbenchPage page) {
	IEditorReference[] result = null;
	if (page != null && page instanceof WorkbenchPage) {
		result = ((WorkbenchPage) page).getSortedEditors();			
	}
	return result;
}
 
Example #6
Source File: GdtPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspectiveDesc) {
  maybeAddNewWizardActionsToPerspective((WorkbenchPage) page, perspectiveDesc);
}
 
Example #7
Source File: GdtPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * If we haven't added them in the past, add the new wizard actions that this to the perspective which is being
 * displayed on the workbench page.
 *
 * Note: This method can only be called once the workbench has been started.
 */
private void maybeAddNewWizardActionsToPerspective(WorkbenchPage page, IPerspectiveDescriptor desc) {
  if (page == null || desc == null) {
    return;
  }

  if (PERSPECTIVES_TO_ADD_WIZARDS_TO.contains(desc.getId())) {
    // Perspective perspective = page.findPerspective(desc);
    // if (perspective != null) {
    // List<String> wizardsToAdd = new ArrayList<String>(
    // WIZARDS_TO_ADD_TO_PERSPECTIVES);
    //
    // // Ignore any wizards we've already tried to add to this perspective.
    // // That way we don't re-add any wizards that the user explicitly
    // // removed from the New shortcut menu.
    // List<String> wizardsAlreadyAdded = GdtPreferences
    // .getAddedNewWizardActionsForPerspective(desc.getId());
    // wizardsToAdd.removeAll(wizardsAlreadyAdded);
    //
    // // Get the current set of wizard shortcuts
    // List<String> currentWizardShortcuts = new ArrayList<String>(
    // Arrays.asList(perspective.getNewWizardShortcuts()));
    //
    // // Ignore wizards that already have shortcuts in this perspective
    // wizardsToAdd.removeAll(currentWizardShortcuts);
    //
    // // Only update the perspective if there are new wizards to add
    // if (!wizardsToAdd.isEmpty()) {
    // currentWizardShortcuts.addAll(wizardsToAdd);
    //
    // // Update the perspective
    // perspective.setNewWizardActionIds(new ArrayList<String>(
    // currentWizardShortcuts));
    // }
    //
    // // Remember the wizards that we've attempted to add to this perspective
    // GdtPreferences.setAddedNewWizardActionsForPerspective(desc.getId(),
    // WIZARDS_TO_ADD_TO_PERSPECTIVES);
    // } else {
    // assert false : "Perspective was activated but not found";
    // }
  }
}
 
Example #8
Source File: DummyEditorSite.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public IActionBars getActionBars() {
    return new EditorActionBars((WorkbenchPage) getPage(),
            (IServiceLocator) PlatformUI.getWorkbench().getService(IServiceLocator.class), GroovyEditor.EDITOR_ID);
}