]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Cleaner chart properties
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 9 Dec 2011 13:18:18 +0000 (13:18 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 9 Dec 2011 13:18:18 +0000 (13:18 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23473 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarAxisTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieGeneralPropertiesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java

index b576aadeedfa3c127d22133c97b44423808bb212..d4922270fa912eca984173f58f58915508b36496 100644 (file)
                         property="org.simantics.sysdyn.ui.nodeClass">\r
                   </test>\r
                   <test\r
-                        args="org.simantics.sysdyn.ui.browser.nodes.ChartNode"\r
+                        args="org.simantics.sysdyn.ui.browser.nodes.LineChartNode"\r
+                        property="org.simantics.sysdyn.ui.nodeClass">\r
+                  </test>\r
+                  <test\r
+                        args="org.simantics.sysdyn.ui.browser.nodes.BarChartNode"\r
+                        property="org.simantics.sysdyn.ui.nodeClass">\r
+                  </test>\r
+                  <test\r
+                        args="org.simantics.sysdyn.ui.browser.nodes.PieChartNode"\r
                         property="org.simantics.sysdyn.ui.nodeClass">\r
                   </test>\r
                </or>\r
index 1fb72a786be6438260cd661021644ee243429b14..7b8ac685b96588617c95577e53af6f186c248484 100644 (file)
@@ -34,6 +34,7 @@ import org.simantics.sysdyn.JFreeChartResource;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.ChartTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.bar.BarAxisTab;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.bar.BarGeneralPropertiesTab;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.bar.BarSeriesTab;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.pie.PieGeneralPropertiesTab;\r
@@ -343,6 +344,11 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 9,\r
                                 r,\r
                                 "Variables"));\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new BarAxisTab(),\r
+                                8,\r
+                                r,\r
+                                "Axis"));                        \r
                     } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                         tabs.add(new ComparableTabContributor(\r
                                 new PieGeneralPropertiesTab(),\r
index 9d71e7588bcfe74b3fb6dc73efc6aadfb4096417..200f0a21888daea025070d29f131143ab5a14f74 100644 (file)
@@ -127,7 +127,7 @@ public class ChartComposite extends Composite {
 \r
             @Override\r
             public void execute(AsyncReadGraph graph, IJFreeChart chart) {\r
-                if(chart == null)\r
+                if(chart == null || composite.isDisposed())\r
                     return;\r
                 \r
                 JFreeChart jfreeChart = chart.getChart();\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarAxisTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarAxisTab.java
new file mode 100644 (file)
index 0000000..c0e84e6
--- /dev/null
@@ -0,0 +1,312 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend.chart.properties.bar;\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Spinner;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListener;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ui.chart.property.DoublePropertyFactory;\r
+import org.simantics.modeling.ui.chart.property.DoublePropertyModifier;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.AxisHidePropertyComposite;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.TrackedSpinner;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+/**\r
+ * Tab for bar chart axis properties\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class BarAxisTab extends LabelPropertyTabContributor implements Widget {\r
+\r
+    private TrackedSpinner angle;\r
+    private Integer angleInt = null;\r
+    private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl();\r
+    private WidgetSupportImpl rangeAxisSupport = new WidgetSupportImpl();\r
+    private TrackedText rangelabel, rangemin, rangemax;\r
+    private ScrolledComposite sc;\r
+    private Composite composite;\r
+\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+        support.register(this);\r
+\r
+        // Scrolled composite containing all of the properties in this tab\r
+        sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(sc);\r
+        sc.setExpandHorizontal(true);\r
+        sc.setExpandVertical(true);\r
+\r
+        composite = new Composite(sc, SWT.NONE);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+\r
+        // Domain Axis properties\r
+        Group domainGroup = new Group(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(domainGroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(domainGroup);\r
+        domainGroup.setText("Domain axis");\r
+\r
+        // Label for x-axis\r
+        Label label = new Label(domainGroup, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Label:");\r
+\r
+        rangelabel = new TrackedText(domainGroup, domainAxisSupport, SWT.BORDER);\r
+        rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
+        rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager()));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget());\r
+\r
+        Composite axisHide = new AxisHidePropertyComposite(domainGroup, context, domainAxisSupport, SWT.NONE);\r
+        GridDataFactory.fillDefaults().span(1, 3).applyTo(axisHide);\r
+\r
+        Label angleLabel = new Label(domainGroup, SWT.NONE);\r
+        angleLabel.setText("Label angle:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(angleLabel);\r
+\r
+        Composite angleComposite = new Composite(domainGroup, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(angleComposite);\r
+        GridLayoutFactory.fillDefaults().applyTo(angleComposite);\r
+        angle = new TrackedSpinner(angleComposite, domainAxisSupport, SWT.BORDER);\r
+        angle.setSelectionFactory(new AngleSelectionFactory());\r
+        angle.addModifyListener(new AngleModifyListener());\r
+        angle.setMinimum(0);\r
+        angle.setMaximum(90);\r
+        angle.getWidget().setIncrement(5);\r
+        GridDataFactory.fillDefaults().applyTo(angle.getWidget());\r
+\r
+        // Domain Color\r
+        label = new Label(domainGroup, SWT.NONE);\r
+        label.setText("Color:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+        Composite colorPicker = new ColorPicker(domainGroup, context, domainAxisSupport, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
+\r
+        domainGroup.layout();\r
+\r
+        // Range Axis properties\r
+        Group rangeGroup = new Group(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(rangeGroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(rangeGroup);\r
+        rangeGroup.setText("Range axis");\r
+\r
+        // Label for range axis\r
+        label = new Label(rangeGroup, SWT.NONE);\r
+        label.setText("Label:");\r
+        label.setAlignment(SWT.RIGHT);\r
+        GridDataFactory.fillDefaults().hint(angleLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+        rangelabel = new TrackedText(rangeGroup, rangeAxisSupport, SWT.BORDER);\r
+        rangelabel.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
+        rangelabel.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        rangelabel.setColorProvider(new JFreeChartPropertyColorProvider(rangelabel.getResourceManager()));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangelabel.getWidget());\r
+\r
+        axisHide = new AxisHidePropertyComposite(rangeGroup, context, rangeAxisSupport, SWT.NONE);\r
+        GridDataFactory.fillDefaults().span(1, 4).applyTo(axisHide);\r
+\r
+        // Min and max values for range axis\r
+        label = new Label(rangeGroup, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Min:");\r
+\r
+        Composite minmax = new Composite(rangeGroup, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(minmax);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(minmax);\r
+        rangemin = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER);\r
+        rangemin.setColorProvider(new JFreeChartPropertyColorProvider(rangemin.getResourceManager()));\r
+        rangemin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
+        rangemin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
+        rangemin.setInputValidator(new DoubleValidator());\r
+\r
+        label = new Label(minmax, SWT.NONE);\r
+        label.setText("Max:");\r
+        rangemax = new TrackedText(minmax, rangeAxisSupport, SWT.BORDER);\r
+        rangemax.setColorProvider(new JFreeChartPropertyColorProvider(rangemax.getResourceManager()));\r
+        rangemax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
+        rangemax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
+        rangemax.setInputValidator(new DoubleValidator());\r
+\r
+        // Range Color\r
+        label = new Label(rangeGroup, SWT.NONE);\r
+        label.setText("Color:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+        colorPicker = new ColorPicker(rangeGroup, context, rangeAxisSupport, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
+\r
+        // Resize scrolled composite\r
+        sc.setContent(composite);\r
+        Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
+        sc.setMinSize(size);\r
+    }\r
+\r
+    /**\r
+     * ModifyListener for the angle {@link TrackedSpinner}\r
+     * \r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class AngleModifyListener implements TextModifyListener, Widget {\r
+\r
+        private ISessionContext context;\r
+        private Object lastInput = null;\r
+\r
+        @Override\r
+        public void modifyText(TrackedModifyEvent e) {\r
+            if(context == null)\r
+                return;\r
+\r
+            // Get the text value from spinner and associated resource (input)\r
+            Spinner spinner = (Spinner)e.getWidget();\r
+            final String textValue = spinner.getText();\r
+            final Object input = lastInput;\r
+\r
+            try {\r
+                context.getSession().syncRequest(new WriteRequest() {\r
+\r
+                    @Override\r
+                    public void perform(WriteGraph graph) throws DatabaseException {\r
+                        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                        Resource domainAxis = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+                        try {\r
+                            // usually reliable, since the spinner does all the checks\r
+                            Double value = Double.parseDouble(textValue); \r
+                            Double oldValue = graph.getPossibleRelatedValue(domainAxis, jfree.Axis_rotateLabelDegrees, Bindings.DOUBLE);\r
+                            if(oldValue == null || !oldValue.equals(value)) {\r
+                                graph.claimLiteral(domainAxis, jfree.Axis_rotateLabelDegrees, value, Bindings.DOUBLE);\r
+                                angleInt = value.intValue();\r
+                            }\r
+                        } catch (NumberFormatException e) {\r
+                            graph.claimLiteral(domainAxis, jfree.Axis_rotateLabelDegrees, 0.0, Bindings.DOUBLE);\r
+                            angleInt = 0;\r
+                        }\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public void setInput(ISessionContext context, Object parameter) {\r
+            this.context = context;\r
+            lastInput = parameter;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Class for setting the value for angle {@link TrackedSpinner}\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class AngleSelectionFactory extends ReadFactoryImpl<Resource, Integer>   {\r
+\r
+        @Override\r
+        public Integer perform(ReadGraph graph, Resource domainAxis) throws DatabaseException {\r
+            if(angleInt == null) {\r
+                Double angle = 0.0;\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                if(domainAxis != null) {\r
+                    Double value = graph.getPossibleRelatedValue(domainAxis, jfree.Axis_rotateLabelDegrees);\r
+                    if(value != null)\r
+                        angle = value;\r
+                }\r
+                return angle.intValue();\r
+            } else {\r
+                return angleInt;\r
+            }\r
+        }\r
+\r
+    }\r
+\r
+    @Override\r
+    public void setInput(final ISessionContext context, Object input) {\r
+        final Resource chart = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+        if(chart == null)\r
+            return; \r
+\r
+        context.getSession().asyncRequest(new ReadRequest() {\r
+\r
+            @Override\r
+            public void run(ReadGraph graph) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(graph);\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot));\r
+                if(plot == null) return;\r
+                Resource rangeAxis = graph.getPossibleObject(plot, jfree.Plot_rangeAxis);\r
+                if(rangeAxis == null) return;\r
+                rangeAxisSupport.fireInput(context, new StructuredSelection(rangeAxis));\r
+\r
+                Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis);\r
+                if(domainAxis == null) return;\r
+                domainAxisSupport.fireInput(context, new StructuredSelection(domainAxis));\r
+            }\r
+        });\r
+    }\r
+\r
+\r
+    /**\r
+     * Validator for validating that an input is double\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class DoubleValidator implements IInputValidator {\r
+        @Override\r
+        public String isValid(String newText) {\r
+            if (newText.trim().isEmpty())\r
+                return null;\r
+            try {\r
+                Double.parseDouble(newText);\r
+                return null;\r
+            } catch (NumberFormatException e) {\r
+                return e.getMessage();\r
+            }\r
+        }\r
+    }\r
+}\r
index aebd5e97a0f887e5fb4ad00310c379b0c86a2d1d..387f34e60b14cfebf6c4bfb0ca91e6fcd2144c62 100644 (file)
@@ -22,7 +22,6 @@ import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Group;\r
 import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Spinner;\r
 import org.eclipse.ui.IWorkbenchSite;\r
 import org.simantics.browsing.ui.swt.widgets.Button;\r
 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
@@ -31,16 +30,11 @@ import org.simantics.browsing.ui.swt.widgets.TrackedCombo;
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
 import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
-import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListener;\r
-import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
-import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
-import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.PossibleObjectWithType;\r
-import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.layer0.Layer0;\r
@@ -52,8 +46,7 @@ import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;
 import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.TitleFactory;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.TitleModifier;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.TrackedSpinner;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+\r
 \r
 /**\r
  * General properties of a bar chart\r
@@ -67,7 +60,7 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
     private Button hgrid, htitle, hlegend;\r
     private TrackedText name, title;\r
     private TrackedCombo type;\r
-    private TrackedSpinner angle;\r
+\r
 \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
@@ -143,22 +136,7 @@ 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
-        Composite angleComposite = new Composite(composite, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(angleComposite);\r
-        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(angleComposite);\r
-        // Line width\r
-        label = new Label(angleComposite, SWT.NONE);\r
-        label.setText("Label angle:");\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
-\r
-        angle = new TrackedSpinner(angleComposite, support, SWT.BORDER);\r
-        angle.setSelectionFactory(new AngleSelectionFactory());\r
-        angle.addModifyListener(new AngleModifyListener());\r
-        angle.setMinimum(0);\r
-        angle.setMaximum(90);\r
-        angle.getWidget().setIncrement(5);\r
-        GridDataFactory.fillDefaults().applyTo(angle.getWidget());\r
-\r
+        // Resize scrolled composite\r
         sc.setContent(composite);\r
         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
         sc.setMinSize(size);\r
@@ -174,13 +152,13 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
             Layer0 l0 = Layer0.getInstance(graph);\r
-            \r
+\r
             Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
             if(plot != null) {\r
                 Resource dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.CategoryDataset));\r
-                \r
+\r
                 if(dataset != null) {\r
-                    Resource renderer = graph.syncRequest(new PossibleObjectWithType(dataset, l0.ConsistsOf, jfree.Dataset_renderer));\r
+                    Resource renderer = graph.syncRequest(new PossibleObjectWithType(dataset, jfree.Dataset_renderer, jfree.Renderer));\r
 \r
                     if(renderer != null && graph.isInstanceOf(renderer, jfree.StackedBarRenderer))\r
                         return "Stacked";\r
@@ -237,89 +215,4 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         }\r
     }\r
 \r
-\r
-\r
-    /**\r
-     * ModifyListener for the angle {@link TrackedSpinner}\r
-     * \r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class AngleModifyListener implements TextModifyListener, Widget {\r
-\r
-        private ISessionContext context;\r
-        private Object lastInput = null;\r
-\r
-        @Override\r
-        public void modifyText(TrackedModifyEvent e) {\r
-            if(context == null)\r
-                return;\r
-\r
-            // Get the text value from spinner and associated resource (input)\r
-            Spinner spinner = (Spinner)e.getWidget();\r
-            final String textValue = spinner.getText();\r
-            final Object input = lastInput;\r
-\r
-            try {\r
-                context.getSession().syncRequest(new WriteRequest() {\r
-\r
-                    @Override\r
-                    public void perform(WriteGraph graph) throws DatabaseException {\r
-                        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-                        Layer0 l0 = Layer0.getInstance(graph);\r
-\r
-                        Resource chart = AdaptionUtils.adaptToSingle(input, Resource.class);\r
-                        Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
-                        Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis);\r
-\r
-                        try {\r
-                            // usually reliable, since the spinner does all the checks\r
-                            Double value = Double.parseDouble(textValue); \r
-                            graph.claimLiteral(domainAxis, jfree.Axis_rotateLabelDegrees, value, Bindings.DOUBLE);\r
-                        } catch (NumberFormatException e) {\r
-                            graph.claimLiteral(domainAxis, jfree.Axis_rotateLabelDegrees, 0.0, Bindings.DOUBLE);\r
-                        }\r
-                    }\r
-\r
-                });\r
-            } catch (DatabaseException e1) {\r
-                e1.printStackTrace();\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public void setInput(ISessionContext context, Object parameter) {\r
-            this.context = context;\r
-            lastInput = parameter;\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * Class for setting the value for angle {@link TrackedSpinner}\r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class AngleSelectionFactory extends ReadFactoryImpl<Resource, Integer>   {\r
-\r
-        @Override\r
-        public Integer perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
-            Double angle = 0.0;\r
-            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-            Layer0 l0 = Layer0.getInstance(graph);\r
-            Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
-            if(plot != null) {\r
-                Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis);\r
-                if(domainAxis != null) {\r
-                    Double value = graph.getPossibleRelatedValue(domainAxis, jfree.Axis_rotateLabelDegrees);\r
-                    if(value != null)\r
-                        angle = value;\r
-                }\r
-            }\r
-            return angle.intValue();\r
-\r
-        }\r
-\r
-    }\r
-\r
 }\r
index 3900631f6f6a80eb7b67d4abe08a422fa09819bc..fdff61b0ab0a156830c2f437cd2df28e53d231ec 100644 (file)
@@ -16,7 +16,6 @@ import org.eclipse.jface.layout.GridLayoutFactory;
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.ScrolledComposite;\r
 import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.widgets.Combo;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Group;\r
 import org.eclipse.swt.widgets.Label;\r
@@ -47,7 +46,6 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
     private Composite composite;\r
     private Button htitle, hlegend;\r
     private TrackedText name, title;\r
-    private Combo type;\r
 \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
@@ -72,25 +70,12 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
         label.setText("Name:");\r
 \r
-        Composite c = new Composite(general, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(c);\r
-        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(c);\r
-\r
-        name = new org.simantics.browsing.ui.swt.widgets.TrackedText(c, support, SWT.BORDER);\r
+        name = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
         name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
         name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
 \r
-        // Type\r
-        label = new Label(c, SWT.NONE);\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Type:");\r
-\r
-        type = new Combo(c, SWT.BORDER | SWT.READ_ONLY);\r
-        type.setItems(new String[] {"Normal", "Stacked"});\r
-        type.select(0);\r
-\r
         // Title (Which is different than name)\r
         label = new Label(general, SWT.NONE);\r
         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
index ea64a17dc1601c3d81c8f0a5d2a77ff10bb0a761..421c63c2c992a2663ab2008c05a8cefcc6c64473 100644 (file)
@@ -87,9 +87,10 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         general.setText("General");\r
 \r
         // Name\r
-        Label label = new Label(general, SWT.NONE);\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Name:");\r
+        Label nameLabel = new Label(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
+        nameLabel.setText("Name:");\r
+        nameLabel.setAlignment(SWT.RIGHT);\r
 \r
         Composite c = new Composite(general, SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(c);\r
@@ -102,7 +103,7 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
 \r
         // Type\r
-        label = new Label(c, SWT.NONE);\r
+        Label label = new Label(c, SWT.NONE);\r
         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
         label.setText("Type:");\r
 \r
@@ -148,9 +149,9 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         xgroup.setText("X-axis");\r
 \r
         // Variable for x-axis (default: empty == time)\r
-        label = new Label(xgroup, SWT.NONE);\r
-        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
-        label.setText("Variable:");\r
+        Label xVariableLabel = new Label(xgroup, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(xVariableLabel);\r
+        xVariableLabel.setText("Variable:");\r
 \r
         xvariable = new TrackedText(xgroup, domainAxisSupport, SWT.BORDER);\r
         xvariable.setTextFactory(new RVIFactory());\r
@@ -194,7 +195,10 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
         xmax.setInputValidator(new DoubleValidator());\r
 \r
-\r
+        // Set the same width to both label rows\r
+        composite.layout();\r
+        GridDataFactory.fillDefaults().hint(xVariableLabel.getBounds().width, SWT.DEFAULT).align(SWT.END, SWT.CENTER).applyTo(nameLabel);\r
+        \r
         sc.setContent(composite);\r
         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
         sc.setMinSize(size);\r