From a5ff4034a90b6276e9ce09badc8dc531915932a1 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Tue, 10 Jun 2014 12:02:13 +0000 Subject: [PATCH] Ability to configure expected boolean value for missing statement. fixes #4940 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29610 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../properties/BooleanSelectionListener.java | 17 ++++++++++++++--- .../properties/bar/BarGeneralPropertiesTab.java | 6 +++--- .../properties/pie/PieGeneralPropertiesTab.java | 6 +++--- .../xyline/XYLineGeneralPropertiesTab.java | 6 +++--- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java index 8364b82c..3fe269b9 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.java @@ -30,6 +30,7 @@ public class BooleanSelectionListener extends SelectionListenerImpl { final private String propertyURI; final private String typeUri; + final private boolean defaultValue; /** * Boolean selection listener for property with propertyURI @@ -38,7 +39,7 @@ public class BooleanSelectionListener extends SelectionListenerImpl { * @param propertyURI uri of the boolean property */ public BooleanSelectionListener(ISessionContext context, String propertyURI) { - this(context, null, propertyURI); + this(context, null, propertyURI, false); } /** @@ -48,12 +49,19 @@ public class BooleanSelectionListener extends SelectionListenerImpl { * @param context ISessionContext * @param typeUri URI for a resource (resource ConsistsOf type) (null allowed -> not used) * @param propertyURI uri of the boolean property + * @param defaultValue expected value if the property does not exist */ - public BooleanSelectionListener(ISessionContext context, String typeUri, String propertyURI) { + public BooleanSelectionListener(ISessionContext context, String typeUri, String propertyURI, boolean defaultValue) { super(context); this.propertyURI = propertyURI; this.typeUri = typeUri; + this.defaultValue = defaultValue; } + + public BooleanSelectionListener(ISessionContext context, String typeUri, String propertyURI) { + this(context, typeUri, propertyURI, false); + } + @Override public void apply(WriteGraph graph, Resource chart) throws DatabaseException { @@ -77,6 +85,9 @@ public class BooleanSelectionListener extends SelectionListenerImpl { private void setValue(WriteGraph graph, Resource resource) throws DatabaseException { Resource property = graph.getResource(propertyURI); Boolean value = graph.getPossibleRelatedValue(resource, property, Bindings.BOOLEAN); - graph.claimLiteral(resource, property, Boolean.FALSE.equals(value)); + if (value == null) + graph.claimLiteral(resource, property, !defaultValue); + else + graph.claimLiteral(resource, property, Boolean.FALSE.equals(value)); } } \ No newline at end of file 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 fa60a3e5..370d14dc 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 @@ -322,15 +322,15 @@ public class BarGeneralPropertiesTab extends AdjustableTab { hgrid = new Button(hideGroup, support, SWT.CHECK); hgrid.setText("Grid"); hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true)); - hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid)); + hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid,true)); htitle = new Button(hideGroup, support, SWT.CHECK); htitle.setText("Title"); htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); - htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); + htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible,true)); hlegend = new Button(hideGroup, support, SWT.CHECK); hlegend.setText("Legend"); hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); - hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); + hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend,true)); if (showFilter) { filteringGroup = new Group(composite, SWT.NONE); 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 3e2b2d2d..3185932a 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 @@ -150,15 +150,15 @@ public class PieGeneralPropertiesTab extends AdjustableTab { htitle = new Button(hideGroup, support, SWT.CHECK); htitle.setText("Title"); htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); - htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); + htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible,true)); hlegend = new Button(hideGroup, support, SWT.CHECK); hlegend.setText("Legend"); hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); - hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); + hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend,true)); hlabels = new Button(hideGroup, support, SWT.CHECK); hlabels.setText("Section labels"); hlabels.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels, true)); - hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels)); + hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels,true)); if (showFilter) { filteringGroup = new Group(composite, SWT.NONE); 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 495a36e1..81581d14 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 @@ -245,15 +245,15 @@ public class XYLineGeneralPropertiesTab extends AdjustableTab implements Widget hgrid = new Button(hideGroup, support, SWT.CHECK); hgrid.setText("Grid"); hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true)); - hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid)); + hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid,true)); htitle = new Button(hideGroup, support, SWT.CHECK); htitle.setText("Title"); htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true)); - htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible)); + htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible,true)); hlegend = new Button(hideGroup, support, SWT.CHECK); hlegend.setText("Legend"); hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true)); - hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend)); + hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend,true)); // X-Axis properties -- 2.47.1