Main.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. MWF.xDesktop.requireApp("service.ServiceManager", "package", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xApplication.process = MWF.xApplication.process || {};
  5. MWF.xApplication.process.ProcessManager = MWF.xApplication.process.ProcessManager || {};
  6. MWF.xDesktop.requireApp("process.ProcessManager", "", null, false);
  7. MWF.xApplication.service = MWF.xApplication.service || {};
  8. MWF.xApplication.service.ServiceManager.Main = new Class({
  9. Extends: MWF.xApplication.process.ProcessManager.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "name": "service.ServiceManager",
  14. "icon": "icon.png",
  15. "width": "1100",
  16. "height": "700",
  17. "title": MWF.xApplication.service.ServiceManager.LP.title
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.service.ServiceManager.LP;
  21. this.currentContentNode = null;
  22. this.restActions = MWF.Actions.get("x_program_center");
  23. },
  24. loadApplication: function(callback){
  25. this.createNode();
  26. this.loadApplicationContent();
  27. if (window.clipboardData){
  28. this.addKeyboardEvents();
  29. }else{
  30. this.keyCopyItemsFun = this.keyCopyItems.bind(this);
  31. this.keyPasteItemsFun = this.keyPasteItems.bind(this);
  32. document.addEventListener('copy', this.keyCopyItemsFun);
  33. document.addEventListener('paste', this.keyPasteItemsFun);
  34. this.addEvent("queryClose", function(){
  35. if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  36. if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
  37. }.bind(this));
  38. }
  39. if (callback) callback();
  40. },
  41. loadStartMenu: function(callback){
  42. this.startMenuNode = new Element("div", {
  43. "styles": this.css.startMenuNode
  44. }).inject(this.node);
  45. this.menu = new MWF.xApplication.service.ServiceManager.Menu(this, this.startMenuNode, {
  46. "onPostLoad": function(){
  47. if (this.status){
  48. if (this.status.navi!=null){
  49. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  50. }else{
  51. this.menu.doAction(this.menu.startNavis[0]);
  52. }
  53. }else{
  54. this.menu.doAction(this.menu.startNavis[0]);
  55. }
  56. }.bind(this)
  57. });
  58. this.addEvent("resize", function(){
  59. if (this.menu) this.menu.onResize();
  60. }.bind(this));
  61. },
  62. clearContent: function(){
  63. if (this.agentConfiguratorContent){
  64. if (this.agentConfigurator) delete this.agentConfigurator;
  65. this.agentConfiguratorContent.destroy();
  66. this.agentConfiguratorContent = null;
  67. }
  68. if (this.invokeConfiguratorContent){
  69. if (this.invokeConfigurator) delete this.invokeConfigurator;
  70. this.invokeConfiguratorContent.destroy();
  71. this.invokeConfiguratorContent = null;
  72. }
  73. },
  74. selectConfig: function(){
  75. this.clearContent();
  76. this.selectConfiguratorContent = new Element("div", {
  77. "styles": this.css.rightContentNode
  78. }).inject(this.node);
  79. this.loadSelectConfig();
  80. },
  81. loadSelectConfig: function(){
  82. MWF.xDesktop.requireApp("service.ServiceManager", "SelectExplorer", function(){
  83. this.selectConfigurator = new MWF.xApplication.service.ServiceManager.SelectExplorer(this.selectConfiguratorContent, this.restActions);
  84. this.selectConfigurator.app = this;
  85. this.selectConfigurator.load();
  86. }.bind(this));
  87. },
  88. agentConfig: function(){
  89. this.clearContent();
  90. this.agentConfiguratorContent = new Element("div", {
  91. "styles": this.css.rightContentNode
  92. }).inject(this.node);
  93. this.loadAgentConfig();
  94. },
  95. loadAgentConfig: function(){
  96. MWF.xDesktop.requireApp("service.ServiceManager", "AgentExplorer", function(){
  97. this.agentConfigurator = new MWF.xApplication.service.ServiceManager.AgentExplorer(this.agentConfiguratorContent, this.restActions);
  98. this.agentConfigurator.app = this;
  99. this.agentConfigurator.load();
  100. }.bind(this));
  101. },
  102. invokeConfig: function(){
  103. this.clearContent();
  104. this.invokeConfiguratorContent = new Element("div", {
  105. "styles": this.css.rightContentNode
  106. }).inject(this.node);
  107. this.loadInvokeConfig();
  108. },
  109. loadInvokeConfig: function(){
  110. MWF.xDesktop.requireApp("service.ServiceManager", "InvokeExplorer", function(){
  111. this.invokeConfigurator = new MWF.xApplication.service.ServiceManager.InvokeExplorer(this.invokeConfiguratorContent, this.restActions);
  112. this.invokeConfigurator.app = this;
  113. this.invokeConfigurator.load();
  114. }.bind(this));
  115. },
  116. recordStatus: function(){
  117. var idx = null;
  118. if (this.menu.currentNavi){
  119. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  120. }
  121. return {"navi": idx};
  122. },
  123. addKeyboardEvents: function(){
  124. this.addEvent("copy", function(){
  125. this.keyCopyItems();
  126. }.bind(this));
  127. this.addEvent("paste", function(){
  128. this.keyPasteItems();
  129. }.bind(this));
  130. },
  131. keyCopyItems: function(e){
  132. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId){
  133. if (this.agentConfigurator){
  134. this.agentConfigurator.keyCopy(e);
  135. if (e) e.preventDefault();
  136. }
  137. if (this.invokeConfigurator){
  138. this.invokeConfigurator.keyCopy(e);
  139. if (e) e.preventDefault();
  140. }
  141. }
  142. },
  143. keyPasteItems: function(e){
  144. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
  145. if (this.agentConfigurator){
  146. this.agentConfigurator.keyPaste(e);
  147. }
  148. if (this.invokeConfigurator){
  149. this.invokeConfigurator.keyPaste(e);
  150. }
  151. }
  152. //if (e) e.preventDefault();
  153. }
  154. });
  155. MWF.xApplication.service.ServiceManager.Menu = new Class({
  156. Extends: MWF.xApplication.process.ProcessManager.Menu,
  157. Implements: [Options, Events]
  158. });