From 4184b3a6df27f1eef102772070594b435b28eae7 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Fri, 5 Jul 2013 09:58:53 +0000 Subject: [PATCH] fixes #4377 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27685 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ChartSelectionTabContributor.java | 8 ++--- .../bar/BarSeriesPropertyComposite.java | 33 +++++++++-------- .../bar/BarSeriesPropertyComposite2.java | 35 +++++++++--------- .../chart/properties/bar/BarSeriesTab.java | 7 ++-- .../chart/properties/bar/BarSeriesTab2.java | 7 ++-- .../pie/PieSeriesPropertyComposite.java | 34 +++++++++--------- .../pie/PieSeriesPropertyComposite2.java | 36 ++++++++++--------- .../chart/properties/pie/PieSeriesTab.java | 8 +++-- .../chart/properties/pie/PieSeriesTab2.java | 6 ++-- 9 files changed, 95 insertions(+), 79 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java index 4855f793..f8b0d764 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java @@ -57,7 +57,7 @@ public class ChartSelectionTabContributor { r, "General")); tabs.add(new ComparableTabContributor( - new BarSeriesTab(), + new BarSeriesTab(options), 9, r, "Variables")); @@ -73,7 +73,7 @@ public class ChartSelectionTabContributor { r, "General")); tabs.add(new ComparableTabContributor( - new PieSeriesTab(), + new PieSeriesTab(options), 9, r, "Variables")); @@ -126,7 +126,7 @@ public class ChartSelectionTabContributor { r, "General")); tabs.add(new ComparableTabContributor( - new BarSeriesTab2(), + new BarSeriesTab2(options), 9, r, "Variables")); @@ -142,7 +142,7 @@ public class ChartSelectionTabContributor { r, "General")); tabs.add(new ComparableTabContributor( - new PieSeriesTab2(), + new PieSeriesTab2(options), 9, r, "Variables")); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite.java index 94b15ee5..ca8777e2 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite.java @@ -21,6 +21,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.ChartPropertyOptions; import org.simantics.jfreechart.chart.properties.DoubleValidator; import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider; import org.simantics.jfreechart.chart.properties.RVIFactory; @@ -41,7 +42,7 @@ public class BarSeriesPropertyComposite extends Composite { private TrackedText variable, label, time; - public BarSeriesPropertyComposite(Composite parent, final ISessionContext context, WidgetSupport support, int style) { + public BarSeriesPropertyComposite(Composite parent, final ISessionContext context, WidgetSupport support, int options, int style) { super(parent, style); GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this); @@ -79,19 +80,21 @@ public class BarSeriesPropertyComposite extends Composite { GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget()); // Time - label = new Label(this, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); - label.setText("Time:"); - - Composite composite = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(composite); - GridLayoutFactory.fillDefaults().applyTo(composite); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); - time.setInputValidator(new DoubleValidator(true)); - time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); - GridDataFactory.fillDefaults().applyTo(time.getWidget()); + if ((options & ChartPropertyOptions.SHOW_TIME) > 0) { + label = new Label(this, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); + label.setText("Time:"); + + Composite composite = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(composite); + GridLayoutFactory.fillDefaults().applyTo(composite); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); + time.setInputValidator(new DoubleValidator(true)); + time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + GridDataFactory.fillDefaults().applyTo(time.getWidget()); + } } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite2.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite2.java index ec2f1dc9..9cb7fdc2 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite2.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesPropertyComposite2.java @@ -23,6 +23,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.ChartPropertyOptions; import org.simantics.jfreechart.chart.properties.ChartVariable; import org.simantics.jfreechart.chart.properties.ChartVariableFactory; import org.simantics.jfreechart.chart.properties.ChartVariableModifier; @@ -45,7 +46,7 @@ public class BarSeriesPropertyComposite2 extends Composite { private TrackedText label, time; private StringChooser variable; - public BarSeriesPropertyComposite2(Composite parent, final ISessionContext context, WidgetSupport support, Collection variables, int style) { + public BarSeriesPropertyComposite2(Composite parent, final ISessionContext context, WidgetSupport support, Collection variables, int options, int style) { super(parent, style); GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this); @@ -95,20 +96,22 @@ public class BarSeriesPropertyComposite2 extends Composite { this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager())); GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget()); - // Time - label = new Label(this, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); - label.setText("Time:"); - - Composite composite = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(composite); - GridLayoutFactory.fillDefaults().applyTo(composite); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); - time.setInputValidator(new DoubleValidator(true)); - time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); - GridDataFactory.fillDefaults().applyTo(time.getWidget()); + if ((options & ChartPropertyOptions.SHOW_TIME) > 0) { + // Time + label = new Label(this, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); + label.setText("Time:"); + + Composite composite = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(composite); + GridLayoutFactory.fillDefaults().applyTo(composite); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); + time.setInputValidator(new DoubleValidator(true)); + time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + GridDataFactory.fillDefaults().applyTo(time.getWidget()); + } } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java index 459d0b32..7eb04623 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab.java @@ -59,10 +59,11 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget private Button add, remove; private Resource chartResource; private BarSeriesPropertyComposite spc; + private int options; - - public BarSeriesTab() { + public BarSeriesTab(int options) { additionalSupport = new WidgetSupportImpl(); + this.options = options; } @Override @@ -123,7 +124,7 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget for(Control child : propertyContainer.getChildren()) { child.dispose(); } - spc = new BarSeriesPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE); + spc = new BarSeriesPropertyComposite(propertyContainer, context, additionalSupport, options,SWT.NONE); additionalSupport.fireInput(context, selection); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java index fc555dbc..4331f92d 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarSeriesTab2.java @@ -65,10 +65,11 @@ public class BarSeriesTab2 extends LabelPropertyTabContributor implements Widget private Button add, remove; private Resource chartResource; private BarSeriesPropertyComposite2 spc; + private int options; - - public BarSeriesTab2() { + public BarSeriesTab2(int options) { additionalSupport = new WidgetSupportImpl(); + this.options = options; } @Override @@ -134,7 +135,7 @@ public class BarSeriesTab2 extends LabelPropertyTabContributor implements Widget try { Collection variables = context.getSession().syncRequest(new AllVariablesOfModel(resource)); - spc = new BarSeriesPropertyComposite2(propertyContainer, context, additionalSupport, variables, SWT.NONE); + spc = new BarSeriesPropertyComposite2(propertyContainer, context, additionalSupport, variables, options, SWT.NONE); additionalSupport.fireInput(context, selection); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite.java index d2b149b0..1dd80e8d 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite.java @@ -22,6 +22,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.ChartPropertyOptions; import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory; import org.simantics.jfreechart.chart.properties.BooleanSelectionListener; import org.simantics.jfreechart.chart.properties.ColorPicker; @@ -45,7 +46,7 @@ public class PieSeriesPropertyComposite extends Composite { private TrackedText variable, label, time; - public PieSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) { + public PieSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int options, int style) { super(parent, style); GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this); @@ -91,21 +92,22 @@ public class PieSeriesPropertyComposite extends Composite { GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); // Time - label = new Label(this, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); - label.setText("Time:"); - - Composite composite = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(composite); - GridLayoutFactory.fillDefaults().applyTo(composite); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); - time.setInputValidator(new DoubleValidator(true)); - time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); - GridDataFactory.fillDefaults().applyTo(time.getWidget()); - + if ((options & ChartPropertyOptions.SHOW_TIME) > 0) { + label = new Label(this, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); + label.setText("Time:"); + + Composite composite = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(composite); + GridLayoutFactory.fillDefaults().applyTo(composite); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); + time.setInputValidator(new DoubleValidator(true)); + time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + GridDataFactory.fillDefaults().applyTo(time.getWidget()); + } // Exploded label = new Label(this, SWT.NONE); label.setText(""); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite2.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite2.java index 70d0076e..181f78ca 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite2.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesPropertyComposite2.java @@ -24,6 +24,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; +import org.simantics.jfreechart.ChartPropertyOptions; import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory; import org.simantics.jfreechart.chart.properties.BooleanSelectionListener; import org.simantics.jfreechart.chart.properties.ChartVariable; @@ -49,7 +50,7 @@ public class PieSeriesPropertyComposite2 extends Composite { private TrackedText label, time; private StringChooser variable; - public PieSeriesPropertyComposite2(Composite parent, ISessionContext context, WidgetSupport support, Collection variables,int style) { + public PieSeriesPropertyComposite2(Composite parent, ISessionContext context, WidgetSupport support, Collection variables,int options, int style) { super(parent, style); GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this); @@ -96,22 +97,23 @@ public class PieSeriesPropertyComposite2 extends Composite { Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker); - // Time - label = new Label(this, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); - label.setText("Time:"); - - Composite composite = new Composite(this, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(composite); - GridLayoutFactory.fillDefaults().applyTo(composite); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); - time.setInputValidator(new DoubleValidator(true)); - time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); - GridDataFactory.fillDefaults().applyTo(time.getWidget()); - + if ((options & ChartPropertyOptions.SHOW_TIME) > 0) { + // Time + label = new Label(this, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label); + label.setText("Time:"); + + Composite composite = new Composite(this, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(composite); + GridLayoutFactory.fillDefaults().applyTo(composite); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time)); + time.setInputValidator(new DoubleValidator(true)); + time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + GridDataFactory.fillDefaults().applyTo(time.getWidget()); + } // Exploded label = new Label(this, SWT.NONE); label.setText(""); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java index 34a09b34..4ede78c4 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab.java @@ -58,9 +58,11 @@ public class PieSeriesTab extends LabelPropertyTabContributor implements Widget private WidgetSupportImpl additionalSupport; private Button add, remove; private Resource chartResource; - - public PieSeriesTab() { + private int options; + + public PieSeriesTab(int options) { additionalSupport = new WidgetSupportImpl(); + this.options = options; } @Override @@ -123,7 +125,7 @@ public class PieSeriesTab extends LabelPropertyTabContributor implements Widget child.dispose(); } - PieSeriesPropertyComposite spc = new PieSeriesPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE); + PieSeriesPropertyComposite spc = new PieSeriesPropertyComposite(propertyContainer, context, additionalSupport, options,SWT.NONE); propertyContainer.setContent(spc); Point size = spc.computeSize(SWT.DEFAULT, SWT.DEFAULT); propertyContainer.setMinSize(size); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java index aa83c72c..65f9a4a8 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieSeriesTab2.java @@ -64,9 +64,11 @@ public class PieSeriesTab2 extends LabelPropertyTabContributor implements Widget private WidgetSupportImpl additionalSupport; private Button add, remove; private Resource chartResource; + private int options; - public PieSeriesTab2() { + public PieSeriesTab2(int options) { additionalSupport = new WidgetSupportImpl(); + this.options = options; } @Override @@ -131,7 +133,7 @@ public class PieSeriesTab2 extends LabelPropertyTabContributor implements Widget try { Collection variables = context.getSession().syncRequest(new AllVariablesOfModel(resource)); - PieSeriesPropertyComposite2 spc = new PieSeriesPropertyComposite2(propertyContainer, context, additionalSupport, variables, SWT.NONE); + PieSeriesPropertyComposite2 spc = new PieSeriesPropertyComposite2(propertyContainer, context, additionalSupport, variables, options, SWT.NONE); propertyContainer.setContent(spc); Point size = spc.computeSize(SWT.DEFAULT, SWT.DEFAULT); propertyContainer.setMinSize(size); -- 2.47.1