--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy - initial API and implementation for issue #4384\r
+ *******************************************************************************/\r
+package org.simantics.diagram.runtime;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.UnaryRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.RVI;\r
+import org.simantics.ui.workbench.IResourceEditorInput2;\r
+\r
+/**\r
+ * Extract a triple <Model URI, Variable URI, RVI> from the input argument. This\r
+ * request is needed in addition to {@link RuntimeVariable} to support possible\r
+ * changes in the data contained by {@link IResourceEditorInput2}.\r
+ * \r
+ * Returns <code>null</code> if it cannot find:\r
+ * <ol>\r
+ * <li>model resource by its URI</li>\r
+ * <li>active realization of the model or base realization as a fallback</li>\r
+ * </ol>\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ * @see RuntimeVariable\r
+ */\r
+class RuntimeVariableForInput extends UnaryRead<IResourceEditorInput2, RuntimeDiagramDesc> {\r
+\r
+ public RuntimeVariableForInput(IResourceEditorInput2 input) {\r
+ super(input);\r
+ }\r
+\r
+ @Override\r
+ public RuntimeDiagramDesc perform(ReadGraph graph) throws DatabaseException {\r
+ Resource model = parameter.getModel(graph);\r
+ String rvis = parameter.getRVI();\r
+ RVI rvi = rvis == null ? null : RVI.fromResourceFormat(graph, rvis);\r
+ return graph.syncRequest(new RuntimeVariable(\r
+ model,\r
+ rvi,\r
+ parameter.getResource()));\r
+ }\r
+\r
+}
\ No newline at end of file