*******************************************************************************/\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
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
\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