import org.simantics.sysdyn.ui.elements.AuxiliaryFactory;\r
import org.simantics.sysdyn.ui.elements.CloudFactory;\r
import org.simantics.sysdyn.ui.elements.InputFactory;\r
+import org.simantics.sysdyn.ui.elements.ShadowFactory;\r
import org.simantics.sysdyn.ui.elements.StockFactory;\r
import org.simantics.sysdyn.ui.elements.ValveFactory;\r
import org.simantics.ui.SimanticsUI;\r
SysdynResource.URIs.InputSymbol,\r
(ShapeNode)InputFactory.INPUT_IMAGE.init(parent)\r
);\r
- }\r
+ } else if (kpe.keyCode == java.awt.event.KeyEvent.VK_G) {\r
+ variableInformation = new VariableInformation(\r
+ java.awt.event.KeyEvent.VK_G,\r
+ SysdynResource.URIs.ShadowSymbol,\r
+ (ShapeNode)ShadowFactory.GHOST_IMAGE.init(parent)\r
+ );\r
+ }\r
\r
if (variableInformation != null) {\r
updateSG();\r
return StatementEvaluation.INCLUDE;\r
else\r
return StatementEvaluation.INCLUDE_AND_FOLLOW;\r
- }\r
+ } else if(statement.getPredicate().equals(SYSDYN.Shadow_original))\r
+ return StatementEvaluation.INCLUDE;\r
} catch (ServiceException e) {\r
e.printStackTrace();\r
}\r
Resource start = soa.adapt(Resource.class);\r
if(g.isInheritedFrom(start, sr.ModuleSymbol) && !end.equals(sr.InputSymbol)) return null;\r
if(end.equals(sr.StockSymbol)) return null;\r
+ if(end.equals(sr.ShadowSymbol)) return null;\r
} else if (currentConnection.equals(flow)) {\r
if(!(end.equals(sr.StockSymbol) || end.equals(sr.ValveSymbol) || end.equals(sr.CloudSymbol))) return null;\r
} else {\r
if(graph.getPossibleObject(dependency, sr.Dependency_refersTo) == null ||\r
graph.getPossibleObject(dependency, sr.Dependency_refersTo).equals(inputVariable)) {\r
Resource output = graph.getSingleObject(dependency, sr.Variable_HasTail);\r
- result.put((String)graph.getRelatedValue(output, l0.HasName), dependency);\r
+ \r
+ if(graph.isInstanceOf(output, sr.Shadow)) {\r
+ output = graph.getPossibleObject(output, sr.Shadow_original);\r
+ }\r
+ \r
+ if(output != null)\r
+ result.put((String)graph.getRelatedValue(output, l0.HasName), dependency);\r
}\r
}\r
return result;\r
Resource valueResource = graph.getPossibleObject(dependency, sr.Variable_HasTail);\r
if(!graph.isInstanceOf(valueResource, sr.Variable))\r
valueResource = graph.getPossibleObject(dependency, sr.Variable_HasHead);\r
- if(!graph.isInstanceOf(valueResource, sr.Variable))\r
+ \r
+ if(graph.isInstanceOf(valueResource, sr.Shadow))\r
+ valueResource = graph.getPossibleObject(valueResource, sr.Shadow_original);\r
+ \r
+ if(valueResource == null || !graph.isInstanceOf(valueResource, sr.Variable))\r
return "";\r
+ \r
return (String)graph.getRelatedValue(valueResource, l0.HasName, Bindings.STRING);\r
}\r
});\r
Resource reference = graph.getPossibleObject(outputRelation, SR.Dependency_refersTo);\r
if(reference != null) {\r
Resource output = graph.getPossibleObject(outputRelation, SR.Variable_HasHead);\r
+ if(output == null)\r
+ continue;\r
String left = graph.getPossibleRelatedValue(output, SR.Variable_unit);\r
String right = graph.getPossibleRelatedValue(reference, SR.Variable_unit);\r
result = UnitUtils.matchUnits(left, right);\r
Resource reference = graph.getPossibleObject(inputRelation, SR.Dependency_refersTo);\r
if(reference != null) {\r
Resource variable = graph.getPossibleObject(inputRelation, SR.Variable_HasTail);\r
+ if(variable == null)\r
+ continue;\r
String left = graph.getPossibleRelatedValue(variable, SR.Variable_unit);\r
String right = graph.getPossibleRelatedValue(reference, SR.Variable_unit);\r
result = UnitUtils.matchUnits(left, right);\r
DiagramResource dr = DiagramResource.getInstance(g);\r
if(runtime == null) return null;\r
Resource resource = ModelingUtils.getPossibleElementCorrespondendence(g, element);\r
+ if(resource != null && g.isInstanceOf(resource, sr.Shadow)) resource = g.getPossibleObject(resource, sr.Shadow_original);\r
if(resource == null || !g.isInstanceOf(resource, sr.Variable)) return null;\r
String variableURI = g.getPossibleRelatedValue(runtime, dr.RuntimeDiagram_HasVariable);\r
if(variableURI != null) {\r
if(dependency.getHead().equals(this)){\r
Input reference = (Input)dependency.refersTo();\r
Variable outputVariable = (Variable)dependency.getTail();\r
+ if(outputVariable instanceof Shadow)\r
+ outputVariable = ((Shadow) outputVariable).getOriginal();\r
+ \r
String name = outputVariable.getName();\r
\r
Module module = (Module)dependency.getHead();\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * 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\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.representation.expressions.IExpression;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType(SysdynResource.URIs.Shadow)\r
+public class Shadow extends Variable {\r
+\r
+ @RelatedElement(SysdynResource.URIs.Shadow_original)\r
+ private Variable original;\r
+\r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ if(getOriginal() != null)\r
+ original.accept(v);\r
+ }\r
+\r
+ public Variable getOriginal() {\r
+ return original;\r
+ }\r
+\r
+ @Override\r
+ public String getName() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getName();\r
+ else\r
+ return super.getName();\r
+ }\r
+\r
+ @Override\r
+ public ArrayList<Enumeration> getArrayIndexes() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getArrayIndexes();\r
+ else\r
+ return super.getArrayIndexes();\r
+ }\r
+\r
+ @Override\r
+ public ArrayList<IExpression> getExpressions() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getExpressions();\r
+ else\r
+ return super.getExpressions();\r
+ }\r
+\r
+ @Override\r
+ public String getVariability() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getVariability();\r
+ else\r
+ return super.getVariability();\r
+ }\r
+\r
+ @Override\r
+ public String getType() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getType();\r
+ else\r
+ return super.getType();\r
+ }\r
+\r
+ @Override\r
+ public String getUnit() {\r
+ if(getOriginal() != null)\r
+ return getOriginal().getUnit();\r
+ else\r
+ return super.getUnit();\r
+ }\r
+\r
+}\r
+\r
addLinkType(MappingSchemas.fromAnnotations(g, Function.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, Entity.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, ParameterOverride.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Shadow.class));\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
} catch (InstantiationException e) {\r
package org.simantics.sysdyn.representation.visitors;\r
\r
import org.simantics.sysdyn.representation.Auxiliary;\r
+import org.simantics.sysdyn.representation.Book;\r
import org.simantics.sysdyn.representation.Cloud;\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.Dependency;\r
import org.simantics.sysdyn.representation.Input;\r
import org.simantics.sysdyn.representation.LibraryDummy;\r
import org.simantics.sysdyn.representation.Module;\r
-import org.simantics.sysdyn.representation.Book;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Valve;\r
+import org.simantics.sysdyn.representation.Variable;\r
\r
public class ElementVisitorVoidAdapter implements IElementVisitorVoid {\r
\r
@Override\r
public void visit(DiagramContainerDummy container) {\r
}\r
+ \r
+ @Override\r
+ public void visit(Variable variable) {\r
+ }\r
}\r
package org.simantics.sysdyn.representation.visitors;\r
\r
import org.simantics.sysdyn.representation.Auxiliary;\r
+import org.simantics.sysdyn.representation.Book;\r
import org.simantics.sysdyn.representation.Cloud;\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.Dependency;\r
import org.simantics.sysdyn.representation.Input;\r
import org.simantics.sysdyn.representation.LibraryDummy;\r
import org.simantics.sysdyn.representation.Module;\r
-import org.simantics.sysdyn.representation.Book;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Valve;\r
+import org.simantics.sysdyn.representation.Variable;\r
\r
public interface IElementVisitorVoid {\r
\r
void visit(LibraryDummy libraryDummy);\r
void visit(Book sheet);\r
void visit(DiagramContainerDummy container);\r
+ void visit(Variable variable);\r
}\r