]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Fixing UI related bugs in Dynamic Visualisations view 53/3353/1
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 17 Oct 2019 08:31:47 +0000 (11:31 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Thu, 17 Oct 2019 08:31:47 +0000 (11:31 +0300)
gitlab #59

Change-Id: I21ea68aedddab8f1f22a0946fb36c44b01d58c9a

org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java

index 46bea63f2a14032bff8e708aa424c44cf9025a02..343ad420524a104708bb6d39cd2d1b8f287e80b5 100644 (file)
@@ -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<String, DynamicColorMap> colorMaps = Simantics.getSession().syncRequest(new UniqueRead<Map<String, DynamicColorMap>>() {
-        
-                                @Override
-                                public Map<String, DynamicColorMap> 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<String, DynamicSizeMap> sizeMaps = Simantics.getSession().syncRequest(new UniqueRead<Map<String, DynamicSizeMap>>() {
-        
-                                @Override
-                                public Map<String, DynamicSizeMap> 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;