use of org.eclipse.scanning.device.ui.composites.MultiStepComposite in project gda-core by openGDA.
the class MultiStepEditorDialog method createDialogArea.
@Override
public Control createDialogArea(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(comp);
Button loadButton = new Button(comp, SWT.PUSH);
loadButton.setImage(Activator.getImage("icons/folder-import.png"));
loadButton.setToolTipText("Load multi-step model");
Button saveButton = new Button(comp, SWT.PUSH);
saveButton.setImage(Activator.getImage("icons/folder-export.png"));
saveButton.setToolTipText("Save multi-step model");
if (model == null) {
model = new AxialMultiStepModel();
model.setName(scannableName);
}
final IModelProvider<AxialMultiStepModel> modelProvider = new IModelProvider<AxialMultiStepModel>() {
@Override
public AxialMultiStepModel getModel() throws Exception {
return model;
}
@Override
public void updateModel(AxialMultiStepModel model) throws Exception {
// updateModel is not needed for this implementation
// Overriding because super throws IllegalArgumentException
}
};
ed = new TypeEditor<>(modelProvider, comp, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(ed);
try {
ed.setModel(model);
} catch (Exception e) {
logger.error("Could not set model:", e);
}
((MultiStepComposite) ed.getUI()).updateUnits(scannableName);
// Disabling scannable name combo since dialog is tied to single scannable
((MultiStepComposite) ed.getUI()).setNameComboEnabled(false);
// Load default values
((MultiStepComposite) ed.getUI()).getStepModels().setBeanConfigurator(getBeanConfigurator());
// save & load logic
ModelPersistAction<AxialMultiStepModel> load = new ModelPersistAction<>(ed, PersistType.LOAD);
loadButton.addListener(SWT.Selection, event -> load.run());
ModelPersistAction<AxialMultiStepModel> save = new ModelPersistAction<>(ed, PersistType.SAVE);
saveButton.addListener(SWT.Selection, event -> save.run());
return ed;
}
Aggregations