use of org.eclipse.e4.ui.di.PersistState in project aero.minova.rcp by minova-afis.
the class MenuProcessor method createMenuEntry.
/**
* Diese Methode erstellt einen Eintrag für ein MMenu aus dem übergebenen MDI-Eintrag
*
* @param entryMDI
* @param actionMDI
* @param modelService
* @param mApplication
* @return
*/
private MHandledMenuItem createMenuEntry(Entry entryMDI, Action actionMDI, EModelService modelService, MApplication mApplication) {
MHandledMenuItem handledMenuItem = modelService.createModelElement(MHandledMenuItem.class);
handledMenuItem.getPersistedState().put("persistState", String.valueOf(false));
MCommand command = mApplication.getCommand("aero.minova.rcp.rcp.command.openform");
handledMenuItem.setCommand(command);
// set the form name as parameter
MParameter mParameterForm = modelService.createModelElement(MParameter.class);
// not used
mParameterForm.setElementId("parameter.formName." + entryMDI.getId());
mParameterForm.setName(Constants.FORM_NAME);
mParameterForm.setValue(actionMDI.getAction());
handledMenuItem.getParameters().add(mParameterForm);
// set the perspective id as parameter
MParameter mParameterId = modelService.createModelElement(MParameter.class);
// not used
mParameterId.setElementId("parameter.formId." + entryMDI.getId());
mParameterId.setName(Constants.FORM_ID);
mParameterId.setValue(actionMDI.getId());
handledMenuItem.getParameters().add(mParameterId);
// set the perspective name as parameter
MParameter mParameterPerspectiveName = modelService.createModelElement(MParameter.class);
// not used
mParameterPerspectiveName.setElementId("parameter.PerspectiveLabel." + entryMDI.getId());
mParameterPerspectiveName.setName(Constants.FORM_LABEL);
mParameterPerspectiveName.setValue(actionMDI.getText());
handledMenuItem.getParameters().add(mParameterPerspectiveName);
// set the perspective icon as parameter
MParameter mParameterPerspectiveIcon = modelService.createModelElement(MParameter.class);
// not used
mParameterPerspectiveIcon.setElementId("parameter.PerspectiveIcon." + entryMDI.getId());
mParameterPerspectiveIcon.setName(Constants.FORM_ICON);
mParameterPerspectiveIcon.setValue(actionMDI.getIcon());
handledMenuItem.getParameters().add(mParameterPerspectiveIcon);
handledMenuItem.setElementId("menuItemFor." + actionMDI.getId());
handledMenuItem.setLabel(actionMDI.getText());
String retrieveIcon = ImageUtil.retrieveIcon(actionMDI.getIcon(), false);
handledMenuItem.setIconURI(retrieveIcon);
return handledMenuItem;
}
use of org.eclipse.e4.ui.di.PersistState 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 org.eclipse.e4.ui.di.PersistState in project aero.minova.rcp by minova-afis.
the class SearchCriteriaSaveHandler method createMenuItem.
private MHandledMenuItem createMenuItem(EModelService service, String criteriaTableName) {
MHandledMenuItem mi = service.createModelElement(MHandledMenuItem.class);
// Name aus dem Eintrag suchen!
// vWorkingTime.erlanger Heute.table
// vWorkingTime.erlanger Heute
// erlanger Heute
String displayName = criteriaTableName.replace(".table", "");
displayName = displayName.substring(displayName.lastIndexOf(".") + 1, displayName.length());
mi.setLabel(displayName);
final MCommand cmd = MCommandsFactory.INSTANCE.createCommand();
cmd.setElementId("aero.minova.rcp.rcp.command.searchCriteria");
mi.setCommand(cmd);
// action
MParameter param = MCommandsFactory.INSTANCE.createParameter();
param.setName("aero.minova.rcp.rcp.commandparameter.criteriaaction");
param.setValue("SAVE_NAME");
mi.getParameters().add(param);
// Name
param = MCommandsFactory.INSTANCE.createParameter();
param.setName("aero.minova.rcp.rcp.commandparameter.criterianame");
param.setValue(displayName);
mi.getParameters().add(param);
// Handler der aufgerufen werden soll, wenn wir auf den Button drücken
mi.getPersistedState().put("persistState", "false");
return mi;
}
use of org.eclipse.e4.ui.di.PersistState in project aero.minova.rcp by minova-afis.
the class WFCDetailPart method persistState.
@PersistState
public void persistState() {
// Grids
for (SectionGrid sg : sectionGrids) {
sg.saveState();
}
// Sections, ein-/ausgeklappt
for (MSection s : mDetail.getMSectionList()) {
MinovaSection section = ((SectionAccessor) s.getSectionAccessor()).getSection();
String prefsExpandedString = form.getTitle() + "." + section.getData(TRANSLATE_PROPERTY) + ".expanded";
prefsDetailSections.put(prefsExpandedString, section.isExpanded() + "");
String prefsMinimizedString = form.getTitle() + "." + section.getData(TRANSLATE_PROPERTY) + ".minimized";
prefsDetailSections.put(prefsMinimizedString, section.isMinimized() + "");
}
try {
prefsDetailSections.flush();
} catch (BackingStoreException e1) {
e1.printStackTrace();
}
}
use of org.eclipse.e4.ui.di.PersistState 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;
}
Aggregations