From: jsimomaa Date: Thu, 17 Oct 2019 08:31:47 +0000 (+0300) Subject: Fixing UI related bugs in Dynamic Visualisations view X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9b69c365052ce52988a98fe851f6a7d931baef03;p=simantics%2Fdistrict.git Fixing UI related bugs in Dynamic Visualisations view gitlab #59 Change-Id: I21ea68aedddab8f1f22a0946fb36c44b01d58c9a --- diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java index 46bea63f..343ad420 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java @@ -960,26 +960,20 @@ public class DynamicVisualisationsUI { String key = variableCombo.getItem(selectionIndex); DynamicColorContribution cont = colorContributions.get(key); if (cont != null) { - String colorMap = colorMapCombo.getItem(colorMapCombo.getSelectionIndex()); - try { - Map colorMaps = Simantics.getSession().syncRequest(new UniqueRead>() { - - @Override - public Map perform(ReadGraph graph) throws DatabaseException { - return DynamicVisualisationsContributions.dynamicColorMaps(graph); - } - }); + + String label = variableCombo.getItem(variableCombo.getSelectionIndex()); + DynamicColorContribution dcc; + if (colorMapCombo.getSelectionIndex() > -1) { + String colorMap = colorMapCombo.getItem(colorMapCombo.getSelectionIndex()); DynamicColorMap dColorMap = colorMaps.get(colorMap); - String label = variableCombo.getItem(variableCombo.getSelectionIndex()); - - DynamicColorContribution dcc = new DynamicColorContribution(label, cont.getModuleName(), cont.getAttributeName(), unit.getText(), cont.getVariableGain(), cont.getVariableBias(), dColorMap, Double.parseDouble(minText.getText()), Double.parseDouble(maxText.getText())); - dcc.setUsed(usedButton.getSelection()); - dcc.setUseDefault(defaultButton.getSelection()); - - return Pair.make(object.getColoringObject().getName(), dcc); - } catch (DatabaseException e) { - LOGGER.error("Could not get DynamicColorContribution", e); + dcc = new DynamicColorContribution(label, cont.getModuleName(), cont.getAttributeName(), unit.getText(), cont.getVariableGain(), cont.getVariableBias(), dColorMap, Double.parseDouble(minText.getText()), Double.parseDouble(maxText.getText())); + } else { + dcc = colorContributions.get(label); } + dcc.setUsed(usedButton.getSelection()); + dcc.setUseDefault(defaultButton.getSelection()); + + return Pair.make(object.getColoringObject().getName(), dcc); } } return null; @@ -1126,26 +1120,20 @@ public class DynamicVisualisationsUI { String key = variableCombo.getItem(selectionIndex); DynamicSizeContribution cont = sizeContributions.get(key); if (cont != null) { - String sizeMap = sizeMapCombo.getItem(sizeMapCombo.getSelectionIndex()); - try { - Map sizeMaps = Simantics.getSession().syncRequest(new UniqueRead>() { - - @Override - public Map perform(ReadGraph graph) throws DatabaseException { - return DynamicVisualisationsContributions.dynamicSizeMaps(graph); - } - }); - DynamicSizeMap dColorMap = sizeMaps.get(sizeMap); - String label = variableCombo.getItem(variableCombo.getSelectionIndex()); - - DynamicSizeContribution dsc = new DynamicSizeContribution(label, cont.getModuleName(), cont.getAttributeName(), unit.getText(), cont.getVariableGain(), cont.getVariableBias(), dColorMap, Double.parseDouble(minText.getText()), Double.parseDouble(maxText.getText())); - dsc.setUsed(usedButton.getSelection()); - dsc.setUseDefault(defaultButton.getSelection()); - - return Pair.make(object.getSizingObject().getName(), dsc); - } catch (DatabaseException e) { - LOGGER.error("Could not get DynamicColorContribution", e); + + String label = variableCombo.getItem(variableCombo.getSelectionIndex()); + DynamicSizeContribution dsc; + if (sizeMapCombo.getSelectionIndex() > -1) { + String sizeMap = sizeMapCombo.getItem(sizeMapCombo.getSelectionIndex()); + DynamicSizeMap dSizeMap = sizeMaps.get(sizeMap); + dsc = new DynamicSizeContribution(label, cont.getModuleName(), cont.getAttributeName(), unit.getText(), cont.getVariableGain(), cont.getVariableBias(), dSizeMap, Double.parseDouble(minText.getText()), Double.parseDouble(maxText.getText())); + } else { + dsc = sizeContributions.get(label); } + dsc.setUsed(usedButton.getSelection()); + dsc.setUseDefault(defaultButton.getSelection()); + + return Pair.make(object.getSizingObject().getName(), dsc); } } return null;