use of aero.minova.rcp.form.menu.mdi.Main 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 in project aero.minova.rcp by minova-afis.
the class MenuTest method openPreferencesAndTestMenu.
@Test
public void openPreferencesAndTestMenu() {
if (System.getProperty("os.name").startsWith("Linux")) {
return;
}
// Einstellungen über Command öffnen
Display.getDefault().asyncExec(() -> {
ECommandService commandService = getEclipseContext().get(ECommandService.class);
EHandlerService handlerService = getEclipseContext().get(EHandlerService.class);
ParameterizedCommand cmd = commandService.createCommand("org.eclipse.ui.window.preferences", null);
handlerService.executeHandler(cmd);
});
// Workspace-Ordner auslesen
SWTBotShell shell = bot.shell("Preferences");
assertNotNull(shell);
SWTBot childBot = new SWTBot(shell.widget);
SWTBotText currentWorkspaceText = childBot.text(1);
assertNotNull(currentWorkspaceText);
assertNotNull(currentWorkspaceText.getText());
String pathWorkspace = currentWorkspaceText.getText();
shell.close();
// application.mdi einlesen und Menü überprüfen
try {
Path path = Path.of(pathWorkspace, "application.mdi");
String applicationString = Files.readString(path);
assertNotNull(applicationString);
Main mainMDI = XmlProcessor.get(applicationString, Main.class);
assertNotNull(mainMDI);
// Liste mit Menueinträgen (depth-first)
List<String> menuEntries = new ArrayList<>();
Map<String, Integer> callsToMenu = new HashMap<>();
SWTBotRootMenu menu = bot.menu();
for (String menuEntry : menu.menuItems()) {
int i = callsToMenu.get(menuEntry) == null ? 0 : callsToMenu.get(menuEntry);
callsToMenu.put(menuEntry, i + 1);
SWTBotMenu menu2 = bot.menu().menu(menuEntry, false, i);
// File Menü überspringen (nicht von uns)
if (menu2.getText().equals("File")) {
continue;
}
getMenuEntries(menuEntries, menu2);
}
// TODO Reihenfolge in der mdi beachten (siehe MenuProcessor)
int counter = 0;
for (Object menuOrEntry : mainMDI.getMenu().getMenuOrEntry()) {
counter = checkEntries(menuEntries, counter, menuOrEntry);
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations