From dfd2be173a687791ad02512347fa9f9e3cc986bd Mon Sep 17 00:00:00 2001 From: miettinen Date: Mon, 17 Feb 2014 12:05:45 +0000 Subject: [PATCH] Improved the layout of Sysdyn and JFreeChart tabs (refs #4708). git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28868 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../jfreechart/chart/ChartComposite.java | 2 ++ .../chart/properties/RangeComposite.java | 11 ++++-- .../chart/properties/bar/BarAxisTab.java | 34 +++++++++---------- .../xyline/AxisPropertyComposite.java | 20 +++++------ .../xyline/XYLineGeneralPropertiesTab.java | 33 +++++++++--------- .../ui/properties/GameExperimentTab.java | 13 ++++--- .../SensitivityAnalysisExperimentTab.java | 10 +++--- .../NameAndArrayRangeModifyListener.java | 4 ++- 8 files changed, 70 insertions(+), 57 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java index dd5b069a..6d571f54 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartComposite.java @@ -121,6 +121,8 @@ public class ChartComposite extends Composite { JFreeChart jfreeChart = chart.getChart(); // Display the result chart + if (composite.isDisposed()) + return; composite.getDisplay().asyncExec(new RunnableWithObject(jfreeChart) { @Override diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java index b3d95473..2b3ce825 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/RangeComposite.java @@ -55,7 +55,7 @@ public class RangeComposite extends Composite implements Widget { public RangeComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) { super(parent, style); support.register(this); - GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 3).applyTo(this); + GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 0).applyTo(this); GridDataFactory.fillDefaults().grab(true, false).applyTo(this); composite = this; } @@ -109,8 +109,15 @@ public class RangeComposite extends Composite implements Widget { composite.layout(); - if(getObject() == null) + if(getObject() == null) { + // No range, print an em dash. + Label label = new Label(composite, SWT.NONE); + label.setText("\u2014"); + label.setEnabled(false); + GridDataFactory.fillDefaults().applyTo(label); + composite.layout(); return; + } // New widgetSupport for the combos WidgetSupportImpl support = new WidgetSupportImpl(); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java index 75c6b609..34862e36 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarAxisTab.java @@ -81,12 +81,12 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { sc.setExpandVertical(true); composite = new Composite(sc, SWT.NONE); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); // Domain Axis properties Group domainGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(domainGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(domainGroup); + GridDataFactory.fillDefaults().grab(true, false).applyTo(domainGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).applyTo(domainGroup); domainGroup.setText("Domain axis"); // Label for x-axis @@ -98,14 +98,14 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget()); - + GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(rangelabel.getWidget()); + Composite axisHide = new AxisHidePropertyComposite(domainGroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide); + GridDataFactory.fillDefaults().span(1, 2).applyTo(axisHide); Label angleLabel = new Label(domainGroup, SWT.NONE); angleLabel.setText("Label angle:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(angleLabel); + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(angleLabel); Composite angleComposite = new Composite(domainGroup, SWT.NONE); GridDataFactory.fillDefaults().applyTo(angleComposite); @@ -116,22 +116,22 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { angle.setMinimum(0); angle.setMaximum(90); angle.getWidget().setIncrement(5); - GridDataFactory.fillDefaults().applyTo(angle.getWidget()); + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(angle.getWidget()); // Domain Color label = new Label(domainGroup, SWT.NONE); label.setText("Color:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label); Composite colorPicker = new ColorPicker(domainGroup, context, domainAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker); domainGroup.layout(); // Range Axis properties Group rangeGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(rangeGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(rangeGroup); + GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).applyTo(rangeGroup); rangeGroup.setText("Range axis"); // Label for range axis @@ -144,10 +144,10 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget()); + GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(rangelabel.getWidget()); axisHide = new AxisHidePropertyComposite(rangeGroup, context, rangeAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().span(1, 4).applyTo(axisHide); + GridDataFactory.fillDefaults().span(1, 2).applyTo(axisHide); // Min and max values for range axis label = new Label(rangeGroup, SWT.NONE); @@ -155,7 +155,7 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { label.setText("Min:"); Composite minmax = new Composite(rangeGroup, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(minmax); + GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, true).applyTo(minmax); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax); rangemin = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER); rangemin.setColorProvider(new JFreeChartPropertyColorProvider(rangemin.getResourceManager())); @@ -174,10 +174,10 @@ public class BarAxisTab extends LabelPropertyTabContributor implements Widget { // Range Color label = new Label(rangeGroup, SWT.NONE); label.setText("Color:"); - GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label); colorPicker = new ColorPicker(rangeGroup, context, rangeAxisSupport, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.BEGINNING, SWT.CENTER).applyTo(colorPicker); // Resize scrolled composite sc.setContent(composite); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java index 14bdb4d4..2c4f9c4b 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/AxisPropertyComposite.java @@ -45,7 +45,7 @@ public class AxisPropertyComposite extends Composite { public AxisPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) { super(parent, style); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(this); // Label (units) Label label = new Label(this, SWT.NONE); @@ -56,7 +56,7 @@ public class AxisPropertyComposite extends Composite { units.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, "")); // FIXME: Units units.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); // FIXME: Units units.setColorProvider(new JFreeChartPropertyColorProvider(units.getResourceManager())); - GridDataFactory.fillDefaults().grab(true, false).applyTo(units.getWidget()); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(units.getWidget()); // Minimum and maximum values @@ -79,7 +79,13 @@ public class AxisPropertyComposite extends Composite { max.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); max.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); max.setInputValidator(new DoubleValidator(true)); - + + // Tick and label visibility + Composite c = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().span(1, 2).applyTo(c); + GridLayoutFactory.fillDefaults().applyTo(c); + Composite axisHide = new AxisHidePropertyComposite(c, context, support, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(axisHide); // Color label = new Label(this, SWT.NONE); @@ -88,13 +94,7 @@ public class AxisPropertyComposite extends Composite { Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); - - // Tick and label visibility - Composite c = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().span(2, 1).applyTo(c); - GridLayoutFactory.fillDefaults().applyTo(c); - Composite axisHide = new AxisHidePropertyComposite(c, context, support, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(axisHide); + } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java index 749bcb53..40519fea 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java @@ -158,7 +158,7 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl // X-Axis properties Group xgroup = new Group(composite, SWT.NONE); GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(xgroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(xgroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(5).applyTo(xgroup); xgroup.setText("X-axis"); // Variable for x-axis (default: empty == time) @@ -173,6 +173,18 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl xvariable.setInputValidator(new VariableExistsValidator(support, xvariable, true)); GridDataFactory.fillDefaults().grab(true, false).applyTo(xvariable.getWidget()); + // Min value for x-axis + label = new Label(xgroup, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Min:"); + + xmin = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER); + xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager())); + xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); + xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); + xmin.setInputValidator(new DoubleValidator(true)); + + // Axis hide buttons Composite axisHide = new AxisHidePropertyComposite(xgroup, context, domainAxisSupport, SWT.NONE); GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide); @@ -187,28 +199,17 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl xlabel.setColorProvider(new JFreeChartPropertyColorProvider(xlabel.getResourceManager())); GridDataFactory.fillDefaults().grab(true, false).applyTo(xlabel.getWidget()); - // Min and max values for x-axis + // Max value for x-axis label = new Label(xgroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Min:"); - - Composite minmax = new Composite(xgroup, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(minmax); - GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax); - xmin = new TrackedText(minmax, domainAxisSupport, SWT.BORDER); - xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager())); - xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min)); - xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min)); - xmin.setInputValidator(new DoubleValidator(true)); - - label = new Label(minmax, SWT.NONE); label.setText("Max:"); - xmax = new TrackedText(minmax, domainAxisSupport, SWT.BORDER); + xmax = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER); xmax.setColorProvider(new JFreeChartPropertyColorProvider(xmax.getResourceManager())); xmax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max)); xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max)); xmax.setInputValidator(new DoubleValidator(true)); - + GridDataFactory.fillDefaults().applyTo(xmax.getWidget()); + // Set the same width to both label rows composite.layout(); GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java index e77b9f86..0a2bf002 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java @@ -43,28 +43,31 @@ public class GameExperimentTab extends LabelPropertyTabContributor { // Label Label label = new Label(composite, SWT.NONE); label.setText("Name"); - + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + TrackedText name = new TrackedText(composite, support, SWT.BORDER); name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel)); name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName)); name.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), name.getWidget()))); - + // Step duration (i.e. how many time units is one step in user's perspective) label = new Label(composite, SWT.NONE); label.setText("Step duration"); - + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + TrackedText stepDuration = new TrackedText(composite, support, SWT.BORDER); stepDuration.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepDuration)); stepDuration.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepDuration)); stepDuration.setInputValidator(new DoubleValidator()); stepDuration.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stepDuration.getWidget()))); - GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(name.getWidget()); + GridDataFactory.fillDefaults().hint(80, SWT.DEFAULT).grab(true, false).applyTo(name.getWidget()); // Integrator step length (i.e. how long is a integration step in the simulator. This time is stepped until stepDuration is full) label = new Label(composite, SWT.NONE); label.setText("Integrator step length"); - + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); + TrackedText integratorStep = new TrackedText(composite, support, SWT.BORDER); integratorStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepLength)); integratorStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepLength)); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java index 2001b02f..3f747ef1 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java @@ -359,7 +359,7 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo parameterProperties = new Composite(parameterPropertyGroup, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterProperties); - GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parameterProperties); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parameterProperties); // Label label = new Label(parameterProperties, SWT.NONE); @@ -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)); variable.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), variable.getWidget()))); variable.setInputValidator(new ParameterExistsValidator(parameterSupport, variable)); - GridDataFactory.fillDefaults().grab(true, false).applyTo(variable.getWidget()); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(variable.getWidget()); label = new Label(parameterProperties, SWT.NONE); label.setText("Range:"); @@ -383,7 +383,7 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo return SysdynResource.getInstance(graph).SensitivityAnalysisExperiment_Parameter_indexes; } }; - GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(rangeComposite); // TrackedText variable = new TrackedText(parameterProperties, parameterSupport, SWT.BORDER); // variable.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_Parameter_variable)); @@ -473,11 +473,9 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo } }); - label = new Label(parameterProperties, SWT.NONE); - DistributionPropertyWidget dpw = new DistributionPropertyWidget(parameterProperties, context, parameterSupport, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(dpw); - + GridLayoutFactory.fillDefaults().margins(6, 0).applyTo(dpw); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java index 90b4319c..6807d491 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/NameAndArrayRangeModifyListener.java @@ -87,7 +87,9 @@ public class NameAndArrayRangeModifyListener extends ComboModifyListenerImpl