String item = templateSelectionCombo.getItem(templateSelectionCombo.getSelectionIndex());
for (NamedResource template : visualisations) {
if (item.equals(template.getName())) {
- Simantics.getSession().asyncRequest(new WriteRequest() {
-
- @Override
- public void perform(WriteGraph graph) throws DatabaseException {
- Resource vf = DynamicVisualisations.getVisualisationFolder(graph, parentResource);
- DynamicVisualisations.setActiveVisualisation(graph, vf, template.getResource());
- }
- });
- break;
+ if (parentResource != null) {
+ Resource res = parentResource;
+ Simantics.getSession().asyncRequest(new WriteRequest() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ Resource vf = DynamicVisualisations.getVisualisationFolder(graph, res);
+ DynamicVisualisations.setActiveVisualisation(graph, vf, template.getResource());
+ }
+ });
+ break;
+ }
}
}
}
private void updateListening() {
if (visualisationsListener != null)
visualisationsListener.dispose();
- visualisationsListener = new VisualisationsListener(this);
- Simantics.getSession().asyncRequest(new DynamicVisualisationsRequest(parentResource), visualisationsListener);
+ if (parentResource != null) {
+ visualisationsListener = new VisualisationsListener(this);
+ Simantics.getSession().asyncRequest(new DynamicVisualisationsRequest(parentResource), visualisationsListener);
+ }
if (listener != null)
listener.dispose();
- listener = new VisualisationListener(this);
- Simantics.getSession().asyncRequest(new ActiveDynamicVisualisationsRequest(parentResource), listener);
+ if (parentResource != null) {
+ listener = new VisualisationListener(this);
+ Simantics.getSession().asyncRequest(new ActiveDynamicVisualisationsRequest(parentResource), listener);
+ }
}
private static class VisualisationsListener implements Listener<Collection<NamedResource>> {