1 /*******************************************************************************
\r
2 * Copyright (c) 2010 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.actions;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.exception.DatabaseException;
\r
17 import org.simantics.project.IProject;
\r
18 import org.simantics.simulation.ontology.SimulationResource;
\r
19 import org.simantics.simulation.project.IExperimentManager;
\r
20 import org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator;
\r
21 import org.simantics.ui.DoubleClickEvent;
\r
22 import org.simantics.ui.IDoubleClickAction;
\r
23 import org.simantics.ui.SimanticsUI;
\r
24 import org.simantics.ui.utils.ResourceAdaptionUtils;
\r
25 import org.simantics.utils.ui.ErrorLogger;
\r
26 import org.simantics.utils.ui.action.PriorityAction;
\r
28 public class ActivateExperimentAction implements IDoubleClickAction {
\r
31 public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {
\r
32 ReadGraph g = e.getGraph();
\r
33 final Resource experiment = ResourceAdaptionUtils.toSingleResource(e.getResource());
\r
34 if (experiment == null)
\r
37 if (g.isInstanceOf(experiment, SimulationResource.getInstance(g).Experiment)) {
\r
38 final IProject project = SimanticsUI.getProject();
\r
39 if (project == null)
\r
42 final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);
\r
43 if (experimentManager == null) {
\r
44 ErrorLogger.defaultLogWarning("Experiment manager not available.", new Exception());
\r
48 e.add(new PriorityAction(PriorityAction.HIGH+20) {
\r
51 SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, experiment);
\r