use of aero.minova.rcp.form.menu.mdi.Main.Action in project aero.minova.rcp by minova-afis.
the class MenuProcessor method processXML.
private void processXML(String fileContent) {
Main mainMDI = null;
MMenuContribution menuContribution = modelService.createModelElement(MMenuContribution.class);
menuContribution.setParentId("org.eclipse.ui.main.menu");
menuContribution.setPositionInParent("after=additions");
menuContribution.setElementId("generated" + menuId++);
menuContribution.getPersistedState().put("persistState", "false");
mApplication.getMenuContributions().add(menuContribution);
try {
mainMDI = XmlProcessor.get(fileContent, Main.class);
List<Object> menuOrEntry = mainMDI.getMenu().getMenuOrEntry();
if (!menuOrEntry.isEmpty()) {
HashMap<String, Action> actionsMDI = new HashMap<>();
if (mainMDI.getAction() != null && !mainMDI.getAction().isEmpty()) {
for (Action action : mainMDI.getAction()) {
actionsMDI.put(action.getId(), action);
}
}
for (Object object : menuOrEntry) {
if (object instanceof MenuType) {
MMenu createMenu = createMenu((MenuType) object, actionsMDI, modelService, mApplication);
menuContribution.getChildren().add(createMenu);
}
}
}
} catch (JAXBException e) {
e.printStackTrace();
}
}
use of aero.minova.rcp.form.menu.mdi.Main.Action in project aero.minova.rcp by minova-afis.
the class MenuProcessor method createMenu.
/**
* Diese Methode erstellt aus dem übergebenen menu ein MMenu inklusiver der Einträge
*
* @param menu_MDI
* @param menu
* @param actions_MDI
* @param modelService
* @param mApplication
*/
private MMenu createMenu(MenuType menu_MDI, HashMap<String, Action> actions_MDI, EModelService modelService, MApplication mApplication) {
MMenu menuGen = modelService.createModelElement(MMenu.class);
menuGen.getPersistedState().put("persistState", String.valueOf(false));
menuGen.setElementId("generated" + menuId++);
menuGen.setLabel(menu_MDI.getText());
// TODO Sortierung des MENUS aus der MDI beachten!!!
if (!menu_MDI.getEntryOrMenu().isEmpty() && menu_MDI.getEntryOrMenu() != null) {
for (Object object : menu_MDI.getEntryOrMenu()) {
if (object instanceof Entry) {
Entry entryMDI = (Entry) object;
if (!entryMDI.getType().equals("separator")) {
String id2 = ((Action) entryMDI.getId()).getId();
MHandledMenuItem handledMenuItem = createMenuEntry(entryMDI, actions_MDI.get(id2), modelService, mApplication);
menuGen.getChildren().add(handledMenuItem);
}
}
}
}
return menuGen;
}
use of aero.minova.rcp.form.menu.mdi.Main.Action in project aero.minova.rcp by minova-afis.
the class MenuTest method checkEntries.
private int checkEntries(List<String> entries, int counter, Object menuOrEntry) {
if (menuOrEntry instanceof MenuType) {
String translated = translationService.translate(((MenuType) menuOrEntry).getText(), null);
assertEquals(translated, entries.get(counter));
counter++;
for (Object o : ((MenuType) menuOrEntry).getEntryOrMenu()) {
counter = checkEntries(entries, counter, o);
}
} else {
Entry entry = (Entry) menuOrEntry;
if (entry.getId() instanceof Action) {
String name = ((Action) entry.getId()).getText();
String translated = translationService.translate(name, null);
assertEquals(translated, entries.get(counter));
counter++;
}
}
return counter;
}
Aggregations