use of org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem 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.MHandledToolItem in project eclipse.platform.ui by eclipse-platform.
the class ProgrammaticProgressView method createViewMenu.
private void createViewMenu() {
MHandledToolItem clearAllButton = modelService.createModelElement(MHandledToolItem.class);
clearAllButton.setIconURI(CLEAR_ALL_ICON_URI);
clearAllButton.setCommand(clearAllCommand);
MToolBar toolBar = modelService.createModelElement(MToolBar.class);
toolBar.getChildren().add(clearAllButton);
part.setToolbar(toolBar);
MHandledMenuItem clearAllMenuItem = modelService.createModelElement(MHandledMenuItem.class);
// $NON-NLS-1$
clearAllMenuItem.setLabel("Clear All");
clearAllMenuItem.setIconURI(CLEAR_ALL_ICON_URI);
clearAllMenuItem.setCommand(clearAllCommand);
MHandledMenuItem preferencesMenuItem = modelService.createModelElement(MHandledMenuItem.class);
// $NON-NLS-1$
preferencesMenuItem.setLabel("Preferences");
preferencesMenuItem.setCommand(showPreferencesCommand);
MMenu menu = modelService.createModelElement(MMenu.class);
// required //$NON-NLS-1$
menu.getTags().add("ViewMenu");
menu.getChildren().add(clearAllMenuItem);
menu.getChildren().add(preferencesMenuItem);
part.getMenus().add(menu);
}
use of org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem in project eclipse.platform.ui by eclipse-platform.
the class ToolBarManagerRenderer method processHandledItem.
private void processHandledItem(ToolBarManager parentManager, MHandledToolItem itemModel) {
IContributionItem ici = getContribution(itemModel);
if (ici != null) {
return;
}
itemModel.setRenderer(this);
final IEclipseContext lclContext = getContext(itemModel);
HandledContributionItem ci = ContextInjectionFactory.make(HandledContributionItem.class, lclContext);
ci.setModel(itemModel);
ci.setVisible(itemModel.isVisible());
addToManager(parentManager, itemModel, ci);
linkModelToContribution(itemModel, ci);
}
use of org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem in project eclipse.platform.ui by eclipse-platform.
the class ToolBarManagerRenderer method modelProcessSwitch.
private void modelProcessSwitch(ToolBarManager parentManager, MToolBarElement childME) {
if (!childME.isToBeRendered()) {
return;
}
if (OpaqueElementUtil.isOpaqueToolItem(childME)) {
MToolItem itemModel = (MToolItem) childME;
processOpaqueItem(parentManager, itemModel);
} else if (childME instanceof MHandledToolItem) {
MHandledToolItem itemModel = (MHandledToolItem) childME;
processHandledItem(parentManager, itemModel);
} else if (childME instanceof MDirectToolItem) {
MDirectToolItem itemModel = (MDirectToolItem) childME;
processDirectItem(parentManager, itemModel);
} else if (childME instanceof MToolBarSeparator) {
MToolBarSeparator itemModel = (MToolBarSeparator) childME;
processSeparator(parentManager, itemModel);
} else if (childME instanceof MToolControl) {
MToolControl itemModel = (MToolControl) childME;
processToolControl(parentManager, itemModel);
}
}
use of org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem in project eclipse.platform.ui by eclipse-platform.
the class ModelAssemblerFragmentOrderingTests method testIncorrectIndexNotEmptyApplication.
@Test
public void testIncorrectIndexNotEmptyApplication() {
// initial application elements
MHandledToolItem x = MMenuFactory.INSTANCE.createHandledToolItem();
x.setElementId("x");
toolBar.getChildren().add(x);
MHandledToolItem y = MMenuFactory.INSTANCE.createHandledToolItem();
y.setElementId("y");
toolBar.getChildren().add(y);
MHandledToolItem z = MMenuFactory.INSTANCE.createHandledToolItem();
z.setElementId("z");
toolBar.getChildren().add(z);
// the fragments
Resource fragmentResource = factory.createResource(URI.createURI("fragmentvirtualuri"));
resourceSet.getResources().add(fragmentResource);
final String contributorName = "testIncorrectIndex1";
final String contributorURI = fragmentResource.getURI().toString();
// the contributed elements
MHandledToolItem a = MMenuFactory.INSTANCE.createHandledToolItem();
a.setElementId("a");
MModelFragments fragmentsContainerA = MFragmentFactory.INSTANCE.createModelFragments();
fragmentResource.getContents().add((EObject) fragmentsContainerA);
ModelFragmentWrapper fragmentWrapperA = createFragmentWrapper(fragmentsContainerA, "children", MAIN_TOOLBAR_ID, Arrays.asList(a), "index:-70", contributorName, contributorURI, false);
MHandledToolItem b = MMenuFactory.INSTANCE.createHandledToolItem();
b.setElementId("b");
MModelFragments fragmentsContainerB = MFragmentFactory.INSTANCE.createModelFragments();
fragmentResource.getContents().add((EObject) fragmentsContainerB);
ModelFragmentWrapper fragmentWrapperB = createFragmentWrapper(fragmentsContainerB, "children", MAIN_TOOLBAR_ID, Arrays.asList(b), "index:70", contributorName, contributorURI, false);
Set<ModelFragmentWrapper> fragmentList = new TreeSet<>(new ModelFragmentComparator(application));
fragmentList.addAll(Arrays.asList(fragmentWrapperA, fragmentWrapperB));
Iterator<ModelFragmentWrapper> iterator = fragmentList.iterator();
assertEquals(fragmentWrapperA, iterator.next());
assertEquals(fragmentWrapperB, iterator.next());
assertEquals(3, toolBar.getChildren().size());
assertEquals(x, toolBar.getChildren().get(0));
assertEquals(y, toolBar.getChildren().get(1));
assertEquals(z, toolBar.getChildren().get(2));
assembler.processFragmentWrappers(fragmentList);
assertEquals(5, toolBar.getChildren().size());
assertEquals(a, toolBar.getChildren().get(3));
assertEquals(b, toolBar.getChildren().get(4));
}
Aggregations