From: lempinen Date: Fri, 20 Jan 2012 12:37:30 +0000 (+0000) Subject: If xy chart has no selection, when variable is added, select the first range axis... X-Git-Tag: simantics-1.6~45 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1bc33863244b3fada48e49013efdfeef2883a802;p=simantics%2Fsysdyn.git If xy chart has no selection, when variable is added, select the first range axis before applying add variable (refs #3082) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24014 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java index 530d611a..3081abbb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.trend.chart.properties.xyline; +import java.util.List; + import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.ISelectionProvider; @@ -24,6 +26,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.IWorkbenchSite; +import org.simantics.browsing.ui.NodeContext; import org.simantics.browsing.ui.swt.SingleSelectionInputSource; import org.simantics.browsing.ui.swt.widgets.Button; import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite; @@ -206,10 +209,25 @@ public class XYLineAxisAndVariablesTab extends LabelPropertyTabContributor { @Override public void apply(WriteGraph graph, Resource input) throws DatabaseException { - if(input == null) + NodeContext nc = explorer.getExplorer().getRoot(); + if(nc == null) return; + JFreeChartResource jfree = JFreeChartResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); + + if(input == null) { + Resource chart = AdaptionUtils.adaptToSingle(nc, Resource.class); + if(chart == null) return; + Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot)); + if(plot == null) return; + Resource rangelist = graph.getPossibleObject(plot, jfree.Plot_rangeAxisList); + if(rangelist == null) return; + List list = ListUtils.toList(graph, rangelist); + if(list == null || list.isEmpty()) return; + input = list.get(0); + } + Resource dataset; if(graph.isInstanceOf(input, jfree.Series)) { // Selected resource is series. Add to same dataset