workArea_pane.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. //Callback of data preparation stage before UI is fully loaded.
  5. function OnInitializeData(reload, preview) {
  6. PUI(()=>{
  7. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  8. //The 'pui' variable is valid in all functions of this document.
  9. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  10. });
  11. //默认到data路径下
  12. ui.floder.value = unit.dir + 'data';
  13. fname = ui.floder.value;
  14. }
  15. //Callback after UI is fully loaded and displayed.
  16. function OnReady(reload, preview) {
  17. PUI(()=>{
  18. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  19. //The 'pui' variable is valid in all functions of this document.
  20. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  21. });
  22. }
  23. function OnCloseForm() {
  24. }
  25. function OnException(err) {
  26. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  27. }
  28. //////////////////////////////////////////////////////////////////////////
  29. // Callback Functions.
  30. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  31. var fname = '';
  32. var name = '';
  33. function OnConfirm(){
  34. if(ui.work_name.value === '') {
  35. unit.form.mainfrm.OnCueline('未输入工作区名字!', 'red');
  36. return;
  37. }
  38. model.checkPath(ui.floder.value, (directories) =>{
  39. if(directories.includes(ui.work_name.value)) {
  40. unit.form.mainfrm.OnCueline('您创建的工作区已存在!', 'red');
  41. }else{
  42. name = fname + "/" +ui.work_name.value;
  43. unit.form.tree.CreateWorkArea(getName());
  44. }
  45. });
  46. unit.form.mainfrm.OnCueline('成功创建工作区!', 'green');
  47. //控制流程
  48. model.global_ctrl[0] = true;
  49. unit.form.workArea.Close();
  50. }
  51. function getName() {
  52. return name;
  53. }
  54. function OngetFloder(){
  55. fname = ui.OpenFolderDialog("Create WorkArea", unit.dir);
  56. ui.floder.value = fname;
  57. }
  58. //The message corresponding callback executed by the docker pane.
  59. // when calling [side_pane].fireEvent(type,para) in the main form.
  60. function OnParentDockerMessage(type, para) {
  61. }
  62. //////////////////////////////////////////////////////////////////////////
  63. // Utils Functions.
  64. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  65. function onDragFile(filepath) {
  66. }
  67. function PUI(cb) {
  68. if(pui){cb();}
  69. }
  70. /*Usage of BLOCK_EVENT
  71. BLOCK_EVENT(()=>{
  72. ui.[name].[var] = ...;
  73. });
  74. */
  75. function BLOCK_EVENT(cb) {
  76. ui.block_event = true;
  77. cb();
  78. ui.block_event = false;
  79. }
  80. //////////////////////////////////////////////////////////////////////////
  81. // template codes for cw callback js.
  82. function CW_DeclareVariable(name, setter, getter) {
  83. if(typeof(__DeclareVariable) === 'function') {
  84. __DeclareVariable(name, setter, getter);
  85. }
  86. }
  87. function CW_DeclareOuterVariable(name) {
  88. if(typeof(__DeclareOuterVariable) === 'function') {
  89. __DeclareOuterVariable(name);
  90. }
  91. }