/*******************************************************************************
- * 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
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - #6948
*******************************************************************************/
package org.simantics.issues.common;
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
new ObjectsWithType(
resource,
Layer0X.getInstance(graph).Activates,
- IssueResource.getInstance(graph).ContinuousIssueSource)
+ resource2)
);
}
/*******************************************************************************
- * 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
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - #6948
*******************************************************************************/
package org.simantics.issues.common;
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;
}
}
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+
+}
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
@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;
}
}
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
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;
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";
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);
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
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
_ : 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
_ : 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
@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
@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
@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
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
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;
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";
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);
</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">
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">
<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>
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>
--- /dev/null
+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();
+ }
+
+}
--- /dev/null
+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);
+ }
+
+}
/*******************************************************************************
- * 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
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - #6948
*******************************************************************************/
package org.simantics.issues.ui;
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);
@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;
+ }
}
}
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") );
+++ /dev/null
-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;
- }
-
-}
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;
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 {
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);
// 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");
@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);
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;
}
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();
}
}
- 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 {
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