From: luukkainen Date: Wed, 3 Jul 2013 07:32:28 +0000 (+0000) Subject: Ability to configure contents of property tabs X-Git-Tag: 1.8.1~274 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=af9ea7cfcb909899a086d59625e0878ec5e78f77;p=simantics%2Fsysdyn.git Ability to configure contents of property tabs refs #4373 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27677 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java new file mode 100644 index 00000000..4b6314ed --- /dev/null +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java @@ -0,0 +1,8 @@ +package org.simantics.jfreechart; + +public class ChartPropertyOptions { + + public static final int SHOW_TIME = 1 << 0; + public static final int SHOW_FILTER = 1 << 1; + +} diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java index f4ff81a4..4855f793 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java @@ -23,8 +23,10 @@ import org.simantics.sysdyn.JFreeChartResource; public class ChartSelectionTabContributor { - - public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs) throws DatabaseException { + public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs) throws DatabaseException{ + return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME); + } + public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs, int options) throws DatabaseException { JFreeChartResource jfree = JFreeChartResource.getInstance(backend); if(backend.isInstanceOf(r, jfree.ChartElement)) { if(backend.hasStatement(r, jfree.ChartElement_component)) @@ -50,7 +52,7 @@ public class ChartSelectionTabContributor { "Axis and Variables")); } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { tabs.add(new ComparableTabContributor( - new BarGeneralPropertiesTab(), + new BarGeneralPropertiesTab(options), 10, r, "General")); @@ -66,7 +68,7 @@ public class ChartSelectionTabContributor { "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( - new PieGeneralPropertiesTab(), + new PieGeneralPropertiesTab(options), 10, r, "General")); @@ -89,7 +91,11 @@ public class ChartSelectionTabContributor { return false; } - public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs) throws DatabaseException { + public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs) throws DatabaseException{ + return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME); + } + + public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs, int options) throws DatabaseException { JFreeChartResource jfree = JFreeChartResource.getInstance(backend); if(backend.isInstanceOf(r, jfree.ChartElement)) { if(backend.hasStatement(r, jfree.ChartElement_component)) @@ -115,7 +121,7 @@ public class ChartSelectionTabContributor { "Axis and Variables")); } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { tabs.add(new ComparableTabContributor( - new BarGeneralPropertiesTab(), + new BarGeneralPropertiesTab(options), 10, r, "General")); @@ -131,7 +137,7 @@ public class ChartSelectionTabContributor { "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( - new PieGeneralPropertiesTab(), + new PieGeneralPropertiesTab(options), 10, r, "General")); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java index e75989ba..035f87ff 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java @@ -38,6 +38,7 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.request.PossibleObjectWithType; import org.simantics.db.exception.DatabaseException; 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.DoublePropertyFactory2; @@ -68,6 +69,17 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { private TrackedCombo type; private TrackedCombo orientation; + private boolean showTime = true; + private boolean showFilter = false; + + public BarGeneralPropertiesTab() { + + } + + public BarGeneralPropertiesTab(int options) { + showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); + showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0); + } @Override public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { @@ -79,7 +91,10 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { sc.setExpandVertical(true); composite = new Composite(sc, SWT.NONE); - GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite); + if (showFilter) + GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite); + else + GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); // General properties Group general = new Group(composite, SWT.NONE); @@ -142,17 +157,19 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { title.addModifyListener(new TitleModifier()); title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); - // Time - label = new Label(labelColumn2, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Time:"); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); - time.setInputValidator(new DoubleValidator(true)); + if (showTime) { + // Time + label = new Label(labelColumn2, SWT.NONE); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Time:"); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); + time.setInputValidator(new DoubleValidator(true)); time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + } Group typeGroup = new Group(composite,SWT.NONE); GridDataFactory.fillDefaults().applyTo(typeGroup); @@ -199,25 +216,27 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); - Group filteringGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(filteringGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); - hideGroup.setText("Filter"); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Use:"); - Button useFilter = new Button(filteringGroup, support, SWT.CHECK); - useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); - useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Percent:"); - TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); - fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); - fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); - fraction.setInputValidator(new DoubleValidator(true)); - fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager())); + if (showFilter) { + Group filteringGroup = new Group(composite, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(filteringGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + hideGroup.setText("Filter"); + label = new Label(filteringGroup, SWT.NONE); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Use:"); + Button useFilter = new Button(filteringGroup, support, SWT.CHECK); + useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); + useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); + label = new Label(filteringGroup, SWT.NONE); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Percent:"); + TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); + fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); + fraction.setInputValidator(new DoubleValidator(true)); + fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager())); + } // Resize scrolled composite sc.setContent(composite); diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java index c2c54ab8..a4fe3b8e 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java @@ -27,6 +27,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.DoublePropertyFactory2; @@ -52,6 +53,18 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { private Composite composite; private Button htitle, hlegend, hlabels; private TrackedText name, title, time; + + private boolean showTime = true; + private boolean showFilter = false; + + public PieGeneralPropertiesTab() { + + } + + public PieGeneralPropertiesTab(int options) { + showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); + showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0); + } @Override public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { @@ -63,7 +76,10 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { sc.setExpandVertical(true); composite = new Composite(sc, SWT.NONE); - GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); + if (showFilter) + GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite); + else + GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite); // General properties Group general = new Group(composite, SWT.NONE); @@ -122,18 +138,19 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { title.addModifyListener(new TitleModifier()); title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager())); - // Time - label = new Label(labelColumn2, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Time:"); - - time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); - time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); - time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); - time.setInputValidator(new DoubleValidator(true)); - time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); - + if (showTime) { + // Time + label = new Label(labelColumn2, SWT.NONE); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Time:"); + + time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget()); + time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time)); + time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time)); + time.setInputValidator(new DoubleValidator(true)); + time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager())); + } // Group for hide options Group hideGroup = new Group(composite, SWT.NONE); GridDataFactory.fillDefaults().applyTo(hideGroup); @@ -153,27 +170,27 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor { hlabels.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels, true)); hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels)); - - Group filteringGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().applyTo(filteringGroup); - GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); - hideGroup.setText("Filter"); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Use:"); - Button useFilter = new Button(filteringGroup, support, SWT.CHECK); - useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); - useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); - label = new Label(filteringGroup, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); - label.setText("Percent:"); - TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); - fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); - fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); - fraction.setInputValidator(new DoubleValidator(true)); - fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager())); - + if (showFilter) { + Group filteringGroup = new Group(composite, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(filteringGroup); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup); + hideGroup.setText("Filter"); + label = new Label(filteringGroup, SWT.NONE); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Use:"); + Button useFilter = new Button(filteringGroup, support, SWT.CHECK); + useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false)); + useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used)); + label = new Label(filteringGroup, SWT.NONE); + GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label); + label.setText("Percent:"); + TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget()); + fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction)); + fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction)); + fraction.setInputValidator(new DoubleValidator(true)); + fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager())); + } sc.setContent(composite); Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);