]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Ability to configure expected boolean value for missing statement.
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 10 Jun 2014 12:02:13 +0000 (12:02 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 10 Jun 2014 12:02:13 +0000 (12:02 +0000)
fixes #4940

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

org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/BooleanSelectionListener.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
org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/xyline/XYLineGeneralPropertiesTab.java

index 8364b82c35d565b815729c2f649bda34a02731fa..3fe269b9098c4600da4f32b2a7b124e3d16a3246 100644 (file)
@@ -30,6 +30,7 @@ public class BooleanSelectionListener extends SelectionListenerImpl<Resource> {
 \r
     final private String propertyURI;\r
     final private String typeUri;\r
+    final private boolean defaultValue;\r
     \r
     /**\r
      * Boolean selection listener for property with propertyURI\r
@@ -38,7 +39,7 @@ public class BooleanSelectionListener extends SelectionListenerImpl<Resource> {
      * @param propertyURI uri of the boolean property\r
      */\r
     public BooleanSelectionListener(ISessionContext context, String propertyURI) {\r
-        this(context, null, propertyURI);\r
+        this(context, null, propertyURI, false);\r
     }\r
 \r
     /**\r
@@ -48,12 +49,19 @@ public class BooleanSelectionListener extends SelectionListenerImpl<Resource> {
      * @param context ISessionContext\r
      * @param typeUri URI for a resource (resource ConsistsOf type) (null allowed -> not used)\r
      * @param propertyURI uri of the boolean property\r
+     * @param defaultValue expected value if the property does not exist\r
      */\r
-    public BooleanSelectionListener(ISessionContext context, String typeUri, String propertyURI) {\r
+    public BooleanSelectionListener(ISessionContext context, String typeUri, String propertyURI, boolean defaultValue) {\r
         super(context);\r
         this.propertyURI = propertyURI;\r
         this.typeUri = typeUri;\r
+        this.defaultValue = defaultValue;\r
     }\r
+    \r
+    public BooleanSelectionListener(ISessionContext context, String typeUri, String propertyURI) {\r
+       this(context, typeUri, propertyURI, false);\r
+    }\r
+\r
 \r
     @Override\r
     public void apply(WriteGraph graph, Resource chart) throws DatabaseException {\r
@@ -77,6 +85,9 @@ public class BooleanSelectionListener extends SelectionListenerImpl<Resource> {
     private void setValue(WriteGraph graph, Resource resource) throws DatabaseException {\r
         Resource property =  graph.getResource(propertyURI);\r
         Boolean value = graph.getPossibleRelatedValue(resource, property, Bindings.BOOLEAN);\r
-        graph.claimLiteral(resource, property, Boolean.FALSE.equals(value));\r
+        if (value == null)\r
+               graph.claimLiteral(resource, property, !defaultValue);\r
+        else\r
+               graph.claimLiteral(resource, property, Boolean.FALSE.equals(value));\r
     }\r
 }
\ No newline at end of file
index fa60a3e5fd3cb5806df12978983fe3ba3e5e9e65..370d14dc3f26b8e284d8417348878706de4162e8 100644 (file)
@@ -322,15 +322,15 @@ public class BarGeneralPropertiesTab extends AdjustableTab {
         hgrid = new Button(hideGroup, support, SWT.CHECK);\r
         hgrid.setText("Grid");\r
         hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true));\r
-        hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid));\r
+        hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid,true));\r
         htitle = new Button(hideGroup, support, SWT.CHECK);\r
         htitle.setText("Title");\r
         htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
-        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
+        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible,true));\r
         hlegend = new Button(hideGroup, support, SWT.CHECK);\r
         hlegend.setText("Legend");\r
         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
-        hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
+        hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend,true));\r
 \r
         if (showFilter) {\r
                filteringGroup = new Group(composite, SWT.NONE);\r
index 3e2b2d2d02d71bd0b55dc25851ec561a6aea9f9e..3185932ae240aee9f37fd8f8186fc363fa79debc 100644 (file)
@@ -150,15 +150,15 @@ public class PieGeneralPropertiesTab extends AdjustableTab {
         htitle = new Button(hideGroup, support, SWT.CHECK);\r
         htitle.setText("Title");\r
         htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
-        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
+        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible,true));\r
         hlegend = new Button(hideGroup, support, SWT.CHECK);\r
         hlegend.setText("Legend");\r
         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
-        hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
+        hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend,true));\r
         hlabels = new Button(hideGroup, support, SWT.CHECK);\r
         hlabels.setText("Section labels");\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
+        hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels,true));\r
         \r
         if (showFilter) {\r
                filteringGroup = new Group(composite, SWT.NONE);\r
index 495a36e11a32da8faa74d3b4e55edadaf1ab5b69..81581d1401af3fa9abe9294032ad1504a3f1808e 100644 (file)
@@ -245,15 +245,15 @@ public class XYLineGeneralPropertiesTab extends AdjustableTab implements Widget
         hgrid = new Button(hideGroup, support, SWT.CHECK);\r
         hgrid.setText("Grid");\r
         hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true));\r
-        hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid));\r
+        hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid,true));\r
         htitle = new Button(hideGroup, support, SWT.CHECK);\r
         htitle.setText("Title");\r
         htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
-        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
+        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible,true));\r
         hlegend = new Button(hideGroup, support, SWT.CHECK);\r
         hlegend.setText("Legend");\r
         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
-        hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
+        hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend,true));\r
 \r
 \r
         // X-Axis properties\r