org.eclipse.e4.ui.workbench.modeling.EPartService Java Examples

The following examples show how to use org.eclipse.e4.ui.workbench.modeling.EPartService. 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: 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 #2
Source File: SwitchToBufferHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Cursor enablement for E4
 */
private void forceActivate() {
	EPartService partService = (EPartService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
	partService.activate(null);
	partService.activate(partService.getActivePart(),true);
	// E4 activation seems slightly hosed - add this in
	EmacsPlusUtils.asyncUiRun(new Runnable() {
		public void run() {
			try {
				// this will finish activating
				EmacsPlusUtils.executeCommand("org.eclipse.ui.window.activateEditor", null);	//$NON-NLS-1$
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}
 
Example #3
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #4
Source File: PerspektiveImportHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void switchToPerspectiveLegacy(MPerspective loadedPerspective,
	List<String> preLoadedFastViewIds){
	
	EModelService modelService = getService(EModelService.class);
	EPartService partService = getService(EPartService.class);
	MApplication mApplication = getService(MApplication.class);
	MTrimmedWindow mWindow = (MTrimmedWindow) modelService.find("IDEWindow", mApplication);
	if (mWindow == null) {
		List<MWindow> windows = mApplication.getChildren();
		if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
			mWindow = (MTrimmedWindow) windows.get(0);
		}
	}
	MPerspective activePerspective = modelService.getActivePerspective(mWindow);
	MElementContainer<MUIElement> perspectiveParent = activePerspective.getParent();
	List<String> fastViewIds = preLoadedFastViewIds;
	
	// add the loaded perspective and switch to it
	String id = loadedPerspective.getElementId();
	Iterator<MUIElement> it = perspectiveParent.getChildren().iterator();
	while (it.hasNext()) {
		MUIElement element = it.next();
		if (id.equals(element.getElementId()) || element.getElementId().startsWith(id + ".<")) {
			it.remove();
		}
	}
	perspectiveParent.getChildren().add(loadedPerspective);
	
	// add fast view
	for (String fastViewId : fastViewIds) {
		ElexisFastViewUtil.addToFastView(loadedPerspective.getElementId(), fastViewId);
	}
	// the workbench window must be on top - otherwise the exception 'Application does not have an active window' occurs
	PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().open();
	
	partService.switchPerspective(loadedPerspective);
}
 
Example #5
Source File: CoolbarToolControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void registerHandlers(final IEclipseContext context, final IWorkbenchPage page) {
    EPartService partService = context.get(EPartService.class);
    ESelectionService selectionService = context.get(ESelectionService.class);
    if (!isRegistered && partService != null && selectionService != null) {
        partService.addPartListener(CoolbarToolControl.this);
        selectionService.addSelectionListener(CoolbarToolControl.this);
        isRegistered = true;
    }
}
 
Example #6
Source File: WindowJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
void closePart(MPart part) {
	// based on org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.closePart()
	IEclipseContext context = part.getContext();
	if (context != null && part.isCloseable()) {
		EPartService partService = context.get(EPartService.class);
		partService.hidePart(part,true);
	}
}
 
Example #7
Source File: SaveHandler.java    From e4Preferences with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #8
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #9
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #10
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #11
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #12
Source File: RestorePerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, MWindow window, EPartService partService) {

	// get active perpective and find stored snippet of this perspective
	MPerspective activePerspective = modelService.getActivePerspective(window);
	MUIElement perspectiveSnippet = modelService.cloneSnippet(window, activePerspective.getElementId(), window);

	// remove existing active perspective
	MElementContainer<MUIElement> parent = activePerspective.getParent();
	modelService.removePerspectiveModel(activePerspective, window);

	// add stored perspective snippet and switch to it
	parent.getChildren().add(perspectiveSnippet);
	partService.switchPerspective((MPerspective) perspectiveSnippet);
}
 
Example #13
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #14
Source File: ShowNXTPerspectiveHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(MApplication app, EPartService partService,
    EModelService modelService) {
  MPerspective element = (MPerspective) modelService.find(PART_ID, app);
  if (element != null) {
    partService.switchPerspective(element);
    logger.trace("Switch to " + PART_ID);
  }
}
 
Example #15
Source File: ShowTraderPerspectiveHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(MApplication app, EPartService partService,
    EModelService modelService) {
  MPerspective element = (MPerspective) modelService.find(PART_ID, app);
  partService.switchPerspective(element);
  logger.trace("Switch to " + PART_ID);
}
 
Example #16
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #17
Source File: SwitchPerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, EPartService partService,
		MWindow window,
		@Named("com.vogella.rcp.jface.translation.commandparameter.perspectiveid") String id) {
	MPerspective activePerspective = modelService
			.getActivePerspective(window);


	MUIElement find = modelService.find(id, window);
	if (find == null || activePerspective.equals(find)) {
		return;
	}

	partService.switchPerspective((MPerspective) find);
}
 
Example #18
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@CanExecute
public boolean canExecute(EPartService partService) {
	if (partService != null) {
		return !partService.getDirtyParts().isEmpty();
	}
	return false;
}
 
Example #19
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #20
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #21
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #22
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #23
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #24
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #25
Source File: SaveHandler.java    From e4Preferences with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #26
Source File: ArrangeDisplayViews.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private static EPartService getPartService() {
	return WorkbenchHelper.getService(EPartService.class);
}
 
Example #27
Source File: SaveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Execute
public void execute(EPartService partService) {
	partService.saveAll(false);
}
 
Example #28
Source File: ShowAccountPerspectiveHandler.java    From offspring with MIT License 4 votes vote down vote up
@Execute
public void execute(MApplication app, EPartService partService, EModelService modelService) {
  MPerspective element = (MPerspective) modelService.find(PART_ID, app);
  partService.switchPerspective(element);
  logger.trace("Switch to " + PART_ID);
}
 
Example #29
Source File: ShowHomePerspectiveHandler.java    From offspring with MIT License 4 votes vote down vote up
@Execute
public void execute(MApplication app, EPartService partService, EModelService modelService) {
  MPerspective element = (MPerspective) modelService.find(PART_ID, app);
  partService.switchPerspective(element);
}
 
Example #30
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Adds a view to the fastview, if {@link MPartStack} not exists it will be created and the view
 * will be added within a {@link MPlaceholder} element.
 * 
 * @param perspectiveId
 * @param viewId
 */
public static void addToFastView(String perspectiveId, String viewId){
	EModelService eModelService = getService(EModelService.class);
	MApplication mApplication = getService(MApplication.class);
	
	MTrimmedWindow window = getCurrentWindow(eModelService, mApplication);
	
	if (window != null) {
		Object obj = eModelService.find(perspectiveId, mApplication);
		if (obj instanceof MPerspective) {
			MPerspective mPerspective = (MPerspective) obj;
			// check if fastview stack exists
			MPartStack stack =
				(MPartStack) eModelService.find(ELEXIS_FASTVIEW_STACK, mPerspective);
			
			if (stack == null) {
				stack = createFastViewStack(window, mPerspective, eModelService);
			}
			if (stack != null) {
				// check if toolcontrol exists
				MToolControl toolControl = (MToolControl) eModelService
					.find(getToolControlId(window, mPerspective), mApplication);
				
				if (toolControl == null) {
					MTrimBar mTrimBar = eModelService.getTrim(window, SideValue.BOTTOM);
					if (toolControl == null) {
						toolControl = createFastViewToolControl(window, mPerspective,
							eModelService, mTrimBar);
					}
				}
				if (toolControl != null
					&& !ElexisFastViewUtil.isViewInsideFastview(stack, viewId)
					&& mApplication.getContext().getActiveChild() != null) {
					EPartService partService = getService(EPartService.class);
					MPlaceholder placeholder = partService.createSharedPart(viewId);
					placeholder.setToBeRendered(true);
					placeholder.setElementId(viewId);
					placeholder.setCloseable(true);
					placeholder.getTags().add(EPartService.REMOVE_ON_HIDE_TAG);
					((MPart) placeholder.getRef()).setToBeRendered(true);
					stack.getChildren().add(placeholder); // Add part to stack
				}
				
			}
		}
	}
}