import org.eclipse.core.runtime.IAdaptable;\r
import org.eclipse.jface.viewers.IStructuredSelection;\r
import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.common.request.SingleObjectWithType;\r
import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
import org.simantics.db.layer0.variable.Variable;\r
import org.simantics.db.layer0.variable.Variables;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.layer0.utils.direct.GraphUtils;\r
import org.simantics.sysdyn.JFreeChartResource;\r
import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
\r
/**\r
* Node representing a chart\r
* @author Teemu Lempinen\r
*\r
*/\r
-public class ChartNode extends AbstractNode<Resource> implements IDropTargetNode {\r
+public class ChartNode extends AbstractNode<Resource> implements IDropTargetNode, IDeletableNode {\r
\r
public ChartNode(Resource data) {\r
super(data);\r
\r
Resource plot = graph.syncRequest(new SingleObjectWithType(data, l0.ConsistsOf, jfree.Plot));\r
\r
- Resource dataset = graph.syncRequest(new SingleObjectWithType(plot, l0.ConsistsOf, jfree.Dataset)); //FIXME: Support multiple datasets\r
+ // FIXME: order of the datasets varies in this way\r
+ Resource dataset = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.Dataset)).iterator().next();\r
\r
String rvi = Variables.getRVI(graph, variable);\r
Resource type = l0.String;\r
});\r
}\r
\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ RemoverUtil.remove(graph, data);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ } \r
+ \r
+ }\r
+\r
}\r