Search in sources :

Example 1 with PersistState

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;
}
Also used : MCommand(org.eclipse.e4.ui.model.application.commands.MCommand) MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem) MParameter(org.eclipse.e4.ui.model.application.commands.MParameter)

Example 2 with PersistState

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();
    }
}
Also used : Action(aero.minova.rcp.form.menu.mdi.Main.Action) MenuType(aero.minova.rcp.form.menu.mdi.MenuType) HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) MMenuContribution(org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution) Main(aero.minova.rcp.form.menu.mdi.Main) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu)

Example 3 with PersistState

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;
}
Also used : MCommand(org.eclipse.e4.ui.model.application.commands.MCommand) MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem) MParameter(org.eclipse.e4.ui.model.application.commands.MParameter)

Example 4 with PersistState

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();
    }
}
Also used : BackingStoreException(org.osgi.service.prefs.BackingStoreException) SectionAccessor(aero.minova.rcp.rcp.accessor.SectionAccessor) MSection(aero.minova.rcp.model.form.MSection) MinovaSection(aero.minova.rcp.css.widgets.MinovaSection) SectionGrid(aero.minova.rcp.rcp.widgets.SectionGrid) PersistState(org.eclipse.e4.ui.di.PersistState)

Example 5 with PersistState

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;
}
Also used : Entry(aero.minova.rcp.form.menu.mdi.Main.Entry) Action(aero.minova.rcp.form.menu.mdi.Main.Action) MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu)

Aggregations

MHandledMenuItem (org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem)4 PersistState (org.eclipse.e4.ui.di.PersistState)3 MCommand (org.eclipse.e4.ui.model.application.commands.MCommand)3 MParameter (org.eclipse.e4.ui.model.application.commands.MParameter)3 Action (aero.minova.rcp.form.menu.mdi.Main.Action)2 IMarshallerService (org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService)2 MMenu (org.eclipse.e4.ui.model.application.ui.menu.MMenu)2 MinovaSection (aero.minova.rcp.css.widgets.MinovaSection)1 Main (aero.minova.rcp.form.menu.mdi.Main)1 Entry (aero.minova.rcp.form.menu.mdi.Main.Entry)1 MenuType (aero.minova.rcp.form.menu.mdi.MenuType)1 MSection (aero.minova.rcp.model.form.MSection)1 SectionAccessor (aero.minova.rcp.rcp.accessor.SectionAccessor)1 SectionGrid (aero.minova.rcp.rcp.widgets.SectionGrid)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 JAXBException (javax.xml.bind.JAXBException)1 MMenuContribution (org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution)1 ValidationException (org.eclipse.scanning.api.ValidationException)1 EventException (org.eclipse.scanning.api.event.EventException)1