ScriptTable.hx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package hide.comp.cdb;
  2. class ScriptTable extends SubTable {
  3. var script : hide.comp.ScriptEditor;
  4. override function makeSubSheet():cdb.Sheet {
  5. var sheet = cell.table.sheet;
  6. var c = cell.column;
  7. var index = cell.line.index;
  8. var key = sheet.getPath() + "@" + c.name + ":" + index;
  9. this.lines = [];
  10. return new cdb.Sheet(editor.base, {
  11. columns : [c],
  12. props : {},
  13. name : key,
  14. lines : [cell.line.obj],
  15. separators: [],
  16. }, key, { sheet : sheet, column : cell.columnIndex, line : index });
  17. }
  18. override public function close() {
  19. if( script != null )
  20. cell.setValue(script.code);
  21. super.close();
  22. }
  23. override function refresh() {
  24. var first = script == null;
  25. element.html("<div class='cdb-script'></div>");
  26. var checker = new ScriptEditor.ScriptChecker(editor.config,"cdb."+cell.getDocumentName(),[ "cdb."+cell.table.sheet.name => cell.line.obj ]);
  27. script = new ScriptEditor(cell.value, checker, element.find("div"));
  28. script.onSave = function() cell.setValue(script.code);
  29. script.onClose = function() { close(); cell.focus(); }
  30. lines = [new Line(this,[],0,script.element)];
  31. if( first ) script.focus();
  32. }
  33. }