}
}
+ private void persistCurrentVisualisationTemplateIfAvailable() {
+ if (visualisation != null) {
+ try {
+ persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource()));
+ } catch (Exception e1) {
+ LOGGER.error("Could not persist visualisation template", e1);
+ ShowError.showError("Could not persist visualisation template", e1.getMessage(), e1);
+ }
+ } else {
+ LOGGER.info("No current visualisation template selected for saving");
+ }
+ }
+
private void persistVisualisationTemplate(String templateName, Optional<Resource> existing) throws Exception {
List<Pair<String, DynamicColorContribution>> colorCollect = colorSuppliers.stream().map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList());
@Override
public void widgetSelected(SelectionEvent e) {
- try {
- persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource()));
- } catch (Exception e1) {
- LOGGER.error("Could not persist visualisation template", e1);
- ShowError.showError("Could not persist visualisation template", e1.getMessage(), e1);
- }
+ persistCurrentVisualisationTemplateIfAvailable();
}
});
} else if (widget instanceof Combo) {
@Override
public void widgetSelected(SelectionEvent e) {
- try {
- persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource()));
- } catch (Exception e1) {
- LOGGER.error("Could not persist visualisation template", e1);
- ShowError.showError("Could not persist visualisation template", e1.getMessage(), e1);
- }
+ persistCurrentVisualisationTemplateIfAvailable();
}
});
} else if (widget instanceof Text) {
@Override
public void focusLost(FocusEvent e) {
- try {
- persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource()));
- } catch (Exception e1) {
- LOGGER.error("Could not persist visualisation template", e1);
- ShowError.showError("Could not persist visualisation template", e1.getMessage(), e1);
- }
+ persistCurrentVisualisationTemplateIfAvailable();
}
});
((Text) widget).addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if(e.keyCode == SWT.CR || e.keyCode == SWT.LF) {
- try {
- persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource()));
- } catch (Exception e1) {
- LOGGER.error("Could not persist visualisation template", e1);
- ShowError.showError("Could not persist visualisation template", e1.getMessage(), e1);
- }
+ persistCurrentVisualisationTemplateIfAvailable();
}
}
});