]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / synchronization / LinesCommandBuilder.java
diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java
new file mode 100644 (file)
index 0000000..37a6513
--- /dev/null
@@ -0,0 +1,72 @@
+package org.simantics.spreadsheet.graph.synchronization;\r
+\r
+import org.simantics.spreadsheet.graph.SpreadsheetBook;\r
+import org.simantics.spreadsheet.graph.SpreadsheetLines;\r
+import org.simantics.structural.synchronization.base.CommandBuilder;\r
+import org.simantics.structural.synchronization.base.Solver;\r
+\r
+public class LinesCommandBuilder implements CommandBuilder {\r
+       \r
+       private final boolean update;\r
+    private String name;\r
+       int[] keys;\r
+       \r
+       public LinesCommandBuilder(String name, boolean update) {\r
+               this.name = name;\r
+               this.update = update;\r
+       }\r
+\r
+       @Override\r
+       public void apply(Solver solver) {\r
+//         if (update)\r
+//             return;\r
+               \r
+               SpreadsheetBook book = solver.getConcreteSolver();\r
+               SpreadsheetLines node = book.ensureSubprocess(name);\r
+               node.setKeys(keys);\r
+               \r
+//             String path = name.substring(0, name.lastIndexOf("/"));\r
+//             String lineName = name.substring(name.lastIndexOf("/")+1);\r
+//             int row = Integer.parseInt(lineName.substring(3));\r
+//             \r
+               \r
+//             SpreadsheetLine line = node.lines.get(-row);\r
+//             if(line == null) {\r
+//                     line = new SpreadsheetLine(node, row);\r
+//                     node.lines.put(-row, line);\r
+//             }\r
+//             \r
+//             for(int i=0;i<bean.cells.length;i++) {\r
+//                     \r
+//                     LineContentBeanCell cell = bean.cells[i];\r
+//                     \r
+//                     try {\r
+//                             \r
+//                             if(ExcelFormula.BINDING.type().equals(cell.content.getBinding().type())) {\r
+//                                     ExcelFormula formula = (ExcelFormula)cell.content.getValue(ExcelFormula.BINDING);\r
+//                                     SheetFormulaParser p = new SheetFormulaParser(new StringReader(formula.expression));\r
+//                                     AstValue v = p.relation();\r
+//                                     line.cells.add(new SpreadsheetCell(line, i, new SpreadsheetFormula(v, formula.expression), 0));\r
+//                             } else {\r
+//                                     line.cells.add(new SpreadsheetCell(line, i, cell.content.getValue(), 0));\r
+//                             }\r
+//                     } catch (Throwable e) {\r
+//                             line.cells.add(new SpreadsheetCell(line, i, cell.content.getValue(), 0));\r
+//                             try {\r
+//                                     new Exception("failed: " + ((ExcelFormula)(cell.content.getValue(ExcelFormula.BINDING))).expression, e).printStackTrace();\r
+//                             } catch (AdaptException e1) {\r
+//                                     e1.printStackTrace();\r
+//                             }\r
+//                     }\r
+//                     \r
+//             }\r
+               \r
+       }\r
+\r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public <T> T getConcrete() {\r
+               return (T)this;\r
+       }\r
+       \r
+}
\ No newline at end of file