Main.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. if (this.scriptConfiguratorContent){
  74. if (this.scriptConfigurator) delete this.scriptConfigurator;
  75. this.scriptConfiguratorContent.destroy();
  76. this.scriptConfiguratorContent = null;
  77. }
  78. if (this.dictionaryConfiguratorContent){
  79. if (this.dictionaryConfigurator) delete this.dictionaryConfigurator;
  80. this.dictionaryConfiguratorContent.destroy();
  81. this.dictionaryConfiguratorContent = null;
  82. }
  83. },
  84. selectConfig: function(){
  85. this.clearContent();
  86. this.selectConfiguratorContent = new Element("div", {
  87. "styles": this.css.rightContentNode
  88. }).inject(this.node);
  89. this.loadSelectConfig();
  90. },
  91. loadSelectConfig: function(){
  92. MWF.xDesktop.requireApp("service.ServiceManager", "SelectExplorer", function(){
  93. this.selectConfigurator = new MWF.xApplication.service.ServiceManager.SelectExplorer(this.selectConfiguratorContent, this.restActions);
  94. this.selectConfigurator.app = this;
  95. this.selectConfigurator.load();
  96. }.bind(this));
  97. },
  98. agentConfig: function(){
  99. this.clearContent();
  100. this.agentConfiguratorContent = new Element("div", {
  101. "styles": this.css.rightContentNode
  102. }).inject(this.node);
  103. this.loadAgentConfig();
  104. },
  105. loadAgentConfig: function(){
  106. MWF.xDesktop.requireApp("service.ServiceManager", "AgentExplorer", function(){
  107. this.agentConfigurator = new MWF.xApplication.service.ServiceManager.AgentExplorer(this.agentConfiguratorContent, this.restActions);
  108. this.agentConfigurator.app = this;
  109. this.agentConfigurator.load();
  110. }.bind(this));
  111. },
  112. invokeConfig: function(){
  113. this.clearContent();
  114. this.invokeConfiguratorContent = new Element("div", {
  115. "styles": this.css.rightContentNode
  116. }).inject(this.node);
  117. this.loadInvokeConfig();
  118. },
  119. loadInvokeConfig: function(){
  120. MWF.xDesktop.requireApp("service.ServiceManager", "InvokeExplorer", function(){
  121. this.invokeConfigurator = new MWF.xApplication.service.ServiceManager.InvokeExplorer(this.invokeConfiguratorContent, this.restActions);
  122. this.invokeConfigurator.app = this;
  123. this.invokeConfigurator.load();
  124. }.bind(this));
  125. },
  126. scriptConfig: function(){
  127. this.clearContent();
  128. this.scriptConfiguratorContent = new Element("div", {
  129. "styles": this.css.rightContentNode
  130. }).inject(this.node);
  131. this.loadScriptConfig();
  132. },
  133. loadScriptConfig: function(){
  134. MWF.xDesktop.requireApp("service.ServiceManager", "ScriptExplorer", function(){
  135. this.scriptConfigurator = new MWF.xApplication.service.ServiceManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  136. this.scriptConfigurator.app = this;
  137. this.scriptConfigurator.load();
  138. }.bind(this));
  139. },
  140. dataConfig: function(){
  141. this.clearContent();
  142. this.dictionaryConfiguratorContent = new Element("div", {
  143. "styles": this.css.rightContentNode
  144. }).inject(this.node);
  145. this.loadDataConfig();
  146. },
  147. loadDataConfig: function(){
  148. MWF.xDesktop.requireApp("service.ServiceManager", "DictionaryExplorer", function(){
  149. this.dictionaryConfigurator = new MWF.xApplication.service.ServiceManager.DictionaryExplorer(this.dictionaryConfiguratorContent, this.restActions);
  150. this.dictionaryConfigurator.app = this;
  151. this.dictionaryConfigurator.load();
  152. }.bind(this));
  153. },
  154. recordStatus: function(){
  155. var idx = null;
  156. if (this.menu.currentNavi){
  157. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  158. }
  159. return {"navi": idx};
  160. },
  161. addKeyboardEvents: function(){
  162. this.addEvent("copy", function(){
  163. this.keyCopyItems();
  164. }.bind(this));
  165. this.addEvent("paste", function(){
  166. this.keyPasteItems();
  167. }.bind(this));
  168. },
  169. keyCopyItems: function(e){
  170. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId){
  171. if (this.agentConfigurator){
  172. this.agentConfigurator.keyCopy(e);
  173. if (e) e.preventDefault();
  174. }
  175. if (this.invokeConfigurator){
  176. this.invokeConfigurator.keyCopy(e);
  177. if (e) e.preventDefault();
  178. }
  179. if (this.scriptConfigurator){
  180. this.scriptConfigurator.keyCopy(e);
  181. if (e) e.preventDefault();
  182. }
  183. if (this.dictionaryConfigurator){
  184. this.dictionaryConfigurator.keyCopy(e);
  185. if (e) e.preventDefault();
  186. }
  187. }
  188. },
  189. keyPasteItems: function(e){
  190. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
  191. if (this.agentConfigurator){
  192. this.agentConfigurator.keyPaste(e);
  193. }
  194. if (this.invokeConfigurator){
  195. this.invokeConfigurator.keyPaste(e);
  196. }
  197. if (this.scriptConfigurator){
  198. this.scriptConfigurator.keyPaste(e);
  199. }
  200. if (this.dictionaryConfigurator){
  201. this.dictionaryConfigurator.keyPaste(e);
  202. }
  203. }
  204. //if (e) e.preventDefault();
  205. }
  206. });
  207. MWF.xApplication.service.ServiceManager.Menu = new Class({
  208. Extends: MWF.xApplication.process.ProcessManager.Menu,
  209. Implements: [Options, Events]
  210. });