Search in sources :

Example 1 with IMappingExperimentBeanProvider

use of uk.ac.diamond.daq.mapping.api.IMappingExperimentBeanProvider in project gda-core by openGDA.

the class MappingXanesTemplateHandler method loadTemplate.

private void loadTemplate(String templatePath) {
    final IMappingExperimentBean template;
    try {
        final byte[] bytes = Files.readAllBytes(Paths.get(templatePath));
        final String json = new String(bytes, "UTF-8");
        final IMarshallerService marshaller = getService(IMarshallerService.class);
        template = marshaller.unmarshal(json, MappingExperimentBean.class);
    } catch (Exception e) {
        logger.error("Error loading template", e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Mapping template", "Could not load map template. Map parameters have not been changed.");
        return;
    }
    final IMappingExperimentBeanProvider beanProvider = getService(IMappingExperimentBeanProvider.class);
    final IMappingExperimentBean currentBean = beanProvider.getMappingExperimentBean();
    template.getScanDefinition().setMappingScanRegion(currentBean.getScanDefinition().getMappingScanRegion());
    beanProvider.setMappingExperimentBean(template);
    final MappingExperimentView view = (MappingExperimentView) getService(EPartService.class).findPart(MappingExperimentView.ID).getObject();
    view.updateControls();
}
Also used : IMarshallerService(org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService) IMappingExperimentBean(uk.ac.diamond.daq.mapping.api.IMappingExperimentBean) MappingExperimentBean(uk.ac.diamond.daq.mapping.impl.MappingExperimentBean) MappingExperimentView(uk.ac.diamond.daq.mapping.ui.experiment.MappingExperimentView) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IMappingExperimentBeanProvider(uk.ac.diamond.daq.mapping.api.IMappingExperimentBeanProvider) ExecutionException(org.eclipse.core.commands.ExecutionException) IMappingExperimentBean(uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)1 IMarshallerService (org.eclipse.dawnsci.analysis.api.persistence.IMarshallerService)1 EPartService (org.eclipse.e4.ui.workbench.modeling.EPartService)1 IMappingExperimentBean (uk.ac.diamond.daq.mapping.api.IMappingExperimentBean)1 IMappingExperimentBeanProvider (uk.ac.diamond.daq.mapping.api.IMappingExperimentBeanProvider)1 MappingExperimentBean (uk.ac.diamond.daq.mapping.impl.MappingExperimentBean)1 MappingExperimentView (uk.ac.diamond.daq.mapping.ui.experiment.MappingExperimentView)1