all-property-planner.js 12 KB

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