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