]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Ability to configure contents of property tabs
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 3 Jul 2013 07:32:28 +0000 (07:32 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 3 Jul 2013 07:32:28 +0000 (07:32 +0000)
refs #4373

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27677 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java [new file with mode: 0644]
org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/bar/BarGeneralPropertiesTab.java
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/pie/PieGeneralPropertiesTab.java

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 (file)
index 0000000..4b6314e
--- /dev/null
@@ -0,0 +1,8 @@
+package org.simantics.jfreechart;\r
+\r
+public class ChartPropertyOptions {\r
+       \r
+       public static final int SHOW_TIME   = 1 << 0;\r
+       public static final int SHOW_FILTER = 1 << 1;\r
+\r
+}\r
index f4ff81a405a2417fd7eabe4e0420b142eee0f137..4855f79352decf8d263cbca804df9d30ce67c0ab 100644 (file)
@@ -23,8 +23,10 @@ import org.simantics.sysdyn.JFreeChartResource;
 \r
 public class ChartSelectionTabContributor {\r
 \r
-       \r
-       public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException {\r
+       public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException{\r
+               return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME);\r
+       }\r
+       public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs, int options) throws DatabaseException {\r
                JFreeChartResource jfree = JFreeChartResource.getInstance(backend);\r
                if(backend.isInstanceOf(r, jfree.ChartElement)) {\r
             if(backend.hasStatement(r, jfree.ChartElement_component))\r
@@ -50,7 +52,7 @@ public class ChartSelectionTabContributor {
                              "Axis and Variables"));\r
                  } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
-                             new BarGeneralPropertiesTab(),\r
+                             new BarGeneralPropertiesTab(options),\r
                              10,\r
                              r,\r
                              "General"));\r
@@ -66,7 +68,7 @@ public class ChartSelectionTabContributor {
                              "Axis"));                        \r
                  } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
-                             new PieGeneralPropertiesTab(),\r
+                             new PieGeneralPropertiesTab(options),\r
                              10,\r
                              r,\r
                              "General"));\r
@@ -89,7 +91,11 @@ public class ChartSelectionTabContributor {
                return false;\r
        }\r
        \r
-       public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException {\r
+       public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException{\r
+               return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME);\r
+       }\r
+       \r
+       public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs, int options) throws DatabaseException {\r
                JFreeChartResource jfree = JFreeChartResource.getInstance(backend);\r
                if(backend.isInstanceOf(r, jfree.ChartElement)) {\r
             if(backend.hasStatement(r, jfree.ChartElement_component))\r
@@ -115,7 +121,7 @@ public class ChartSelectionTabContributor {
                              "Axis and Variables"));\r
                  } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
-                             new BarGeneralPropertiesTab(),\r
+                             new BarGeneralPropertiesTab(options),\r
                              10,\r
                              r,\r
                              "General"));\r
@@ -131,7 +137,7 @@ public class ChartSelectionTabContributor {
                              "Axis"));                        \r
                  } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
-                             new PieGeneralPropertiesTab(),\r
+                             new PieGeneralPropertiesTab(options),\r
                              10,\r
                              r,\r
                              "General"));\r
index e75989ba31113cc108cced9acc5d6fc77b7d8cf5..035f87ffa3b1355734da4a0b9cb4bd403b9e29b4 100644 (file)
@@ -38,6 +38,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.PossibleObjectWithType;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.jfreechart.ChartPropertyOptions;\r
 import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
 import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
 import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2;\r
@@ -68,6 +69,17 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
     private TrackedCombo type;\r
     private TrackedCombo orientation;\r
 \r
+    private boolean showTime = true;\r
+    private boolean showFilter = false;\r
+    \r
+    public BarGeneralPropertiesTab() {\r
+       \r
+    }\r
+    \r
+    public BarGeneralPropertiesTab(int options) {\r
+       showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); \r
+       showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0);\r
+    }\r
 \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
@@ -79,7 +91,10 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         sc.setExpandVertical(true);\r
 \r
         composite = new Composite(sc, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite);\r
+        if (showFilter)\r
+               GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite);\r
+        else\r
+               GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
 \r
         // General properties\r
         Group general = new Group(composite, SWT.NONE);\r
@@ -142,17 +157,19 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         title.addModifyListener(new TitleModifier());\r
         title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
 \r
-        // Time\r
-        label = new Label(labelColumn2, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Time:");\r
-        \r
-        time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
-        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
-        time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
-        time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
-        time.setInputValidator(new DoubleValidator(true));\r
+        if (showTime) {\r
+               // Time\r
+               label = new Label(labelColumn2, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+               label.setText("Time:");\r
+               \r
+               time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
+               GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
+               time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
+               time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
+               time.setInputValidator(new DoubleValidator(true));\r
         time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
+        }\r
         \r
         Group typeGroup = new Group(composite,SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(typeGroup);\r
@@ -199,25 +216,27 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
         hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
 \r
-        Group filteringGroup = new Group(composite, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
-        hideGroup.setText("Filter");\r
-        label = new Label(filteringGroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Use:");\r
-        Button useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
-        useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
-        useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
-        label = new Label(filteringGroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Percent:");\r
-        TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
-        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
-        fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
-        fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
-        fraction.setInputValidator(new DoubleValidator(true));\r
-        fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
+        if (showFilter) {\r
+               Group filteringGroup = new Group(composite, SWT.NONE);\r
+               GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
+               GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
+               hideGroup.setText("Filter");\r
+               label = new Label(filteringGroup, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+               label.setText("Use:");\r
+               Button useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
+               useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
+               useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
+               label = new Label(filteringGroup, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+               label.setText("Percent:");\r
+               TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
+               GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
+               fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
+               fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
+               fraction.setInputValidator(new DoubleValidator(true));\r
+               fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
+        }\r
         \r
         // Resize scrolled composite\r
         sc.setContent(composite);\r
index c2c54ab87d577e6c30a0e7ff00c31e6bbb31193d..a4fe3b8eaf1a4a0f8261c94c7f20c9ac4fa56856 100644 (file)
@@ -27,6 +27,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.jfreechart.ChartPropertyOptions;\r
 import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
 import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
 import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2;\r
@@ -52,6 +53,18 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
     private Composite composite;\r
     private Button htitle, hlegend, hlabels;\r
     private TrackedText name, title, time;\r
+    \r
+    private boolean showTime = true;\r
+    private boolean showFilter = false;\r
+    \r
+    public PieGeneralPropertiesTab() {\r
+       \r
+    }\r
+    \r
+    public PieGeneralPropertiesTab(int options) {\r
+       showTime = ((options & ChartPropertyOptions.SHOW_TIME) > 0); \r
+       showFilter = ((options & ChartPropertyOptions.SHOW_FILTER) > 0);\r
+    }\r
 \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
@@ -63,7 +76,10 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
         sc.setExpandVertical(true);\r
 \r
         composite = new Composite(sc, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
+        if (showFilter)\r
+               GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
+        else\r
+               GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
 \r
         // General properties\r
         Group general = new Group(composite, SWT.NONE);\r
@@ -122,18 +138,19 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
         title.addModifyListener(new TitleModifier());\r
         title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
 \r
-        // Time\r
-        label = new Label(labelColumn2, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Time:");\r
-        \r
-        time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
-        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
-        time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
-        time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
-        time.setInputValidator(new DoubleValidator(true));\r
-        time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
-\r
+        if (showTime) {\r
+               // Time\r
+               label = new Label(labelColumn2, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+               label.setText("Time:");\r
+               \r
+               time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
+               GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
+               time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
+               time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
+               time.setInputValidator(new DoubleValidator(true));\r
+               time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
+        }\r
         // Group for hide options\r
         Group hideGroup = new Group(composite, SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(hideGroup);\r
@@ -153,27 +170,27 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
         hlabels.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels, true));\r
         hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels));\r
         \r
-        \r
-        Group filteringGroup = new Group(composite, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
-        hideGroup.setText("Filter");\r
-        label = new Label(filteringGroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Use:");\r
-        Button useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
-        useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
-        useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
-        label = new Label(filteringGroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Percent:");\r
-        TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
-        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
-        fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
-        fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
-        fraction.setInputValidator(new DoubleValidator(true));\r
-        fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
-        \r
+        if (showFilter) {\r
+               Group filteringGroup = new Group(composite, SWT.NONE);\r
+               GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
+               GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
+               hideGroup.setText("Filter");\r
+               label = new Label(filteringGroup, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+               label.setText("Use:");\r
+               Button useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
+               useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
+               useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
+               label = new Label(filteringGroup, SWT.NONE);\r
+               GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+               label.setText("Percent:");\r
+               TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
+               GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
+               fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
+               fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
+               fraction.setInputValidator(new DoubleValidator(true));\r
+               fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
+        }\r
         \r
         sc.setContent(composite);\r
         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r