1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.simulation.ui.handlers;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.project.IProject;
18 import org.simantics.simulation.ontology.SimulationResource;
19 import org.simantics.simulation.project.IExperimentManager;
20 import org.simantics.ui.DoubleClickEvent;
21 import org.simantics.ui.IDoubleClickAction;
22 import org.simantics.ui.SimanticsUI;
23 import org.simantics.ui.utils.ResourceAdaptionUtils;
24 import org.simantics.utils.ui.action.PriorityAction;
27 * A double click action handler for the graph explorer browser. Intended for
28 * invocation when an experiment resource is double clicked, which is controlled
29 * from outside of this class.
31 * @author Tuukka Lehtonen
33 * @see ExperimentActivator
35 public class ActivateExperimentAction implements IDoubleClickAction {
38 public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {
39 ReadGraph g = e.getGraph();
40 final Resource experiment = ResourceAdaptionUtils.toSingleResource(e.getResource());
41 if (experiment == null)
44 if (g.isInstanceOf(experiment, SimulationResource.getInstance(g).Experiment)) {
45 final IProject project = SimanticsUI.getProject();
49 final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);
50 if (experimentManager != null) {
51 e.add(new PriorityAction(PriorityAction.HIGH+10) {
54 ExperimentActivator.scheduleActivation(project.getSession(), project, experimentManager, experiment);
60 ExperimentUtil.activateExperiment(g, experiment);