]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineUpdater.java
Improved exception message
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / synchronization / LineUpdater.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.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.base.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 }