X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.simulation.ui%2Fsrc%2Forg%2Fsimantics%2Fsimulation%2Fui%2Fhandlers%2FActivateExperimentAction.java;h=d6fae16ccf7e780b42a5bd5db2a8c3d3f7980695;hp=9be2285a461dd3ab4d9ae685f6276f3df2106617;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.simulation.ui/src/org/simantics/simulation/ui/handlers/ActivateExperimentAction.java b/bundles/org.simantics.simulation.ui/src/org/simantics/simulation/ui/handlers/ActivateExperimentAction.java index 9be2285a4..d6fae16cc 100644 --- a/bundles/org.simantics.simulation.ui/src/org/simantics/simulation/ui/handlers/ActivateExperimentAction.java +++ b/bundles/org.simantics.simulation.ui/src/org/simantics/simulation/ui/handlers/ActivateExperimentAction.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.simulation.ui.handlers; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.project.IProject; -import org.simantics.simulation.ontology.SimulationResource; -import org.simantics.simulation.project.IExperimentManager; -import org.simantics.ui.DoubleClickEvent; -import org.simantics.ui.IDoubleClickAction; -import org.simantics.ui.SimanticsUI; -import org.simantics.ui.utils.ResourceAdaptionUtils; -import org.simantics.utils.ui.action.PriorityAction; - -/** - * A double click action handler for the graph explorer browser. Intended for - * invocation when an experiment resource is double clicked, which is controlled - * from outside of this class. - * - * @author Tuukka Lehtonen - * - * @see ExperimentActivator - */ -public class ActivateExperimentAction implements IDoubleClickAction { - - @Override - public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException { - ReadGraph g = e.getGraph(); - final Resource experiment = ResourceAdaptionUtils.toSingleResource(e.getResource()); - if (experiment == null) - return; - - if (g.isInstanceOf(experiment, SimulationResource.getInstance(g).Experiment)) { - final IProject project = SimanticsUI.getProject(); - if (project == null) - return; - - final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); - if (experimentManager != null) { - e.add(new PriorityAction(PriorityAction.HIGH+10) { - @Override - public void run() { - ExperimentActivator.scheduleActivation(project.getSession(), project, experimentManager, experiment); - } - }); - e.consume(); - return; - } /*else { - ExperimentUtil.activateExperiment(g, experiment); - }*/ - - } - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.simulation.ui.handlers; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.project.IProject; +import org.simantics.simulation.ontology.SimulationResource; +import org.simantics.simulation.project.IExperimentManager; +import org.simantics.ui.DoubleClickEvent; +import org.simantics.ui.IDoubleClickAction; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; +import org.simantics.utils.ui.action.PriorityAction; + +/** + * A double click action handler for the graph explorer browser. Intended for + * invocation when an experiment resource is double clicked, which is controlled + * from outside of this class. + * + * @author Tuukka Lehtonen + * + * @see ExperimentActivator + */ +public class ActivateExperimentAction implements IDoubleClickAction { + + @Override + public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException { + ReadGraph g = e.getGraph(); + final Resource experiment = ResourceAdaptionUtils.toSingleResource(e.getResource()); + if (experiment == null) + return; + + if (g.isInstanceOf(experiment, SimulationResource.getInstance(g).Experiment)) { + final IProject project = SimanticsUI.getProject(); + if (project == null) + return; + + final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); + if (experimentManager != null) { + e.add(new PriorityAction(PriorityAction.HIGH+10) { + @Override + public void run() { + ExperimentActivator.scheduleActivation(project.getSession(), project, experimentManager, experiment); + } + }); + e.consume(); + return; + } /*else { + ExperimentUtil.activateExperiment(g, experiment); + }*/ + + } + } + +}