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