use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project whole by wholeplatform.
the class E4ModelProcessor method createToolBar.
private MToolBar createToolBar() {
MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
toolBar.setElementId("toolbar:org.eclipse.ui.main.toolbar");
List<MToolBarElement> toolItems = toolBar.getChildren();
toolItems.add(createHandledToolItem("save", "Save", "org.eclipse.ui.file.save", "platform:/plugin/org.whole.product.e4.lw/icons/save_edit.png"));
toolItems.add(createHandledToolItem("quit", "Quit", "org.eclipse.ui.file.exit"));
toolItems.add(createHandledToolItem("revert", "Revert", "org.eclipse.ui.file.revert"));
toolItems.add(createHandledToolItem("generateJava", "Generate Java", "org.whole.lang.e4.ui.command::generateJava"));
return toolBar;
}
use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project aero.minova.rcp by minova-afis.
the class WFCDetailPart method createToolItemInPartToolbar.
private ButtonAccessor createToolItemInPartToolbar(aero.minova.rcp.form.model.xsd.Button btn) {
// Kein Gruppenname: Element nur in Toolbar, kein Menü
if (btn.getGroup() == null) {
MHandledToolItem handledToolItem = eModelService.createModelElement(MHandledToolItem.class);
fillMHandledItemWithValues(handledToolItem, btn);
mPart.getToolbar().getChildren().add(handledToolItem);
return new ButtonAccessor(handledToolItem);
}
// Menü für Gruppennamen finden
MMenu groupMenu = null;
if (btn.getGroup() != null) {
for (MToolBarElement element : mPart.getToolbar().getChildren()) {
if (btn.getGroup().equalsIgnoreCase(element.getPersistedState().get(Constants.GROUP_NAME))) {
groupMenu = ((MHandledToolItem) element).getMenu();
break;
}
}
}
MHandledToolItem handledToolItem = null;
// Erstes Vorkommen des Gruppennamens: Element in Toolbar, Menü muss noch erstellt werden
if (groupMenu == null) {
handledToolItem = eModelService.createModelElement(MHandledToolItem.class);
fillMHandledItemWithValues(handledToolItem, btn);
mPart.getToolbar().getChildren().add(handledToolItem);
groupMenu = eModelService.createModelElement(MMenu.class);
handledToolItem.getPersistedState().put(Constants.GROUP_NAME, btn.getGroup());
handledToolItem.setMenu(groupMenu);
}
// Wenn Gruppenname gegeben ist soll der Button immer auch in das Dropdown-Menü
MHandledMenuItem menuEntry = eModelService.createModelElement(MHandledMenuItem.class);
fillMHandledItemWithValues(menuEntry, btn);
groupMenu.getChildren().add(menuEntry);
return new ButtonAccessor(handledToolItem, menuEntry);
}
use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project aero.minova.rcp by minova-afis.
the class BlockHandler method init.
private void init(MPart part) {
this.mPart = part;
this.detail = (WFCDetailPart) part.getObject();
this.keyLong = detail.getDetail().getField("KeyLong");
this.blocked = detail.getDetail().getField("Blocked");
blocked.addValueChangeListener(this);
// Knopf finden
for (MToolBarElement item : mPart.getToolbar().getChildren()) {
if (item.getElementId().equals("aero.minova.rcp.rcp.handledtoolitem.block")) {
blockedToolItem = (HandledToolItemImpl) item;
}
}
firstCall = false;
}
use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project eclipse.platform.ui by eclipse-platform.
the class ContributionsAnalyzer method processAddition.
public static boolean processAddition(final MToolBar toolBarModel, MToolBarContribution toolBarContribution, List<MToolBarElement> contributions, HashSet<String> existingSeparatorNames) {
int idx = getIndex(toolBarModel, toolBarContribution.getPositionInParent());
if (idx == -1) {
return false;
}
for (MToolBarElement item : toolBarContribution.getChildren()) {
if (item instanceof MToolBarSeparator && existingSeparatorNames.contains(item.getElementId())) {
// skip this, it's already there
continue;
}
MToolBarElement copy = (MToolBarElement) EcoreUtil.copy((EObject) item);
if (DEBUG) {
// $NON-NLS-1$
trace("addToolBarContribution " + copy, toolBarModel.getWidget(), toolBarModel);
}
toolBarModel.getChildren().add(idx++, copy);
contributions.add(copy);
if (copy instanceof MToolBarSeparator && copy.getElementId() != null) {
existingSeparatorNames.add(copy.getElementId());
}
}
return true;
}
use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project eclipse.platform.ui by eclipse-platform.
the class ToolBarContributionRecord method computeVisibility.
public boolean computeVisibility(HashSet<ToolBarContributionRecord> recentlyUpdated, MToolBarElement item, ExpressionContext exprContext) {
boolean currentVisibility = isVisible;
if (item instanceof MToolBarSeparator) {
ArrayList<ToolBarContributionRecord> list = renderer.getList(item);
if (list != null) {
Iterator<ToolBarContributionRecord> cr = list.iterator();
while (!currentVisibility && cr.hasNext()) {
ToolBarContributionRecord rec = cr.next();
if (!recentlyUpdated.contains(rec)) {
rec.updateIsVisible(exprContext);
recentlyUpdated.add(rec);
}
currentVisibility |= rec.isVisible;
}
}
}
if (currentVisibility && item.getPersistedState().get(MenuManagerRenderer.VISIBILITY_IDENTIFIER) != null) {
String identifier = item.getPersistedState().get(MenuManagerRenderer.VISIBILITY_IDENTIFIER);
Object rc = exprContext.eclipseContext.get(identifier);
if (rc instanceof Boolean) {
currentVisibility = ((Boolean) rc).booleanValue();
}
}
if (currentVisibility && item.getVisibleWhen() != null) {
boolean val = ContributionsAnalyzer.isVisible(item.getVisibleWhen(), exprContext);
currentVisibility = val;
}
return currentVisibility;
}
Aggregations