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