]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Preliminary support for purely Variable based dynamic issue sources 70/270/5
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 13 Jan 2017 06:56:18 +0000 (08:56 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 17 Jan 2017 15:05:29 +0000 (17:05 +0200)
refs #6948

Change-Id: I7da7446a57a3da7836b59eb2e2c3dc60858818bf

20 files changed:
bundles/org.simantics.issues.common/src/org/simantics/issues/common/ActiveModelIssueSources.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/ActiveProjectIssueSources.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/DynamicIssueSources.java [new file with mode: 0644]
bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueUtils.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/SelectedModelBatchIssueSources.java
bundles/org.simantics.issues.ontology/graph.tg
bundles/org.simantics.issues.ontology/graph/Issue.pgraph
bundles/org.simantics.issues.ontology/src/org/simantics/issues/ontology/IssueResource.java
bundles/org.simantics.issues.ui.ontology/graph.tg
bundles/org.simantics.issues.ui.ontology/graph/IssueUI.pgraph
bundles/org.simantics.issues.ui.ontology/src/org/simantics/issues/ui/ontology/IssueUIResource.java
bundles/org.simantics.issues.ui/adapters.xml
bundles/org.simantics.issues.ui/plugin.xml
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceHierarchyRule.java [new file with mode: 0644]
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceRule.java [new file with mode: 0644]
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/IssueImageRule.java
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/IssueLabelRule.java
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/ModeledActions.java [deleted file]
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/handler/RunActiveValidations.java
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/handler/UpdateIssuesForOpenDiagrams.java

index 40d7f2ec3dcfc92e14f82a20007d00aa81458f8c..1803d427438f7e66488695f7343e632155ff84fe 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2017 Association for Decentralized Information Management
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - #6948
  *******************************************************************************/
 package org.simantics.issues.common;
 
@@ -16,18 +17,17 @@ import java.util.Collection;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.request.ObjectsWithType;
-import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.common.request.ResourceRead2;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.issues.ontology.IssueResource;
 import org.simantics.operation.Layer0X;
 
 /**
  * @author Tuukka Lehtonen
  */
-public class ActiveModelIssueSources extends ResourceRead<Collection<Resource>> {
+public class ActiveModelIssueSources extends ResourceRead2<Collection<Resource>> {
 
-    public ActiveModelIssueSources(Resource resource) {
-        super(resource);
+    public ActiveModelIssueSources(Resource resource, Resource expectedSourceType) {
+        super(resource, expectedSourceType);
     }
 
     @Override
@@ -36,7 +36,7 @@ public class ActiveModelIssueSources extends ResourceRead<Collection<Resource>>
                 new ObjectsWithType(
                         resource,
                         Layer0X.getInstance(graph).Activates,
-                        IssueResource.getInstance(graph).ContinuousIssueSource)
+                        resource2)
         );
     }
 
index 3f593e6431cc6c0084d5e54be284d1e1fbc80ec0..b44e80f7407d19acefe31ccd02ff174ede3418e4 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2017 Association for Decentralized Information Management
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - #6948
  *******************************************************************************/
 package org.simantics.issues.common;
 
@@ -16,28 +17,26 @@ import java.util.Collection;
 
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
-import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.common.request.ResourceRead2;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.ActiveModels;
 
 /**
  * @author Tuukka Lehtonen
  */
-public class ActiveProjectIssueSources extends ResourceRead<Collection<Resource>> {
+public class ActiveProjectIssueSources extends ResourceRead2<Collection<Resource>> {
 
-    public ActiveProjectIssueSources(Resource resource) {
-        super(resource);
+    public ActiveProjectIssueSources(Resource resource, Resource expectedType) {
+        super(resource, expectedType);
     }
 
     @Override
     public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
-       
-       ArrayList<Resource> result = new ArrayList<Resource>();
-       for(Resource model : graph.sync(new ActiveModels(resource))) {
-               result.addAll(graph.sync(new ActiveModelIssueSources(model)));
-       }
-       return result;
-       
+        ArrayList<Resource> result = new ArrayList<>();
+        for (Resource model : graph.syncRequest(new ActiveModels(resource))) {
+            result.addAll(graph.syncRequest(new ActiveModelIssueSources(model, resource2)));
+        }
+        return result;
     }
 
 }
diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DynamicIssueSources.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DynamicIssueSources.java
new file mode 100644 (file)
index 0000000..c0b0ade
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.issues.common;
+
+import java.util.Set;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.request.PossibleVariable;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.issues.ontology.IssueResource;
+
+import gnu.trove.set.hash.THashSet;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.27
+ */
+public class DynamicIssueSources extends ResourceRead<Set<Variable>> {
+
+    public DynamicIssueSources(Resource project) {
+        super(project);
+    }
+
+    @Override
+    public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+        IssueResource ISSUE = IssueResource.getInstance(graph);
+        Set<Variable> result = new THashSet<>();
+        for (Resource source : graph.syncRequest(new ActiveProjectIssueSources(resource, ISSUE.DynamicIssueSource))) {
+            boolean selected = graph.hasStatement(source, ISSUE.IssueSource_Selected);
+            if (!selected)
+                continue;
+            Variable v = graph.syncRequest(new PossibleVariable(source));
+            if (v != null)
+                result.add(v);
+        }
+        return result;
+    }
+
+}
index 866323bab9d1132d16d86eb529901e789ed3495c..bb0c8a5b189c1ee5f0b11905f18e3cad4bae1183 100644 (file)
@@ -278,7 +278,7 @@ public class IssueUtils {
     public static Disposable listenActiveProjectIssueSources(RequestProcessor processor, Resource project) throws DatabaseException {
         final AtomicBoolean disposed = new AtomicBoolean(false);
         processor.syncRequest(
-                new ActiveProjectIssueSources(project),
+                new ActiveProjectIssueSources(project, IssueResource.getInstance(processor).ContinuousIssueSource),
                 new ActiveIssueSourceListener(disposed));
         return new Disposable() {
             @Override
index 9d2df7a04e098f31b2c92dfd189cfbc51c5032cc..9931ec64b50a540e6f375fc31a546154bc171356 100644 (file)
@@ -33,13 +33,13 @@ public class SelectedModelBatchIssueSources extends ResourceRead<Collection<Reso
 
     @Override
     public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
-       Layer0 L0 = Layer0.getInstance(graph);
-       IssueResource ISSUE = IssueResource.getInstance(graph);
-       ArrayList<Resource> result = new ArrayList<Resource>();
-       for(Resource issueSource : graph.sync(new ObjectsWithType(resource, L0.ConsistsOf, ISSUE.IssueSource))) {
-               if(graph.hasStatement(issueSource,  ISSUE.IssueSource_Selected)) result.add(issueSource);
-       }
-       return result;
+        Layer0 L0 = Layer0.getInstance(graph);
+        IssueResource ISSUE = IssueResource.getInstance(graph);
+        ArrayList<Resource> result = new ArrayList<>();
+        for(Resource issueSource : graph.sync(new ObjectsWithType(resource, L0.ConsistsOf, ISSUE.IssueSource))) {
+            if(graph.hasStatement(issueSource, ISSUE.IssueSource_Selected)) result.add(issueSource);
+        }
+        return result;
     }
 
 }
index 23e0bb966130559958b64a621b58761346a6a198..d0ad31bf4c0463847af4658c7484b4f053f0fcaf 100644 (file)
Binary files a/bundles/org.simantics.issues.ontology/graph.tg and b/bundles/org.simantics.issues.ontology/graph.tg differ
index f97f68240f1a57faf44ed825ab613b23220235cd..3d428ed595088b49d085a52e55ab8837e8d5f0fd 100644 (file)
@@ -24,6 +24,9 @@ ISSUE.IssueSource <T L0.Entity : ISSUE.IssueSourceType
 ISSUE.ContinuousIssueSource <T ISSUE.IssueSource
     >-- ISSUE.ContinuousIssueSource.lastUpdateRevision --> L0.Long <R L0.HasProperty : L0.FunctionalRelation
 
+ISSUE.DynamicIssueSource <T ISSUE.IssueSource
+    L0.HasDescription "A dynamic issue source is a source that is browsed purely through the Variable interface to produce a single subtree to represent issues. The issues do not have to have a database resource representation backing them."
+
 ISSUE.Issue <T L0.Entity
     L0.HasDescription "A notification of specified severity about an issue in the model."
     >-- ISSUE.Issue.HasContext <R L0.IsRelatedTo
index 93aa7480f9424b5a64b53b05747fd0dd1addd072..0bb8fd55f46c977de1af7f5f1fc3c735c14d4611 100644 (file)
@@ -13,6 +13,7 @@ public class IssueResource {
     public final Resource ContinuousIssueSource;
     public final Resource ContinuousIssueSource_lastUpdateRevision;
     public final Resource ContinuousIssueSource_lastUpdateRevision_Inverse;
+    public final Resource DynamicIssueSource;
     public final Resource Functions;
     public final Resource Functions_defaultDescription;
     public final Resource Functions_dependencyBaseRealizationFunction;
@@ -78,6 +79,7 @@ public class IssueResource {
         public static final String ContinuousIssueSource = "http://www.simantics.org/Issue-1.2/ContinuousIssueSource";
         public static final String ContinuousIssueSource_lastUpdateRevision = "http://www.simantics.org/Issue-1.2/ContinuousIssueSource/lastUpdateRevision";
         public static final String ContinuousIssueSource_lastUpdateRevision_Inverse = "http://www.simantics.org/Issue-1.2/ContinuousIssueSource/lastUpdateRevision/Inverse";
+        public static final String DynamicIssueSource = "http://www.simantics.org/Issue-1.2/DynamicIssueSource";
         public static final String Functions = "http://www.simantics.org/Issue-1.2/Functions";
         public static final String Functions_defaultDescription = "http://www.simantics.org/Issue-1.2/Functions/defaultDescription";
         public static final String Functions_dependencyBaseRealizationFunction = "http://www.simantics.org/Issue-1.2/Functions/dependencyBaseRealizationFunction";
@@ -153,6 +155,7 @@ public class IssueResource {
         ContinuousIssueSource = getResourceOrNull(graph, URIs.ContinuousIssueSource);
         ContinuousIssueSource_lastUpdateRevision = getResourceOrNull(graph, URIs.ContinuousIssueSource_lastUpdateRevision);
         ContinuousIssueSource_lastUpdateRevision_Inverse = getResourceOrNull(graph, URIs.ContinuousIssueSource_lastUpdateRevision_Inverse);
+        DynamicIssueSource = getResourceOrNull(graph, URIs.DynamicIssueSource);
         Functions = getResourceOrNull(graph, URIs.Functions);
         Functions_defaultDescription = getResourceOrNull(graph, URIs.Functions_defaultDescription);
         Functions_dependencyBaseRealizationFunction = getResourceOrNull(graph, URIs.Functions_dependencyBaseRealizationFunction);
index 50682c6e64dc576118bb4f8b50784bc41dfe575e..fc1fd6498348e1fc77a615a673e8e1fdb2a8b79f 100644 (file)
Binary files a/bundles/org.simantics.issues.ui.ontology/graph.tg and b/bundles/org.simantics.issues.ui.ontology/graph.tg differ
index 74296d8bc035f939c8b1c6e0613a7ac57960f93d..abc2da18bc877746ef74cbac9ab166ef5411e779 100644 (file)
@@ -30,38 +30,26 @@ UI.ShowNormalIssues <R L0.HasProperty : L0.FunctionalRelation
 UI.ShowUserIssues <R L0.HasProperty : L0.FunctionalRelation
     L0.HasRange L0.Boolean
 
-//--------------------------------------------------------------------------
-// Issue Browse context
 
-IBC = UI.IssueBrowseContext : VP.BrowseContext
+//--------------------------------------------------------------------------
+// ACTIONS
 
-// Rules
-IBC.IssueLabelDecorationRule : VP.LabelDecorationRule
-IBC.IssueImageDecorationRule : VP.ImageDecorationRule
-IBC.IssueContextDropAction : ACT.DropAction
-IBC.UserIssueTest : VP.Test
+ACTIONS = UI.Actions : L0.Library
 
-// UIpoint
-IBC
-    @VP.customLabelDecorationRule ISSUE.Issue IBC.IssueLabelDecorationRule
-    @VP.dropActionContribution ISSUE.Issue IBC.IssueContextDropAction 1.0
+ACTIONS.SeverityActionCategory : VP.ActionCategory
+    L0.HasLabel "Set Severity"
+    VP.ActionCategory.IsSubmenu L0.True
 
-//--------------------------------------------------------------------------
-// Batch Issue Source Browse context
+ACTIONS.SetSeverityAction <T ACT.Action
+    >-- ACTIONS.SetSeverityAction.HasSeverity --> ISSUE.Severity <R L0.DependsOn : L0.FunctionalRelation
 
-BISBC = UI.BatchIssueSourceBrowseContext : VP.BrowseContext
 
-// Rules
-BISBC.IssueSourceRule : VP.ChildRule
-BISBC.IssueSourceLabelRule : VP.LabelRule
-BISBC.IssueSourceCheckRule : VP.CheckedStateRule
+//--------------------------------------------------------------------------
+// Issue Browse context
 
-// UIpoint
-BISBC
-    @VP.relationChildRule         SIMU.Model   L0.ConsistsOf ISSUE.IssueSource
-    @VP.customLabelRule           ISSUE.IssueSource VP.ResourceLabelLabelRule
-    @VP.customCheckedStateRule    ISSUE.IssueSource BISBC.IssueSourceCheckRule
+IBC = UI.IssueBrowseContext : VP.BrowseContext
 
+// Node types
 IBC.FatalFolder : VP.ResourceNodeType
 IBC.ErrorFolder : VP.ResourceNodeType
 IBC.WarningFolder : VP.ResourceNodeType
@@ -71,18 +59,36 @@ IBC.UnknownFolder : VP.ResourceNodeType
 
 IBC.Issue : VP.NodeType
     VP.HasContentType "Variable"
+IBC.DynamicIssueHierarchyNode : VP.NodeType
+    VP.HasContentType "Variable"
 
+// Rules
 IBC.SeverityFolderRule <T VP.ChildRule
     >-- IBC.SeverityFolderRule.HasSeverity --> ISSUE.Severity <R L0.DependsOn : L0.FunctionalRelation
-
 IBC.SeverityChildRule <T VP.ChildRule
     >-- IBC.SeverityChildRule.HasSeverity --> ISSUE.Severity <R L0.DependsOn : L0.FunctionalRelation
+IBC.DynamicIssueSourceRule : VP.ChildRule
+    L0.HasDescription "Looks for all ISSUE.DynamicIssueSource instances from the active index roots. Produces a separate subtree out of each dynamic issue source."
+IBC.DynamicIssueSourceHierarchyRule : VP.ChildRule
+    L0.HasDescription "Looks for all ISSUE.DynamicIssueSource instances from the active index roots. Produces a separate subtree out of each dynamic issue source."
 
 IBC.SeverityFolderLabelRule <T VP.LabelRule
     >-- IBC.SeverityFolderLabelRule.HasSeverity --> ISSUE.Severity <R L0.DependsOn : L0.FunctionalRelation
+IBC.IssueLabelRule : VP.LabelRule
+IBC.IssueImageRule : VP.ImageRule
+
+IBC.IssueLabelDecorationRule : VP.LabelDecorationRule
+IBC.IssueImageDecorationRule : VP.ImageDecorationRule
+IBC.IssueContextDropAction : ACT.DropAction
+IBC.UserIssueTest : VP.Test
 
+// Browse context
 IBC
     // Structure
+    @VP.customChildRule PROJECT.Project 
+        _ : IBC.SeverityFolderRule
+            IBC.SeverityFolderRule.HasSeverity ISSUE.Severity.Note
+        IBC.NoteFolder
     @VP.customChildRule PROJECT.Project 
         _ : IBC.SeverityFolderRule
             IBC.SeverityFolderRule.HasSeverity ISSUE.Severity.Fatal
@@ -99,11 +105,10 @@ IBC
         _ : IBC.SeverityFolderRule
             IBC.SeverityFolderRule.HasSeverity ISSUE.Severity.Info
         IBC.InfoFolder
-    @VP.customChildRule PROJECT.Project 
-        _ : IBC.SeverityFolderRule
-            IBC.SeverityFolderRule.HasSeverity ISSUE.Severity.Note
-        IBC.NoteFolder
-        
+    @VP.customChildRule PROJECT.Project
+        IBC.DynamicIssueSourceRule
+        IBC.DynamicIssueHierarchyNode
+    
     // Content
     @VP.customChildRule IBC.FatalFolder 
         _ : IBC.SeverityChildRule
@@ -125,7 +130,10 @@ IBC
         _ : IBC.SeverityChildRule
             IBC.SeverityChildRule.HasSeverity ISSUE.Severity.Note
         IBC.Issue
-        
+    @VP.customChildRule IBC.DynamicIssueHierarchyNode
+        IBC.DynamicIssueSourceHierarchyRule
+        IBC.DynamicIssueHierarchyNode
+    
     // Labels
     @VP.customLabelRule IBC.FatalFolder 
         _ : IBC.SeverityFolderLabelRule
@@ -142,9 +150,10 @@ IBC
     @VP.customLabelRule IBC.NoteFolder 
         _ : IBC.SeverityFolderLabelRule
             IBC.SeverityFolderLabelRule.HasSeverity ISSUE.Severity.Note
-    @VP.customLabelRule IBC.Issue 
-        IBC.IssueLabelRule : VP.ChildRule
+    @VP.customLabelRule IBC.Issue IBC.IssueLabelRule
+    @VP.customLabelRule IBC.DynamicIssueHierarchyNode IBC.IssueLabelRule
     @VP.customVisualsRuleWithPriorityAndTest IBC.Issue VP.VariableLabelModifierRule  1.0 IBC.UserIssueTest
+    @VP.customLabelDecorationRule ISSUE.Issue IBC.IssueLabelDecorationRule
     
     // Images
     @VP.constantImageRule IBC.FatalFolder SILK.bomb
@@ -153,20 +162,13 @@ IBC
     @VP.constantImageRule IBC.InfoFolder SILK.information
     @VP.constantImageRule IBC.NoteFolder SILK.note
     @VP.constantImageRule IBC.UnknownFolder SILK.help
-    @VP.customLabelRule IBC.Issue 
-        IBC.IssueImageRule : VP.ImageRule
-
-// ACTIONS
-
-ACTIONS = UI.Actions : L0.Library
-
-ACTIONS.SeverityActionCategory : VP.ActionCategory
-    L0.HasLabel "Set Severity"
-    VP.ActionCategory.IsSubmenu L0.True
-
-ACTIONS.SetSeverityAction <T ACT.Action
-    >-- ACTIONS.SetSeverityAction.HasSeverity --> ISSUE.Severity <R L0.DependsOn : L0.FunctionalRelation
+    @VP.customImageRule IBC.Issue IBC.IssueImageRule
+    @VP.customImageRule IBC.DynamicIssueHierarchyNode IBC.IssueImageRule
+    
+    // Drop actions
+    @VP.dropActionContribution ISSUE.Issue IBC.IssueContextDropAction 1.0
 
+// Action context for context menu
 IAC = UI.ActionContext : VP.BrowseContext
     // Set severity
     @VP.actionContribution "Fatal" IBC.Issue SILK.bomb ACTIONS.SeverityActionCategory 
@@ -193,6 +195,27 @@ IAC = UI.ActionContext : VP.BrowseContext
     @VP.actionContribution "Unhide" IBC.Issue SILK.shading VP.EditActionCategory 
         ACTIONS.Unhide : ACT.Action
 
+
+//--------------------------------------------------------------------------
+// Batch Issue Source Browse context
+
+BISBC = UI.BatchIssueSourceBrowseContext : VP.BrowseContext
+
+// Rules
+//BISBC.IssueSourceRule : VP.ChildRule
+//BISBC.IssueSourceLabelRule : VP.LabelRule
+BISBC.IssueSourceCheckRule : VP.CheckedStateRule
+
+// UIpoint
+BISBC
+    @VP.relationChildRule         SIMU.Model   L0.ConsistsOf ISSUE.IssueSource
+    @VP.customLabelRule           ISSUE.IssueSource VP.ResourceLabelLabelRule
+    @VP.customCheckedStateRule    ISSUE.IssueSource BISBC.IssueSourceCheckRule
+
+
+//--------------------------------------------------------------------------
+// Issue view UI definitions
+
 UI.IssueView.Description 
     @VIEWS.Explorer.Column.full "single" "Description" "LEFT" 150 "Description" true 1
 UI.IssueView.Resource 
@@ -226,7 +249,7 @@ UI.IssueView : VIEWS.TabFolder
                             VIEWS.Explorer.persistor MOD.Functions.standardPersistor
                             VIEWS.Explorer.browseContext _ : VIEWS.ResourceURI
                               VIEWS.ResourceURI.HasResource IBC
-            UI.IssueView.Batch : VIEWS.Composite            
+            UI.IssueView.Batch : VIEWS.Composite
                 SG.Node.children _ : L0.List
                     @L0.list
                         UI.IssueView.Batch.Explorer : VIEWS.Explorer
index ef0d6a24f27f2280050c840176b02567c62c4f02..95eadd6a977f4f40d3914b43bd85748160bdfcee 100644 (file)
@@ -22,12 +22,13 @@ public class IssueUIResource {
     public final Resource Actions_Unresolve;
     public final Resource BatchIssueSourceBrowseContext;
     public final Resource BatchIssueSourceBrowseContext_IssueSourceCheckRule;
-    public final Resource BatchIssueSourceBrowseContext_IssueSourceLabelRule;
-    public final Resource BatchIssueSourceBrowseContext_IssueSourceRule;
     public final Resource Functions;
     public final Resource Functions_activeModel;
     public final Resource Functions_issueSourceSelected;
     public final Resource IssueBrowseContext;
+    public final Resource IssueBrowseContext_DynamicIssueHierarchyNode;
+    public final Resource IssueBrowseContext_DynamicIssueSourceHierarchyRule;
+    public final Resource IssueBrowseContext_DynamicIssueSourceRule;
     public final Resource IssueBrowseContext_ErrorFolder;
     public final Resource IssueBrowseContext_FatalFolder;
     public final Resource IssueBrowseContext_InfoFolder;
@@ -79,12 +80,13 @@ public class IssueUIResource {
         public static final String Actions_Unresolve = "http://www.simantics.org/IssueUI-1.1/Actions/Unresolve";
         public static final String BatchIssueSourceBrowseContext = "http://www.simantics.org/IssueUI-1.1/BatchIssueSourceBrowseContext";
         public static final String BatchIssueSourceBrowseContext_IssueSourceCheckRule = "http://www.simantics.org/IssueUI-1.1/BatchIssueSourceBrowseContext/IssueSourceCheckRule";
-        public static final String BatchIssueSourceBrowseContext_IssueSourceLabelRule = "http://www.simantics.org/IssueUI-1.1/BatchIssueSourceBrowseContext/IssueSourceLabelRule";
-        public static final String BatchIssueSourceBrowseContext_IssueSourceRule = "http://www.simantics.org/IssueUI-1.1/BatchIssueSourceBrowseContext/IssueSourceRule";
         public static final String Functions = "http://www.simantics.org/IssueUI-1.1/Functions";
         public static final String Functions_activeModel = "http://www.simantics.org/IssueUI-1.1/Functions/activeModel";
         public static final String Functions_issueSourceSelected = "http://www.simantics.org/IssueUI-1.1/Functions/issueSourceSelected";
         public static final String IssueBrowseContext = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext";
+        public static final String IssueBrowseContext_DynamicIssueHierarchyNode = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext/DynamicIssueHierarchyNode";
+        public static final String IssueBrowseContext_DynamicIssueSourceHierarchyRule = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext/DynamicIssueSourceHierarchyRule";
+        public static final String IssueBrowseContext_DynamicIssueSourceRule = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext/DynamicIssueSourceRule";
         public static final String IssueBrowseContext_ErrorFolder = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext/ErrorFolder";
         public static final String IssueBrowseContext_FatalFolder = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext/FatalFolder";
         public static final String IssueBrowseContext_InfoFolder = "http://www.simantics.org/IssueUI-1.1/IssueBrowseContext/InfoFolder";
@@ -146,12 +148,13 @@ public class IssueUIResource {
         Actions_Unresolve = getResourceOrNull(graph, URIs.Actions_Unresolve);
         BatchIssueSourceBrowseContext = getResourceOrNull(graph, URIs.BatchIssueSourceBrowseContext);
         BatchIssueSourceBrowseContext_IssueSourceCheckRule = getResourceOrNull(graph, URIs.BatchIssueSourceBrowseContext_IssueSourceCheckRule);
-        BatchIssueSourceBrowseContext_IssueSourceLabelRule = getResourceOrNull(graph, URIs.BatchIssueSourceBrowseContext_IssueSourceLabelRule);
-        BatchIssueSourceBrowseContext_IssueSourceRule = getResourceOrNull(graph, URIs.BatchIssueSourceBrowseContext_IssueSourceRule);
         Functions = getResourceOrNull(graph, URIs.Functions);
         Functions_activeModel = getResourceOrNull(graph, URIs.Functions_activeModel);
         Functions_issueSourceSelected = getResourceOrNull(graph, URIs.Functions_issueSourceSelected);
         IssueBrowseContext = getResourceOrNull(graph, URIs.IssueBrowseContext);
+        IssueBrowseContext_DynamicIssueHierarchyNode = getResourceOrNull(graph, URIs.IssueBrowseContext_DynamicIssueHierarchyNode);
+        IssueBrowseContext_DynamicIssueSourceHierarchyRule = getResourceOrNull(graph, URIs.IssueBrowseContext_DynamicIssueSourceHierarchyRule);
+        IssueBrowseContext_DynamicIssueSourceRule = getResourceOrNull(graph, URIs.IssueBrowseContext_DynamicIssueSourceRule);
         IssueBrowseContext_ErrorFolder = getResourceOrNull(graph, URIs.IssueBrowseContext_ErrorFolder);
         IssueBrowseContext_FatalFolder = getResourceOrNull(graph, URIs.IssueBrowseContext_FatalFolder);
         IssueBrowseContext_InfoFolder = getResourceOrNull(graph, URIs.IssueBrowseContext_InfoFolder);
index 55eb87c84c84166252a850566cb56096f92d78de..0754b4acd2b61b36a3da2ee118baed04d5860340 100644 (file)
@@ -36,7 +36,9 @@
                </type>
                <resource
                        uri="http://www.simantics.org/IssueUI-0.0/IssueBrowseContext/IssueImageRule"
-                       class="org.simantics.issues.ui.IssueImageRule"/>
+                       class="org.simantics.issues.ui.IssueImageRule">
+                       <graph/>
+               </resource>
        </target>
 
        <target interface="org.simantics.db.layer0.adapter.DropActionFactory">
@@ -45,8 +47,7 @@
                        class="org.simantics.issues.ui.contribution.IssueContextDropAction" />
        </target>
 
-    <target interface="org.simantics.browsing.ui.model.children.ChildRule">
-    
+       <target interface="org.simantics.browsing.ui.model.children.ChildRule">
                <type uri="http://www.simantics.org/IssueUI-0.0/IssueBrowseContext/SeverityFolderRule"
                        class="org.simantics.issues.ui.SeverityFolderRule">
                        <this />
                        class="org.simantics.issues.ui.SeverityChildRule">
                        <this />
                </type>
-               
-    </target>
+               <resource uri="http://www.simantics.org/IssueUI-0.0/IssueBrowseContext/DynamicIssueSourceRule"
+                       class="org.simantics.issues.ui.DynamicIssueSourceRule"/>
+               <resource uri="http://www.simantics.org/IssueUI-0.0/IssueBrowseContext/DynamicIssueSourceHierarchyRule"
+                       class="org.simantics.issues.ui.DynamicIssueSourceHierarchyRule"/>
+       </target>
 
        <target interface="org.simantics.db.layer0.adapter.ActionFactory">
 
@@ -74,7 +78,7 @@
                <resource uri="http://www.simantics.org/IssueUI-0.0/Actions/Unhide"
                        class="org.simantics.issues.ui.handler.Unhide"/>
                
-    </target>
-                       
+       </target>
+
 
-</adapters>
\ No newline at end of file
+</adapters>
index 88623c5b2f2bad2db1392b637511c8db2b2ac643..e67d2e12bdc8e5f669a403dc06ca84a944861346 100644 (file)
                 id="org.simantics.issues.actions">
           </dynamic>
           <dynamic
-                class="org.simantics.issues.ui.ModeledActions"
+                class="org.simantics.modeling.ui.actions.ModeledActions:context=http://www.simantics.org/IssueUI-1.1/ActionContext"
                 id="org.simantics.issues.actions2">
           </dynamic>
       </menuContribution>
diff --git a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceHierarchyRule.java b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceHierarchyRule.java
new file mode 100644 (file)
index 0000000..0e61209
--- /dev/null
@@ -0,0 +1,34 @@
+package org.simantics.issues.ui;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.simantics.browsing.ui.model.children.ChildRule;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.27
+ */
+public class DynamicIssueSourceHierarchyRule implements ChildRule {
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Variable.class);
+    }
+
+    @Override
+    public Collection<?> getChildren(ReadGraph graph, Object parent) throws DatabaseException {
+        Variable v = (Variable) parent;
+        return v.getChildren(graph);
+    }
+
+    @Override
+    public Collection<?> getParents(ReadGraph graph, Object child) throws DatabaseException {
+        Variable parent = ((Variable)child).getParent(graph);
+        return parent != null ? Collections.singleton(parent) : Collections.emptyList();
+    }
+
+}
diff --git a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceRule.java b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceRule.java
new file mode 100644 (file)
index 0000000..3a62551
--- /dev/null
@@ -0,0 +1,33 @@
+package org.simantics.issues.ui;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.simantics.browsing.ui.model.children.ChildRule;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.issues.common.DynamicIssueSources;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.27
+ */
+public class DynamicIssueSourceRule implements ChildRule {
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Resource.class);
+    }
+
+    @Override
+    public Collection<?> getChildren(ReadGraph graph, Object parent) throws DatabaseException {
+        return graph.syncRequest(new DynamicIssueSources((Resource) parent));
+    }
+
+    @Override
+    public Collection<?> getParents(ReadGraph graph, Object child) throws DatabaseException {
+        return Collections.singleton(child);
+    }
+
+}
index b19a1f711ed507e7099f9258f92bc1f3e6ec2f7d..10de114c780b55a6b2cb1162940fc57d6ecc7053 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2017 Association for Decentralized Information Management
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - #6948
  *******************************************************************************/
 package org.simantics.issues.ui;
 
@@ -31,6 +32,25 @@ public class IssueImageRule implements ImageRule {
 
     private final String DESCRIPTION = ColumnKeys.SINGLE;
 
+    private final ImageDescriptor tick;
+    private final ImageDescriptor fatal;
+    private final ImageDescriptor error;
+    private final ImageDescriptor warning;
+    private final ImageDescriptor info;
+    private final ImageDescriptor note;
+    private final ImageDescriptor help;
+
+    public IssueImageRule(ReadGraph graph) throws DatabaseException {
+        SilkResources SILK = SilkResources.getInstance(graph);
+        tick = graph.adapt(SILK.tick, ImageDescriptor.class);
+        fatal = graph.adapt(SILK.bomb, ImageDescriptor.class);
+        error = graph.adapt(SILK.exclamation, ImageDescriptor.class);
+        warning = graph.adapt(SILK.error, ImageDescriptor.class);
+        info = graph.adapt(SILK.information, ImageDescriptor.class);
+        note = graph.adapt(SILK.note, ImageDescriptor.class);
+        help = graph.adapt(SILK.help, ImageDescriptor.class);
+    }
+
     @Override
     public boolean isCompatible(Class<?> contentType) {
         return contentType.equals(Variable.class);
@@ -38,26 +58,32 @@ public class IssueImageRule implements ImageRule {
 
     @Override
     public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
+        Variable issue = (Variable) content;
+        String severity = issue.getPossiblePropertyValue(graph, "severity");
+        if (severity == null)
+            return Collections.emptyMap();
+        boolean resolved = isResolved(graph, issue);
+        return Collections.singletonMap(DESCRIPTION, resolved ? tick : toImageDescriptor(severity));
+    }
 
-        Variable issue = (Variable)content;
-
-        IssueResource ISSUE = IssueResource.getInstance(graph);
-        SilkResources SILK = SilkResources.getInstance(graph);
-        String severity = issue.getPropertyValue(graph, "severity");
-
-        // TODO: now to do this with variables?
+    public boolean isResolved(ReadGraph graph, Variable issue) throws DatabaseException {
         Resource issueResource = issue.getPossibleRepresents(graph);
-        boolean resolved = issueResource != null ? graph.hasStatement(issueResource, ISSUE.Resolved) : false;
-        if (resolved)
-            return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.tick, ImageDescriptor.class));
+        if (issueResource != null)
+            return graph.hasStatement(issueResource, IssueResource.getInstance(graph).Resolved);
 
-        if("Fatal".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.bomb, ImageDescriptor.class));
-        else if("Error".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.exclamation, ImageDescriptor.class));
-        else if("Warning".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.error, ImageDescriptor.class));
-        else if("Info".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.information, ImageDescriptor.class));
-        else if("Note".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.note, ImageDescriptor.class));
-        else return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.help, ImageDescriptor.class));
+        Boolean resolved = issue.getPossiblePropertyValue(graph, "resolved");
+        return Boolean.TRUE.equals(resolved);
+    }
 
+    private ImageDescriptor toImageDescriptor(String severity) {
+        switch (severity) {
+        case "Fatal":   return fatal;
+        case "Error":   return error;
+        case "Warning": return warning;
+        case "Info":    return info;
+        case "Note":    return note;
+        default:        return help;
+        }
     }
 
 }
index 1a58f4d81f824e636e3ca6572005e2f0e315e28c..1d9b1099c5dd84fd9d3139cbd4c6523e9b5499bc 100644 (file)
@@ -39,8 +39,6 @@ public class IssueLabelRule implements LabelRule {
     public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
 
         Variable issue = (Variable)content;
-        //Layer0 L0 = Layer0.getInstance(graph);
-        //IssueResource ISSUE = IssueResource.getInstance(graph);
         String description = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "HasDescription") );
         String resource = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "resource") );
         String path = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "path") );
diff --git a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/ModeledActions.java b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/ModeledActions.java
deleted file mode 100644 (file)
index 84118d0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.simantics.issues.ui;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.simantics.issues.ui.ontology.IssueUIResource;
-
-public class ModeledActions extends org.simantics.modeling.ui.actions.ModeledActions {
-
-       final static public Set<String> browseContexts = Collections.singleton(IssueUIResource.URIs.ActionContext);
-
-    public Collection<String> getBrowseContexts() {
-        return browseContexts;
-    }
-
-}
index d2e2572115681744f5f150239cef17ee59f0e2b1..803324613a1501045a4ed7973c9cb70d413df8e5 100644 (file)
@@ -31,6 +31,7 @@ import org.simantics.Simantics;
 import org.simantics.SleepingDatabaseJob;
 import org.simantics.db.Issue;
 import org.simantics.db.ReadGraph;
+import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.common.request.Queries;
@@ -66,7 +67,7 @@ public class RunActiveValidations extends AbstractHandler {
         final Session session = Simantics.getSession();
 
         // 1. query for which composites to run the validation
-        final Collection<BatchIssueSource> validations = new ArrayList<BatchIssueSource>();
+        final Collection<BatchIssueSource> validations = new ArrayList<>();
         final BatchIssueValidationContext context = new BatchIssueValidationContext();
 
         try {
@@ -79,12 +80,9 @@ public class RunActiveValidations extends AbstractHandler {
                             Resource model = session.sync(new PossibleActiveModel(Simantics.getProjectResource()));
                             if(model == null) return;
 
-                            Collection<Resource> activeSources = session.syncRequest(new SelectedModelBatchIssueSources(model));
-                            for(Resource source : activeSources) {
-                                BatchIssueSource bis = session.syncRequest(Queries.adapt(source, BatchIssueSource.class, true));
-                                if(bis != null)
-                                    validations.add(bis);
-                            }
+                            toBatchIssueSources(session,
+                                    session.syncRequest(new SelectedModelBatchIssueSources(model)),
+                                    validations);
 
                             SubMonitor.convert(monitor, "Preparing resources for validation", 100);
                             context.contexts = Collections.singletonList(model);
@@ -111,12 +109,21 @@ public class RunActiveValidations extends AbstractHandler {
             // Operation cancelled, ignore.
             return;
         }
-        
+
         if(!validations.isEmpty() && !context.contexts.isEmpty())
             run(postValidation, validations, context);
 
     }
 
+    static Collection<BatchIssueSource> toBatchIssueSources(RequestProcessor processor, Collection<Resource> sources, Collection<BatchIssueSource> result) throws DatabaseException {
+        for (Resource source : sources) {
+            BatchIssueSource bis = processor.syncRequest(Queries.adapt(source, BatchIssueSource.class, true));
+            if (bis != null)
+                result.add(bis);
+        }
+        return result;
+    }
+
     public static void run(Runnable postValidation, final Collection<BatchIssueSource> validations, final BatchIssueValidationContext context) {
         // Run the validations for the selected composites
         SleepingDatabaseJob dbLock = new SleepingDatabaseJob("Validation");
@@ -139,7 +146,7 @@ public class RunActiveValidations extends AbstractHandler {
                                     @Override
                                     public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
                                         IssueResource ISSUE = IssueResource.getInstance(graph);
-                                        ArrayList<Resource> result = new ArrayList<Resource>();
+                                        ArrayList<Resource> result = new ArrayList<>();
                                         for (Resource issue : graph.syncRequest(new ManagedIssues(resource))) {
                                             Resource list = graph.getSingleObject(issue, ISSUE.Issue_HasContexts);
                                             List<Resource> l = ListUtils.toList(graph, list);
index 9b2040c4b01bf854f753a0f8811414d99d33b936..0f7cec48de62500cab7e84868569aa040d0b053c 100644 (file)
@@ -34,7 +34,6 @@ import org.simantics.browsing.ui.common.ErrorLogger;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
-import org.simantics.db.common.request.Queries;
 import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.ActiveModels;
@@ -67,7 +66,7 @@ public class UpdateIssuesForOpenDiagrams extends AbstractHandler {
     }
 
     public static void update(Runnable postValidation) throws DatabaseException, PartInitException {
-        final List<IResourceEditorInput> inputs = new ArrayList<IResourceEditorInput>();
+        final List<IResourceEditorInput> inputs = new ArrayList<>();
         IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
         for (IWorkbenchWindow wb : windows) {
             IWorkbenchPage pages[] = wb.getPages();
@@ -82,9 +81,9 @@ public class UpdateIssuesForOpenDiagrams extends AbstractHandler {
             }
         }
 
-        final Set<Resource> compositesToValidate = new TreeSet<Resource>();
-        final Collection<BatchIssueSource> validations = new ArrayList<BatchIssueSource>();
-        final Collection<Resource> activeModels = new ArrayList<Resource>();
+        final Set<Resource> compositesToValidate = new TreeSet<>();
+        final Collection<BatchIssueSource> validations = new ArrayList<>();
+        final Collection<Resource> activeModels = new ArrayList<>();
        final BatchIssueValidationContext context = new BatchIssueValidationContext();
 
         try {
@@ -98,11 +97,9 @@ public class UpdateIssuesForOpenDiagrams extends AbstractHandler {
                         activeModels.addAll(session.syncRequest(new ActiveModels(project)));
                         if(activeModels.size() != 1) return;
 
-                        Collection<Resource> activeSources = session.syncRequest(new SelectedModelBatchIssueSources(activeModels.iterator().next()));
-                        for(Resource source : activeSources) {
-                            BatchIssueSource bis = session.syncRequest(Queries.adapt(source, BatchIssueSource.class));
-                            validations.add(bis);
-                        }
+                        RunActiveValidations.toBatchIssueSources(session,
+                                session.syncRequest(new SelectedModelBatchIssueSources(activeModels.iterator().next())),
+                                validations);
 
                         session.syncRequest(new ReadRequest() {
                             @Override