]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Drafts for both polarities in dependencies and issue view
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 6 Oct 2011 10:17:56 +0000 (10:17 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 6 Oct 2011 10:17:56 +0000 (10:17 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@22551 ac1ea38d-2e2b-0410-8846-a27921b304fc

21 files changed:
org.simantics.sysdyn.ontology/META-INF/MANIFEST.MF
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/GeneralSymbols.pgraph [new file with mode: 0644]
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/graph/Validation.pgraph [new file with mode: 0644]
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/META-INF/MANIFEST.MF
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyEdgeClass.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ModelUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ActiveIssueSources.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyIssueSource.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyIssues.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencySynchronizer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyValidator.java [new file with mode: 0644]

index d9f12151e4b9bd264c6443046fa3e184dac53a21..08acfa9fd1ab468774527ccc0cb36e117bcb67bb 100644 (file)
@@ -10,7 +10,8 @@ Require-Bundle: org.simantics.layer0,
  org.simantics.g2d.ontology;bundle-version="1.0.0",
  org.simantics.project.ontology;bundle-version="1.0.0",
  org.simantics.viewpoint.ontology;bundle-version="1.0.0",
- org.simantics.layer0x.ontology;bundle-version="1.0.0"
+ org.simantics.layer0x.ontology;bundle-version="1.0.0",
+ org.simantics.issues.ontology;bundle-version="1.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Export-Package: org.simantics.sysdyn
 Bundle-Vendor: VTT Technical Reserarch Centre of Finland
index 601e29b7e019b7ff85e331e1fcf63181541d1abe..bb64744d19f0db3ad0cc8a960dbe9c681887a957 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
diff --git a/org.simantics.sysdyn.ontology/graph/GeneralSymbols.pgraph b/org.simantics.sysdyn.ontology/graph/GeneralSymbols.pgraph
new file mode 100644 (file)
index 0000000..3a55dd7
--- /dev/null
@@ -0,0 +1,14 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+G2D = <http://www.simantics.org/G2D-1.0>\r
+DIA = <http://www.simantics.org/Diagram-2.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+\r
+GENERAL = SYSDYN.SymbolReferences.GeneralSymbols : DIA.SymbolReferenceLibrary\r
+    L0.HasDescription "General graphical components"\r
+\r
+SYSDYN.AdditionalSymbols : L0.Library\r
+\r
+SYSDYN.AdditionalSymbols.Text <T DIA.TextElement\r
+    L0.HasLabel "Text"\r
+    L0.IsDependencyOf GENERAL\r
+    G2D.HasSVGDocument """<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" overflow="visible" version="1.1"><g style="fill:#000000;fill-opacity:1;stroke:none"><path d="m 4.2699962,-2.1489344 -0.4716797,0 C 3.7572928,-2.3129896 3.6832369,-2.5078137 3.5761485,-2.733407 3.4690444,-2.9589851 3.3494156,-3.1720383 3.2172618,-3.3725672 3.0805357,-3.5821941 2.9312845,-3.7656249 2.7695079,-3.9228601 2.6077171,-4.0800777 2.4516301,-4.1700841 2.3012462,-4.1928797 2.1599637,-4.2110997 1.9822295,-4.2247716 1.768043,-4.2338953 1.5538445,-4.2430007 1.3556025,-4.247558 1.1733165,-4.2475672 l -0.3964844,0 0,7.7587891 c -5.05e-6,0.1503919 0.031896,0.2882498 0.0957031,0.4135742 0.0637969,0.1253264 0.17545037,0.2221687 0.33496097,0.2905273 0.082026,0.031902 0.2540632,0.075196 0.5161132,0.1298829 0.2620381,0.054688 0.4659766,0.08431 0.6118165,0.088867 l 0,0.4853516 -4.5800782,0 0,-0.4853516 c 0.127602,-0.00911 0.3224261,-0.027343 0.5844727,-0.054687 0.2620414,-0.027343 0.4431935,-0.061523 0.543457,-0.102539 0.15038733,-0.059244 0.26090154,-0.1446932 0.33154298,-0.2563477 0.0706345,-0.1116526 0.10595343,-0.2609038 0.10595704,-0.4477539 l 0,-7.8203125 -0.39648442,0 c -0.1412791,9.2e-6 -0.3167346,0.00343 -0.5263671,0.010254 -0.2096379,0.00685 -0.4101586,0.021656 -0.6015625,0.044434 -0.1503926,0.018238 -0.3064797,0.1082447 -0.4682618,0.2700196 -0.1617853,0.1617925 -0.3110364,0.3452233 -0.4477539,0.5502929 -0.1367197,0.2050862 -0.2574879,0.4226967 -0.3623047,0.6528321 -0.1048184,0.2301506 -0.177735,0.4204173 -0.21875,0.5708007 l -0.4785156,0 0,-2.6318359 8.4492188,0 z" /></g></svg>""" : L0.String\r
index 84c4f19ce464b238b751ba63ab802d94d363fea0..5be5fa7cc76d3b202cb95d6699c3e7b2f1952fbc 100644 (file)
@@ -65,6 +65,7 @@ SYSDYN.ConfigurationDiagram <T DIA.Diagram
     DIA.HasSymbolContribution _ : DIA.BasicSymbolContribution
         DIA.BasicSymbolContributionHasSymbolLibrary
             BasicSymbols
+            SYSDYN.SymbolReferences.GeneralSymbols
             
 SYSDYN.ConfigurationDiagramTemplate : MOD.DiagramTemplate
     MOD.HasDiagramType SYSDYN.ConfigurationDiagram            
@@ -197,10 +198,9 @@ SYSDYN.Flow <T STR.Connection
     @L0.singleProperty SYSDYN.HasTail
 
 SYSDYN.RefersTo <R L0.IsRelatedTo : L0.FunctionalRelation
-    L0.HasDomain SYSDYN.Variable
+    L0.HasDomain SYSDYN.Dependency
     L0.HasRange SYSDYN.Variable
 
-
 //#####################################################################
 // Expression
 //#####################################################################
@@ -470,6 +470,9 @@ SYSDYN.StockSymbol <T DIA.FontProvider <T DIA.ColorProvider
 
 SYSDYN.angle <R L0.HasProperty : L0.FunctionalRelation
     L0.HasRange L0.Double
+    
+SYSDYN.Polarity <R L0.HasProperty : L0.FunctionalRelation
+    L0.HasRange L0.String
 
 SYSDYN.FlowConnection <T DIA.Connection
     MOD.DiagramConnectionTypeToConnectionType
@@ -477,6 +480,7 @@ SYSDYN.FlowConnection <T DIA.Connection
 
 SYSDYN.DependencyConnection <T DIA.Connection
     @L0.singleProperty SYSDYN.angle
+    @L0.optionalProperty SYSDYN.Polarity
     @L0.assert SYSDYN.angle 0.1
     MOD.DiagramConnectionTypeToConnectionType
         SYSDYN.Dependency
diff --git a/org.simantics.sysdyn.ontology/graph/Validation.pgraph b/org.simantics.sysdyn.ontology/graph/Validation.pgraph
new file mode 100644 (file)
index 0000000..b83275c
--- /dev/null
@@ -0,0 +1,10 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+ISSUE = <http://www.simantics.org/Issue-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+\r
+VALIDATIONS = SYSDYN.Validations : L0.Library\r
+\r
+SYSDYN.SysdynIssue <T ISSUE.TextualIssue\r
+\r
+VALIDATIONS.DependencyConnections : ISSUE.IssueSource\r
+    L0.HasLabel "Find inconsistent equations and dependencies"
\ No newline at end of file
index d9aa04d7494759af0d207e3f292d7e71f5ec2c94..90fd042d2b4ffe0a21c49782af0078732701f591 100644 (file)
@@ -8,6 +8,8 @@ import org.simantics.db.exception.DatabaseException;
 \r
 public class SysdynResource {\r
     \r
+    public final Resource AdditionalSymbols;\r
+    public final Resource AdditionalSymbols_Text;\r
     public final Resource ArrayIndexes;\r
     public final Resource ArrayIndexes_Inverse;\r
     public final Resource Auxiliary;\r
@@ -138,6 +140,8 @@ public class SysdynResource {
     public final Resource ModuleSymbol;\r
     public final Resource NormalExpression;\r
     public final Resource ParameterExpression;\r
+    public final Resource Polarity;\r
+    public final Resource Polarity_Inverse;\r
     public final Resource ProjectActionContext;\r
     public final Resource ProjectActionContext_Actions;\r
     public final Resource ProjectActionContext_Actions_NewEnumeration;\r
@@ -172,14 +176,18 @@ public class SysdynResource {
     public final Resource StockSymbol;\r
     public final Resource SymbolReferences;\r
     public final Resource SymbolReferences_BasicSymbols;\r
+    public final Resource SymbolReferences_GeneralSymbols;\r
     public final Resource Symbols;\r
     public final Resource SysdynConnectionType;\r
     public final Resource SysdynDiagramModelingRules;\r
+    public final Resource SysdynIssue;\r
     public final Resource SysdynModel;\r
     public final Resource SysdynModelicaFunction;\r
     public final Resource SysdynModelicaFunctionLibrary;\r
     public final Resource SysdynModuleLibrary;\r
     public final Resource SysdynTerminal;\r
+    public final Resource Validations;\r
+    public final Resource Validations_DependencyConnections;\r
     public final Resource Valve;\r
     public final Resource ValveSymbol;\r
     public final Resource Variable;\r
@@ -190,6 +198,8 @@ public class SysdynResource {
     public final Resource angle_Inverse;\r
         \r
     public static class URIs {\r
+        public static final String AdditionalSymbols = "http://www.simantics.org/Sysdyn-1.0/AdditionalSymbols";\r
+        public static final String AdditionalSymbols_Text = "http://www.simantics.org/Sysdyn-1.0/AdditionalSymbols/Text";\r
         public static final String ArrayIndexes = "http://www.simantics.org/Sysdyn-1.0/ArrayIndexes";\r
         public static final String ArrayIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.0/ArrayIndexes/Inverse";\r
         public static final String Auxiliary = "http://www.simantics.org/Sysdyn-1.0/Auxiliary";\r
@@ -320,6 +330,8 @@ public class SysdynResource {
         public static final String ModuleSymbol = "http://www.simantics.org/Sysdyn-1.0/ModuleSymbol";\r
         public static final String NormalExpression = "http://www.simantics.org/Sysdyn-1.0/NormalExpression";\r
         public static final String ParameterExpression = "http://www.simantics.org/Sysdyn-1.0/ParameterExpression";\r
+        public static final String Polarity = "http://www.simantics.org/Sysdyn-1.0/Polarity";\r
+        public static final String Polarity_Inverse = "http://www.simantics.org/Sysdyn-1.0/Polarity/Inverse";\r
         public static final String ProjectActionContext = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext";\r
         public static final String ProjectActionContext_Actions = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions";\r
         public static final String ProjectActionContext_Actions_NewEnumeration = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewEnumeration";\r
@@ -354,14 +366,18 @@ public class SysdynResource {
         public static final String StockSymbol = "http://www.simantics.org/Sysdyn-1.0/StockSymbol";\r
         public static final String SymbolReferences = "http://www.simantics.org/Sysdyn-1.0/SymbolReferences";\r
         public static final String SymbolReferences_BasicSymbols = "http://www.simantics.org/Sysdyn-1.0/SymbolReferences/BasicSymbols";\r
+        public static final String SymbolReferences_GeneralSymbols = "http://www.simantics.org/Sysdyn-1.0/SymbolReferences/GeneralSymbols";\r
         public static final String Symbols = "http://www.simantics.org/Sysdyn-1.0/Symbols";\r
         public static final String SysdynConnectionType = "http://www.simantics.org/Sysdyn-1.0/SysdynConnectionType";\r
         public static final String SysdynDiagramModelingRules = "http://www.simantics.org/Sysdyn-1.0/SysdynDiagramModelingRules";\r
+        public static final String SysdynIssue = "http://www.simantics.org/Sysdyn-1.0/SysdynIssue";\r
         public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.0/SysdynModel";\r
         public static final String SysdynModelicaFunction = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunction";\r
         public static final String SysdynModelicaFunctionLibrary = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunctionLibrary";\r
         public static final String SysdynModuleLibrary = "http://www.simantics.org/Sysdyn-1.0/SysdynModuleLibrary";\r
         public static final String SysdynTerminal = "http://www.simantics.org/Sysdyn-1.0/SysdynTerminal";\r
+        public static final String Validations = "http://www.simantics.org/Sysdyn-1.0/Validations";\r
+        public static final String Validations_DependencyConnections = "http://www.simantics.org/Sysdyn-1.0/Validations/DependencyConnections";\r
         public static final String Valve = "http://www.simantics.org/Sysdyn-1.0/Valve";\r
         public static final String ValveSymbol = "http://www.simantics.org/Sysdyn-1.0/ValveSymbol";\r
         public static final String Variable = "http://www.simantics.org/Sysdyn-1.0/Variable";\r
@@ -382,6 +398,8 @@ public class SysdynResource {
     }\r
     \r
     public SysdynResource(ReadGraph graph) {\r
+        AdditionalSymbols = getResourceOrNull(graph, URIs.AdditionalSymbols);\r
+        AdditionalSymbols_Text = getResourceOrNull(graph, URIs.AdditionalSymbols_Text);\r
         ArrayIndexes = getResourceOrNull(graph, URIs.ArrayIndexes);\r
         ArrayIndexes_Inverse = getResourceOrNull(graph, URIs.ArrayIndexes_Inverse);\r
         Auxiliary = getResourceOrNull(graph, URIs.Auxiliary);\r
@@ -512,6 +530,8 @@ public class SysdynResource {
         ModuleSymbol = getResourceOrNull(graph, URIs.ModuleSymbol);\r
         NormalExpression = getResourceOrNull(graph, URIs.NormalExpression);\r
         ParameterExpression = getResourceOrNull(graph, URIs.ParameterExpression);\r
+        Polarity = getResourceOrNull(graph, URIs.Polarity);\r
+        Polarity_Inverse = getResourceOrNull(graph, URIs.Polarity_Inverse);\r
         ProjectActionContext = getResourceOrNull(graph, URIs.ProjectActionContext);\r
         ProjectActionContext_Actions = getResourceOrNull(graph, URIs.ProjectActionContext_Actions);\r
         ProjectActionContext_Actions_NewEnumeration = getResourceOrNull(graph, URIs.ProjectActionContext_Actions_NewEnumeration);\r
@@ -546,14 +566,18 @@ public class SysdynResource {
         StockSymbol = getResourceOrNull(graph, URIs.StockSymbol);\r
         SymbolReferences = getResourceOrNull(graph, URIs.SymbolReferences);\r
         SymbolReferences_BasicSymbols = getResourceOrNull(graph, URIs.SymbolReferences_BasicSymbols);\r
+        SymbolReferences_GeneralSymbols = getResourceOrNull(graph, URIs.SymbolReferences_GeneralSymbols);\r
         Symbols = getResourceOrNull(graph, URIs.Symbols);\r
         SysdynConnectionType = getResourceOrNull(graph, URIs.SysdynConnectionType);\r
         SysdynDiagramModelingRules = getResourceOrNull(graph, URIs.SysdynDiagramModelingRules);\r
+        SysdynIssue = getResourceOrNull(graph, URIs.SysdynIssue);\r
         SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
         SysdynModelicaFunction = getResourceOrNull(graph, URIs.SysdynModelicaFunction);\r
         SysdynModelicaFunctionLibrary = getResourceOrNull(graph, URIs.SysdynModelicaFunctionLibrary);\r
         SysdynModuleLibrary = getResourceOrNull(graph, URIs.SysdynModuleLibrary);\r
         SysdynTerminal = getResourceOrNull(graph, URIs.SysdynTerminal);\r
+        Validations = getResourceOrNull(graph, URIs.Validations);\r
+        Validations_DependencyConnections = getResourceOrNull(graph, URIs.Validations_DependencyConnections);\r
         Valve = getResourceOrNull(graph, URIs.Valve);\r
         ValveSymbol = getResourceOrNull(graph, URIs.ValveSymbol);\r
         Variable = getResourceOrNull(graph, URIs.Variable);\r
index 9363e36ede4fb3c60b92703e2b1705ba634aaad2..30281ccd1dc4bde8f5958fd71db8b7c894c3a0f9 100644 (file)
@@ -43,7 +43,10 @@ Require-Bundle: org.simantics.layer0.utils;bundle-version="0.6.2",
  org.simantics.browsing.ui.model;bundle-version="1.0.0",
  org.simantics.spreadsheet.ui;bundle-version="1.1.0",
  org.simantics.views.swt;bundle-version="1.0.0",
- org.simantics.selectionview;bundle-version="1.0.0"
+ org.simantics.selectionview;bundle-version="1.0.0",
+ org.simantics.issues;bundle-version="1.1.0",
+ org.simantics.issues.ui;bundle-version="1.1.0",
+ org.simantics.issues.common;bundle-version="1.1.0"
 Bundle-Activator: org.simantics.sysdyn.ui.Activator
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.sysdyn.ui.browser.nodes
index f15dc9e0aaebfe852a8976eb99352f5d809ca4a8..454d59a4d061e6ccd26b7f0f969ddcae7614baeb 100644 (file)
@@ -10,5 +10,5 @@
         VTT Technical Research Centre of Finland - initial API and implementation\r
  -->\r
 
-<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r<!-- \r       <target interface="org.simantics.db.layer0.variable.Variable">\r         <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r                     class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r                      <this />\r               </type>\r                <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r                     class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r                      <this />\r               </type>\r        </target>\r -->\r\r        <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.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               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->\r         <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                     class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <!-- : SYSDYN.Connection-->\r            <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>            \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>              \r    \r     \r
+<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r<!-- \r       <target interface="org.simantics.db.layer0.variable.Variable">\r         <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r                     class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r                      <this />\r               </type>\r                <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r                     class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r                      <this />\r               </type>\r        </target>\r -->\r\r        <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.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               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->\r         <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                     class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <!-- : SYSDYN.Connection-->\r            <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>            \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>              \r  \r  \r  <!-- ISSUES -->\r    <target interface="org.simantics.db.layer0.adapter.IssueSource">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-1.0/Validations/DependencyConnections"\r            class="org.simantics.sysdyn.ui.validation.DependencyIssueSource">\r            <graph/>\r            <this />\r        </resource>\r    </target>\r
 </adapters>
\ No newline at end of file
index 16bcbc7af820756cc2c4eed9e50b477046debd8f..f6fb712b037dde7c840d45e563c3ee8ac6b591ce 100644 (file)
                relationship="stack"\r
                relative="org.simantics.sysdyn.ui.trend.view">\r
          </view>\r
+         <view\r
+               id="org.simantics.issues.ui.issueview"\r
+               minimized="false"\r
+               relationship="stack"\r
+               relative="org.simantics.browsing.ui.graph.propertyView">\r
+         </view>\r
          \r
       </perspectiveExtension>\r
    </extension>\r
index 9ef4fa9ff9cd4375889fe1a35cbf688d9ca64d53..e7bb25f474435b1a19104de941f85af2e27a7292 100644 (file)
@@ -30,6 +30,8 @@ import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.IElement;\r
 import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
 import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
@@ -79,8 +81,10 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter {
                                \r
                                ready.incrementAndGet();\r
                                Layer0 l0;\r
+                               ModelingResources mr;\r
                                try {\r
                                        l0 = Layer0.getInstance(graph.getSession());\r
+                                       mr = ModelingResources.getInstance(graph.getSession());\r
                                } catch (DatabaseException e) {\r
                                        e.printStackTrace();\r
                                        return;\r
@@ -154,6 +158,48 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter {
                                        \r
                                });\r
                                \r
+                               \r
+//                             graph.forPossibleObject(elementResource, mr.DiagramConnectionToConnection,  new AsyncProcedure<Resource>() {\r
+//\r
+//                    @Override\r
+//                    public void execute(AsyncReadGraph graph, Resource result) {\r
+//                        SysdynResource sr;\r
+//                        try {\r
+//                            sr = SysdynResource.getInstance(graph.getSession());\r
+//                        } catch (DatabaseException e) {\r
+//                            e.printStackTrace();\r
+//                            return;\r
+//                        }\r
+//                        graph.forPossibleRelatedValue(result, sr.Polarity, Bindings.STRING, new AsyncProcedure<String>() {\r
+//\r
+//                            @Override\r
+//                            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+//                                throwable.printStackTrace();\r
+//                            }\r
+//\r
+//                            @Override\r
+//                            public void execute(AsyncReadGraph graph, String name) {\r
+//                                \r
+//                                properties.put("polarity", Pair.make(property, (Object)name));\r
+////                              System.out.println("load properties " + name + " => " + value);\r
+//                                if(ready.decrementAndGet() == 0) {\r
+//                                    element.setHint(DiagramHints.PROPERTIES, new HashMap<String, Pair<Resource, Object>>(properties));\r
+//                                    procedure.execute(graph, element);\r
+//                                }\r
+//                                \r
+//                            }\r
+//                            \r
+//                        });\r
+//                        \r
+//                    }\r
+//\r
+//                    @Override\r
+//                    public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+//                        throwable.printStackTrace();                        \r
+//                    }\r
+//\r
+//                             });\r
+                               \r
                        }\r
 \r
                        @Override\r
index 284a7bd48ae906ffa7a60dab00ea301392c7819f..e527e0a4c769553e73d8a5560b6e13c2e4ade384 100644 (file)
@@ -13,12 +13,14 @@ package org.simantics.sysdyn.ui.elements2.connections;
 \r
 import java.awt.BasicStroke;\r
 import java.awt.Color;\r
+import java.awt.Font;\r
 import java.awt.Shape;\r
 import java.awt.Stroke;\r
 import java.awt.geom.Path2D;\r
 import java.awt.geom.Rectangle2D;\r
 import java.beans.PropertyChangeEvent;\r
 import java.beans.PropertyChangeListener;\r
+import java.util.HashMap;\r
 import java.util.Map;\r
 \r
 import org.simantics.db.Resource;\r
@@ -30,6 +32,7 @@ import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;
 import org.simantics.g2d.diagram.handler.Topology;\r
 import org.simantics.g2d.diagram.handler.Topology.Connection;\r
 import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementHints;\r
 import org.simantics.g2d.element.ElementUtils;\r
 import org.simantics.g2d.element.IElement;\r
 import org.simantics.g2d.element.SceneGraphNodeKey;\r
@@ -44,8 +47,12 @@ import org.simantics.g2d.element.handler.impl.ConnectionSelectionOutline;
 import org.simantics.g2d.element.handler.impl.FillColorImpl;\r
 import org.simantics.g2d.element.handler.impl.ParentImpl;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
 import org.simantics.g2d.elementclass.connection.EdgeClass.EdgeHandler;\r
 import org.simantics.g2d.elementclass.connection.EdgeClass.FixedTransform;\r
+import org.simantics.g2d.utils.Alignment;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
 import org.simantics.scenegraph.utils.NodeUtil;\r
 import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
@@ -87,6 +94,9 @@ public class DependencyEdgeClass {
                 ConfigurableEdgeVisuals.DEFAULT,\r
                 FillColorImpl.BLACK,\r
                 FixedTransform.INSTANCE,\r
+                TextImpl.INSTANCE,\r
+                TextColorImpl.BLACK,\r
+                TextFontImpl.DEFAULT,\r
                 new NodePick(),\r
                 ConnectionSelectionOutline.INSTANCE,\r
                 SimpleElementLayers.INSTANCE,\r
@@ -102,11 +112,18 @@ public class DependencyEdgeClass {
         public static final Stroke ARROW_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);\r
 \r
         public static final Key KEY_SG_NODE = new SceneGraphNodeKey(DependencyNode.class, "EDGE_NODE");\r
-\r
+        \r
         @Override\r
         public void init(IElement e, G2DParentNode parent) {\r
             DependencyNode node = ElementUtils.getOrCreateNode(e, parent, KEY_SG_NODE, "edge_" + e.hashCode(), DependencyNode.class);\r
-            node.setAngle(0.1);\r
+            \r
+            Font font = ElementUtils.getTextFont(e);\r
+            Color color = ElementUtils.getTextColor(e);\r
+            \r
+            HashMap<String, Object> properties = e.getHint(DiagramHints.PROPERTIES);\r
+            Pair<?, ?> polarityPair =  (Pair<?, ?>)properties.get("Polarity");\r
+            if(polarityPair != null)\r
+                node.init((String)  polarityPair.second, font, color, 0, 0, 0.235);\r
             \r
             update(e);\r
         }\r
@@ -146,9 +163,7 @@ public class DependencyEdgeClass {
                 \r
                        });\r
 \r
-            EdgeVisuals vh = e.getElementClass().getSingleItem(EdgeVisuals.class);\r
-            Stroke stroke = vh.getStroke(e);\r
-            Color c = ElementUtils.getFillColor(e, Color.BLACK);\r
+\r
 \r
             Shape beginTerminalShape = null;\r
             Shape endTerminalShape = null;\r
@@ -164,10 +179,26 @@ public class DependencyEdgeClass {
             \r
             if(beginTerminalShape == null || endTerminalShape == null) return;\r
             \r
+            EdgeVisuals vh = e.getElementClass().getSingleItem(EdgeVisuals.class);\r
+            Stroke stroke = vh.getStroke(e);\r
+            Font font = ElementUtils.getTextFont(e);\r
+            Color color = ElementUtils.getTextColor(e);\r
+//            Color fillColor = ElementUtils.getFillColor(e);\r
+            Color borderColor = ElementUtils.getBorderColor(e, Color.BLACK);\r
+//            String text = ElementUtils.getText(e);\r
+            Alignment hAlign = ElementUtils.getHintOrDefault(e, ElementHints.KEY_HORIZONTAL_ALIGN, Alignment.CENTER);\r
+            node.setBackgroundColor(null);\r
+            node.setBorderColor(borderColor);\r
+            node.setHorizontalAlignment((byte) hAlign.ordinal());\r
+            node.setPadding(0, 0);\r
+            node.setBorderWidth((float) 0);\r
+            node.setEditable(false);\r
+            node.setFont(font);\r
+            \r
             node.setBeginBounds(beginTerminalShape.getBounds2D());\r
             node.setEndBounds(endTerminalShape.getBounds2D());\r
             node.setStroke(stroke);\r
-            node.setColor(c);\r
+            node.setColor(color);\r
             node.setShapes(DependencyRouter.createArrowShape(node.getShapes(), node.getBeginBounds(), node.getEndBounds(), node.getAngle()));\r
 \r
             Map<String, Pair<Resource, Object>> properties = e.getHint(DiagramHints.PROPERTIES);\r
@@ -207,5 +238,5 @@ public class DependencyEdgeClass {
         }\r
 \r
     }\r
-\r
+  \r
 }\r
index 04fc95bb481f462311ede652ad49c70f9549202f..780d8f1ae51d1e4cfb2abb1ae1c5421d4d889a09 100644 (file)
@@ -20,18 +20,19 @@ import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;\r
 import java.awt.geom.Arc2D;\r
 import java.awt.geom.Path2D;\r
+import java.awt.geom.Point2D;\r
 import java.awt.geom.Rectangle2D;\r
 import java.beans.PropertyChangeEvent;\r
 import java.beans.PropertyChangeListener;\r
 \r
+import org.simantics.diagram.elements.TextNode;\r
 import org.simantics.scenegraph.ISelectionPainterNode;\r
-import org.simantics.scenegraph.g2d.G2DNode;\r
 import org.simantics.scenegraph.g2d.events.ISGMouseEvent;\r
 import org.simantics.scenegraph.utils.NodeUtil;\r
 import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
-public class DependencyNode extends G2DNode implements ISelectionPainterNode, MouseListener, MouseMotionListener {\r
+public class DependencyNode extends TextNode implements ISelectionPainterNode, MouseListener, MouseMotionListener {\r
 \r
     private static final long serialVersionUID = 1294351381209071074L;\r
 \r
@@ -102,13 +103,13 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode, Mo
     public void setAngle(Double angle) {\r
         this.angle = angle.doubleValue();\r
         if(this.beginBounds != null && this.endBounds != null)\r
-               this.shapes = DependencyRouter.createArrowShape(this.shapes, this.beginBounds, this.endBounds, this.angle);\r
+            this.shapes = DependencyRouter.createArrowShape(this.shapes, this.beginBounds, this.endBounds, this.angle);\r
     }\r
-    \r
+\r
     @PropertySetter("shapes")\r
     @SyncField("shapes")\r
     public void setShapes(Pair<Arc2D, Path2D> shapes) {\r
-       this.shapes = shapes;\r
+        this.shapes = shapes;\r
     }\r
 \r
     public Color getColor() {\r
@@ -130,13 +131,13 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode, Mo
     public double getAngle() {\r
         return angle;\r
     }\r
-    \r
+\r
     public Pair<Arc2D, Path2D> getShapes() {\r
         return shapes;\r
     }\r
-    \r
 \r
-    \r
+\r
+\r
     @Override\r
     public void render(Graphics2D g) {\r
         if(beginBounds == null || endBounds == null) return;\r
@@ -170,6 +171,26 @@ public class DependencyNode extends G2DNode implements ISelectionPainterNode, Mo
             g.fill(shapes.second);\r
         }\r
 \r
+        \r
+        double angleRad = angle > 0 ? \r
+                Math.toRadians(shapes.first.getAngleStart() + shapes.first.getAngleExtent()) : \r
+                    Math.toRadians(shapes.first.getAngleStart());\r
+        Point2D point = angle > 0 ? shapes.first.getEndPoint() : shapes.first.getStartPoint();\r
+        \r
+        double a = Math.toRadians(angle < 0 ? 255 : -75);\r
+        double s = Math.sin(a) * 2;\r
+        double c = Math.cos(a) * 3;\r
+        \r
+        g.translate(point.getX(), point.getY());\r
+        g.rotate(-angleRad);\r
+        g.translate(s, c);\r
+        g.rotate(angleRad);\r
+        super.render(g);\r
+        g.rotate(-angleRad);\r
+        g.translate(-s, -c);\r
+        g.rotate(angleRad);\r
+        g.translate(-point.getX(), -point.getY());\r
+        \r
     }\r
 \r
     boolean pressHit = false;\r
index a4c3175d20f63aa4d93818187aaf1188b1944202..f073d5d8f73df16b4c3636d3133a2829b33fc830 100644 (file)
@@ -12,8 +12,9 @@
 package org.simantics.sysdyn.ui.project;\r
 \r
 import java.io.File;\r
+import java.util.Collection;\r
 import java.util.HashMap;\r
-import java.util.UUID;\r
+import java.util.Map;\r
 \r
 import org.eclipse.core.runtime.Platform;\r
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;\r
@@ -21,54 +22,45 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.ui.PartInitException;\r
 import org.osgi.service.prefs.BackingStoreException;\r
-import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.accessor.Accessor;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.procedure.single.SingleSetSyncListener;\r
 import org.simantics.db.common.request.Queries;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.IssueSource;\r
 import org.simantics.db.layer0.adapter.RuntimeValuations;\r
-import org.simantics.db.layer0.adapter.Template;\r
 import org.simantics.db.layer0.adapter.TrendVariable;\r
 import org.simantics.db.layer0.service.ActivationManager;\r
+import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.db.service.GraphChangeListenerSupport;\r
 import org.simantics.db.service.LifecycleSupport;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
-import org.simantics.document.DocumentResource;\r
 import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.modeling.ModelingUtils;\r
 import org.simantics.modeling.services.CaseInsensitiveComponentNamingStrategy2;\r
 import org.simantics.modeling.services.ComponentNamingStrategy;\r
-import org.simantics.operation.Layer0X;\r
 import org.simantics.project.IProject;\r
 import org.simantics.project.ProjectElementType;\r
 import org.simantics.project.ProjectElements;\r
 import org.simantics.project.ProjectKeys;\r
 import org.simantics.project.exception.ProjectException;\r
 import org.simantics.project.features.AbstractProjectFeature;\r
-import org.simantics.project.ontology.ProjectResource;\r
 import org.simantics.simulation.experiment.IExperiment;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.simulation.project.IExperimentManager;\r
-import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.sysdyn.ui.editor.SysdynEditorNamingService;\r
-import org.simantics.sysdyn.ui.utils.SheetUtils;\r
-import org.simantics.ui.SimanticsUI;\r
+import org.simantics.sysdyn.ui.validation.ActiveIssueSources;\r
 import org.simantics.ui.workbench.IEditorNamingService;\r
 import org.simantics.ui.workbench.action.ChooseActionRequest;\r
 import org.simantics.ui.workbench.project.UIModelManager;\r
 import org.simantics.ui.workbench.project.UIModelManagerBase;\r
-import org.simantics.ui.workbench.project.UIModelManagerBase.WriteRunnable;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
 import org.simantics.utils.datastructures.Callback;\r
 import org.simantics.utils.ui.ErrorLogger;\r
 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
@@ -84,7 +76,8 @@ public class SysdynProject extends AbstractProjectFeature {
                 Callback<Resource> callback, Callback<Throwable> errorCallback) {\r
 \r
             if (ProjectElements.MODEL.equals(kind)) {\r
-                request(session, container, callback, errorCallback, CREATE_MODEL);\r
+                //FIXME: Should not be needed anymore\r
+//                request(session, container, callback, errorCallback, CREATE_MODEL);\r
                 return;\r
             }\r
 \r
@@ -108,92 +101,7 @@ public class SysdynProject extends AbstractProjectFeature {
         }\r
     }\r
 \r
-    private final WriteRunnable CREATE_MODEL = new WriteRunnable() {\r
-       \r
-        @Override\r
-        public void run(WriteGraph g, Resource library, Callback<Resource> callback, Callback<Throwable> errorCallback) {\r
-            try {\r
-                Layer0 l0 = Layer0.getInstance(g);\r
-                Layer0X L0X = Layer0X.getInstance(g);\r
-                SysdynResource sr = SysdynResource.getInstance(g);\r
-                SpreadsheetResource SHEET = SpreadsheetResource.getInstance(g);\r
-                ModelingUtils mu = new ModelingUtils(g);\r
-                DocumentResource DOC = DocumentResource.getInstance(g);\r
-                \r
-                String modelName = NameUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), l0.ConsistsOf, "%s%d");\r
-\r
-                Resource model = g.newResource();\r
-                g.claimLiteral(model, l0.HasName, modelName);\r
-                g.claimLiteral(model, l0.HasLabel, modelName);\r
-                g.claim(model, l0.InstanceOf, sr.SysdynModel);\r
-                g.claim(model, l0.PartOf, SimanticsUI.getProject().get());\r
-\r
-                Resource conf = GraphUtils.create2(g,\r
-                        sr.Configuration,\r
-                        l0.PartOf, model,\r
-                        L0X.IsBaseRealizationOf, model,\r
-                        l0.HasName, modelName\r
-                );\r
-                \r
-                Resource diagram = g.newResource();\r
-                g.adapt(sr.ConfigurationDiagramTemplate, Template.class).apply(g,\r
-                        ArrayMap\r
-                        .keys("", "diagram", "name")\r
-                        .values(conf, diagram, "Diagrammi")\r
-                );\r
-\r
-                g.claim(model, mu.SIMU.HasConfiguration, conf);\r
-\r
-                       Resource book = g.newResource();\r
-                       g.claim(book, l0.InstanceOf, null, SHEET.Book);\r
-                       g.addLiteral(book, l0.HasName, l0.NameOf, l0.String, "Book" + UUID.randomUUID().toString(), Bindings.STRING);\r
-                       g.claim(conf, l0.ConsistsOf, l0.PartOf, book);\r
-                       \r
-                       SheetUtils.createSheet(g, book, "Sheet1", new String[] { }, new int[] { 50 });\r
-                \r
-                \r
-                \r
-                ModelingResources mr = ModelingResources.getInstance(g);\r
-                // Remove default mapping and add sysdyn mapping\r
-                for(Resource trigger : g.getObjects(diagram, L0X.HasTrigger)) {\r
-                       if(g.isInstanceOf(trigger, mr.DiagramToCompositeMapping)) {\r
-                               g.deny(diagram, L0X.HasTrigger, trigger);\r
-                       }\r
-                }\r
-                Resource mapping = g.newResource();\r
-                g.claim(mapping, l0.InstanceOf, null, sr.DiagramToCompositeMapping);\r
-                g.claim(diagram, L0X.HasTrigger, mapping);\r
-\r
-                Resource report = GraphUtils.create2(g, DOC.Report,  DOC.HasDocumentation, "===Report===");\r
-\r
-                GraphUtils.create2(g, mu.SIMU.Experiment,\r
-                        l0.HasName, "Experiment",\r
-                        l0.HasLabel, "Experiment",\r
-                        DOC.HasReportFactory, report,\r
-                        l0.PartOf, model);\r
-                \r
-                ProjectResource PROJ = ProjectResource.getInstance(g);\r
-                for(Resource dep : g.getObjects(library, l0.IsLinkedTo)) {\r
-                       if(g.isInstanceOf(dep, PROJ.NamespaceRequirement)) {\r
-                               for(Resource req : g.getObjects(dep, PROJ.RequiresNamespace)) {\r
-                                       String uri = g.getPossibleValue(req, Bindings.STRING);\r
-                                       if(uri != null) {\r
-                                               Resource target = g.getResource(uri);\r
-                                               if(target != null) {\r
-                                                       g.claim(model, l0.IsLinkedTo, null, target);\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-                }\r
-\r
-                \r
-                callback.run(model);\r
-            } catch(Exception e) {\r
-                errorCallback.run(e);\r
-            }\r
-        }\r
-    };\r
\r
 \r
     ModelManager mm;\r
 \r
@@ -287,6 +195,79 @@ public class SysdynProject extends AbstractProjectFeature {
                 ErrorLogger.defaultLogError(e);\r
             }\r
         }\r
+        \r
+        \r
+        // Issues\r
+        \r
+        try {\r
+            \r
+            session.syncRequest(new ActiveIssueSources(project.get()), new SingleSetSyncListener<Resource>() {\r
+\r
+                Map<Resource, IssueSource> sources = new HashMap<Resource, IssueSource>();\r
+                Map<Resource, Runnable> listeners = new HashMap<Resource, Runnable>();\r
+                \r
+                @Override\r
+                public void add(ReadGraph graph, final Resource source) throws DatabaseException {\r
+                    final IssueSource is = graph.adapt(source, IssueSource.class);\r
+                    if(is != null) {\r
+\r
+                        Runnable listener = new Runnable() {\r
+\r
+                            @Override\r
+                            public void run() {\r
+\r
+                                project.getSession().asyncRequest(new WriteRequest() {\r
+\r
+                                    @Override\r
+                                    public void perform(WriteGraph graph) throws DatabaseException {\r
+                                        is.update(graph);\r
+                                    }\r
+\r
+                                });\r
+\r
+                            }\r
+\r
+                        };\r
+\r
+                        is.addDirtyListener(listener);\r
+                        sources.put(source, is);\r
+                        listeners.put(source, listener);\r
+\r
+                    } else {\r
+\r
+                        System.err.println("Issue source " + source + " does not have adapter!");\r
+\r
+                    }\r
+\r
+                }\r
+\r
+                @Override\r
+                public void remove(ReadGraph graph, final Resource source) throws DatabaseException {\r
+\r
+                    IssueSource is = sources.get(source);\r
+                    Runnable listener = listeners.get(source);\r
+                    if(is != null && listener != null) {\r
+                        is.removeDirtyListener(listener);\r
+                    }\r
+                    sources.remove(source);\r
+\r
+                }\r
+\r
+                @Override\r
+                public void exception(ReadGraph graph, Throwable t) {\r
+                 Logger.defaultLogError(t);\r
+                }\r
+\r
+                @Override\r
+                public boolean isDisposed() {\r
+                    return false;\r
+                }\r
+\r
+            });\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+     \r
     }\r
 \r
     @Override\r
index 1119f941b05d7847f75b16dde2288e8e1063f9a1..6b72b35c4ca4211d0e762bf283e1913ee97fc30d 100644 (file)
@@ -21,7 +21,7 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.db.management.ISessionContext;\r
-import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
 \r
 public class DependencyTab  extends LabelPropertyTabContributor {\r
 \r
@@ -31,8 +31,8 @@ public class DependencyTab  extends LabelPropertyTabContributor {
         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(Layer0.URIs.HasName));\r
-        nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+        nameText.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.Polarity));\r
+        nameText.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.Polarity));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
     }\r
 \r
index 79af5b1264d1927fc4ae53906ee75f297185d68f..058d265ad9c644f0faa0648db51c84d15a5c1156 100644 (file)
@@ -226,13 +226,15 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                                                        0,\r
                                                                        r,\r
                                                        "Reference Properties"));\r
-                               else\r
+                               else {\r
+                                   Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
                                        return Collections.singleton(\r
                                                        new ComparableTabContributor(\r
                                                                        new DependencyTab(),\r
                                                                        0,\r
-                                                                       r,\r
+                                                                       diaConnection,\r
                                                        "Dependency Properties"));\r
+                               }\r
                        if (backend.isInheritedFrom(r, sr.ModuleSymbol)) {\r
                                r =  backend.getPossibleObject(r, mr.SymbolToComponentType);\r
                                if(r != null)\r
index b5c30574efae3cda3541f1fc21cb15d18711de9d..f1fb5d894d4dab52ef2c2077ff6ab14dbe9f2e26 100644 (file)
@@ -1,5 +1,8 @@
 package org.simantics.sysdyn.ui.utils;\r
 \r
+import java.text.DateFormat;\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
 import java.util.UUID;\r
 \r
 import org.simantics.databoard.Bindings;\r
@@ -10,6 +13,7 @@ import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.adapter.Template;\r
 import org.simantics.document.DocumentResource;\r
+import org.simantics.issues.ontology.IssueResource;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.modeling.ModelingResources;\r
@@ -63,11 +67,15 @@ public class ModelUtils {
 \r
             String modelName = NameUtils.findFreshName(g, "Model", library, l0.ConsistsOf, "%s%d");\r
 \r
-            Resource model = g.newResource();\r
-            g.claimLiteral(model, l0.HasName, modelName);\r
-            g.claimLiteral(model, l0.HasLabel, modelName);\r
-            g.claim(model, l0.InstanceOf, sr.SysdynModel);\r
-            g.claim(model, l0.PartOf, SimanticsUI.getProject().get());\r
+            Resource project = SimanticsUI.getProject().get();\r
+            Resource model = GraphUtils.create2(g,\r
+                    sr.SysdynModel,\r
+                    l0.PartOf, project,\r
+                    l0.HasName, modelName,\r
+                    l0.HasLabel, modelName,\r
+                    L0X.IsActivatedBy, project,\r
+                    L0X.Activates, sr.Validations_DependencyConnections\r
+            );\r
 \r
             Resource conf = GraphUtils.create2(g,\r
                     sr.Configuration,\r
@@ -127,6 +135,22 @@ public class ModelUtils {
                     }\r
                 }\r
             }\r
+            \r
+            /*\r
+            IssueResource ISSUE = IssueResource.getInstance(g);\r
+            Resource sampleNote = g.newResource();\r
+            g.claim(sampleNote, l0.InstanceOf, null, ISSUE.TextualIssue);\r
+            g.claimLiteral(sampleNote, l0.HasName, "sampleNote");\r
+            g.claim(sampleNote, ISSUE.HasSeverity, ISSUE.Severity_Error);\r
+            g.claim(sampleNote, ISSUE.HasIssueContext, model);\r
+            g.claimLiteral(sampleNote, l0.HasLabel, "Test note", Bindings.STRING);\r
+            g.claimLiteral(sampleNote, l0.HasDescription, "= Test =\nThis is a test note.\n", Bindings.STRING);\r
+                     DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");\r
+                     String created = format.format(Calendar.getInstance().getTime());\r
+            g.claimLiteral(sampleNote, ISSUE.HasCreationTime, created, Bindings.STRING);\r
+            g.claim(model, l0.ConsistsOf, sampleNote);\r
+            */\r
+            \r
         } catch (DatabaseException e ) {\r
 \r
         }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ActiveIssueSources.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ActiveIssueSources.java
new file mode 100644 (file)
index 0000000..06229d9
--- /dev/null
@@ -0,0 +1,43 @@
+package org.simantics.sysdyn.ui.validation;\r
+\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\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.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.issues.ontology.IssueResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ActiveIssueSources extends ResourceRead<Collection<Resource>> {\r
+    \r
+    Resource project;\r
+    \r
+    public ActiveIssueSources(Resource project) {\r
+        super(project);\r
+        this.project = project;\r
+    }\r
+\r
+    @Override\r
+    public Set<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+        \r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        Layer0X l0X = Layer0X.getInstance(graph);\r
+        IssueResource ISSUE = IssueResource.getInstance(graph);\r
+        \r
+        HashSet<Resource> result = new HashSet<Resource>();\r
+        \r
+        for(Resource model : graph.syncRequest(new ObjectsWithType(project, l0.ConsistsOf, sr.SysdynModel))) {\r
+            result.addAll(graph.syncRequest(new ObjectsWithType(model, l0X.Activates,  ISSUE.IssueSource)));\r
+        }\r
+        \r
+        return result;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyIssueSource.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyIssueSource.java
new file mode 100644 (file)
index 0000000..a72218c
--- /dev/null
@@ -0,0 +1,79 @@
+package org.simantics.sysdyn.ui.validation;\r
+\r
+import java.util.concurrent.CopyOnWriteArraySet;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.changeset.GenericChangeListener;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.IssueSource;\r
+import org.simantics.db.layer0.genericrelation.DependenciesRelation.DependencyChangesRequest;\r
+import org.simantics.db.layer0.genericrelation.DependencyChanges;\r
+import org.simantics.db.layer0.util.Simantics;\r
+import org.simantics.db.service.GraphChangeListenerSupport;\r
+import org.simantics.issues.common.IssueSourceUtils;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class DependencyIssueSource implements IssueSource {\r
+\r
+    private Resource source;\r
+    private Resource model;\r
+    private Resource baseRealization;\r
+\r
+    private CopyOnWriteArraySet<Runnable> listeners = new CopyOnWriteArraySet<Runnable>();\r
+    private boolean tracking = false;\r
+\r
+    public DependencyIssueSource(ReadGraph graph, Resource source) throws DatabaseException {\r
+        Layer0X L0X = Layer0X.getInstance(graph);\r
+        this.source = source;\r
+        this.model = graph.getSingleObject(source, L0X.IsActivatedBy);\r
+        this.baseRealization = graph.getSingleObject(model, L0X.HasBaseRealization);\r
+    }\r
+\r
+    @Override\r
+    public void addDirtyListener(Runnable runnable) {\r
+\r
+        boolean added = listeners.add(runnable);\r
+        if(added && !tracking) {\r
+\r
+            GraphChangeListenerSupport changeSupport = Simantics.getSession().getService(GraphChangeListenerSupport.class);\r
+            changeSupport.addMetadataListener(new GenericChangeListener<DependencyChangesRequest, DependencyChanges>() {\r
+\r
+                @Override\r
+                public void onEvent(ReadGraph graph, DependencyChanges event) throws DatabaseException {\r
+                    if(IssueSourceUtils.hasChanges(graph, event, model, baseRealization)) {\r
+                        for(Runnable r : listeners) {\r
+                            r.run();\r
+                        }\r
+                    }\r
+\r
+                }\r
+\r
+            });\r
+\r
+        }\r
+\r
+    }\r
+\r
+    @Override\r
+    public void removeDirtyListener(Runnable runnable) {\r
+        listeners.remove(runnable);\r
+    }\r
+\r
+    @Override\r
+    public void update(WriteGraph graph) throws DatabaseException {\r
+\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+        for(Resource unit : IssueSourceUtils.getChangedDependencies(graph, source, model, baseRealization, sr.Variable)) {\r
+            if(!graph.syncRequest(new DependencyValidator(unit, model))) new DependencySynchronizer(unit, model).perform(graph);\r
+        }\r
+\r
+        IssueSourceUtils.claimUpdated(graph, source);\r
+\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyIssues.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyIssues.java
new file mode 100644 (file)
index 0000000..3ed195a
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.sysdyn.ui.validation;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.issues.common.AllVisibleIssues;\r
+import org.simantics.issues.ontology.IssueResource;\r
+\r
+public class DependencyIssues extends ResourceRead<Set<Resource>>{\r
+\r
+    public DependencyIssues(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+    @Override\r
+    public Set<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+        IssueResource ISSUE = IssueResource.getInstance(graph);\r
+        HashSet<Resource> result = new HashSet<Resource>();\r
+        for (Resource issue : graph.syncRequest(new AllVisibleIssues(resource))) {\r
+            if (ISSUE.Severity_Error.equals(graph.getPossibleObject(issue, ISSUE.HasSeverity)))\r
+                result.add(issue);\r
+        }\r
+        return result;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencySynchronizer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencySynchronizer.java
new file mode 100644 (file)
index 0000000..84be096
--- /dev/null
@@ -0,0 +1,111 @@
+package org.simantics.sysdyn.ui.validation;\r
+\r
+import java.text.DateFormat;\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.UUID;\r
+\r
+import org.simantics.databoard.Bindings;\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.issues.ontology.IssueResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class DependencySynchronizer extends WriteRequest {\r
+    public static final boolean DEBUG = true;\r
+    \r
+    final private Resource unit;\r
+    final private Resource model;\r
+\r
+    public DependencySynchronizer(Resource unit, Resource model) {\r
+     this.unit = unit;\r
+     this.model = model;\r
+    }\r
+\r
+    @Override\r
+    public void perform(WriteGraph graph) throws DatabaseException {\r
+\r
+     Layer0 L0 = Layer0.getInstance(graph);\r
+     \r
+     StructuralResource2 sr = StructuralResource2.getInstance(graph);\r
+     IssueResource ISSUE = IssueResource.getInstance(graph);\r
+\r
+     if(DEBUG) System.out.println("Running DependencySynchronizer for " + unit);\r
+\r
+     Set<Resource> set  = graph.syncRequest(new DependencyIssues(model));\r
+     \r
+     if(DEBUG) System.out.println(set.size() + " issues");\r
+     \r
+     /*\r
+     Collection<Resource> removed = new HashSet<Resource>();\r
+\r
+     boolean unitExists = graph.hasStatement(unit);\r
+     if(unitExists) {\r
+     \r
+      removed.addAll(map.values());\r
+    \r
+      for(Resource predicate : graph.getPredicates(unit)) {\r
+       if(graph.isSubrelationOf(predicate, FB.Parameter)) {\r
+        boolean hasIssue = false;\r
+        Resource literal = graph.getPossibleObject(unit, predicate);\r
+        Boolean required = graph.getPossibleRelatedValue(literal, FB.IsRequired, Bindings.BOOLEAN);\r
+        if(required != null && required && !DependencyValidator.excluded(graph, unit)) {\r
+         Boolean def = graph.getPossibleRelatedValue(literal, FB.IsDefault, Bindings.BOOLEAN);\r
+         if(def != null && def) {\r
+          hasIssue = true;\r
+         }\r
+        }\r
+        Resource issue = map.get(Pair.make(unit, predicate)); \r
+        if(hasIssue != (issue != null)) {\r
+         \r
+         if(hasIssue) {\r
+          \r
+          issue = graph.newResource();\r
+          graph.claim(issue, L0.InstanceOf, null, FB.ParameterIssue);\r
+          graph.claim(issue, ISSUE.HasIssueContext, null, unit);\r
+          graph.claim(issue, ISSUE.HasIssueContext, null, predicate);\r
+          graph.claim(issue, ISSUE.HasSeverity, ISSUE.Severity_Error);\r
+          graph.claimValue(issue, L0.HasDescription, "= Missing connection =", Bindings.STRING);\r
+          graph.claimValue(issue, L0.HasName, UUID.randomUUID().toString(), Bindings.STRING);\r
+          DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");\r
+          String created = format.format(Calendar.getInstance().getTime());\r
+          graph.claimValue(issue, ISSUE.HasCreationTime, created, Bindings.STRING);\r
+          graph.claim(model, L0.ConsistsOf, issue);\r
+          \r
+         } else {\r
+          \r
+          graph.deny(issue, L0.PartOf);\r
+          \r
+         }\r
+         \r
+        }\r
+        \r
+       }\r
+      }\r
+      \r
+     } else {\r
+      \r
+      for(Map.Entry<Pair<Resource, Resource>, Resource> entry : map.entrySet()) {\r
+//       System.err.println("entry " + entry.getKey());\r
+       if(entry.getKey().first.equals(unit)) {\r
+        graph.deny(entry.getValue(), L0.PartOf);\r
+       }\r
+       if(entry.getKey().first == null) {\r
+        graph.deny(entry.getValue(), L0.PartOf);\r
+       }\r
+      }\r
+      \r
+     }\r
+*/\r
+     \r
+    }\r
+    \r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyValidator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyValidator.java
new file mode 100644 (file)
index 0000000..ffac712
--- /dev/null
@@ -0,0 +1,69 @@
+package org.simantics.sysdyn.ui.validation;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ResourceRead2;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.issues.common.impl.DependencyIssue;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class DependencyValidator extends ResourceRead2<Boolean> {\r
+\r
+    public static final boolean DEBUG = true;\r
+    \r
+    public DependencyValidator(Resource resource, Resource resource2) {\r
+        super(resource, resource2);\r
+    }\r
+\r
+    static boolean excluded(ReadGraph graph, Resource component) throws DatabaseException {\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        return !graph.isInstanceOf(component, sr.Variable);\r
+    }\r
+\r
+    @Override\r
+    public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+\r
+        if(DEBUG) System.out.println("Running DependencyValidator for " + resource);\r
+\r
+        //if(!graph.hasStatement(resource, L0.Represents)) return false;\r
+\r
+        if(!graph.hasStatement(resource)) return false;\r
+\r
+        Set<Resource> resources = graph.syncRequest(new DependencyIssues(resource2));\r
+        if(DEBUG) System.out.println(resources.size() + " resources");\r
+\r
+        /*\r
+        Set<Resource> resources = graph.syncRequest(new DependencyIssues(resource2));\r
+        HashMap<Pair<Resource, Resource>, Resource> existing = new HashMap<Pair<Resource, Resource>, Resource>(existing_); \r
+\r
+        for(Resource predicate : graph.getPredicates(resource)) {\r
+            if(graph.isSubrelationOf(predicate, FB.Parameter)) {\r
+                boolean hasIssue = false;\r
+                Resource literal = graph.getPossibleObject(resource, predicate);\r
+                Boolean required = graph.getPossibleRelatedValue(literal, FB.IsRequired, Bindings.BOOLEAN);\r
+                if(required != null && required && !excluded(graph, resource)) {\r
+                    Boolean def = graph.getPossibleRelatedValue(literal, FB.IsDefault, Bindings.BOOLEAN);\r
+                    if(def != null && def) {\r
+                        hasIssue = true;\r
+                        return false;\r
+                    }\r
+                }\r
+                if(hasIssue != existing.containsKey(Pair.make(resource, predicate))) return false;\r
+            }\r
+        }\r
+        */\r
+\r
+        return true;\r
+\r
+    }\r
+\r
+}\r