all-property.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. Ext.ns('App.property');
  2. App.property.AbstractPropertyPanel = Ext.extend(Ext.Panel, {
  3. title: '属性面板',
  4. iconCls: 'tb-prop',
  5. layout: 'fit',
  6. split: true,
  7. draggable :false,
  8. // tools: [{
  9. // id: 'maximize',
  10. // handler: function(event, toolEl, panel) {
  11. // panel.propertyManager.changePropertyStatus('max');
  12. // }
  13. // }],
  14. // ========================================================================
  15. initComponent: function() {
  16. var tabPanel = new Ext.TabPanel({
  17. enableTabScroll:true,
  18. layoutOnTabChange: true,
  19. defaults: {
  20. autoScroll: true
  21. }
  22. });
  23. this.tabPanel = tabPanel;
  24. this.items = [tabPanel];
  25. App.property.AbstractPropertyPanel.superclass.initComponent.call(this);
  26. },
  27. setPropertyManager: function(propertyManager) {
  28. this.propertyManager = propertyManager;
  29. },
  30. getTabPanel: function() {
  31. return this.tabPanel;
  32. },
  33. hide: function() {
  34. this.clearItem(this.tabPanel);
  35. App.property.AbstractPropertyPanel.superclass.hide.call(this);
  36. },
  37. clearItem: function(p) {
  38. if (typeof p.items != 'undefined') {
  39. var item = null;
  40. while ((item = p.items.last())) {
  41. p.remove(item, true);
  42. }
  43. }
  44. }
  45. });
  46. Ext.ns('App.property');
  47. App.property.BottomPanel = Ext.extend(App.property.AbstractPropertyPanel, {
  48. region: 'south',
  49. height: 200,
  50. draggable: {
  51. insertProxy: false,
  52. onDrag: function(e) {
  53. var pel = this.proxy.getEl();
  54. this.x = pel.getLeft(true);
  55. this.y = pel.getTop(true);
  56. },
  57. endDrag: function(e) {
  58. var x = this.x;
  59. var y = this.y;
  60. var propertyManager = this.panel.propertyManager;
  61. var size = Ext.getBody().getViewSize();
  62. if (y < size.height - 200) {
  63. if (x > size.width - 200) {
  64. propertyManager.changePropertyStatus('right');
  65. } else {
  66. propertyManager.changePropertyStatus('max');
  67. }
  68. }
  69. }
  70. },
  71. getStatusName: function() {
  72. return 'bottom';
  73. }
  74. });
  75. Ext.ns('App.property');
  76. App.property.MaxWindow = Ext.extend(Ext.Window, {
  77. title: '属性面板',
  78. iconCls: 'tb-prop',
  79. layout: 'fit',
  80. stateful: false,
  81. draggable :false, //不允许拖动 bug zhouy
  82. closable: false,
  83. width: 500,
  84. height: 400,
  85. // FIXME: 希望实现,不disable editor,编辑window中的元素时,不会选中editor中的元素
  86. modal: false,
  87. constrainHeader: true,
  88. autoScroll: true,
  89. // tools: [{
  90. // id: 'restore',
  91. // handler: function(event, toolEl, panel) {
  92. // panel.propertyManager.changePropertyStatus(panel.restore.getStatusName());
  93. // }
  94. // }],
  95. // ========================================================================
  96. initComponent: function() {
  97. var tabPanel = new Ext.TabPanel({
  98. enableTabScroll:true,
  99. layoutOnTabChange: true
  100. });
  101. this.tabPanel = tabPanel;
  102. this.items = [tabPanel];
  103. App.property.MaxWindow.superclass.initComponent.call(this);
  104. },
  105. afterRender: function() {
  106. App.property.MaxWindow.superclass.afterRender.call(this);
  107. this.dd.endDrag = function(e) {
  108. try {
  109. this.win.unghost();
  110. // this.win.saveState();
  111. var x = e.xy[0];
  112. var y = e.xy[1];
  113. var propertyManager = this.win.propertyManager;
  114. var size = Ext.getBody().getViewSize();
  115. if (y > size.height - 200) {
  116. propertyManager.changePropertyStatus('bottom');
  117. } else if (x > size.width - 200) {
  118. propertyManager.changePropertyStatus('right');
  119. }
  120. } catch(e) {
  121. Gef.error(e);
  122. }
  123. }.createDelegate(this.dd);
  124. },
  125. setPropertyManager: function(propertyManager) {
  126. this.propertyManager = propertyManager;
  127. },
  128. getTabPanel: function() {
  129. return this.tabPanel;
  130. },
  131. clearItem: function(p) {
  132. if (typeof p.items != 'undefined') {
  133. var item = null;
  134. while ((item = p.items.last())) {
  135. p.remove(item, true);
  136. }
  137. }
  138. },
  139. // ========================================================================
  140. hide: function() {
  141. this.clearItem(this.tabPanel);
  142. if (this.el) {
  143. if (Gef.activeEditor) {
  144. //Gef.activeEditor.enable();
  145. }
  146. App.property.MaxWindow.superclass.hide.call(this);
  147. }
  148. },
  149. show: function() {
  150. if (Gef.activeEditor) {
  151. //Gef.activeEditor.disable();
  152. }
  153. delete this.x;
  154. delete this.y;
  155. App.property.MaxWindow.superclass.show.call(this);
  156. },
  157. getStatusName: function() {
  158. return 'max';
  159. },
  160. setRestore: function(restore) {
  161. this.restore = restore;
  162. }
  163. });
  164. Ext.ns('App.property');
  165. App.property.PropertyManager = Ext.extend(Object, {
  166. constructor: function() {
  167. this.bottomPanel = new App.property.BottomPanel();
  168. this.bottomPanel.setPropertyManager(this);
  169. this.rightPanel = new App.property.RightPanel();
  170. this.rightPanel.setPropertyManager(this);
  171. this.maxWindow = new App.property.MaxWindow();
  172. this.maxWindow.setPropertyManager(this);
  173. var propertyStatus = Cookies.get('_gef_jbpm4_property_status');
  174. if (propertyStatus != 'bottom') {
  175. propertyStatus = 'right';
  176. }
  177. this.changePropertyStatus(propertyStatus);
  178. this.initMap();
  179. },
  180. changePropertyStatus: function(status) {
  181. try {
  182. status = status ? status : 'right';
  183. Cookies.set('_gef_jbpm4_property_status', status);
  184. switch (status) {
  185. case 'right':
  186. this.current = this.rightPanel;
  187. this.current.show();
  188. if (this.form) {
  189. this.form.decorate(this.current.getTabPanel(), this.model);
  190. }
  191. this.maxWindow.hide();
  192. this.bottomPanel.hide();
  193. if (this.rightPanel.ownerCt) {
  194. this.rightPanel.ownerCt.doLayout();
  195. }
  196. break;
  197. case 'bottom':
  198. this.current = this.bottomPanel;
  199. this.current.show();
  200. if (this.form) {
  201. this.form.decorate(this.current.getTabPanel(), this.model);
  202. }
  203. this.maxWindow.hide();
  204. this.rightPanel.hide();
  205. if (this.rightPanel.ownerCt) {
  206. this.rightPanel.ownerCt.doLayout();
  207. }
  208. break;
  209. case 'max':
  210. this.maxWindow.setRestore(this.current);
  211. this.current = this.maxWindow;
  212. this.current.show();
  213. if (this.form) {
  214. this.form.decorate(this.current.getTabPanel(), this.model);
  215. }
  216. this.bottomPanel.hide();
  217. this.rightPanel.hide();
  218. if (this.rightPanel.ownerCt) {
  219. this.rightPanel.ownerCt.doLayout();
  220. }
  221. break;
  222. }
  223. } catch(e) {
  224. Gef.error(e);
  225. }
  226. },
  227. getBottom: function() {
  228. return this.bottomPanel;
  229. },
  230. getRight: function() {
  231. return this.rightPanel;
  232. },
  233. getMax: function() {
  234. return this.max;
  235. },
  236. getCurrent: function() {
  237. return this.current;
  238. },
  239. getSelectionListener: function() {
  240. return this.selectionListener;
  241. },
  242. initMap: function() {
  243. this.formMap = {
  244. process: App.form.ProcessForm,
  245. start: App.form.StartForm,
  246. end: App.form.EndForm,
  247. cancel: App.form.CancelForm,
  248. error: App.form.ErrorForm,
  249. state: App.form.StateForm,
  250. task: App.form.TaskForm,
  251. decision: App.form.DecisionForm,
  252. fork: App.form.ForkForm,
  253. join: App.form.JoinForm,
  254. java: App.form.JavaForm,
  255. script: App.form.ScriptForm,
  256. hql: App.form.HqlForm,
  257. sql: App.form.SqlForm,
  258. mail: App.form.MailForm,
  259. custom: App.form.CustomForm,
  260. subProcess: App.form.SubProcessForm,
  261. transition: App.form.TransitionForm,
  262. jms: App.form.JmsForm,
  263. ruleDecision: App.form.RuleDecisionForm,
  264. rules: App.form.RulesForm,
  265. auto: App.form.AutoForm,
  266. human: App.form.HumanForm,
  267. 'counter-sign': App.form.CounterSignForm,
  268. foreach: App.form.ForeachForm
  269. };
  270. },
  271. updateForm: function(model) {
  272. this.model = model;
  273. var modelType = model.getType();
  274. var constructor = this.formMap[modelType];
  275. if (!constructor) {
  276. Gef.debug('cannot find form for [' + modelType + ']',
  277. 'App.property.PropertyManager.updateForm()');
  278. }
  279. this.form = new constructor;
  280. this.form.decorate(this.current.getTabPanel(), model);
  281. },
  282. initSelectionListener: function(editor) {
  283. this.selectionListener = new Gef.jbs.ExtSelectionListener(this);
  284. editor.addSelectionListener(this.selectionListener);
  285. this.selectionListener.setEditor(editor);
  286. var model = this.selectionListener.getModel();
  287. this.updateForm(model);
  288. },
  289. initSelectionListener2: function(editor,data) {
  290. var k=editor
  291. this.selectionListener = new Gef.jbs.ExtSelectionListener(this);
  292. editor.addSelectionListener(this.selectionListener);
  293. this.selectionListener.setEditor(editor);
  294. var model = this.selectionListener.getModel();
  295. model.dom.setAttribute("data",data);
  296. this.updateForm(model);
  297. },
  298. selectSpecialNode:function(editor,editPart){
  299. var editmodel=editPart.getModel();
  300. this.selectionListener = new Gef.jbs.ExtSelectionListener(this);
  301. editor.addSelectionListener(this.selectionListener);
  302. this.selectionListener.setEditor(editor);
  303. this.selectionListener.selectNode(editPart);
  304. var model = this.selectionListener.getModel();
  305. this.updateForm(model);
  306. },
  307. initSelectionListener3:function(editor,constructor){
  308. this.selectionListener = new Gef.jbs.ExtSelectionListener(this);
  309. editor.addSelectionListener(this.selectionListener);
  310. this.selectionListener.setEditor(editor);
  311. var model = this.selectionListener.getModel();
  312. if(model.dom.getAttribute("data")){
  313. model.dom.removeAttribute("data");
  314. }
  315. model.dom.setAttribute("constructor",constructor);
  316. this.updateForm(model);
  317. }
  318. });
  319. var Cookies = {};
  320. Cookies.set = function(name, value){
  321. var argv = arguments;
  322. var argc = arguments.length;
  323. var expires = (argc > 2) ? argv[2] : null;
  324. var path = (argc > 3) ? argv[3] : '/';
  325. var domain = (argc > 4) ? argv[4] : null;
  326. var secure = (argc > 5) ? argv[5] : false;
  327. document.cookie = name + "=" + escape (value) +
  328. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  329. ((path == null) ? "" : ("; path=" + path)) +
  330. ((domain == null) ? "" : ("; domain=" + domain)) +
  331. ((secure == true) ? "; secure" : "");
  332. };
  333. Cookies.get = function(name){
  334. var arg = name + "=";
  335. var alen = arg.length;
  336. var clen = document.cookie.length;
  337. var i = 0;
  338. var j = 0;
  339. while(i < clen){
  340. j = i + alen;
  341. if (document.cookie.substring(i, j) == arg)
  342. return Cookies.getCookieVal(j);
  343. i = document.cookie.indexOf(" ", i) + 1;
  344. if(i == 0)
  345. break;
  346. }
  347. return null;
  348. };
  349. Cookies.clear = function(name) {
  350. if(Cookies.get(name)){
  351. document.cookie = name + "=" +
  352. "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  353. }
  354. };
  355. Cookies.getCookieVal = function(offset){
  356. var endstr = document.cookie.indexOf(";", offset);
  357. if(endstr == -1){
  358. endstr = document.cookie.length;
  359. }
  360. return unescape(document.cookie.substring(offset, endstr));
  361. };
  362. Ext.ns('App.property');
  363. App.property.RightPanel = Ext.extend(App.property.AbstractPropertyPanel, {
  364. region: 'east',
  365. width: 250, //修改属性面板的宽度
  366. frame:true,
  367. //不允许面板拖拽 2012-08-27
  368. // draggable: {
  369. // insertProxy: false,
  370. // onDrag: function(e) {
  371. // var pel = this.proxy.getEl();
  372. // this.x = pel.getLeft(true);
  373. // this.y = pel.getTop(true);
  374. // },
  375. // endDrag: function(e) {
  376. // var x = this.x;
  377. // var y = this.y;
  378. // var propertyManager = this.panel.propertyManager;
  379. // var size = Ext.getBody().getViewSize();
  380. //
  381. // if (x < size.width - 200) {
  382. // if (y > size.height - 200) {
  383. // propertyManager.changePropertyStatus('bottom');
  384. // } else {
  385. // propertyManager.changePropertyStatus('max');
  386. // }
  387. // }
  388. // }
  389. // },
  390. getStatusName: function() {
  391. return 'right';
  392. }
  393. });