1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.browser.actions;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.WriteGraph;
\r
17 import org.simantics.db.common.request.WriteRequest;
\r
18 import org.simantics.db.exception.DatabaseException;
\r
19 import org.simantics.sysdyn.SysdynResource;
\r
20 import org.simantics.ui.DoubleClickEvent;
\r
21 import org.simantics.ui.IDoubleClickAction;
\r
22 import org.simantics.ui.utils.ResourceAdaptionUtils;
\r
25 * Activates a result dataset to be shown in charts and other result visualizations
\r
27 * @author Teemu Lempinen
\r
30 public class ActivateResultDatasetAction implements IDoubleClickAction {
\r
33 public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {
\r
34 final Resource result = ResourceAdaptionUtils.toSingleResource(e.getResource());
\r
38 ReadGraph graph = e.getGraph();
\r
40 if(graph.isInstanceOf(result, SysdynResource.getInstance(graph).Result)) {
\r
42 graph.getSession().asyncRequest(new WriteRequest() {
\r
45 public void perform(WriteGraph graph) throws DatabaseException {
\r
46 SysdynResource sr = SysdynResource.getInstance(graph);
\r
47 if(graph.isInstanceOf(result, sr.Result)) {
\r
48 if (graph.hasStatement(result, sr.Result_showResult)) {
\r
49 graph.denyStatement(result, sr.Result_showResult, result);
\r
51 graph.claim(result, sr.Result_showResult, result);
\r