]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineNodeUpdater.java
Spreadsheet changes
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / synchronization / LineNodeUpdater.java
1 package org.simantics.spreadsheet.graph.synchronization;
2
3 import java.util.Collection;
4 import java.util.Map;
5
6 import org.simantics.databoard.binding.mutable.Variant;
7 import org.simantics.spreadsheet.solver.SheetLineComponent;
8 import org.simantics.structural.synchronization.base.CommandBuilder;
9 import org.simantics.structural.synchronization.base.ModuleUpdateContext;
10 import org.simantics.structural.synchronization.base.ModuleUpdaterBase;
11 import org.simantics.structural.synchronization.base.PropertyUpdateRule;
12
13 public class LineNodeUpdater extends ModuleUpdaterBase<SheetLineComponent> {
14         
15         public LineNodeUpdater(String id) {
16                 
17                 super(id);
18                 
19                 isComposite = true;
20                 
21                 addPropertyUpdateRule(new PropertyUpdateRule<SheetLineComponent>() {
22                         
23                         @Override
24                         public String getPropertyName() {
25                                 return "keys";
26                         }
27                         
28                         @Override
29                         public void apply(ModuleUpdateContext<SheetLineComponent> context, boolean isCreating,
30                                         Map<String, Variant> propertyMap, Map<String, Collection<String>> connectionMap, Variant value) {
31                                 
32                                 LinesCommandBuilder builder = context.<LinesCommandBuilder>getConcreteCommand();
33                                 Variant v = propertyMap.get("keys");
34                                 if (v != null & v.getValue() != null)
35                                     builder.keys = (int[])v.getValue();
36                                 
37                         }
38                         
39                 });
40                 
41         }
42
43         @Override
44         public CommandBuilder createAddCommandBuilder(String name) {
45                 return new LinesCommandBuilder(name, false);
46         }
47
48         @Override
49         public CommandBuilder createUpdateCommandBuilder(String name) {
50                 return new LinesCommandBuilder(name, true);
51         }
52         
53 }