<resource\r
uri="http://www.simantics.org/Sysdyn-1.0/SysdynProject"\r
class="org.simantics.sysdyn.ui.project.SysdynProject" />\r
- </target>\r
+ </target>\r \r
<target\r
interface="org.simantics.scenegraph.adapters.ISceneGraphProvider">\r
<type\r
<graph />\r
<this />\r
</type>\r
- </target>\r
+ </target>\r \r <target\r interface="org.simantics.sysdyn.ui.browser.nodes.AbstractNode">\r <type\r uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/Variable"\r class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r <this />\r </type>\r </target>\r \r
</adapters>
\ No newline at end of file
<visibleWhen checkEnabled="true">\r
</visibleWhen>\r
</command>\r
+ <menu\r
+ label="New">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newModel"\r
+ id="org.simantics.sysdyn.ui.browser.newModel"\r
+ label="Model"\r
+ style="push">\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newModuleNode"\r
+ id="org.simantics.sysdyn.ui.browser.newModule"\r
+ label="Module"\r
+ style="push">\r
+ </command>\r
+ </menu>\r
</menuContribution>\r
<menuContribution\r
locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
id="org.simantics.sysdyn.ui.simulate.state">\r
</state>\r
</command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.newModuleNode"\r
+ name="New Module">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.newModel"\r
+ name="New Model">\r
+ </command>\r
</extension>\r
<extension\r
point="org.eclipse.ui.handlers">\r
</with>\r
</activeWhen>\r
</handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.NewModuleNodeHandler"\r
+ commandId="org.simantics.sysdyn.ui.newModuleNode">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.NewModelHandler"\r
+ commandId="org.simantics.sysdyn.ui.newModel">\r
+ </handler>\r
</extension>\r
<extension\r
point="org.eclipse.ui.cheatsheets.cheatSheetContent">\r
Simple System Dynamics Tutorials\r
</description>\r
</cheatsheet>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.viewpointContributionBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Variable"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Experiments"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Model"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.OperatingInterfaces"\r
+ preference="1.0">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.labelerBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ConfigurationLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.VariableLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ExperimentsLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModelLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModulesLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.OperatingInterfacesLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ </binding>\r
</extension>
</plugin>\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.browser;\r
\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.common.EvaluatorData;\r
-import org.simantics.browsing.ui.common.EvaluatorDataImpl;\r
-import org.simantics.browsing.ui.common.EvaluatorImpl;\r
-import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.content.Labeler;\r
-import org.simantics.browsing.ui.content.LabelerFactory;\r
-import org.simantics.browsing.ui.graph.impl.GraphViewpointFactory;\r
-import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
-import org.simantics.browsing.ui.graph.impl.LazyGraphLabeler;\r
+import java.util.Set;\r
import org.simantics.browsing.ui.swt.ContextMenuInitializer;\r
import org.simantics.browsing.ui.swt.GraphExplorerView;\r
import org.simantics.browsing.ui.swt.IContextMenuInitializer;\r
-import org.simantics.db.Builtins;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.datastructures.hints.HintContext;\r
\r
\r
public class SysdynBrowser extends GraphExplorerView {\r
-\r
+ \r
+ private static final Set<String> browseContexts = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser");\r
+ \r
@Override\r
protected IContextMenuInitializer getContextMenuInitializer() {\r
return new ContextMenuInitializer("#SysdynBrowserPopup");\r
}\r
-\r
+ \r
@Override\r
- protected EvaluatorData createEvaluatorData(Session session) {\r
- HintContext factoryHints = new HintContext();\r
- //if (sessionContext != null)\r
- //factoryHints.setHint(IGraphExplorerHints.KEY_SESSION_CONTEXT, sessionContext);\r
-\r
- EvaluatorData data = new EvaluatorDataImpl();\r
- data.addEvaluator(Resource.class, createResourceEvaluator(session, factoryHints));\r
- return data;\r
+ protected Set<String> getBrowseContexts() {\r
+ return browseContexts;\r
}\r
-\r
- private Evaluator createResourceEvaluator(Session session, HintContext factoryHints) {\r
- Evaluator evaluator = new EvaluatorImpl();\r
- evaluator.addViewpoint(new GraphViewpointFactory() {\r
- @Override\r
- protected Collection<?> getChildren(ReadGraph g, Resource r)\r
- throws DatabaseException {\r
- Builtins b = g.getBuiltins();\r
- SysdynResource sr = SysdynResource.getInstance(g);\r
- ArrayList<Resource> result = new ArrayList<Resource>();\r
- for(Resource c : g.getObjects(r, b.ConsistsOf)) {\r
- if( g.isInstanceOf(c, sr.Configuration)\r
- || (g.isInstanceOf(c, sr.Variable) &&\r
- !g.isInstanceOf(c, sr.Cloud)\r
- )\r
- )\r
- result.add(c);\r
- }\r
- return result;\r
- }\r
- }, 1.0);\r
- evaluator.addLabeler(new LabelerFactory() {\r
- @Override\r
- public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) {\r
- return new LazyGraphLabeler(updater, context, key) {\r
-\r
- Resource nameResource;\r
-\r
- @Override\r
- public Map<String, String> labels(ReadGraph g)\r
- throws DatabaseException {\r
- Builtins b = g.getBuiltins();\r
- nameResource = b.HasName;\r
- Resource el = (Resource) context.getConstant(BuiltinKeys.INPUT);\r
- StringBuilder sb = new StringBuilder();\r
- for(Resource r : g.getObjects(el, b.HasName))\r
- sb.append(g.getValue(r));\r
- sb.append(" : ");\r
- for(Resource t : g.getObjects(el, b.InstanceOf))\r
- for(Resource r : g.getObjects(t, b.HasName))\r
- sb.append(g.getValue(r));\r
- return Collections.singletonMap(ColumnKeys.SINGLE, sb.toString());\r
- }\r
-\r
- @Override\r
- public Modifier getModifier(String key) {\r
- LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), (Resource) context.getConstant(BuiltinKeys.INPUT), nameResource) {\r
- @Override\r
- public String isValid(String label) {\r
- if (label.isEmpty())\r
- return "Empty label not allowed";\r
- if (label.contains(" "))\r
- return "Spaces are not allowed";\r
- return null;\r
- }\r
- };\r
- return modifier;\r
- }\r
- };\r
- }\r
-\r
- }, 1.0);\r
- /*evaluator.addImager(new ImagerFactory() {\r
- @Override\r
- public Imager create(PrimitiveQueryUpdater updater, INodeContext context) {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
- });*/\r
- return evaluator;\r
- }\r
-\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.ui.icons.ImageDescriptorProvider;\r
+\r
+public class AbstractNodeImager extends ImagerContributor<AbstractNode> {\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode node) throws DatabaseException {\r
+ if (!graph.hasStatement(node.resource))\r
+ return null;\r
+ ImageDescriptorProvider provider = graph.adapt(node.resource, ImageDescriptorProvider.class);\r
+ return provider != null ? provider.get() : null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+\r
+public class AbstractNodeLabeler extends LabelerContributor<AbstractNode> {\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, AbstractNode node) throws DatabaseException {\r
+ if (!graph.hasStatement(node.resource))\r
+ return "";\r
+ return graph.adapt(node.resource, String.class);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class Configuration extends ViewpointContributor<ModelNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModelNode model)\r
+ throws DatabaseException {\r
+ return new DataContainer<AbstractNode>(new ConfigurationNode(\r
+ graph.getSingleObject(\r
+ model.resource, \r
+ graph.getBuiltins().HasConfiguration))\r
+ );\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class ConfigurationLabeler extends LabelerContributor<ConfigurationNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ConfigurationNode conf) throws DatabaseException {\r
+ String name = graph.getPossibleRelatedValue(conf.resource, graph.getBuiltins().HasName);\r
+ return name == null ? "Project (no name)" : name;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+\r
+public class Experiment extends ViewpointContributor<ExperimentsFolder> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ExperimentsFolder input) throws DatabaseException {\r
+ // hasExperiment or something\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+\r
+public class ExperimentLabeler extends LabelerContributor<ExperimentNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ExperimentNode input) throws DatabaseException {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class Experiments extends ViewpointContributor<ModelNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+ return new DataContainer<AbstractNode>(new ExperimentsFolder(model.resource));\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+\r
+public class ExperimentsLabeler extends LabelerContributor<ExperimentsFolder> {\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ExperimentsFolder experiments) throws DatabaseException {\r
+ return "Experiments";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ *\r
+ * @param <T> input library node type\r
+ */\r
+public abstract class LibraryViewpointContributor<T extends AbstractNode> extends ViewpointContributor<T> {\r
+\r
+ protected abstract Read<Collection<Resource>> getChildRequest(ReadGraph graph, T lib) throws DatabaseException;\r
+\r
+ @Override\r
+ public final Collection<?> getContribution(ReadGraph graph, T lib) throws DatabaseException {\r
+ ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+ for (Resource r : graph.syncRequest(getChildRequest(graph, lib))) {\r
+ try {\r
+ AbstractNode n = graph.adapt(r, AbstractNode.class);\r
+ result.add(n);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class Model extends ViewpointContributor<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource project)\r
+ throws DatabaseException {\r
+\r
+ ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+ Builtins b = graph.getBuiltins();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(project, b.ConsistsOf, sr.SysdynModel))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ result.add(new ModulesNode(project));\r
+ return result;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+ \r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+\r
+public class ModelLabeler extends LabelerContributor<ModelNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+ String name = graph.getPossibleRelatedValue(model.resource, graph.getBuiltins().HasName);\r
+ return name == null ? "Model (no name)" : name;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class ModulesLabeler extends LabelerContributor<ModulesNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModulesNode input) throws DatabaseException {\r
+ return "Modules";\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class OperatingInterfaces extends ViewpointContributor<ModelNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+ return new DataContainer<AbstractNode>(new OperatingInterfacesFolder(model.resource));\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder;\r
+\r
+public class OperatingInterfacesLabeler extends LabelerContributor<OperatingInterfacesFolder> {\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, OperatingInterfacesFolder input) throws DatabaseException {\r
+ return "Operating interfaces";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class Variable extends ViewpointContributor<ConfigurationNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
+ ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+ Builtins b = graph.getBuiltins();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class VariableLabeler extends LabelerContributor<VariableNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, VariableNode var) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ Resource varres = var.resource;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(Resource r : graph.getObjects(varres, b.HasName))\r
+ sb.append(graph.getValue(r));\r
+ sb.append(" : ");\r
+ for(Resource t : graph.getObjects(varres, b.InstanceOf))\r
+ for(Resource r : graph.getObjects(t, b.HasName))\r
+ sb.append(graph.getValue(r));\r
+ return sb.toString();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.simantics.db.Resource;\r
+\r
+public abstract class AbstractNode implements IAdaptable {\r
+ public final Resource resource;\r
+\r
+ public AbstractNode(Resource resource) {\r
+ assert(resource != null);\r
+ this.resource = resource;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return resource.hashCode() + getClass().hashCode();\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ AbstractNode other = (AbstractNode) obj;\r
+ return resource.equals(other.resource);\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if(adapter.equals(Resource.class))\r
+ return resource;\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ConfigurationNode extends AbstractNode implements IDeletable, IModifiableNode {\r
+\r
+ public ConfigurationNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), resource) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class ExperimentNode extends AbstractNode {\r
+\r
+ public ExperimentNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class ExperimentsFolder extends AbstractNode {\r
+\r
+ public ExperimentsFolder(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ModelNode extends AbstractNode implements IDeletable, IModifiableNode {\r
+\r
+ public ModelNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), resource) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class ModulesNode extends AbstractNode {\r
+ \r
+ public ModulesNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class OperatingInterfacesFolder extends AbstractNode {\r
+\r
+ public OperatingInterfacesFolder(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 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
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class VariableNode extends AbstractNode {\r
+\r
+ public VariableNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException; \r
+import org.simantics.db.Builtins;\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.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class NewModelHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ // Same as in SysdynProject.java. Should use the same code, not copy.\r
+ Builtins b = graph.getBuiltins();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource model = graph.newResource();\r
+ graph.claimValue(model, b.HasName, "Model1");\r
+ graph.claim(model, b.InstanceOf, sr.SysdynModel);\r
+ graph.claim(model, b.PartOf, SimanticsUI.getProject().get());\r
+ \r
+ Resource conf = graph.newResource();\r
+ graph.claimValue(conf, b.HasName, "Configuration");\r
+ graph.claim(conf, b.InstanceOf, sr.Configuration);\r
+ graph.claim(model, b.HasConfiguration, conf);\r
+ graph.claimValue(conf, sr.HasStartTime, 0.0);\r
+ graph.claimValue(conf, sr.HasStopTime, 10.0);\r
+ }\r
+ });\r
+ return null;\r
+ }\r
+\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+\r
+public class NewModuleNodeHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ System.out.println("New module!");\r
+ return null;\r
+ }\r
+\r
+\r
+}\r
Builtins b = g.getBuiltins();\r
SysdynResource sr = SysdynResource.getInstance(g);\r
Resource model = g.newResource();\r
- g.claimValue(model, b.HasName, "Configuration");\r
- g.claim(model, b.InstanceOf, null, sr.Configuration);\r
+ g.claimValue(model, b.HasName, "Model1");\r
+ g.claim(model, b.InstanceOf, sr.SysdynModel);\r
g.claim(model, b.PartOf, library);\r
- g.claimValue(model, sr.HasStartTime, 0.0);\r
- g.claimValue(model, sr.HasStopTime, 10.0);\r
+ \r
+ Resource conf = g.newResource();\r
+ g.claimValue(conf, b.HasName, "Configuration");\r
+ g.claim(conf, b.InstanceOf, sr.Configuration);\r
+ g.claim(model, b.HasConfiguration, conf);\r
+ g.claimValue(conf, sr.HasStartTime, 0.0);\r
+ g.claimValue(conf, sr.HasStopTime, 10.0);\r
\r
} catch(Exception e) {\r
errorCallback.run(e);\r
public final Resource RefersTo;\r
public final Resource Stock;\r
public final Resource StockExpression;\r
+ public final Resource SysdynModel;\r
public final Resource SysdynProject;\r
public final Resource Terminal;\r
public final Resource Valve;\r
public static final String RefersTo = "http://www.simantics.org/Sysdyn-1.0/RefersTo";\r
public static final String Stock = "http://www.simantics.org/Sysdyn-1.0/Stock";\r
public static final String StockExpression = "http://www.simantics.org/Sysdyn-1.0/StockExpression";\r
+ public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.0/SysdynModel";\r
public static final String SysdynProject = "http://www.simantics.org/Sysdyn-1.0/SysdynProject";\r
public static final String Terminal = "http://www.simantics.org/Sysdyn-1.0/Terminal";\r
public static final String Valve = "http://www.simantics.org/Sysdyn-1.0/Valve";\r
RefersTo = getResourceOrNull(graph, URIs.RefersTo);\r
Stock = getResourceOrNull(graph, URIs.Stock);\r
StockExpression = getResourceOrNull(graph, URIs.StockExpression);\r
+ SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
SysdynProject = getResourceOrNull(graph, URIs.SysdynProject);\r
Terminal = getResourceOrNull(graph, URIs.Terminal);\r
Valve = getResourceOrNull(graph, URIs.Valve);\r
%import "layer0.graph" L0\r
%import "structural2.graph" ST\r
%import "project.graph" PROJ\r
+%import "simulation.graph" SIMU\r
\r
%deflib L0.Type Sysdyn\r
%deflib L0.Relation Sysdyn\r
L0.HasDescription """System dynamics modelling project. Create system dynamics models and simulate them with OpenModelica.""" : L0.String\r
L0.PartOf Sysdyn\r
L0.PartOf PROJ.PublishedProjectFeatures\r
+ \r
+######################################################################\r
+# Model\r
+###################################################################### \r
\r
-#SysdynTest : PROJ.Project2\r
-# PROJ.HasFeature SysdynProject\r
-# L0.PartOf L0.Projects\r
+SysdynModel <T SIMU.Model\r
+ [SIMU.HasConfiguration all Configuration]\r
\r
######################################################################\r
# Configuration\r
Variable <T ST.Component \r
[HasX card "1"]\r
[HasY card "1"]\r
+ \r
HasX <R L0.HasProperty : L0.FunctionalRelation\r
L0.HasRange L0.Double\r
HasY <R L0.HasProperty : L0.FunctionalRelation\r
- L0.HasRange L0.Double \r
+ L0.HasRange L0.Double\r
HasExpression <R L0.IsRelatedTo : L0.FunctionalRelation\r
L0.HasRange Expression\r
\r
Module <T Variable\r
[HasTerminal]\r
\r
-HasTerminal <R L0.IsRelatedTo\r
- L0.HasRange [Terminal]\r
Terminal <T Variable\r
[RefersTo card "0..1"]\r
-RefersTo <R L0.IsRelatedTo\r
- L0.HasDomain [Terminal]\r
- L0.HasRange [IndependentVariable]\r
+\r
\r
######################################################################\r
-# Connections\r
+# Connections and Relations\r
######################################################################\r
\r
HasAngle <R L0.HasProperty\r
Flow <T ST.Connection\r
[HasHead card "1"]\r
[HasTail card "1"]\r
+ \r
+RefersTo <R L0.IsRelatedTo\r
+ L0.HasDomain [Terminal]\r
+ L0.HasRange [IndependentVariable]\r
+ \r
+HasTerminal <R L0.IsRelatedTo\r
+ L0.HasRange [Terminal]\r
+ \r
\r
######################################################################\r
# Expression\r
\r
WithLookupExpression <T Expression\r
[HasLookup card "1"] \r
- [HasEquation card "1"] \r
-\r
-######################################################################\r
-# Test configuration\r
-######################################################################\r
-\r
-#TestConfiguration @ "TestConfiguration" : Configuration\r
-# L0.PartOf SysdynTest\r
-# HasStartTime "0.0" : L0.Double\r
-# HasStopTime "10.0" : L0.Double\r
+ [HasEquation card "1"]
\ No newline at end of file