org.eclipse.e4.ui.model.application.ui.basic.MTrimElement Java Examples

The following examples show how to use org.eclipse.e4.ui.model.application.ui.basic.MTrimElement. 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: GamlReferenceSearch.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void install() {
	WorkbenchHelper.runInUI("Install GAML Search", 0, m -> {
		final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if (window instanceof WorkbenchWindow) {
			final MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
			for (final MTrimElement element : topTrim.getChildren()) {
				if ("SearchField".equals(element.getElementId())) {
					final Composite parent = ((Control) element.getWidget()).getParent();
					final Control old = (Control) element.getWidget();
					WorkbenchHelper.runInUI("Disposing old search control", 500, m2 -> old.dispose());
					element.setWidget(GamlSearchField.installOn(parent));
					parent.layout(true, true);
					parent.update();
					break;
				}
			}
		}
	});
}
 
Example #2
Source File: SamplePart.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent, IPresentationEngine presentationEngine, EModelService modelService, MApplication app, IEclipseContext context) {
	List<MTrimContribution> trimContributions = app.getTrimContributions();
	
	Optional<MTrimElement> findAny = trimContributions.stream().flatMap(tbc -> tbc.getChildren().stream()).filter(tbe -> "com.vogella.e4.renderer.toolbar".equals(tbe.getElementId())).findAny();

	findAny.ifPresent(uiElement -> {
		ToolBar toolBar = new ToolBar(parent, SWT.NONE);
		presentationEngine.createGui(uiElement, toolBar, context);
	});
}
 
Example #3
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);
		}
	}
	
}