]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
If xy chart has no selection, when variable is added, select the first range axis...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 Jan 2012 12:37:30 +0000 (12:37 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 Jan 2012 12:37:30 +0000 (12:37 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24014 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java

index 530d611a0ba2ce80926b7dc1b9e3f1b0624b81f3..3081abbbf105e84c742a5cdad89ed5fc74652de4 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
+import java.util.List;\r
+\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.viewers.ISelectionProvider;\r
@@ -24,6 +26,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Tree;\r
 import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.NodeContext;\r
 import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
 import org.simantics.browsing.ui.swt.widgets.Button;\r
 import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
@@ -206,10 +209,25 @@ public class XYLineAxisAndVariablesTab extends LabelPropertyTabContributor {
 \r
         @Override\r
         public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
-            if(input == null)\r
+            NodeContext nc = explorer.getExplorer().getRoot();\r
+            if(nc == null)\r
                 return;\r
+            \r
             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
             Layer0 l0 = Layer0.getInstance(graph);\r
+            \r
+            if(input == null) {\r
+                Resource chart = AdaptionUtils.adaptToSingle(nc, Resource.class);\r
+                if(chart == null) return;\r
+                Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot));\r
+                if(plot == null) return;\r
+                Resource rangelist = graph.getPossibleObject(plot, jfree.Plot_rangeAxisList);\r
+                if(rangelist == null) return;\r
+                List<Resource> list = ListUtils.toList(graph, rangelist);\r
+                if(list == null || list.isEmpty()) return;\r
+                input = list.get(0);\r
+            }\r
+            \r
             Resource dataset;\r
             if(graph.isInstanceOf(input, jfree.Series)) {\r
                 // Selected resource is series. Add to same dataset\r