Project_pane.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. }
  12. //Callback after UI is fully loaded and displayed.
  13. function OnReady(reload, preview) {
  14. PUI(()=>{
  15. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  16. //The 'pui' variable is valid in all functions of this document.
  17. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  18. });
  19. }
  20. function OnCloseForm() {
  21. }
  22. function OnException(err) {
  23. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  24. }
  25. //////////////////////////////////////////////////////////////////////////
  26. // Callback Functions.
  27. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  28. var name = '';
  29. function OnConfirm(){
  30. if(!model.global_ctrl[0]) {
  31. unit.form.mainfrm.OnCueline('工作区不存在,请先创建工作区或者打开工作区!', 'red');
  32. unit.form.Project.Close();
  33. return;
  34. }
  35. let work_name = model.acax_app.model.workArea.Current();
  36. model.checkPath(work_name, (directories) =>{
  37. if(directories.includes(ui.project_name.value)) {
  38. unit.form.mainfrm.OnCueline('您创建的工程已存在!', 'red');
  39. }else{
  40. name = ui.project_name.value;
  41. unit.form.tree.CreateProject(getName());
  42. }
  43. });
  44. unit.form.mainfrm.OnCueline('成功创建工程!', 'green');
  45. model.global_ctrl[1] = true;
  46. unit.form.Project.Close();
  47. }
  48. function getName() {
  49. return name;
  50. }
  51. //The message corresponding callback executed by the docker pane.
  52. // when calling [side_pane].fireEvent(type,para) in the main form.
  53. function OnParentDockerMessage(type, para) {
  54. }
  55. //////////////////////////////////////////////////////////////////////////
  56. // Utils Functions.
  57. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  58. function onDragFile(filepath) {
  59. }
  60. function PUI(cb) {
  61. if(pui){cb();}
  62. }
  63. /*Usage of BLOCK_EVENT
  64. BLOCK_EVENT(()=>{
  65. ui.[name].[var] = ...;
  66. });
  67. */
  68. function BLOCK_EVENT(cb) {
  69. ui.block_event = true;
  70. cb();
  71. ui.block_event = false;
  72. }
  73. //////////////////////////////////////////////////////////////////////////
  74. // template codes for cw callback js.
  75. function CW_DeclareVariable(name, setter, getter) {
  76. if(typeof(__DeclareVariable) === 'function') {
  77. __DeclareVariable(name, setter, getter);
  78. }
  79. }
  80. function CW_DeclareOuterVariable(name) {
  81. if(typeof(__DeclareOuterVariable) === 'function') {
  82. __DeclareOuterVariable(name);
  83. }
  84. }