Search in sources :

Example 6 with PersistState

use of org.eclipse.e4.ui.di.PersistState in project aero.minova.rcp by minova-afis.

the class SearchCriteriaLoadHandler 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("LOAD");
    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 7 with PersistState

use of org.eclipse.e4.ui.di.PersistState in project gda-core by openGDA.

the class MappingExperimentView method saveState.

@PersistState
public void saveState(MPart part) {
    // serialize the json bean and save it in the preferences
    final IMarshallerService marshaller = injectionContext.get(IMarshallerService.class);
    try {
        logger.trace("Saving the current state of the mapping view.");
        final String json = marshaller.marshal(mappingBeanProvider.getMappingExperimentBean());
        part.getPersistedState().put(STATE_KEY_MAPPING_BEAN_JSON, json);
    } catch (Exception e) {
        logger.error("Could not save current the state of the mapping view.", e);
    }
    // Now save any other persistent data that is outside the mapping bean
    for (IMappingSection section : sections.values()) {
        section.saveState(part.getPersistedState());
    }
}
Also used : IMarshallerService(org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService) PersistState(org.eclipse.e4.ui.di.PersistState)

Example 8 with PersistState

use of org.eclipse.e4.ui.di.PersistState in project gda-core by openGDA.

the class TimeSeriesScanView method saveState.

@PersistState
public void saveState(MPart part) {
    try {
        final Map<String, String> state = part.getPersistedState();
        state.put(STATE_KEY_MALCOLM_DEVICE_NAME, getSelectedMalcolmDeviceName());
        state.put(STATE_KEY_NUM_STEPS, numStepsSpinner.getText());
        final IMarshallerService marshaller = eclipseContext.get(IMarshallerService.class);
        final String outerScannablesJson = marshaller.marshal(outerScannablesBlock.getOuterScannables());
        state.put(STATE_KEY_OUTER_SCANNABLES, outerScannablesJson);
    } catch (Exception e) {
        logger.error("Could not save the current state of the Time Series Scan view", e);
    }
}
Also used : IMarshallerService(org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService) URISyntaxException(java.net.URISyntaxException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) ValidationException(org.eclipse.scanning.api.ValidationException) EventException(org.eclipse.scanning.api.event.EventException) PersistState(org.eclipse.e4.ui.di.PersistState)

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