1 /*******************************************************************************
\r
2 * Copyright (c) 2013 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\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 * Semantum Oy - initial API and implementation for issue #4384
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.runtime;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.common.request.UnaryRead;
\r
17 import org.simantics.db.exception.DatabaseException;
\r
18 import org.simantics.db.layer0.variable.RVI;
\r
19 import org.simantics.ui.workbench.IResourceEditorInput2;
\r
22 * Extract a triple <Model URI, Variable URI, RVI> from the input argument. This
\r
23 * request is needed in addition to {@link RuntimeVariable} to support possible
\r
24 * changes in the data contained by {@link IResourceEditorInput2}.
\r
26 * Returns <code>null</code> if it cannot find:
\r
28 * <li>model resource by its URI</li>
\r
29 * <li>active realization of the model or base realization as a fallback</li>
\r
32 * @author Tuukka Lehtonen
\r
33 * @see RuntimeVariable
\r
35 class RuntimeVariableForInput extends UnaryRead<IResourceEditorInput2, RuntimeDiagramDesc> {
\r
37 public RuntimeVariableForInput(IResourceEditorInput2 input) {
\r
42 public RuntimeDiagramDesc perform(ReadGraph graph) throws DatabaseException {
\r
43 Resource model = parameter.getModel(graph);
\r
44 String rvis = parameter.getRVI();
\r
45 RVI rvi = rvis == null ? null : RVI.fromResourceFormat(graph, rvis);
\r
46 return graph.syncRequest(new RuntimeVariable(
\r
49 parameter.getResource()));
\r