Rename_pane.js 3.0 KB

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