import org.simantics.browsing.ui.content.Labeler.Modifier;\r
import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.CancelTransactionException;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.ui.ExceptionUtils;\r
\r
public class ModelNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
\r
+ Listener<String> configurationNameSynchronizer;\r
+ private boolean disposed = false;\r
\r
public ModelNode(Resource resource) {\r
super(resource);\r
+ \r
+ // Not the best solution for name sync\r
+ configurationNameSynchronizer = new Listener<String>() {\r
+\r
+ @Override\r
+ public void execute(final String result) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ SimulationResource sim = SimulationResource.getInstance(graph);\r
+ Resource configuration = graph.getPossibleObject(data, sim.HasConfiguration);\r
+ graph.claimValue(configuration, b.HasLabel, result);\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+ };\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ return graph.getRelatedValue(data, b.HasLabel);\r
+ }\r
+ \r
+ }, configurationNameSynchronizer);\r
}\r
\r
@Override\r
\r
@Override\r
public void delete() throws DeleteException {\r
+ disposed = true;\r
try {\r
SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
@Override\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.procedure.Listener;\r
import org.simantics.db.request.Read;\r
import org.simantics.modeling.ModelingResources;\r
import org.simantics.simulation.ontology.SimulationResource;\r
\r
public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
\r
+ \r
+ Listener<String> configurationNameSynchronizer;\r
+ private boolean disposed = false;\r
+ \r
public ModuleTypeNode(Resource resource) {\r
super(resource);\r
+ \r
+ // Not the best solution for name sync\r
+ configurationNameSynchronizer = new Listener<String>() {\r
+\r
+ @Override\r
+ public void execute(final String result) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+ Resource configuration = graph.getPossibleObject(type, sr2.IsDefinedBy);\r
+ graph.claimValue(configuration, b.HasLabel, result);\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+ };\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+ return graph.getRelatedValue(type, b.HasName);\r
+ }\r
+ \r
+ }, configurationNameSynchronizer);\r
+ \r
}\r
\r
@Override\r
\r
@Override\r
public void delete() throws DeleteException {\r
+ disposed = true;\r
try {\r
SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
\r
Resource conf = GraphUtils.create2(g,\r
sr.Configuration,\r
b.PartOf, model,\r
- b.HasName, modelName+"Configuration"\r
+ b.HasName, modelName\r
);\r
\r
g.claim(conf, mr.CompositeToDiagram, diagram);\r
\r
Resource moduleSymbol = g.newResource();\r
g.claimValue(moduleSymbol, mu.b.HasName, name + " Symbol");\r
- g.claimValue(moduleSymbol, mu.b.HasLabel, name + " SymbolLabel");\r
+ g.claimValue(moduleSymbol, mu.b.HasLabel, name);\r
g.claim(moduleSymbol, mu.b.Inherits, sr.ModuleSymbol);\r
g.claim(moduleSymbol, mu.mr.SymbolToComponentType, moduleType);\r
\r
label.setText("Name");\r
\r
TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
- name.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
- name.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName));\r
+ name.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasLabel));\r
+ name.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasLabel));\r
name.setInputValidator(new IInputValidator() {\r
\r
@Override\r
r,\r
"Input"));\r
}\r
- if (backend.isInstanceOf(r, sr.Configuration) || (backend.isInstanceOf(r, sr.SysdynModel))) {\r
+ Resource represents = backend.getPossibleObject(r, b.Represents);\r
+ if ((represents != null && backend.isInstanceOf(represents, sr.Configuration)) || (backend.isInstanceOf(r, sr.SysdynModel))) {\r
Resource model;\r
- if (backend.isInstanceOf(r, sr.Configuration))\r
- model = backend.getPossibleObject(r, SimulationResource.getInstance(backend).IsConfigurationOf);\r
+ if (represents != null)\r
+ model = backend.getPossibleObject(represents, SimulationResource.getInstance(backend).IsConfigurationOf);\r
else\r
model = r;\r
if (model != null)\r
item = new TableItem(functionTable, SWT.NONE);\r
item.setText("interpolate()");\r
item.setData("interpolate( x, table)"); \r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("delay()");\r
+ item.setData("delay( expression, delayTime)"); \r
functions.setControl(functionTable);\r
}\r
\r