]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/AssignSymbolGroupRequest.java
Disable SCL Issue provider by default
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / AssignSymbolGroupRequest.java
1 package org.simantics.modeling;
2
3 import java.util.Collection;
4
5 import org.simantics.db.Resource;
6 import org.simantics.db.WriteGraph;
7 import org.simantics.db.common.request.WriteRequest;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.diagram.stubs.DiagramResource;
10
11 public class AssignSymbolGroupRequest extends WriteRequest {
12     
13     Collection<Resource>    addedSymbolGroup;
14     Collection<Resource>    removedSymbolGroup;
15     Collection<Resource>    symbols;
16     
17     public AssignSymbolGroupRequest(Collection<Resource> addedSymbolGroups, Collection<Resource> removedSymbolGroups, Collection<Resource> symbols) {
18         this.addedSymbolGroup = addedSymbolGroups;
19         this.removedSymbolGroup = removedSymbolGroups;
20         this.symbols = symbols;
21     }
22
23     @Override
24     public void perform(WriteGraph graph) throws DatabaseException {
25         assignSymbolGroup(graph, addedSymbolGroup, removedSymbolGroup, symbols);
26     }
27
28     public static void assignSymbolGroup(WriteGraph graph, Collection<Resource> addedSymbolGroups, Collection<Resource> removedSymbolGroups, Collection<Resource> symbols) throws DatabaseException {
29         graph.markUndoPoint();
30         DiagramResource DIA = DiagramResource.getInstance(graph);
31         for (Resource symbol : symbols) {
32             for (Resource group : addedSymbolGroups)
33                 graph.claim(group, DIA.HasSymbol, symbol);
34             for (Resource group : removedSymbolGroups)
35                 graph.deny(group, DIA.HasSymbol, symbol);
36         }
37     }
38     
39 }