]> gerrit.simantics Code Review - simantics/platform.git/blob
66acdcefef4e4faabc008b15e25ae433d984ddcc
[simantics/platform.git] /
1 package org.simantics.spreadsheet.graph.synchronization;
2
3 import java.util.Collection;
4 import java.util.Map;
5
6 import org.simantics.databoard.adapter.AdaptException;
7 import org.simantics.databoard.binding.mutable.Variant;
8 import org.simantics.spreadsheet.graph.function.LineContentBean;
9 import org.simantics.structural.synchronization.utils.CommandBuilder;
10 import org.simantics.structural.synchronization.utils.ModuleUpdateContext;
11 import org.simantics.structural.synchronization.utils.ModuleUpdaterBase;
12 import org.simantics.structural.synchronization.utils.PropertyUpdateRule;
13
14 public class LineUpdater extends ModuleUpdaterBase<SheetLineComponent> {
15         
16         public LineUpdater(String id) {
17                 super(id);
18                 addPropertyUpdateRule(new PropertyUpdateRule<SheetLineComponent>() {
19                         
20                         @Override
21                         public String getPropertyName() {
22                                 return "content";
23                         }
24                         
25                         @Override
26                         public void apply(ModuleUpdateContext<SheetLineComponent> context, boolean isCreating,
27                                         Map<String, Variant> propertyMap, Map<String, Collection<String>> connectionMap, Variant value) {
28                                 
29                                 LineCommandBuilder builder = context.<LineCommandBuilder>getConcreteCommand();
30                 try {
31                     LineContentBean valuee = (LineContentBean) value.getValue(LineContentBean.BINDING);
32                     builder.bean = valuee;
33                 } catch (AdaptException e) {
34                     e.printStackTrace();
35                 } catch (ClassCastException e) {
36                     e.printStackTrace();
37                 }
38 //                              if (valuee instanceof LineContentBean)
39 //                          
40 //                      else
41 //                          System.err.println("valuee is instanceof " + valuee.getClass().getSimpleName() + " " + valuee);
42                         
43                         }
44                         
45                 });
46         }
47
48         @Override
49         public CommandBuilder createAddCommandBuilder(String name) {
50                 return new LineCommandBuilder(name, false);
51         }
52
53         @Override
54         public CommandBuilder createUpdateCommandBuilder(String name) {
55                 return new LineCommandBuilder(name, true);
56         }
57         
58 }