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

The following examples show how to use org.eclipse.e4.ui.workbench.modeling.EModelService. 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: PerspectiveHelper.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void cleanPerspectives() {
	final EModelService e = PlatformUI.getWorkbench().getService(EModelService.class);
	final MApplication a = PlatformUI.getWorkbench().getService(MApplication.class);

	final List<PerspectiveImpl> perspectives = e.findElements(a, PerspectiveImpl.class, EModelService.ANYWHERE,
		element -> matches(element.getElementId()));
	for ( final PerspectiveImpl p : perspectives ) {
		// DEBUG.OUT("Dirty perspective implementation found and removed: " + p.getElementId());
		p.getParent().getChildren().remove(p);
	}

	final IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry();
	for ( final IPerspectiveDescriptor desc : reg.getPerspectives() ) {
		if ( matches(desc.getId()) ) {
			// DEBUG.OUT("Dirty perspective descriptor found and removed: " + desc.getId());
			reg.deletePerspective(desc);
		}
	}

	// DEBUG.OUT("Current perspectives: " + listCurrentPerspectives());
}
 
Example #2
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private static MPartStack createFastViewStack(MTrimmedWindow window, MPerspective mPerspective,
	EModelService eModelService){
	
	if (window != null && mPerspective != null) {
		MPartStack mPartStack = eModelService.createModelElement(MPartStack.class);
		mPartStack.setElementId(ELEXIS_FASTVIEW_STACK);
		mPartStack.setToBeRendered(true);
		mPartStack.getTags().add("Minimized");
		mPartStack.setOnTop(false);
		mPartStack.setVisible(false);
		mPartStack.getTags().add("NoAutoCollapse");
		mPartStack.getTags().add("active");
		mPerspective.getChildren().add(0, mPartStack);
		return mPartStack;
	}
	return null;
}
 
Example #3
Source File: UiStartupHandler.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void handleEvent(Event event){
	Object property = event.getProperty("org.eclipse.e4.data");
	if (property instanceof MApplication) {
		MApplication application = (MApplication) property;
		
		EModelService modelService = application.getContext().get(EModelService.class);
		
		UiDesk.asyncExec(new Runnable() {
			public void run(){
				addMandantSelectionItem(application, modelService);
				ElexisFastViewUtil.registerPerspectiveListener();
			}
		});
		
	}
}
 
Example #4
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private static MToolControl createFastViewToolControl(MTrimmedWindow window,
	MPerspective mPerspective, EModelService eModelService, MTrimBar mTrimBar){
	if (mTrimBar != null) {
		MToolControl mToolControl = eModelService.createModelElement(MToolControl.class);
		mToolControl.setElementId(getToolControlId(window, mPerspective));
		mToolControl.setContributionURI(
			"bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.TrimStack");
		mToolControl.setToBeRendered(true);
		mToolControl.setVisible(true);
		mToolControl.getTags().add("TrimStack");
		if (!hasFastViewPersistedState(mPerspective)) {
			mToolControl.getPersistedState().put("YSize", "600");
		}
		mTrimBar.getChildren().add(0, mToolControl);
		mTrimBar.setVisible(true);
		mTrimBar.setToBeRendered(true);
		
		return mToolControl;
	}
	return null;
}
 
Example #5
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private static Optional<MToolControl> getFastViewToolControl(EModelService eModelService,
	MTrimmedWindow workbenchWindow, String perspectiveId, SideValue sideValue){
	if (workbenchWindow != null) {
		MTrimBar trimbar = findTrimBar(eModelService, workbenchWindow, sideValue);
		if (trimbar != null) {
			MToolControl toolControl = (MToolControl) eModelService
				.find(getToolControlId(workbenchWindow, perspectiveId), trimbar);
			if (toolControl == null && workbenchWindow.getElementId() != null) {
				// it also can be that the main view id is also a part of the stack
				toolControl = (MToolControl) eModelService.find(ELEXIS_FASTVIEW_STACK + "("
					+ workbenchWindow.getElementId() + ").(" + perspectiveId + ")", trimbar);
				if (toolControl != null) {
					toolControl.setElementId(getToolControlId(workbenchWindow, perspectiveId));
				}
			}
			if (toolControl != null) {
				return Optional.of(toolControl);
			}
		}
	}
	return Optional.empty();
}
 
Example #6
Source File: FrameJoinCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.e4.commands.E4WindowCmd#getAdjacentElement(org.eclipse.e4.ui.model.application.ui.MElementContainer, boolean, org.eclipse.e4.ui.model.application.ui.basic.MPart)
 */
protected MElementContainer<MUIElement> getAdjacentElement(MElementContainer<MUIElement> dragStack, MPart part, boolean stackp) {
	MElementContainer<MUIElement> result = null;
	if (dragStack != null) {
		MElementContainer<MUIElement> psash = dragStack.getParent();
		MElementContainer<MUIElement> top = getTopElement(psash);
		if ((Object)top instanceof MTrimmedWindow) {
			// if we contain splits, remove them first
			if (top != psash) {
				super.joinAll(part);
			}
			Collection<MPart> parts = getParts(application.getChildren().get(0), EModelService.IN_SHARED_AREA);
			for (MPart p : parts) {
				List<MElementContainer<MUIElement>> all = getOrderedStacks(p);
				// if it has a PartStack, it sh/c/ould be an editor stack
				if (!all.isEmpty()) {
					result = all.get(0);
					break;
				};
			};
		}
	}
	return result;
}
 
Example #7
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get the list of detached windows, if any
 * 
 * NB: The docs don't guarantee a non-null return, but the implementation seems to
 * Nor do they guarantee an order, but the implementation currently returns the same order
 * @return the list of detached windows 
 */
List<MTrimmedWindow> getDetachedFrames() {
	final MWindow topWindow = application.getChildren().get(0); 
	// NB Selectors aren't supported until Luna
	//		final Selector match = new Selector() {
	//			public boolean select(MApplicationElement element) {
	//				boolean result = element != topWindow && ((MTrimmedWindow)element).isToBeRendered();
	//				return result && !modelService.findElements((MUIElement)element, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty();
	//			}
	//		};
	//		List<MTrimmedWindow> mts = modelService.findElements(topWindow, MTrimmedWindow.class, EModelService.IN_ANY_PERSPECTIVE, match); 
	// get the all detached editor trimmed windows
	// the implementation searches all detached windows in this case
	List<MTrimmedWindow> mts = modelService.findElements(topWindow, null, MTrimmedWindow.class, null, EModelService.IN_ANY_PERSPECTIVE); 
	List<MTrimmedWindow> refined = new ArrayList<MTrimmedWindow>();
	for (MTrimmedWindow mt : mts) {
		if (mt != topWindow && mt.isToBeRendered() && !modelService.findElements(mt, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty()) {
			refined.add(mt);
		}
	}
	return refined; 
}
 
Example #8
Source File: E4WindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find the edit area.  
 * 
 * @param w
 * 
 * @return the MArea element containing the editors
 */
protected MUIElement getEditArea(MWindow w) {
	// Seems like we should be able to use modelService.find(ID_EDITOR_AREA, w), but that returns a useless PlaceHolder
	// NB Selectors aren't supported until Luna
	//		final Selector match = new Selector() {
	//			public boolean select(MApplicationElement element) {
	//				return !modelService.findElements((MUIElement)element, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty();
	//			}
	//		};
	//		List<MArea> area = modelService.findElements(w, MArea.class, EModelService.IN_SHARED_AREA, match);
	List<MArea> area = modelService.findElements(w, null, MArea.class, null, EModelService.IN_SHARED_AREA);
	List<MArea> refined = new ArrayList<MArea>();
	if (area != null) {
		for (MArea m : area) {
			if (!modelService.findElements(m, null, MPart.class, EDITOR_TAG, EModelService.IN_ANY_PERSPECTIVE).isEmpty()) {
				refined.add(m);
			}
		}
	}
	return refined.isEmpty() ? null : refined.get(0);
}
 
Example #9
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Transfer persisted state (incl. size) of fastview {@link MToolControl} defined in window, to
 * fastview defined in perspective.
 * 
 * @param fromWindow
 * @param toPerspective
 */
public static void transferFastViewPersistedState(MTrimmedWindow fromWindow,
	MPerspective toPerspective){
	EModelService modelService = getService(EModelService.class);
	// check if toolcontrol exists
	MToolControl toolControl = (MToolControl) modelService
		.find(ElexisFastViewUtil.getToolControlId(fromWindow, toPerspective), fromWindow);
	if (toolControl != null && toolControl.getPersistedState() != null) {
		Optional<MPartStack> mStack = getFastViewPartStack(toPerspective);
		mStack.ifPresent(stack -> {
			Map<String, String> perspectiveState = stack.getPersistedState();
			for (String key : toolControl.getPersistedState().keySet()) {
				perspectiveState.put(key, toolControl.getPersistedState().get(key));
			}
		});
	}
}
 
Example #10
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Transfer persisted state (incl. size) of fastview defined in perspective, to fastview
 * {@link MToolControl} defined in window.
 * 
 * @param fromPerspective
 * @param toWindow
 */
public static void transferFastViewPersistedState(MPerspective fromPerspective,
	MTrimmedWindow toWindow){
	EModelService modelService = getService(EModelService.class);
	String perspectiveId = fromPerspective.getElementId();
	
	Optional<MToolControl> mToolControl =
		getFastViewToolControl(modelService, toWindow, perspectiveId, SideValue.BOTTOM);
	mToolControl.ifPresent(toolControl -> {
		Optional<MPartStack> mStack = getFastViewPartStack(fromPerspective);
		mStack.ifPresent(stack -> {
			if (stack.getPersistedState() != null && !stack.getPersistedState().isEmpty()) {
				for (String key : stack.getPersistedState().keySet()) {
					toolControl.getPersistedState().put(key,
						stack.getPersistedState().get(key));
				}
			}
		});
	});
}
 
Example #11
Source File: InitialPerspectiveStorageAddon.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Inject
@Optional
public void selectedElement(@EventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event, EModelService modelService) {
	if (!UIEvents.isSET(event)) {
		return;
	}

	Object newlySelectedPerspective = event.getProperty(EventTags.NEW_VALUE);
	if (newlySelectedPerspective instanceof MPerspective) {
		MPerspective perspectiveToBeCloned = (MPerspective) newlySelectedPerspective;

		MWindow topLevelWindow = modelService.getTopLevelWindowFor(perspectiveToBeCloned);
		
		// try to find already existing snippet
		if (null == modelService.findSnippet(topLevelWindow, perspectiveToBeCloned.getElementId())) {
			// clone perspective in case there is no snippet yet
			modelService.cloneElement(perspectiveToBeCloned, topLevelWindow);
		}
	}
}
 
Example #12
Source File: PerspectiveImportService.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private MPerspectiveStack getPerspectiveStack(){
	EModelService modelService = getService(EModelService.class);
	MWindow window = getActiveWindow();
	List<MPerspectiveStack> theStack =
		modelService.findElements(window, null, MPerspectiveStack.class, null);
	if (theStack.size() > 0) {
		return theStack.get(0);
	}
	
	for (MWindowElement child : window.getChildren()) {
		if (child instanceof MPerspectiveStack) {
			return (MPerspectiveStack) child;
		}
	}
	return null;
}
 
Example #13
Source File: ElexisProcessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void updateModelVersions(MApplication mApplication, EModelService eModelService){
	try {
		List<MWindow> windows = mApplication.getChildren();
		if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
			MTrimmedWindow mWindow = (MTrimmedWindow) windows.get(0);
			// remove old model elements like perspectives etc
			for (String modelElementId : removeModelElements) {
				MUIElement element = eModelService.find(modelElementId, mApplication);
				if (element != null) {
					if (element instanceof MPerspective) {
						eModelService.removePerspectiveModel((MPerspective) element, mWindow);
						logger.info(
							"model element (perspective): " + modelElementId + " removed!");
					} else {
						MElementContainer<MUIElement> parent = element.getParent();
						parent.getChildren().remove(element);
						element.setToBeRendered(false);
						logger.info("model element: " + modelElementId + " removed!");
					}
				}
			}
		} else {
			logger.warn("cannot find active window");
		}
	} catch (Exception e) {
		logger.error("unexpected exception - cannot do updates on models", e);
	}
}
 
Example #14
Source File: ElexisProcessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(MApplication mApplication, EModelService eModelService){
	this.mApplication = mApplication;
	this.eModelService = eModelService;

	if (eModelService != null) {
		updateModelVersions(mApplication, eModelService);
	}
	
	updateToolbar();
	
	updateInjectViews();
	
	updateE4Views();
}
 
Example #15
Source File: PerspectiveUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static MPerspective getActivePerspective(){
	EModelService modelService = getService(EModelService.class);
	MTrimmedWindow mWindow = getActiveWindow();
	if (mWindow != null) {
		return modelService.getActivePerspective(mWindow);
	}
	return null;
}
 
Example #16
Source File: PerspectiveUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static MTrimmedWindow getActiveWindow(){
	EModelService modelService = getService(EModelService.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);
		}
	}
	return mWindow;
}
 
Example #17
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 #18
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static MTrimBar findTrimBar(EModelService eModelService, MTrimmedWindow workbenchWindow,
	SideValue sideValue){
	if (workbenchWindow != null) {
		MTrimBar trimbar = eModelService.getTrim(workbenchWindow, sideValue);
		return trimbar;
	}
	return null;
}
 
Example #19
Source File: PerspectiveImportService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private MPerspective getActivePerspective(){
	EModelService modelService = getService(EModelService.class);
	MTrimmedWindow mWindow = getActiveWindow();
	if (mWindow != null) {
		return modelService.getActivePerspective(mWindow);
	}
	return null;
}
 
Example #20
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static Optional<MPartStack> getFastViewPartStack(MPerspective mPerspective){
	EModelService modelService = getService(EModelService.class);
	MPartStack stack =
		(MPartStack) modelService.find(ElexisFastViewUtil.ELEXIS_FASTVIEW_STACK, mPerspective);
	if (stack != null) {
		return Optional.of(stack);
	}
	return Optional.empty();
}
 
Example #21
Source File: PerspectiveImportService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public MTrimmedWindow getActiveWindow(){
	EModelService modelService = getService(EModelService.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);
		}
	}
	return mWindow;
}
 
Example #22
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean hasFastViewPersistedState(MTrimmedWindow mWindow, String perspectiveId){
	EModelService eModelService = getService(EModelService.class);
	Optional<MToolControl> mToolControl =
		getFastViewToolControl(eModelService, mWindow, perspectiveId, SideValue.BOTTOM);
	if (mToolControl.isPresent()) {
		Map<String, String> persistedState = mToolControl.get().getPersistedState();
		return persistedState != null && !persistedState.isEmpty();
	}
	return false;
}
 
Example #23
Source File: PerspectiveExportService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=481996 Set the references of the
 * placeholder to the corresponding parts again in the copy.
 */
private static MPerspective clonePerspectiveWithWorkaround(EModelService modelService,
	MPerspective original){
	MPerspective clone = (MPerspective) modelService.cloneElement(original, null);
	clone.setElementId(original.getElementId());
	
	List<MPlaceholder> placeholderClones = modelService.findElements(clone, null,
		MPlaceholder.class, null, EModelService.IN_ANY_PERSPECTIVE);
	// For each placeholder in the new perspective, set the reference value to the one from the old perspective
	for (MPlaceholder placeholderClone : placeholderClones) {
		// Search for the corresponding placeholder in the "old" perspective
		List<MPlaceholder> placeholderOriginal =
			modelService.findElements(original, placeholderClone.getElementId(),
				MPlaceholder.class, null, EModelService.IN_ANY_PERSPECTIVE);
		if (placeholderOriginal.size() == 1) {
			// We found only one corresponding placeholder element. Set reference of old element to the new element
			placeholderClone.setRef((placeholderOriginal.get(0).getRef()));
		} else if (placeholderOriginal.isEmpty()) {
			System.out.println("NO PLACEHOLDER");
		} else {
			System.out.println("MORE THEN ONE PLACEHOLDER" + " " //$NON-NLS-1$
				+ placeholderOriginal.toString());
			placeholderClone.setRef((placeholderOriginal.get(0).getRef()));
		}
	}
	
	return clone;
}
 
Example #24
Source File: UiStartupHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void addMandantSelectionItem(MApplication mApplication, EModelService eModelService){
	
	MTrimBar trimbar =
		(MTrimBar) eModelService.find("org.eclipse.ui.main.toolbar", mApplication);
	
	if (trimbar != null) {
		MTrimElement mTrimElement = null;
		int position = 0;
		int i = 0;
		List<MTrimElement> childrens = trimbar.getChildren();
		for (MTrimElement element : childrens) {
			
			if ("ch.elexis.core.ui.toolcontrol.mandantselection"
				.equals(element.getElementId())) {
				mTrimElement = element;
			}
			
			if (position == 0 && ("ch.elexis.toolbar1".equals(element.getElementId())
				|| "PerspectiveSpacer".equals(element.getElementId()))) {
				position = i;
			}
			i++;
		}
		
		if (mTrimElement == null) {
			MToolControl mToolControl = eModelService.createModelElement(MToolControl.class);
			mToolControl.setElementId("ch.elexis.core.ui.toolcontrol.mandantselection");
			mToolControl.setContributionURI(
				"bundleclass://ch.elexis.core.ui/ch.elexis.core.ui.coolbar.MandantSelectionContributionItem");
			mToolControl.setToBeRendered(true);
			mToolControl.setVisible(true);
			
			childrens.add(position, mToolControl);
		}
	}
	
}
 
Example #25
Source File: ElexisFastViewUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static MTrimmedWindow getCurrentWindow(EModelService eModelService,
	MApplication mApplication){
	MTrimmedWindow window = (MTrimmedWindow) eModelService.find("IDEWindow", mApplication);
	if (window == null) {
		List<MWindow> windows = mApplication.getChildren();
		if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
			window = (MTrimmedWindow) windows.get(0);
		}
	}
	return window;
}
 
Example #26
Source File: PerspectiveHelper.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public static void deletePerspectiveFromApplication(final IPerspectiveDescriptor d) {
	final MApplication a = PlatformUI.getWorkbench().getService(MApplication.class);
	final EModelService e = PlatformUI.getWorkbench().getService(EModelService.class);
	final List<PerspectiveImpl> perspectives = e.findElements(a, PerspectiveImpl.class, EModelService.ANYWHERE,
		element -> element.getElementId().contains(d.getId()));
	for ( final PerspectiveImpl p : perspectives ) {
		// DEBUG.OUT("Dirty perspective implementation found and removed: " + p.getElementId());
		p.getParent().getChildren().remove(p);
	}
}
 
Example #27
Source File: SmallCoolBarHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	MWindow model = ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getModel();
	EModelService modelService = model.getContext().get(EModelService.class);
	MToolControl bonitaCoolBar = (MToolControl) modelService.find(
			"BonitaCoolbar", model);
	if(bonitaCoolBar != null){
		CoolbarToolControl coolbarControl = (CoolbarToolControl) bonitaCoolBar.getObject();
		coolbarControl.minimizeCoolbar();
	}
	return null;
}
 
Example #28
Source File: NormalCoolBarHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	MWindow model = ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getModel();
	EModelService modelService = model.getContext().get(EModelService.class);
	MToolControl bonitaCoolBar = (MToolControl) modelService.find(
			"BonitaCoolbar", model);
	if(bonitaCoolBar != null){
		CoolbarToolControl coolbarControl = (CoolbarToolControl) bonitaCoolBar.getObject();
		coolbarControl.maximizeCoolbar();
	}
	return null;
}
 
Example #29
Source File: AutomaticSwitchPerspectivePartListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected String getActivePerspectiveId(final MPart part) {
    if (part != null && part.getContext() != null) {
        final EModelService service = part.getContext().get(EModelService.class);
        final MWindow window = service.getTopLevelWindowFor(part);
        String activePerspective = null;
        final MPerspective selectedElement = service.getActivePerspective(window);
        if (selectedElement != null) {
            activePerspective = selectedElement.getElementId();
        }
        return activePerspective;
    }
    return null;
}
 
Example #30
Source File: FrameJoinCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
void joinOne(MTrimmedWindow mt) {
	// As long as it has any editor MParts, we can join it
	List<MPart> parts = getParts(mt, EModelService.IN_ANY_PERSPECTIVE);
	if (!parts.isEmpty()) {
		super.joinOne(parts.get(0));
	}
}