1 package org.simantics.modeling;
3 import java.util.Collection;
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;
11 public class AssignSymbolGroupRequest extends WriteRequest {
13 Collection<Resource> addedSymbolGroup;
14 Collection<Resource> removedSymbolGroup;
15 Collection<Resource> symbols;
17 public AssignSymbolGroupRequest(Collection<Resource> addedSymbolGroups, Collection<Resource> removedSymbolGroups, Collection<Resource> symbols) {
18 this.addedSymbolGroup = addedSymbolGroups;
19 this.removedSymbolGroup = removedSymbolGroups;
20 this.symbols = symbols;
24 public void perform(WriteGraph graph) throws DatabaseException {
25 assignSymbolGroup(graph, addedSymbolGroup, removedSymbolGroup, symbols);
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);