DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
Resource model = graph.syncRequest(new IndexRoot(parameter));
Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model);
- Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
- if (activeVisualisation != null) {
- return DistrictNetworkUtil.colorBarOptions(graph, activeVisualisation);
+ if (vf != null) {
+ Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
+ if (activeVisualisation != null) {
+ return DistrictNetworkUtil.colorBarOptions(graph, activeVisualisation);
+ }
+ } else {
+ LOGGER.debug("No visualisation folder available for model {}", model);
}
return ColorBarOptions.useDefault();
}
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
Resource model = graph.syncRequest(new IndexRoot(parameter));
Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model);
- Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
- if (activeVisualisation != null) {
- return DistrictNetworkUtil.colorContributions(graph, activeVisualisation);
+ if (vf != null) {
+ Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
+ if (activeVisualisation != null) {
+ return DistrictNetworkUtil.colorContributions(graph, activeVisualisation);
+ }
+ } else {
+ LOGGER.debug("No visualisation folder available for model {}", model);
}
return Collections.emptyMap();
}
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
Resource model = graph.syncRequest(new IndexRoot(parameter));
Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model);
- Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
- if (activeVisualisation != null) {
- return DistrictNetworkUtil.sizeBarOptions(graph, activeVisualisation);
+ if (vf != null) {
+ Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
+ if (activeVisualisation != null) {
+ return DistrictNetworkUtil.sizeBarOptions(graph, activeVisualisation);
+ }
+ } else {
+ LOGGER.debug("No visualisation folder available for model {}", model);
}
return SizeBarOptions.useDefault();
}
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
Resource model = graph.syncRequest(new IndexRoot(parameter));
Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model);
- Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
- if (activeVisualisation != null) {
- return DistrictNetworkUtil.sizeContributions(graph, activeVisualisation);
+ if (vf != null) {
+ Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
+ if (activeVisualisation != null) {
+ return DistrictNetworkUtil.sizeContributions(graph, activeVisualisation);
+ }
+ } else {
+ LOGGER.debug("No visualisation folder available for model {}", model);
}
return Collections.emptyMap();
}
}
}
+ 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();
}
}
});