--- /dev/null
+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
\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
"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
"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
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
"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
"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
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
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
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
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
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
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
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
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
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
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