]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16847 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Jul 2010 14:34:23 +0000 (14:34 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Jul 2010 14:34:23 +0000 (14:34 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleTypeLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleOutputTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java

index 379e3a56d1d731c37e18c4a9cf659e9e23ea2403..2161aaee512f41c2f8fea454ca5ea1e09133e0c6 100644 (file)
@@ -20,8 +20,7 @@ public class ConfigurationLabeler extends LabelerContributor<ConfigurationNode>{
 \r
     @Override\r
     public String getLabel(ReadGraph graph, ConfigurationNode conf) throws DatabaseException {\r
-        String name = graph.getPossibleRelatedValue(conf.resource, graph.getBuiltins().HasLabel);\r
-        return name == null ? "Project (no name)" : name;\r
+        return "Configuration";\r
     }\r
 \r
 }\r
index fd43e11f999e0ce267da53a859f29751cae2bbc6..7eea1213598af895f9c18c0c50ac186e84929c8a 100644 (file)
@@ -36,7 +36,6 @@ public abstract class LibraryViewpointContributor<T extends AbstractNode> extend
         ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
         for (Resource r : graph.syncRequest(getChildRequest(graph, lib))) {\r
             try {\r
-                System.out.println("Is Flow? " + graph.isInstanceOf(r, SysdynResource.getInstance(graph).Flow));\r
                 AbstractNode n = graph.adapt(r, AbstractNode.class);\r
                 result.add(n);\r
             } catch (DatabaseException e) {\r
index 54011f7db8bcaaa47531550d165f3109886352f3..59945da359400cc6f5e2cc53256e9875b91ee345 100644 (file)
@@ -22,7 +22,8 @@ public class Module  extends ViewpointContributor<ModuleNode> {
         Builtins b = graph.getBuiltins();\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
         StructuralResource2 str = StructuralResource2.getInstance(graph);\r
-        Resource instance = graph.getSingleObject(module.resource, b.InstanceOf);\r
+        Resource instance = graph.getPossibleObject(module.resource, b.InstanceOf);\r
+        if(instance == null) return result;\r
         Resource conf = graph.getSingleObject(instance, str.IsDefinedBy);\r
         for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.IndependentVariable))) {\r
             try {\r
index 00bc9fb5edc5357eaf2d7e4eecb2b95f72dcad46..5e79acd95a586caf271891465490b815a7ca152d 100644 (file)
@@ -4,13 +4,10 @@ import java.util.ArrayList;
 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.exception.DatabaseException;\r
 import org.simantics.modeling.ModelingResources;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
-import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
 \r
@@ -19,9 +16,6 @@ public class ModuleType  extends ViewpointContributor<ModuleTypeNode> {
     @Override\r
     public Collection<?> getContribution(ReadGraph graph, ModuleTypeNode module) throws DatabaseException {\r
         ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
-        Builtins b = graph.getBuiltins();\r
-        SysdynResource sr = SysdynResource.getInstance(graph);\r
-        StructuralResource2 str = StructuralResource2.getInstance(graph);\r
         ModelingResources mr = ModelingResources.getInstance(graph);\r
         Resource symbol = graph.getPossibleObject(module.resource, mr.ComponentTypeToSymbol);\r
         result.add(graph.adapt(symbol, AbstractNode.class));\r
index cefdd32b37f45f951895d9614ba318c335d9c778..4390dcdf670a3540bac489d8f857f520a760b082 100644 (file)
@@ -10,7 +10,7 @@ public class ModuleTypeLabeler extends LabelerContributor<ModuleTypeNode>{
     @Override\r
     public String getLabel(ReadGraph graph, ModuleTypeNode moduleType) throws DatabaseException {\r
         String label = graph.getPossibleRelatedValue(moduleType.resource, graph.getBuiltins().HasLabel);\r
-        return label == null ? "Model (no name)" : label;\r
+        return label == null ? "ModuleType (no name)" : label;\r
     }\r
 \r
 }\r
index 3db2b187bb3a2e17267677d9b76484149c6e5b10..5d6d72b7a5d9a8880accc9ed2d2d632617fd2d7e 100644 (file)
@@ -40,8 +40,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
                 ModelingUtils mu = new ModelingUtils(g);\r
                 \r
                 Resource moduleType = g.newResource();\r
-                g.claimValue(moduleType, mu.b.HasName, "ModuleType");\r
-                g.claimValue(moduleType, mu.b.HasLabel, "ModuleTypeLabel");\r
+                g.claimValue(moduleType, mu.b.HasLabel, "New Module Type");\r
                 g.claim(moduleType, mu.b.Inherits, sr.Module);\r
                 g.claim(moduleType, mu.b.PartOf, model);\r
                 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java
new file mode 100644 (file)
index 0000000..30eebee
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class DependencyTab  extends PropertyTabContributorImpl {\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+        Composite composite = new Composite(body, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(composite);\r
+        TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+        nameText.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
+        nameText.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+    }\r
+\r
+\r
+}\r
index 08a6c6129139a0706ee22a425e12c188ef1a0ceb..f8fccc79406939deca37c07ea3004c557756e0e2 100644 (file)
@@ -54,7 +54,8 @@ public class ModuleInputTab  extends PropertyTabContributorImpl {
                 SysdynResource sr = SysdynResource.getInstance(graph);\r
                 StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
                 ArrayList<ReferenceRow> result = new ArrayList<ReferenceRow>();\r
-                Resource instanceOf = graph.getSingleObject(module, b.InstanceOf);\r
+                Resource instanceOf = graph.getPossibleObject(module, b.InstanceOf);\r
+                if(instanceOf == null) return result;\r
                 Resource configuration = graph.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
                 for(Resource input : graph.syncRequest(new ObjectsWithType(configuration, b.ConsistsOf, sr.Input))) {\r
                     Resource dependency = null;\r
index 0cd2b29c55340809fe627afe734e4b2f59bec344..a12623a4f08f33cb0386968853f3fb4e1ac87f74 100644 (file)
@@ -54,7 +54,8 @@ public class ModuleOutputTab   extends PropertyTabContributorImpl {
                 SysdynResource sr = SysdynResource.getInstance(graph);\r
                 StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
                 ArrayList<ReferenceRow> result = new ArrayList<ReferenceRow>();\r
-                Resource instanceOf = graph.getSingleObject(module, b.InstanceOf);\r
+                Resource instanceOf = graph.getPossibleObject(module, b.InstanceOf);\r
+                if(instanceOf == null) return result;\r
                 Resource configuration = graph.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
                 for(Resource variable : graph.syncRequest(new ObjectsWithType(configuration, b.ConsistsOf, sr.Variable))) {\r
                     if(!graph.hasStatement(variable, sr.IsOutput)) continue;\r
index ff30ee0dd2668a08d533ed36575c3869ebe0a9a5..1ecd329c981a136bbf28ec69b86b3f826a80fd19 100644 (file)
@@ -121,6 +121,13 @@ public class ResourceSelectionProcessor implements SelectionProcessor<ISelection
                                     0,\r
                                     r,\r
                             "Reference Properties"));\r
+                else\r
+                    return Collections.singleton(\r
+                            new ComparableTabContributor(\r
+                                    new DependencyTab(),\r
+                                    0,\r
+                                    r,\r
+                            "Dependency Properties"));\r
         } catch (ServiceException e) {\r
             e.printStackTrace();\r
         } catch (ManyObjectsForFunctionalRelationException e) {\r