]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Improved the layout of Sysdyn and JFreeChart tabs (refs #4708).
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 17 Feb 2014 12:05:45 +0000 (12:05 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 17 Feb 2014 12:05:45 +0000 (12:05 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28868 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java

index dd5b069ab70bba6f07bf2ff034911b3f5b9285f6..6d571f5430b7fbb3f51ee4b43a32bf50be875c25 100644 (file)
@@ -121,6 +121,8 @@ public class ChartComposite extends Composite {
                 \r
                 JFreeChart jfreeChart = chart.getChart();\r
                 // Display the result chart\r
+                if (composite.isDisposed())\r
+                       return;\r
                 composite.getDisplay().asyncExec(new RunnableWithObject(jfreeChart) {\r
 \r
                     @Override\r
index b3d9547348f418329b2e0d2a3bce72d4b068514f..2b3ce8250aa07fc9c2b97f210612991af5a1db3f 100644 (file)
@@ -55,7 +55,7 @@ public class RangeComposite extends Composite implements Widget {
     public RangeComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
         super(parent, style);\r
         support.register(this);\r
-        GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 3).applyTo(this);\r
+        GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 0).applyTo(this);\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(this);\r
         composite = this;\r
     }\r
@@ -109,8 +109,15 @@ public class RangeComposite extends Composite implements Widget {
                         \r
                         composite.layout();\r
 \r
-                        if(getObject() == null)\r
+                        if(getObject() == null) {\r
+                               // No range, print an em dash.\r
+                               Label label = new Label(composite, SWT.NONE);\r
+                            label.setText("\u2014");\r
+                            label.setEnabled(false);\r
+                            GridDataFactory.fillDefaults().applyTo(label);\r
+                            composite.layout();\r
                             return;\r
+                        }\r
 \r
                         // New widgetSupport for the combos\r
                         WidgetSupportImpl support = new WidgetSupportImpl();\r
index 75c6b6094caefea586967a3ea0badda3802b1e88..34862e36ffd01d57a2aa918f9d140b00b2b370ef 100644 (file)
@@ -81,12 +81,12 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget {
         sc.setExpandVertical(true);\r
 \r
         composite = new Composite(sc, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
 \r
         // Domain Axis properties\r
         Group domainGroup = new Group(composite, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(domainGroup);\r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(domainGroup);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(domainGroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).applyTo(domainGroup);\r
         domainGroup.setText("Domain axis");\r
 \r
         // Label for x-axis\r
@@ -98,14 +98,14 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget {
         rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
         rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
         rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager()));\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget());\r
-\r
+        GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(rangelabel.getWidget());\r
+        \r
         Composite axisHide = new AxisHidePropertyComposite(domainGroup, context, domainAxisSupport, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide);\r
+        GridDataFactory.fillDefaults().span(1, 2).applyTo(axisHide);\r
 \r
         Label angleLabel = new Label(domainGroup, SWT.NONE);\r
         angleLabel.setText("Label angle:");\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(angleLabel);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(angleLabel);\r
 \r
         Composite angleComposite = new Composite(domainGroup, SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(angleComposite);\r
@@ -116,22 +116,22 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget {
         angle.setMinimum(0);\r
         angle.setMaximum(90);\r
         angle.getWidget().setIncrement(5);\r
-        GridDataFactory.fillDefaults().applyTo(angle.getWidget());\r
+        GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(angle.getWidget());\r
 \r
         // Domain Color\r
         label = new Label(domainGroup, SWT.NONE);\r
         label.setText("Color:");\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label);\r
 \r
         Composite colorPicker = new ColorPicker(domainGroup, context, domainAxisSupport, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
+        GridDataFactory.fillDefaults().grab(false, true).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker);\r
 \r
         domainGroup.layout();\r
 \r
         // Range Axis properties\r
         Group rangeGroup = new Group(composite, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(rangeGroup);\r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(rangeGroup);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeGroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).applyTo(rangeGroup);\r
         rangeGroup.setText("Range axis");\r
 \r
         // Label for range axis\r
@@ -144,10 +144,10 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget {
         rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
         rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
         rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager()));\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget());\r
+        GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(rangelabel.getWidget());\r
 \r
         axisHide = new AxisHidePropertyComposite(rangeGroup, context, rangeAxisSupport, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(1, 4).applyTo(axisHide);\r
+        GridDataFactory.fillDefaults().span(1, 2).applyTo(axisHide);\r
 \r
         // Min and max values for range axis\r
         label = new Label(rangeGroup, SWT.NONE);\r
@@ -155,7 +155,7 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget {
         label.setText("Min:");\r
 \r
         Composite minmax = new Composite(rangeGroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(minmax);\r
+        GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(minmax);\r
         GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax);\r
         rangemin = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER);\r
         rangemin.setColorProvider(new JFreeChartPropertyColorProvider(rangemin.getResourceManager()));\r
@@ -174,10 +174,10 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget {
         // Range Color\r
         label = new Label(rangeGroup, SWT.NONE);\r
         label.setText("Color:");\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label);\r
 \r
         colorPicker = new ColorPicker(rangeGroup, context, rangeAxisSupport, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
+        GridDataFactory.fillDefaults().grab(false, true).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker);\r
 \r
         // Resize scrolled composite\r
         sc.setContent(composite);\r
index 14bdb4d4df5e083ed6c03f81eeb3df74e7b6b3e1..2c4f9c4bf0ead77365f19c5b53a86e4fc458429b 100644 (file)
@@ -45,7 +45,7 @@ public class AxisPropertyComposite extends Composite {
     public AxisPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
         super(parent, style);\r
         \r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(this);\r
         \r
         // Label (units)\r
         Label label = new Label(this, SWT.NONE);\r
@@ -56,7 +56,7 @@ public class AxisPropertyComposite extends Composite {
         units.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); // FIXME: Units \r
         units.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); // FIXME: Units \r
         units.setColorProvider(new JFreeChartPropertyColorProvider(units.getResourceManager()));\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(units.getWidget());\r
+        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(units.getWidget());\r
         \r
         \r
         // Minimum and maximum values\r
@@ -79,7 +79,13 @@ public class AxisPropertyComposite extends Composite {
         max.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
         max.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
         max.setInputValidator(new DoubleValidator(true));\r
-\r
+        \r
+        // Tick and label visibility\r
+        Composite c = new Composite(this, SWT.NONE);\r
+        GridDataFactory.fillDefaults().span(1, 2).applyTo(c);\r
+        GridLayoutFactory.fillDefaults().applyTo(c);\r
+        Composite axisHide = new AxisHidePropertyComposite(c, context, support, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(axisHide);\r
         \r
         // Color\r
         label = new Label(this, SWT.NONE);\r
@@ -88,13 +94,7 @@ public class AxisPropertyComposite extends Composite {
         \r
         Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
-        \r
-        // Tick and label visibility\r
-        Composite c = new Composite(this, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(2, 1).applyTo(c);\r
-        GridLayoutFactory.fillDefaults().applyTo(c);\r
-        Composite axisHide = new AxisHidePropertyComposite(c, context, support, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(axisHide);\r
+\r
     }\r
     \r
 }\r
index 749bcb53f35d93b9d02412e635008aebcd47aee7..40519fea4afa6b445e85988ba0f01d4d49b67e09 100644 (file)
@@ -158,7 +158,7 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         // X-Axis properties\r
         Group xgroup = new Group(composite, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(xgroup);\r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(xgroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).applyTo(xgroup);\r
         xgroup.setText("X-axis");\r
 \r
         // Variable for x-axis (default: empty == time)\r
@@ -173,6 +173,18 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         xvariable.setInputValidator(new VariableExistsValidator(support, xvariable, true));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget());\r
         \r
+        // Min value for x-axis\r
+        label = new Label(xgroup, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Min:");\r
+\r
+        xmin = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER);\r
+        xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager()));\r
+        xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
+        xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
+        xmin.setInputValidator(new DoubleValidator(true));\r
+        \r
+        // Axis hide buttons\r
         Composite axisHide = new AxisHidePropertyComposite(xgroup, context, domainAxisSupport, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide);\r
 \r
@@ -187,28 +199,17 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         xlabel.setColorProvider(new JFreeChartPropertyColorProvider(xlabel.getResourceManager()));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget());\r
 \r
-        // Min and max values for x-axis\r
+        // Max value for x-axis\r
         label = new Label(xgroup, SWT.NONE);\r
         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Min:");\r
-\r
-        Composite minmax = new Composite(xgroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(minmax);\r
-        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax);\r
-        xmin = new TrackedText(minmax, domainAxisSupport, SWT.BORDER);\r
-        xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager()));\r
-        xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
-        xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
-        xmin.setInputValidator(new DoubleValidator(true));\r
-\r
-        label = new Label(minmax, SWT.NONE);\r
         label.setText("Max:");\r
-        xmax = new TrackedText(minmax, domainAxisSupport, SWT.BORDER);\r
+        xmax = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER);\r
         xmax.setColorProvider(new JFreeChartPropertyColorProvider(xmax.getResourceManager()));\r
         xmax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
         xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
         xmax.setInputValidator(new DoubleValidator(true));\r
-\r
+        GridDataFactory.fillDefaults().applyTo(xmax.getWidget());\r
+        \r
         // Set the same width to both label rows\r
         composite.layout();\r
         GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
index e77b9f8680924c1c27afeb7aa9076148727518a9..0a2bf0026cb8d8da88cdc44b9ba3c858694eaffc 100644 (file)
@@ -43,28 +43,31 @@ public class GameExperimentTab extends LabelPropertyTabContributor {
         // Label\r
         Label label = new Label(composite, SWT.NONE);\r
         label.setText("Name");\r
-        \r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
         TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
         name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
         name.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), name.getWidget())));\r
-\r
+        \r
         // Step duration (i.e. how many time units is one step in user's perspective)\r
         label = new Label(composite, SWT.NONE);\r
         label.setText("Step duration");\r
-        \r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
         TrackedText stepDuration = new TrackedText(composite, support, SWT.BORDER);\r
         stepDuration.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepDuration));\r
         stepDuration.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepDuration));\r
         stepDuration.setInputValidator(new DoubleValidator());\r
         stepDuration.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stepDuration.getWidget())));\r
-        GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(name.getWidget());\r
+        GridDataFactory.fillDefaults().hint(80, SWT.DEFAULT).grab(true, false).applyTo(name.getWidget());\r
 \r
         // Integrator step length (i.e. how long is a integration step in the simulator. This time is stepped until stepDuration is full)\r
         label = new Label(composite, SWT.NONE);\r
         label.setText("Integrator step length");\r
-        \r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
         TrackedText integratorStep = new TrackedText(composite, support, SWT.BORDER);\r
         integratorStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepLength));\r
         integratorStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepLength));\r
index 2001b02fac4405fc6d42da5d7f23ebf25c1e3f8b..3f747ef1e67e0467578bcd0a933515ec67f3ee90 100644 (file)
@@ -359,7 +359,7 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
         \r
         parameterProperties = new Composite(parameterPropertyGroup, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterProperties);\r
-        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parameterProperties);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parameterProperties);\r
 \r
         // Label\r
         label = new Label(parameterProperties, SWT.NONE);\r
@@ -371,7 +371,7 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
         variable.addModifyListener(new VariableNameModifier(variable.getWidget(), parameterSupport, SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_variable, SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_indexes));\r
         variable.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), variable.getWidget())));\r
         variable.setInputValidator(new ParameterExistsValidator(parameterSupport, variable));\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(variable.getWidget());\r
+        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(variable.getWidget());\r
         \r
         label = new Label(parameterProperties, SWT.NONE);\r
         label.setText("Range:");\r
@@ -383,7 +383,7 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
                 return SysdynResource.getInstance(graph).SensitivityAnalysisExperiment_Parameter_indexes;\r
             }\r
         };\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);\r
+        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(rangeComposite);\r
         \r
 //        TrackedText variable = new TrackedText(parameterProperties, parameterSupport, SWT.BORDER);\r
 //        variable.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_variable));\r
@@ -473,11 +473,9 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
             }\r
         });\r
 \r
-        label = new Label(parameterProperties, SWT.NONE);\r
-        \r
         DistributionPropertyWidget dpw = new DistributionPropertyWidget(parameterProperties, context, parameterSupport, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(dpw);\r
-\r
+        GridLayoutFactory.fillDefaults().margins(6, 0).applyTo(dpw);\r
     }\r
 \r
 \r
index 90b4319cd7a8824add5d8a744b4c571cba20a0a2..6807d491a98f64d5321ee92d5e917c80feca0765 100644 (file)
@@ -87,7 +87,9 @@ public class NameAndArrayRangeModifyListener extends ComboModifyListenerImpl<Res
                }\r
                \r
                // If expression has changed (i.e. user actually selects a different item in the combo), save the previous \r
-               if(lastExpression != null && !lastExpression.equals(activeExpression)) {\r
+               if(lastExpression != null \r
+                               && !lastExpression.equals(activeExpression)\r
+                               && expressionWidget != null) {\r
                        expressionWidget.save();\r
                }\r
 \r