all-network.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133
  1. Ext.ns('App');
  2. App = {
  3. webforms: {},
  4. init: function() {
  5. Ext.QuickTips.init();
  6. this.propertyManager = new App.property.PropertyManager();
  7. var viewport = new Ext.Viewport({
  8. layout: 'border',
  9. items: [
  10. this.createNorth(),
  11. this.createSouth(),
  12. this.createWest(),
  13. this.createEast(),
  14. this.createCenter()
  15. ]
  16. });
  17. this.initEditor();
  18. setTimeout(function() {
  19. Ext.get('loading').remove();
  20. Ext.get('loading-mask').fadeOut({remove:true});
  21. }, 100);
  22. },
  23. initEditor: function() {
  24. var xml = "<?xml version='1.0' encoding='UTF-8'?>"
  25. + "<process name='untitled' xmlns='http://jbpm.org/4.4/jpdl'>"
  26. + "<Cloud g='564,112,128,128' name='Cloud 1'/>"
  27. + "<Cloud g='581,272,128,128' name='Cloud 2'/>"
  28. + "<Firewall g='506,161.5,62,206.5' name='Firewall 1'>"
  29. + "<transition to='Coreswitcher 1'/>"
  30. + "</Firewall>"
  31. + "<rect rounded='0' g='748,79,251,147' name='rect 1'/>"
  32. + "<House2 g='775.5,101.5,73.5,64.5' name='House2 1'>"
  33. + "<transition to='Cloud 1'/>"
  34. + "</House2>"
  35. + "<House2 g='827.5,133.5,76.5,61.5' name='House2 2'>"
  36. + "<transition to='Cloud 1'/>"
  37. + "</House2>"
  38. + "<Pc g='904.5,144.5,79,71' name='Pc 1'>"
  39. + "<transition to='Cloud 1'/>"
  40. + "</Pc>"
  41. + "<rect rounded='0' g='752,268,249,155' name='rect 3'/>"
  42. + "<Networkserver g='787,277,60,83' name='Networkserver 1'/>"
  43. + "<Webserver g='871,280,53,79' name='Webserver 1'/>"
  44. + "<Webserver g='835,345,63,79' name='Webserver 2'/>"
  45. + "<ellipse g='813,320,80,60' name='ellipse 1'>"
  46. + "<transition to='Cloud 2'/>"
  47. + "</ellipse>"
  48. + "<Coreswitcher g='187,189.5,120,68.5' name='Coreswitcher 1'>"
  49. + "<transition to='Firewall 1'/>"
  50. + "<transition name='to Software 2' to='Software 2'/>"
  51. + "<transition name='to Software 3' to='Software 3'/>"
  52. + "<transition name='to Software 1' to='Software 1'/>"
  53. + "<transition name='to A10700 1' g='246,303;124,301:-46,27' to='A10700 1'/>"
  54. + "<transition name='to A10700 2' g='6,31' to='A10700 2'/>"
  55. + "<transition name='to Cluster 1' g='247,303;436,303:66,38' to='Cluster 1'/>"
  56. + "</Coreswitcher>"
  57. + "<A10700 g='84.5,359,77,52' name='A10700 1'/>"
  58. + "<A10700 g='210.5,355,77,52' name='A10700 2'/>"
  59. + "<Cluster g='353,347,172,100' name='Cluster 1'/>"
  60. + "<Software g='93.5,50,91,86' name='Software 1'/>"
  61. + "<Software g='206.5,44,91,86' name='Software 2'/>"
  62. + "<Software g='331.5,46,91,86' name='Software 3'/>"
  63. + "</process>";
  64. var editor = new Gef.jbs.ExtEditor();
  65. var input = new Gef.jbs.JBSEditorInput();
  66. input.readXml(xml);
  67. var workbenchWindow = new Gef.ui.support.DefaultWorkbenchWindow();
  68. workbenchWindow.getActivePage().openEditor(editor, input);
  69. workbenchWindow.render();
  70. Gef.activeEditor = editor;
  71. this.propertyManager.initSelectionListener(editor);
  72. },
  73. getProcessModel: function() {
  74. var viewer = Gef.activeEditor.getGraphicalViewer();
  75. var processEditPart = viewer.getContents();
  76. return processEditPart.model;
  77. },
  78. createNorth: function() {
  79. var p = null;
  80. if (Gef.MODE_DEMO === true) {
  81. p = new Ext.Panel({
  82. region: 'north'
  83. });
  84. } else {
  85. p = new Ext.Panel({
  86. region: 'north',
  87. //height: 60,
  88. html: '<h1 id="pageh1">Web网络拓扑图 - 多比图形控件演示<h1>'
  89. });
  90. }
  91. App.northPanel = p;
  92. return p;
  93. },
  94. createSouth: function() {
  95. var p = this.propertyManager.getBottom();
  96. return p;
  97. },
  98. createWest: function() {
  99. var p = new App.PalettePanel({
  100. collapsible: true
  101. });
  102. App.westPanel = p;
  103. return p;
  104. },
  105. createEast: function() {
  106. var p = this.propertyManager.getRight();
  107. return p;
  108. },
  109. createCenter: function() {
  110. var p = new App.CanvasPanel();
  111. App.centerPanel = p;
  112. return p;
  113. },
  114. getSelectionListener: function() {
  115. if (!this.selectionListener) {
  116. this.selectionListener = new Gef.jbs.ExtSelectionListener(null);
  117. }
  118. return this.selectionListener;
  119. }
  120. };
  121. /*
  122. Gef.override(App.PalettePanel, {
  123. configItems: function() {
  124. this.html = 'sdfasfdfdsa';
  125. }
  126. });
  127. */
  128. //Gef.PALETTE_TYPE = 'plain';
  129. Gef.PALETTE_TYPE = 'accordion';
  130. Ext.onReady(App.init, App);
  131. Gef.DEPLOY_URL = '../../console/d!deployJpdl.do';
  132. Gef.SAVE_URL = '../../console/d!saveJpdl.do';
  133. App.CanvasPanel = Ext.extend(Ext.Panel, {
  134. initComponent: function() {
  135. //this.on('bodyresize', function(p, w, h) {
  136. // var b = p.body.getBox();
  137. //});
  138. this.region = 'center';
  139. this.autoScroll = true;
  140. this.tbar = new Ext.Toolbar([{
  141. text: '新建',
  142. iconCls: 'tb-new',
  143. handler: function() {
  144. alert("ninia");
  145. Gef.activeEditor.reset();
  146. }
  147. }, {
  148. text: '导入',
  149. iconCls: 'tb-webform',
  150. handler: function() {
  151. var xml = Gef.activeEditor.serial();
  152. if (!this.openWin) {
  153. this.openWin = new Ext.Window({
  154. title: 'xml',
  155. layout: 'fit',
  156. width: 500,
  157. height: 300,
  158. closeAction: 'hide',
  159. modal: true,
  160. items: [{
  161. id: '__gef_jbpm4_xml_import__',
  162. xtype: 'textarea'
  163. }],
  164. buttons: [{
  165. text: '导入',
  166. handler: function() {
  167. var xml = Ext.getDom('__gef_jbpm4_xml_import__').value;
  168. Gef.activeEditor.resetAndOpen(xml);
  169. this.openWin.hide();
  170. },
  171. scope: this
  172. }, {
  173. text: '取消',
  174. handler: function() {
  175. this.openWin.hide();
  176. },
  177. scope: this
  178. }]
  179. });
  180. this.openWin.on('show', function() {
  181. Gef.activeEditor.disable();
  182. });
  183. this.openWin.on('hide', function() {
  184. Gef.activeEditor.enable();
  185. });
  186. }
  187. this.openWin.show(null, function() {
  188. Ext.getDom('__gef_jbpm4_xml_import__').value = xml;
  189. });
  190. }
  191. }, {
  192. text: '导出',
  193. iconCls: 'tb-prop',
  194. handler: function() {
  195. var xml = Gef.activeEditor.serial();
  196. if (!this.openWin) {
  197. this.openWin = new Ext.Window({
  198. title: 'xml',
  199. layout: 'fit',
  200. width: 500,
  201. height: 300,
  202. closeAction: 'hide',
  203. modal: true,
  204. items: [{
  205. id: '__gef_jbpm4_xml_export__',
  206. xtype: 'textarea'
  207. }],
  208. buttons: [{
  209. text: '关闭',
  210. handler: function() {
  211. this.openWin.hide();
  212. },
  213. scope: this
  214. }]
  215. });
  216. this.openWin.on('show', function() {
  217. Gef.activeEditor.disable();
  218. });
  219. this.openWin.on('hide', function() {
  220. Gef.activeEditor.enable();
  221. });
  222. }
  223. this.openWin.show(null, function() {
  224. Ext.getDom('__gef_jbpm4_xml_export__').value = xml;
  225. });
  226. }
  227. }, {
  228. text: '保存',
  229. iconCls: 'tb-save',
  230. handler: function() {
  231. var editor = Gef.activeEditor;
  232. var xml = editor.serial();
  233. var name = editor.getGraphicalViewer().getContents().getModel().text;
  234. Ext.Msg.wait('正在保存');
  235. Ext.Ajax.request({
  236. method: 'post',
  237. url: Gef.SAVE_URL,
  238. success: function(response) {
  239. try {
  240. var o = Ext.decode(response.responseText);
  241. if (o.success === true) {
  242. Ext.Msg.alert('信息', '操作成功');
  243. } else {
  244. Ext.Msg.alert('错误', o.errors.msg);
  245. }
  246. } catch(e) {
  247. Ext.Msg.alert('系统错误', response.responseText);
  248. }
  249. },
  250. failure: function(response) {
  251. Ext.Msg.alert('系统错误', response.responseText);
  252. },
  253. params: {
  254. id: Gef.PROCESS_ID,
  255. processName: name,
  256. xml: xml
  257. }
  258. });
  259. }
  260. }, {
  261. text: '发布',
  262. iconCls: 'tb-deploy',
  263. handler: function() {
  264. alert("这里 !");
  265. var editor = Gef.activeEditor;
  266. var isValid = new Validation(editor).validate();
  267. if (!isValid) {
  268. return false;
  269. }
  270. var xml = editor.serial();
  271. var model = editor.getGraphicalViewer().getContents().getModel();
  272. var name = model.text;
  273. alert(Gef.PROCESS_ID);
  274. Ext.Msg.wait('正在发布');
  275. Ext.Ajax.request({
  276. method: 'post',
  277. url: Gef.DEPLOY_URL,
  278. success: function(response) {
  279. try {
  280. var o = Ext.decode(response.responseText);
  281. if (o.success === true) {
  282. Ext.Msg.alert('信息', '操作成功');
  283. } else {
  284. Ext.Msg.alert('错误', o.errors.msg);
  285. }
  286. } catch(e) {
  287. Ext.Msg.alert('系统错误', response.responseText);
  288. }
  289. },
  290. failure: function(response) {
  291. Ext.Msg.alert('系统错误', response.responseText);
  292. },
  293. params: {
  294. id: Gef.PROCESS_ID,
  295. procCatId: model.procCatId,
  296. procDefName: model.procDefName,
  297. procDefCode: model.procDefCode,
  298. procVerName: model.procVerName,
  299. xml: xml
  300. }
  301. });
  302. }
  303. }, {
  304. text: '清空',
  305. iconCls: 'tb-clear',
  306. handler: function() {
  307. Gef.activeEditor.clear();
  308. }
  309. }, {
  310. text: '撤销',
  311. iconCls: 'tb-undo',
  312. handler: function() {
  313. var viewer = Gef.activeEditor.getGraphicalViewer();
  314. var browserListener = viewer.getBrowserListener();
  315. var selectionManager = browserListener.getSelectionManager();
  316. selectionManager.clearAll();
  317. var commandStack = viewer.getEditDomain().getCommandStack();
  318. commandStack.undo();
  319. },
  320. scope: this
  321. }, {
  322. text: '重做',
  323. iconCls: 'tb-redo',
  324. handler: function() {
  325. var viewer = Gef.activeEditor.getGraphicalViewer();
  326. var browserListener = viewer.getBrowserListener();
  327. var selectionManager = browserListener.getSelectionManager();
  328. selectionManager.clearAll();
  329. var commandStack = viewer.getEditDomain().getCommandStack();
  330. commandStack.redo();
  331. },
  332. scope: this
  333. }, {
  334. text: '布局',
  335. iconCls: 'tb-activity',
  336. handler: function() {
  337. var viewer = Gef.activeEditor.getGraphicalViewer();
  338. var browserListener = viewer.getBrowserListener();
  339. var selectionManager = browserListener.getSelectionManager();
  340. selectionManager.clearAll();
  341. new Layout(Gef.activeEditor).doLayout();
  342. },
  343. scope: this
  344. }, {
  345. text: '删除',
  346. iconCls: 'tb-delete',
  347. handler: this.removeSelected,
  348. scope: this
  349. }]);
  350. App.CanvasPanel.superclass.initComponent.call(this);
  351. },
  352. afterRender: function() {
  353. App.CanvasPanel.superclass.afterRender.call(this);
  354. var width = 4000;
  355. var height = 2500;
  356. Ext.DomHelper.append(this.body, [{
  357. id: '__gef_jbs__',
  358. tag: 'div',
  359. style: 'width:' + (width + 10) + 'px;height:' + (height + 10) + 'px;',
  360. children: [{
  361. id: '__gef_jbs_center__',
  362. tag: 'div',
  363. style: 'width:' + width + 'px;height:' + height + 'px;float:left;'
  364. }, {
  365. id: '__gef_jbs_right__',
  366. tag: 'div',
  367. style: 'width:10px;height:' + height + 'px;float:left;background-color:#EEEEEE;cursor:pointer;'
  368. }, {
  369. id: '__gef_jbs_bottom__',
  370. tag: 'div',
  371. style: 'width:' + (width + 10) + 'px;height:10px;float:left;background-color:#EEEEEE;cursor:pointer;'
  372. }]
  373. }]);
  374. var rightEl = Ext.fly('__gef_jbs_right__');
  375. rightEl.on('mouseover', function(e) {
  376. var t = e.getTarget();
  377. t.style.backgroundColor = 'yellow';
  378. t.style.backgroundImage = 'url(images/arrow/arrow-right.png)';
  379. });
  380. rightEl.on('mouseout', function(e) {
  381. var t = e.getTarget();
  382. t.style.backgroundColor = '#EEEEEE';
  383. t.style.backgroundImage = '';
  384. });
  385. rightEl.on('click', function(e) {
  386. Ext.fly('__gef_jbs__').setWidth(Ext.fly('__gef_jbs__').getWidth() + 100);
  387. Ext.fly('__gef_jbs_center__').setWidth(Ext.fly('__gef_jbs_center__').getWidth() + 100);
  388. Ext.fly('__gef_jbs_bottom__').setWidth(Ext.fly('__gef_jbs_bottom__').getWidth() + 100);
  389. Gef.activeEditor.addWidth(100);
  390. });
  391. var bottomEl = Ext.fly('__gef_jbs_bottom__');
  392. bottomEl.on('mouseover', function(e) {
  393. var t = e.getTarget();
  394. t.style.backgroundColor = 'yellow';
  395. t.style.backgroundImage = 'url(images/arrow/arrow-bottom.png)';
  396. });
  397. bottomEl.on('mouseout', function(e) {
  398. var t = e.getTarget();
  399. t.style.backgroundColor = '#EEEEEE';
  400. t.style.backgroundImage = '';
  401. });
  402. rightEl.on('click', function(e) {
  403. Ext.fly('__gef_jbs__').setHeight(Ext.fly('__gef_jbs__').getHeight() + 100);
  404. Ext.fly('__gef_jbs_center__').setHeight(Ext.fly('__gef_jbs_center__').getHeight() + 100);
  405. Ext.fly('__gef_jbs_right__').setHeight(Ext.fly('__gef_jbs_right__').getHeight() + 100);
  406. Gef.activeEditor.addHeight(100);
  407. });
  408. this.body.on('contextmenu', this.onContextMenu, this);
  409. },
  410. onContextMenu: function(e) {
  411. if (!this.contextMenu) {
  412. this.contextMenu = new Ext.menu.Menu({
  413. items: [{
  414. text: '详细配置',
  415. iconCls: 'tb-prop',
  416. handler: this.showWindow,
  417. scope: this
  418. }, {
  419. text: '删除',
  420. iconCls: 'tb-remove',
  421. handler: this.removeSelected,
  422. scope: this
  423. }]
  424. });
  425. }
  426. e.preventDefault();
  427. this.contextMenu.showAt(e.getXY());
  428. },
  429. showWindow: function() {
  430. App.propertyManager.changePropertyStatus('max');
  431. },
  432. removeSelected: function() {
  433. var viewer = Gef.activeEditor.getGraphicalViewer();
  434. var browserListener = viewer.getBrowserListener();
  435. var selectionManager = browserListener.getSelectionManager();
  436. var edge = selectionManager.selectedConnection;
  437. var nodes = selectionManager.items;
  438. var request = {};
  439. if (edge != null) {
  440. request.role = {
  441. name: 'REMOVE_EDGE'
  442. };
  443. this.executeCommand(edge, request);
  444. selectionManager.removeSelectedConnection();
  445. } else if (nodes.length > 0) {
  446. request.role = {
  447. name: 'REMOVE_NODES',
  448. nodes: nodes
  449. };
  450. this.executeCommand(viewer.getContents(), request);
  451. selectionManager.clearAll();
  452. }
  453. },
  454. executeCommand: function(editPart, request) {
  455. var command = editPart.getCommand(request);
  456. if (command != null) {
  457. Gef.activeEditor.getGraphicalViewer().getEditDomain().getCommandStack().execute(command);
  458. }
  459. }
  460. });
  461. /*
  462. * Compressed by JSA(www.xidea.org)
  463. */
  464. Layout = function(editor) {
  465. this.editor = editor;
  466. this.processEditPart = editor.getGraphicalViewer().getContents();
  467. this.processModel = this.processEditPart.getModel();
  468. };
  469. Layout.prototype = {
  470. doLayout: function() {
  471. var diagram = new Diagram();
  472. diagram.init(this.processModel);
  473. var sorter = new TopologicalSorter(diagram);
  474. var sortedElements = sorter.getSortedElements();
  475. var sortedIds = [];
  476. for (var i = 0; i < sortedElements.length; i++) {
  477. sortedIds.push(sortedElements[i].id);
  478. }
  479. //console.info(sortedIds);
  480. var layouter = new LeftToRightGridLayouter(diagram, sortedIds);
  481. layouter.doLayout();
  482. var edgeMap = diagram.getEdgeMap();
  483. for (var edgeId in edgeMap) {
  484. var edge = edgeMap[edgeId];
  485. new EdgeLayouter(layouter.grid, edge);
  486. }
  487. diagram.updateModel();
  488. }
  489. };
  490. ;
  491. Diagram = function() {
  492. };
  493. Diagram.prototype = {
  494. getNodeMap: function() {
  495. return this.nodeMap;
  496. },
  497. getEdgeMap: function() {
  498. return this.edgeMap;
  499. },
  500. init: function(process) {
  501. this.process = process;
  502. this.nodeMap = {};
  503. this.edgeMap = {};
  504. for (var i = 0; i < this.process.children.length; i++) {
  505. var child = process.children[i];
  506. var node = new Node();
  507. node.id = child.text;
  508. node.type = child.type;
  509. node.x = child.x;
  510. node.y = child.y;
  511. node.w = child.w;
  512. node.h = child.h;
  513. this.nodeMap[node.id] = node;
  514. }
  515. for (var i = 0; i < this.process.children.length; i++) {
  516. var child = process.children[i];
  517. for (var j = 0; j < child.getOutgoingConnections().length; j++) {
  518. var connection = child.getOutgoingConnections()[j];
  519. this.createEdge(connection);
  520. }
  521. }
  522. },
  523. createEdge: function(connection) {
  524. var connectionId = connection.getSource().text + '_' + connection.getTarget().text;
  525. var edge = this.edgeMap[connectionId];
  526. if (!edge) {
  527. edge = new Edge();
  528. edge.id = connectionId;
  529. edge.name = connection.text;
  530. edge.source = this.nodeMap[connection.getSource().text];
  531. edge.target = this.nodeMap[connection.getTarget().text];
  532. edge.source.outgoingLinks.push(edge);
  533. edge.target.incomingLinks.push(edge);
  534. this.edgeMap[connectionId] = edge;
  535. }
  536. },
  537. updateModel: function() {
  538. for (var nodeId in this.nodeMap) {
  539. var item = this.nodeMap[nodeId];
  540. var model = this.getModel(nodeId);
  541. model.x = item.x;
  542. model.y = item.y;
  543. model.getEditPart().getFigure().x = model.x;
  544. model.getEditPart().getFigure().y = model.y;
  545. for (var i = 0; i < item.outgoingLinks.length; i++) {
  546. var connection = item.outgoingLinks[i];
  547. var connectionModel = this.getConnectionModel(model, connection);
  548. if (connectionModel == null) {
  549. continue;
  550. }
  551. connectionModel.innerPoints = typeof connection.innerPoints == 'undefined' ? []
  552. : connection.innerPoints;
  553. connectionModel.textX = 0;
  554. connectionModel.textY = 0;
  555. connectionModel.getEditPart().getFigure().innerPoints = connectionModel.innerPoints;
  556. connectionModel.getEditPart().getFigure().textX = connectionModel.textX;
  557. connectionModel.getEditPart().getFigure().textY = connectionModel.textY;
  558. }
  559. }
  560. this.process.getEditPart().refresh();
  561. },
  562. getModel: function(name) {
  563. var model = null;
  564. Gef.each(this.process.children, function(item) {
  565. if (item.text == name) {
  566. model = item;
  567. return false;
  568. }
  569. });
  570. return model;
  571. },
  572. getConnectionModel: function(nodeModel, edge) {
  573. var model = null;
  574. Gef.each(nodeModel.getOutgoingConnections(), function(item) {
  575. if (item.getTarget().text == edge.getTarget().id) {
  576. model = item;
  577. return false;
  578. }
  579. });
  580. return model;
  581. }
  582. };
  583. ;
  584. // should be change name to LayoutingElement
  585. Node = function() {
  586. this.incomingLinks = [];
  587. this.outgoingLinks = [];
  588. };
  589. Node.prototype = {
  590. getIncomingLinks: function() {
  591. return this.incomingLinks;
  592. },
  593. getOutgoingLinks: function() {
  594. return this.outgoingLinks;
  595. },
  596. getPrecedingElements: function() {
  597. var previousElements = [];
  598. for (var i = 0; i < this.incomingLinks.length; i++) {
  599. previousElements.push(this.incomingLinks[i].source);
  600. }
  601. return previousElements;
  602. },
  603. getFollowingElements: function() {
  604. var followingElements = [];
  605. for (var i = 0; i < this.outgoingLinks.length; i++) {
  606. followingElements.push(this.outgoingLinks[i].target);
  607. }
  608. return followingElements;
  609. },
  610. isJoin: function() {
  611. return this.incomingLinks.length > 1;
  612. },
  613. isSplit: function() {
  614. return this.outgoingLinks.length > 1;
  615. },
  616. prevSplit: function() {
  617. var distance = 1000;
  618. var candidateDistance = 0;
  619. var split = null;
  620. var candidate = null;
  621. var precedingElements = this.getPrecedingElements();
  622. for (var i = 0; i < precedingElements.length; i++) {
  623. var elem = precedingElements[i];
  624. if (elem.isSplit()) {
  625. return elem;
  626. }
  627. candidate = elem.prevSplit();
  628. if (this.isJoin()) {
  629. // if this is not a join, we have only one precedingElement.
  630. candidateDistance = elem.backwardDistanceTo(candidate);
  631. }
  632. if (candidateDistance < distance) {
  633. split = candidate;
  634. distance = candidateDistance;
  635. }
  636. }
  637. return split;
  638. },
  639. backwardDistanceTo: function(other) {
  640. return this._backwardDistanceTo(other, []);
  641. },
  642. _backwardDistanceTo: function(other, historyElements) {
  643. if (other == this) {
  644. return 0;
  645. }
  646. if (historyElements.indexOf(this) != -1) {
  647. return 1000;
  648. }
  649. var d = 1000;
  650. var newHistory = [];
  651. newHistory.push(this);
  652. var precedingElements = this.getPrecedingElements();
  653. for (var i = 0; i < precedingElements.length; i++) {
  654. var el = precedingElements[i];
  655. d = Math.min(d, el._backwardDistanceTo(other, newHistory));
  656. }
  657. return d == 1000 ? d : d + 1;
  658. }
  659. };
  660. ;
  661. Edge = function() {
  662. this.source = null;
  663. this.target = null;
  664. };
  665. Edge.prototype = {
  666. getSource: function() {
  667. return this.source;
  668. },
  669. getTarget: function() {
  670. return this.target;
  671. },
  672. reverseOutgoingAndIncoming: function() {
  673. var index = 0;
  674. var oldSource = this.source;
  675. var oldTarget = this.target;
  676. index = oldSource.outgoingLinks.indexOf(this);
  677. oldSource.outgoingLinks.splice(index, 1);
  678. index = oldTarget.incomingLinks.indexOf(this);
  679. oldTarget.incomingLinks.splice(index, 1);
  680. var newSource = oldTarget;
  681. var newTarget = oldSource;
  682. newSource.outgoingLinks.push(this);
  683. newTarget.incomingLinks.push(this);
  684. this.source = newSource;
  685. this.target = newTarget;
  686. }
  687. };
  688. ;
  689. TopologicalSorter = function(diagram) {
  690. this.diagram = diagram;
  691. this.prepareDataAndSort(true);
  692. this.prepareDataAndSort(false);
  693. };
  694. TopologicalSorter.prototype = {
  695. getSortedElements: function() {
  696. return this.sortedElements;
  697. },
  698. prepareDataAndSort: function(shouldBackpatch) {
  699. this.sortedElements = [];
  700. this.elementsToSort = {};
  701. this.backwardsEdges = [];
  702. this.elementsToSortCount = 0;
  703. this.addAllChildren();
  704. this.topologicalSort();
  705. if (shouldBackpatch === true) {
  706. this.backpatchBackwardsEdges();
  707. }
  708. this.reverseBackwardsEdges();
  709. },
  710. addAllChildren: function() {
  711. for (var nodeId in this.diagram.nodeMap) {
  712. var node = this.diagram.nodeMap[nodeId];
  713. this.elementsToSort[nodeId] = new SortableLayoutingElement(node);
  714. this.elementsToSortCount++;
  715. }
  716. },
  717. topologicalSort: function() {
  718. var count = 0;
  719. var oldCount = 0;
  720. while (this.elementsToSortCount > 0) {
  721. var freeElements = this.getFreeElements();
  722. if (freeElements.length > 0) {
  723. for (var i = 0; i < freeElements.length; i++) {
  724. var freeElement = freeElements[i];
  725. this.sortedElements.push(freeElement.node);
  726. this.freeElementsFrom(freeElement);
  727. delete this.elementsToSort[freeElement.node.id];
  728. }
  729. } else {
  730. var entry = this.getLoopEntryPoint();
  731. for (var i = 0; i < entry.incomingLinks.length; i++) {
  732. var backId = entry.incomingLinks[i];
  733. entry.reverseIncomingLinkFrom(backId);
  734. var elem = this.elementsToSort[backId];
  735. elem.reverseOutgoingLinkTo(entry.node.id);
  736. this.backwardsEdges.push(new BackwardsEdge(backId, entry.node.id));
  737. }
  738. }
  739. }
  740. },
  741. backpatchBackwardsEdges: function() {
  742. var newBackwardsEdges = [];
  743. for (var i = 0; i < this.backwardsEdges.length; i++) {
  744. newBackwardsEdges.push(this.backwardsEdges[i]);
  745. }
  746. for (var i = 0; i < this.backwardsEdges.length; i++) {
  747. var edge = this.backwardsEdges[i];
  748. var sourceId = edge.getSource();
  749. var targetId = edge.getTarget();
  750. var sourceElement = this.diagram.nodeMap[sourceId];
  751. while (!(sourceElement.isJoin() || sourceElement.isSplit())) {
  752. var newSourceElement = sourceElement.getPrecedingElements()[0];
  753. targetId = newSourceElement.id;
  754. newBackwardsEdges.push(new BackwardsEdge(targetId, sourceId));
  755. sourceElement = newSourceElement;
  756. sourceId = targetId;
  757. }
  758. }
  759. this.backwardsEdges = newBackwardsEdges;
  760. },
  761. reverseBackwardsEdges: function() {
  762. var edgeMap = this.diagram.edgeMap;
  763. for (var i = 0; i < this.backwardsEdges.length; i++) {
  764. var backwardsEdge = this.backwardsEdges[i];
  765. var sourceId = backwardsEdge.getSource();
  766. var targetId = backwardsEdge.getTarget();
  767. var sourceElement = this.diagram.nodeMap[sourceId];
  768. var targetElement = this.diagram.nodeMap[targetId];
  769. var edge = this.getEdge(edgeMap, sourceElement, targetElement);
  770. backwardsEdge.setEdge(edge);
  771. if (edge) {
  772. // reverse edge outgoing and incoming
  773. edge.reverseOutgoingAndIncoming();
  774. }
  775. }
  776. },
  777. getFreeElements: function() {
  778. var freeElements = [];
  779. for (var nodeId in this.elementsToSort) {
  780. var elem = this.elementsToSort[nodeId];
  781. if (elem.isFree()) {
  782. freeElements.push(elem);
  783. }
  784. }
  785. return freeElements;
  786. },
  787. freeElementsFrom: function(freeElement) {
  788. for (var i = 0; i < freeElement.outgoingLinks.length; i++) {
  789. var id = freeElement.outgoingLinks[i];
  790. var targetElement = this.elementsToSort[id];
  791. if (targetElement) {
  792. targetElement.removeIncomingLinkFrom(freeElement.node.id);
  793. }
  794. }
  795. this.elementsToSortCount--;
  796. },
  797. getLoopEntryPoint: function() {
  798. for (var nodeId in this.elementsToSort) {
  799. var candidate = this.elementsToSort[nodeId];
  800. if (candidate.oldInCount > 1
  801. && candidate.oldInCount > candidate.incomingLinks.length) {
  802. return candidate;
  803. }
  804. }
  805. throw new Error('Could not find a valid loop entry point');
  806. },
  807. getEdge: function(edgeMap, sourceElement, targetElement) {
  808. for (var i = 0; i < sourceElement.outgoingLinks.length; i++) {
  809. var edge = sourceElement.outgoingLinks[i];
  810. if (edge.getTarget().id == targetElement.id) {
  811. return edge;
  812. }
  813. }
  814. return null;
  815. }
  816. };
  817. ;
  818. SortableLayoutingElement = function(node) {
  819. this.node = node;
  820. this.incomingLinks = [];
  821. this.outgoingLinks = [];
  822. for (var i = 0; i < node.incomingLinks.length; i++) {
  823. this.incomingLinks.push(node.incomingLinks[i].source.id);
  824. }
  825. for (var i = 0; i < node.outgoingLinks.length; i++) {
  826. this.outgoingLinks.push(node.outgoingLinks[i].target.id);
  827. }
  828. this.oldInCount = this.incomingLinks.length;
  829. this.isJoin = node.isJoin();
  830. };
  831. SortableLayoutingElement.prototype = {
  832. isFree: function() {
  833. return this.incomingLinks.length == 0;
  834. },
  835. removeIncomingLinkFrom: function(sourceId) {
  836. var index = this.incomingLinks.indexOf(sourceId);
  837. this.incomingLinks.splice(index, 1);
  838. },
  839. reverseIncomingLinkFrom: function(id) {
  840. this.removeIncomingLinkFrom(id);
  841. this.outgoingLinks.push(id);
  842. },
  843. reverseOutgoingLinkTo: function(id) {
  844. var index = this.outgoingLinks.indexOf(id);
  845. this.outgoingLinks.splice(index, 1);
  846. this.incomingLinks.push(id);
  847. }
  848. };
  849. ;
  850. BackwardsEdge = function(source, target) {
  851. this.source = source;
  852. this.target = target;
  853. };
  854. BackwardsEdge.prototype = {
  855. getEdge: function() {
  856. return this.edge;
  857. },
  858. setEdge: function(edge) {
  859. this.edge = edge;
  860. },
  861. getSource: function() {
  862. return this.source;
  863. },
  864. getTarget: function() {
  865. return this.target;
  866. }
  867. };
  868. ;
  869. LeftToRightGridLayouter = function(diagram, sortedIds) {
  870. this.diagram = diagram;
  871. this.sortedIds = sortedIds;
  872. };
  873. LeftToRightGridLayouter.prototype = {
  874. doLayout: function() {
  875. this.grid = new Grid();
  876. this.layoutElements();
  877. this.calcGeometry(this.grid);
  878. this.writeGeometry(this.grid);
  879. this.diagram.updateModel();
  880. },
  881. layoutElements: function() {
  882. for (var i = 0; i < this.sortedIds.length; i++) {
  883. var sortedId = this.sortedIds[i];
  884. var currentElement = this.diagram.nodeMap[sortedId];
  885. var precedingElements = currentElement.getPrecedingElements();
  886. var cellOfElement = this.placeElement(currentElement, precedingElements);
  887. if (currentElement.isJoin() && precedingElements.length != 0) {
  888. // there is an edge hitting us left, so lets forbid
  889. // interleaving to use the left cell, if this is empty
  890. cellOfElement.getPrevCell().setPackable(false);
  891. }
  892. if (currentElement.isSplit()) {
  893. this.prelayoutSuccessors(currentElement, cellOfElement);
  894. }
  895. }
  896. },
  897. placeElement: function(currentElement, precedingElements) {
  898. var newCell = null;
  899. if (precedingElements.length == 0) {
  900. this.grid.startCell.value = currentElement;
  901. newCell = this.grid.startCell;
  902. } else {
  903. var leftCell = null;
  904. var newCell = this.grid.getCellOfItem(currentElement);
  905. if (currentElement.isJoin()) {
  906. var splitFound = false;
  907. var split = currentElement.prevSplit();
  908. if (split != null) {
  909. var splits = new PriorityQueue(currentElement);
  910. splits.add(split);
  911. for (var i = 0; i < precedingElements.length; i++) {
  912. var elem = precedingElements[i];
  913. split = elem.prevSplit();
  914. if (split != null && !splits.contains(split)) {
  915. splits.add(split);
  916. //console.info(splits.items);
  917. }
  918. }
  919. split = null;
  920. // get split with most connections
  921. var maxCon = 0;
  922. for (var i = 0; i < splits.items.length; i++) {
  923. var target = splits.items[i];
  924. if (target == currentElement) {
  925. continue;
  926. }
  927. // current connections
  928. var curCon = 0;
  929. for (var j = 0; j < precedingElements.length; j++) {
  930. var elem = precedingElements[j];
  931. if (elem.backwardDistanceTo(target) < 1000) {
  932. curCon++;
  933. }
  934. }
  935. if (curCon > maxCon) {
  936. maxCon = curCon;
  937. split = target;
  938. }
  939. }
  940. splitFound = split != null;
  941. }
  942. // current cell position
  943. var x = 0;
  944. var yAcc = 0;
  945. var yCnt = 0;
  946. for (var i = 0; i < precedingElements.length; i++) {
  947. var elem = precedingElements[i];
  948. var tmp = this.grid.getCellOfItem(elem);
  949. if (tmp == null) {
  950. tmp = {
  951. getColIndex: function() {
  952. return 0;
  953. }
  954. };
  955. } else {
  956. yAcc += tmp.getRowIndex();
  957. yCnt++;
  958. }
  959. x = Math.max(x, tmp.getColIndex());
  960. }
  961. // farthest to the right
  962. if (splitFound) {
  963. leftCell = this.grid.getCellOfItem(split).row.cells[x];
  964. // set path to split unpackable
  965. for (var c = leftCell; c.value != split; c = c.getPrevCell()) {
  966. c.setPackable(false);
  967. }
  968. } else {
  969. if (yCnt == 0) {
  970. leftCell = this.grid.rows[0].above().cells[x];
  971. } else {
  972. leftCell = this.grid.rows[yAcc / yCnt].cells[x];
  973. }
  974. }
  975. if (newCell != null && newCell.value == currentElement) {
  976. newCell.value = null;
  977. }
  978. newCell = leftCell.after();
  979. // set all incoming pathes unpackable
  980. for (var i = 0; i < precedingElements.length; i++) {
  981. var el = precedingElements[i];
  982. var target = this.grid.getCellOfItem(el);
  983. if (target == null) {
  984. continue;
  985. }
  986. var start = target.row.cells[x + 1];
  987. for (var c = start; c != target; c = c.getPrevCell()) {
  988. c.setPackable(false);
  989. }
  990. }
  991. } else if (newCell == null) {
  992. // if not preLayouted
  993. var preElem = precedingElements[0];
  994. leftCell = this.grid.getCellOfItem(preElem);
  995. newCell = leftCell.after();
  996. }
  997. if (newCell.isFilled() && newCell.value != currentElement) {
  998. newCell.row.insertRowBeneath();
  999. newCell = newCell.beneath();
  1000. }
  1001. newCell.value = currentElement;
  1002. newCell.getPrevCell().setPackable(false);
  1003. }
  1004. return newCell;
  1005. },
  1006. prelayoutSuccessors: function(currentElement, cellOfElement) {
  1007. var baseCell = cellOfElement.after();
  1008. var topCell = baseCell;
  1009. var followingElements = currentElement.getFollowingElements();
  1010. // heuristic for direct connection to join
  1011. var directJoin = null;
  1012. for (var i = 0; i < followingElements.length; i++) {
  1013. var possibleJoin = followingElements[i];
  1014. if (possibleJoin.isJoin()) {
  1015. directJoin = possibleJoin;
  1016. }
  1017. }
  1018. if (directJoin != null) {
  1019. // put in the middle
  1020. var index = followingElements.indexOf(directJoin);
  1021. // remove
  1022. followingElements.splice(index, 1);
  1023. var position = parseInt(followingElements.length / 2, 10);
  1024. // insert
  1025. followingElements.splice(position, 0, directJoin);
  1026. }
  1027. // normal preLayout following elements
  1028. var follow = parseInt(followingElements.length / 2, 10);
  1029. for (var i = 0; i < follow; i++) {
  1030. topCell.row.insertRowAbove();
  1031. baseCell.row.insertRowBeneath();
  1032. topCell = topCell.above();
  1033. }
  1034. for (var i = 0; i < followingElements.length; i++) {
  1035. var newElem = followingElements[i];
  1036. if (this.grid.getCellOfItem(newElem)) {
  1037. continue;
  1038. }
  1039. topCell.value = newElem;
  1040. topCell = topCell.beneath();
  1041. if (topCell == baseCell && followingElements.length % 2 == 0) {
  1042. topCell = topCell.beneath();
  1043. }
  1044. }
  1045. },
  1046. calcGeometry: function(grid) {
  1047. grid.pack();
  1048. var heightOfRow = [];
  1049. for (var i = 0; i < grid.rowCount; i++) {
  1050. heightOfRow.push(0);
  1051. }
  1052. var widthOfColumn = [];
  1053. for (var i = 0; i < grid.colCount; i++) {
  1054. widthOfColumn.push(0);
  1055. }
  1056. for (var i = 0; i < grid.rowCount; i++) {
  1057. var row = grid.rows[i];
  1058. for (var j = 0; j < grid.colCount; j++) {
  1059. var cell = row.cells[j];
  1060. if (cell.isFilled()) {
  1061. var elem = cell.value;
  1062. widthOfColumn[j] = Math.max(widthOfColumn[j], elem.w + 30);
  1063. heightOfRow[i] = Math.max(heightOfRow[i], elem.h + 30);
  1064. }
  1065. }
  1066. }
  1067. this.heightOfRow = heightOfRow;
  1068. this.widthOfColumn = widthOfColumn;
  1069. this.totalWidth = 0;
  1070. this.totalHeight = 0;
  1071. for (var i = 0; i < grid.colCount; i++) {
  1072. this.totalWidth += widthOfColumn[i];
  1073. }
  1074. for (var i = 0; i < grid.rowCount; i++) {
  1075. this.totalHeight += heightOfRow[i];
  1076. }
  1077. },
  1078. writeGeometry: function(grid) {
  1079. var x = 0;
  1080. var y = 0;
  1081. for (var i = 0; i < grid.rowCount; i++) {
  1082. var row = grid.rows[i];
  1083. var cellHeight = this.heightOfRow[i];
  1084. for (var j = 0; j < grid.colCount; j++) {
  1085. var cell = row.cells[j];
  1086. var cellWidth = this.widthOfColumn[j];
  1087. if (cell.isFilled()) {
  1088. var elem = cell.value;
  1089. var newX = x + cellWidth / 2 - elem.w / 2;
  1090. var newY = y + cellHeight / 2 - elem.h / 2;
  1091. elem.x = newX;
  1092. elem.y = newY;
  1093. }
  1094. x += cellWidth;
  1095. }
  1096. x = 0;
  1097. y += cellHeight;
  1098. }
  1099. }
  1100. };
  1101. ;
  1102. Grid = function() {
  1103. var cell = new Cell();
  1104. var row = new Row();
  1105. row.grid = this;
  1106. row.addCell(cell);
  1107. this.rows = [row];
  1108. this.startCell = cell;
  1109. this.colCount = 1;
  1110. this.rowCount = this.rows.length;
  1111. };
  1112. Grid.prototype = {
  1113. addFirstRow: function() {
  1114. var row = new Row();
  1115. row.grid = this;
  1116. for (var i = 0; i < this.rolCount; i++) {
  1117. var cell = new Cell();
  1118. row.addCell(cell);
  1119. }
  1120. this.rows.unshift(row);
  1121. this.rowCount = this.rows.length;
  1122. },
  1123. addLastRow: function() {
  1124. var row = new Row();
  1125. row.grid = this;
  1126. for (var i = 0; i < this.rolCount; i++) {
  1127. row.addCell(new Cell());
  1128. }
  1129. this.rows.push(row);
  1130. this.rowCount = this.rows.length;
  1131. },
  1132. addLastCol: function() {
  1133. for (var i = 0; i < this.rowCount; i++) {
  1134. var row = this.rows[i];
  1135. row.addCell(new Cell());
  1136. }
  1137. this.colCount++;
  1138. },
  1139. getCellOfItem: function(elem) {
  1140. for (var i = 0; i < this.rowCount; i++) {
  1141. var row = this.rows[i];
  1142. for (var j = 0; j < this.colCount; j++) {
  1143. var cell = row.cells[j];
  1144. if (cell.value == elem) {
  1145. return cell;
  1146. }
  1147. }
  1148. }
  1149. return null;
  1150. },
  1151. pack: function() {
  1152. var changed = false;
  1153. do {
  1154. changed = false;
  1155. for (var i = 0; i < this.rows.length; i++) {
  1156. var row = this.rows[i];
  1157. changed |= row.tryInterleaveWith(row.getPrevRow());
  1158. }
  1159. for (var i = 0; i < this.rows.length; i++) {
  1160. var row = this.rows[i];
  1161. changed |= row.tryInterleaveWith(row.getNextRow());
  1162. }
  1163. } while (changed);
  1164. },
  1165. info: function() {
  1166. var value = '';
  1167. for (var i = 0; i < this.rows.length; i++) {
  1168. var row = this.rows[i];
  1169. for (var j = 0; j < row.cells.length; j++) {
  1170. var cell = row.cells[j];
  1171. var id = '[ ]';
  1172. if (cell.isFilled()) {
  1173. id = cell.value.id;
  1174. } else if (cell.packable === false) {
  1175. id = '[ p ]';
  1176. }
  1177. value += id;
  1178. }
  1179. value += '\n'
  1180. }
  1181. return value;
  1182. }
  1183. };
  1184. ;
  1185. Cell = function() {
  1186. this.packable = true;
  1187. };
  1188. Cell.prototype = {
  1189. isFilled: function() {
  1190. return typeof this.value != 'undefined' && this.value != null;
  1191. },
  1192. isUnpackable: function() {
  1193. return this.isFilled() || (this.packable === false);
  1194. },
  1195. setPackable: function(packable) {
  1196. this.packable = packable;
  1197. },
  1198. getRowIndex: function() {
  1199. return this.row.getIndex();
  1200. },
  1201. getColIndex: function() {
  1202. for (var i = 0; i < this.row.cells.length; i++) {
  1203. if (this.row.cells[i] == this) {
  1204. return i;
  1205. }
  1206. }
  1207. },
  1208. after: function() {
  1209. var colIndex = this.getColIndex();
  1210. if (colIndex == this.row.cells.length - 1) {
  1211. this.grid.addLastCol();
  1212. }
  1213. return this.row.cells[colIndex + 1];
  1214. },
  1215. above: function() {
  1216. var rowIndex = this.getRowIndex();
  1217. var colIndex = this.getColIndex();
  1218. if (rowIndex == 0) {
  1219. this.row.insertRowAbove();
  1220. }
  1221. return this.grid.rows[rowIndex - 1].cells[colIndex];
  1222. },
  1223. beneath: function() {
  1224. var rowIndex = this.getRowIndex();
  1225. var colIndex = this.getColIndex();
  1226. if (rowIndex == this.grid.rowCount - 1) {
  1227. this.row.insertRowBeneath();
  1228. }
  1229. return this.grid.rows[rowIndex + 1].cells[colIndex];
  1230. },
  1231. getPrevCell: function() {
  1232. var index = this.getColIndex();
  1233. return this.row.cells[index - 1];
  1234. },
  1235. getNextCell: function() {
  1236. var index = this.getColIndex();
  1237. return this.row.cells[index + 1];
  1238. }
  1239. };
  1240. ;
  1241. Row = function() {
  1242. this.cells = [];
  1243. };
  1244. Row.prototype = {
  1245. addCell: function(cell) {
  1246. cell.row = this;
  1247. cell.grid = this.grid;
  1248. this.cells.push(cell);
  1249. },
  1250. getIndex: function() {
  1251. for (var i = 0; i < this.grid.rows.length; i++) {
  1252. if (this.grid.rows[i] == this) {
  1253. return i;
  1254. }
  1255. }
  1256. },
  1257. insertRowBeneath: function() {
  1258. var row = new Row();
  1259. row.grid = this.grid;
  1260. for (var i = 0; i < this.grid.colCount; i++) {
  1261. row.addCell(new Cell());
  1262. }
  1263. var rowIndex = this.getIndex();
  1264. var rows = this.grid.rows;
  1265. if (rowIndex == rows.length - 1) {
  1266. rows.push(row);
  1267. } else {
  1268. rows.splice(rowIndex + 1, 0, row);
  1269. }
  1270. this.grid.rowCount = rows.length;
  1271. },
  1272. insertRowAbove: function() {
  1273. var row = new Row();
  1274. row.grid = this.grid;
  1275. for (var i = 0; i < this.grid.colCount; i++) {
  1276. row.addCell(new Cell());
  1277. }
  1278. var rowIndex = this.getIndex();
  1279. var rows = this.grid.rows;
  1280. if (rowIndex == 0) {
  1281. rows.unshift(row);
  1282. } else {
  1283. rows.splice(rowIndex, 0, row);
  1284. }
  1285. this.grid.rowCount = rows.length;
  1286. },
  1287. getPrevRow: function() {
  1288. var index = this.getIndex();
  1289. if (index > 0) {
  1290. return this.grid.rows[index - 1];
  1291. } else {
  1292. return null;
  1293. }
  1294. },
  1295. getNextRow: function() {
  1296. var index = this.getIndex();
  1297. if (index < this.grid.rows.length) {
  1298. return this.grid.rows[index + 1];
  1299. } else {
  1300. return null;
  1301. }
  1302. },
  1303. tryInterleaveWith: function(other) {
  1304. if (!this.isInterleaveWith(other)) {
  1305. return false;
  1306. }
  1307. for (var i = 0; i < this.cells.length; i++) {
  1308. var cell = this.cells[i];
  1309. var otherCell = other.cells[i];
  1310. if (cell.isFilled()) {
  1311. other.cells[i] = cell;
  1312. } else if (cell.isUnpackable()) {
  1313. otherCell.setPackable(false);
  1314. }
  1315. }
  1316. this._remove();
  1317. return true;
  1318. },
  1319. isInterleaveWith: function(other) {
  1320. if (other == null || other == this) {
  1321. return false;
  1322. } else if (other.getPrevRow() != this && other.getNextRow() != this) {
  1323. return false;
  1324. }
  1325. for (var i = 0; i < this.cells.length; i++) {
  1326. var cell = this.cells[i];
  1327. var otherCell = other.cells[i];
  1328. if (cell.isUnpackable() && otherCell.isUnpackable()) {
  1329. return false;
  1330. }
  1331. }
  1332. return true;
  1333. },
  1334. _remove: function() {
  1335. var index = this.getIndex();
  1336. this.grid.rows.splice(index, 1);
  1337. this.grid.rowCount--;
  1338. }
  1339. };
  1340. ;
  1341. PriorityQueue = function(center) {
  1342. this.ce = center;
  1343. this.items = [];
  1344. };
  1345. PriorityQueue.prototype = {
  1346. add: function(element) {
  1347. this.items.push(element);
  1348. var len = this.items.length;
  1349. for (var i = 0; i < len; i++) {
  1350. for (var j = i; j < len; j++) {
  1351. var elem1 = this.items[i];
  1352. var elem2 = this.items[j];
  1353. if (this.compareTo(elem1, elem2) > 0) {
  1354. this.items[i] = elem2;
  1355. this.items[j] = elem1;
  1356. }
  1357. }
  1358. }
  1359. },
  1360. compareTo: function(elem1, elem2) {
  1361. return this.ce.backwardDistanceTo(elem1) - this.ce.backwardDistanceTo(elem2);
  1362. },
  1363. contains: function(element) {
  1364. return this.items.indexOf(element) != -1;
  1365. }
  1366. };
  1367. ;
  1368. EdgeLayouter = function(grid, edge) {
  1369. this.grid = grid;
  1370. this.edge = edge;
  1371. edge.innerPoints = [];
  1372. this.calculateGlobals();
  1373. this.pickLayoutForEdge();
  1374. };
  1375. EdgeLayouter.prototype = {
  1376. calculateGlobals: function() {
  1377. this.source = this.edge.source;
  1378. this.target = this.edge.target;
  1379. this.sourceRelativeCenterX = this.source.w / 2;
  1380. this.sourceRelativeCenterY = this.source.h / 2;
  1381. this.targetRelativeCenterX = this.target.w / 2;
  1382. this.targetRelativeCenterY = this.target.h / 2;
  1383. this.sourceAbsoluteCenterX = this.source.x + this.sourceRelativeCenterX;
  1384. this.sourceAbsoluteCenterY = this.source.y + this.sourceRelativeCenterY;
  1385. this.targetAbsoluteCenterX = this.target.x + this.targetRelativeCenterX;
  1386. this.targetAbsoluteCenterY = this.target.y + this.targetRelativeCenterY;
  1387. this.sourceAbsoluteX = this.source.x;
  1388. this.sourceAbsoluteY = this.source.y;
  1389. this.sourceAbsoluteX2 = this.source.x + this.source.w;
  1390. this.sourceAbsoluteY2 = this.source.y + this.source.h;
  1391. this.targetAbsoluteX = this.target.x;
  1392. this.targetAbsoluteY = this.target.y;
  1393. this.targetAbsoluteX2 = this.target.x + this.target.w;
  1394. this.targetAbsoluteY2 = this.target.y + this.target.h;
  1395. this.sourceJoin = this.source.isJoin();
  1396. this.sourceSplit = this.source.isSplit();
  1397. this.targetJoin = this.target.isJoin();
  1398. this.targetSplit = this.target.isSplit();
  1399. this.backwards = this.sourceAbsoluteCenterX > this.targetAbsoluteCenterX;
  1400. },
  1401. pickLayoutForEdge: function() {
  1402. // sourceX == targetX, up and down
  1403. if (this.sourceAbsoluteCenterX == this.targetAbsoluteCenterX) {
  1404. this.setEdgeDirectCenter();
  1405. return;
  1406. } else if (this.sourceAbsoluteCenterY == this.targetAbsoluteCenterY) {
  1407. if (this.areCellsHorizontalFree()) {
  1408. this.setEdgeDirectCenter();
  1409. } else {
  1410. this.setEdgeAroundTheCorner(true);
  1411. }
  1412. return;
  1413. }
  1414. if (this.sourceAbsoluteCenterX <= this.targetAbsoluteCenterX
  1415. && this.sourceAbsoluteCenterY <= this.targetAbsoluteCenterY) {
  1416. // target is right under
  1417. if (this.sourcejoin && this.sourceSplit) {
  1418. this.setEdgeStepRight();
  1419. return;
  1420. } else if (this.sourceSplit) {
  1421. this.setEdge90DegreeRightUnderAntiClockwise();
  1422. return;
  1423. } else if (this.targetJoin) {
  1424. this.setEdge90DegreeRightUnderClockwise();
  1425. return;
  1426. }
  1427. } else if (this.sourceAbsoluteCenterX <= this.targetAbsoluteCenterX
  1428. && this.sourceAbsoluteCenterY > this.targetAbsoluteCenterY) {
  1429. // target is right above
  1430. if (this.sourcejoin && this.sourceSplit) {
  1431. this.setEdgeStepRight();
  1432. return;
  1433. } else if (this.sourceSplit) {
  1434. this.setEdge90DegreeRightAboveClockwise();
  1435. return;
  1436. } else if (this.targetJoin) {
  1437. this.setEdge90DegreeRightAboveAntiClockwise();
  1438. return;
  1439. }
  1440. }
  1441. if (this.sourceJoin && sourceSplit && (!this.backwards)) {
  1442. this.setEdgeStepRight();
  1443. return;
  1444. }
  1445. if (this.sourceJoin && sourceSplit) {
  1446. this.setEdgeAroundTheCorner(true);
  1447. return;
  1448. }
  1449. this.setEdgeDirectCenter();
  1450. },
  1451. areCellsHorizontalFree: function() {
  1452. var fromCell = null;
  1453. var toCell = null;
  1454. if (this.sourceAbsoluteCenterX < this.targetAbsoluteCenterX) {
  1455. fromCell = this.grid.getCellOfItem(this.source);
  1456. toCell = this.grid.getCellOfItem(this.target);
  1457. } else {
  1458. fromCell = this.grid.getCellOfItem(this.target);
  1459. toCell = this.grid.getCellOfItem(this.source);
  1460. }
  1461. fromCell = fromCell.getNextCell();
  1462. while (fromCell != toCell) {
  1463. if (fromCell == null || fromCell.isFilled()) {
  1464. return false;
  1465. }
  1466. fromCell = fromCell.getNextCell();
  1467. }
  1468. return true;
  1469. },
  1470. setEdgeDirectCenter: function() {
  1471. var boundsMinX = Math.min(this.sourceAbsoluteCenterX,
  1472. this.targetAbsoluteCenterX);
  1473. var boundsMinY = Math.min(this.sourceAbsoluteCenterY,
  1474. this.targetAbsoluteCenterY);
  1475. var boundsMaxX = Math.max(this.sourceAbsoluteCenterX,
  1476. this.targetAbsoluteCenterX);
  1477. var boundsMaxY = Math.max(this.sourceAbsoluteCenterY,
  1478. this.targetAbsoluteCenterY);
  1479. // this.edge.innerPoints = [];
  1480. },
  1481. setEdge90DegreeRightAboveClockwise: function() {
  1482. this.edge.innerPoints = [
  1483. [this.sourceAbsoluteCenterX, this.targetAbsoluteCenterY]
  1484. ];
  1485. },
  1486. setEdge90DegreeRightAboveAntiClockwise: function() {
  1487. this.edge.innerPoints = [
  1488. [this.targetAbsoluteCenterX, this.sourceAbsoluteCenterY]
  1489. ];
  1490. },
  1491. setEdge90DegreeRightUnderClockwise: function() {
  1492. this.edge.innerPoints = [
  1493. [this.targetAbsoluteCenterX, this.sourceAbsoluteCenterY]
  1494. ];
  1495. },
  1496. setEdge90DegreeRightUnderAntiClockwise: function() {
  1497. this.edge.innerPoints = [
  1498. [this.sourceAbsoluteCenterX, this.targetAbsoluteCenterY]
  1499. ];
  1500. },
  1501. setEdgeAroundTheCorner: function(down) {
  1502. var height = Math.max(this.source.h / 2, this.target.h / 2) + 20;
  1503. if (down) {
  1504. height *= -1;
  1505. }
  1506. this.edge.innerPoints = [
  1507. [this.sourceAbsoluteCenterX, this.sourceAbsoluteCenterY + height],
  1508. [this.targetAbsoluteCenterX, this.sourceAbsoluteCenterY + height]
  1509. ];
  1510. }
  1511. };
  1512. Ext.ux.OneCombo = Ext.extend(Ext.form.ComboBox, {
  1513. initComponent: function() {
  1514. this.readOnly = true;
  1515. this.displayField = 'text';
  1516. this.valueField = 'text';
  1517. this.triggerAction = 'all';
  1518. this.mode = 'local';
  1519. this.emptyText = 'Please Select...';
  1520. this.store = new Ext.data.SimpleStore({
  1521. expandData: true,
  1522. fields: ['text']
  1523. });
  1524. this.store.loadData(this.data);
  1525. Ext.ux.OneCombo.superclass.initComponent.call(this);
  1526. }
  1527. });
  1528. Ext.reg('onecombo', Ext.ux.OneCombo);
  1529. Gef.ns("Gef.planner");
  1530. Gef.ns("Gef.planner.model");
  1531. Gef.ns("Gef.planner.figure");
  1532. Gef.ns("Gef.planner.editpart");
  1533. function registerClass(type, name, url, w, h){
  1534. function capitaliseFirstLetter(string)
  1535. {
  1536. return string.charAt(0).toUpperCase() + string.slice(1);
  1537. }
  1538. var preType = type;
  1539. Gef.planner.model[preType+"Model"] = Gef.extend(Gef.jbs.model.GenericImageModel, {
  1540. type: preType,
  1541. url: url,
  1542. constructor: function(conf) {
  1543. Gef.planner.model[preType+"Model"].superclass.constructor.call(this, conf);
  1544. this.w = w;
  1545. this.h = h;
  1546. }
  1547. });
  1548. Gef.planner.figure[preType+"Figure"] = Gef.extend(Gef.jbs.figure.GenericImageFigure, {
  1549. });
  1550. Gef.planner.editpart[preType+"EditPart"] = Gef.extend(Gef.jbs.editpart.GenericImageEditPart, {
  1551. _figureClassName: "Gef.planner.figure." + preType + "Figure"
  1552. });
  1553. Gef.jbs.JBSModelFactory.registerModel(type, "Gef.planner.model." + preType + "Model");
  1554. Gef.jbs.JBSEditPartFactory.registerEditPart(type, "Gef.planner.editpart." + preType + "EditPart");
  1555. }
  1556. var tpls = [
  1557. ['A10700','A10700', 'images/stenciles/network/10700.jpg', 77, 52],
  1558. ['Antenna','Antenna', 'images/stenciles/network/antenna.jpg', 88, 102],
  1559. ['AXP','AXP', 'images/stenciles/network/AXP.jpg', 77, 74],
  1560. ['Bbfw','Bbfw', 'images/stenciles/network/bbfw.jpg', 20, 16],
  1561. ['Cloud','Cloud', 'images/stenciles/network/cloud1.png', 128, 128],
  1562. ['Cluster','Cluster', 'images/stenciles/network/cluster.jpg', 172,100 ],
  1563. ['Communicator','Communicator', 'images/stenciles/network/communicator.jpg', 134, 74],
  1564. ['Coreswitcher','Coreswitcher', 'images/stenciles/network/core_switcher.png', 148, 95],
  1565. ['Dish','Dish', 'images/stenciles/network/dish.jpg', 98, 72],
  1566. ['Fax','Fax', 'images/stenciles/network/fax.jpg', 126, 60],
  1567. ['Firewall','Firewall', 'images/stenciles/network/firewall.png', 62, 147],
  1568. ['Gatekeeper','Gatekeeper', 'images/stenciles/network/gatekeeper.jpg', 79,57 ],
  1569. ['Hootphone','Hootphone', 'images/stenciles/network/hootphone.jpg', 64, 48],
  1570. ['House1','House1', 'images/stenciles/network/house1.png', 157, 117],
  1571. ['House2','House2', 'images/stenciles/network/house2.png', 173, 115],
  1572. ['Hpprinter','Hpprinter', 'images/stenciles/network/hp_printer.png', 128,128 ],
  1573. ['Ibm','Ibm', 'images/stenciles/network/ibm.png', 212,142 ],
  1574. ['Mycomputer2','Mycomputer2', 'images/stenciles/network/my_computer2.png', 128,128 ],
  1575. ['Network2','Network2', 'images/stenciles/network/network_2.png',128 ,128 ],
  1576. ['Networkserver','Networkserver', 'images/stenciles/network/network_server.png',128 ,128 ],
  1577. ['Pc','Pc', 'images/stenciles/network/pc.jpg',79 ,71 ],
  1578. ['Phone','Phone', 'images/stenciles/network/phone.jpg',33 ,57 ],
  1579. ['Modem','Modem', 'images/stenciles/network/modem.png', 128,128 ],
  1580. ['Sattelite','Sattelite', 'images/stenciles/network/sattelite.jpg',133 ,45 ],
  1581. ['Software','Software', 'images/stenciles/network/software.jpg',91 ,86 ],
  1582. ['Streamer','Streamer', 'images/stenciles/network/streamer.jpg', 407, 223],
  1583. ['Terminal','Terminal', 'images/stenciles/network/terminal.jpg', 98, 119],
  1584. ['User', 'User', 'images/stenciles/network/user.png',128 ,128 ],
  1585. ['Webserver','Webserver', 'images/stenciles/network/web_server.png', 128, 128],
  1586. ['Wirelesstower2','Wirelesstower2', 'images/stenciles/network/wireless_tower_2.png', 128, 128]
  1587. ];
  1588. (function regClasses(arr){
  1589. for(var i=0;i<tpls.length;i++){
  1590. registerClass.apply(this, tpls[i]);
  1591. }
  1592. })(tpls);
  1593. function makePaletteArray1(arr){
  1594. var ret = [
  1595. {name: 'select', image: 'scripts/gef/images/activities/select32.png', title: '选择'},
  1596. {name: 'transition', image: 'scripts/gef/images/activities/32/flow_sequence.png', title: '连线'},
  1597. {name: 'rect', image: 'scripts/gef/images/activities/draw_rectangle.png', title: '矩形'},
  1598. {name: 'ellipse', image: 'scripts/gef/images/activities/draw_ellipse.png', title: '椭圆'}
  1599. ];
  1600. return ret;
  1601. }
  1602. function makePaletteArray2(arr){
  1603. var ret = [];
  1604. for(var i=0;i<tpls.length;i++){
  1605. ret.push({name: tpls[i][0], image: tpls[i][2], title: tpls[i][1]});
  1606. }
  1607. return ret;
  1608. }
  1609. function makeModelArray(arr){
  1610. var ret = {
  1611. select: {
  1612. text: 'select',
  1613. creatable: false
  1614. },
  1615. transition: {
  1616. text: 'transition',
  1617. creatable: false,
  1618. isConnection: true
  1619. },
  1620. rect: {
  1621. text: 'rect',
  1622. w: 80,
  1623. h: 60
  1624. },
  1625. ellipse: {
  1626. text: 'ellipse',
  1627. w: 80,
  1628. h: 60
  1629. }
  1630. };
  1631. for(var i=0;i<tpls.length;i++){
  1632. ret[tpls[i][0]] = {
  1633. text: tpls[i][0],
  1634. w: tpls[i][3],
  1635. h: tpls[i][4]
  1636. };
  1637. }
  1638. return ret;
  1639. }
  1640. Gef.jbs.ExtPaletteHelper = Gef.extend(Gef.jbs.JBSPaletteHelper, {
  1641. createSource: function() {
  1642. return makeModelArray();
  1643. },
  1644. getSource: function() {
  1645. if (!this.source) {
  1646. this.source = this.createSource();
  1647. }
  1648. return this.source;
  1649. },
  1650. render: Gef.emptyFn,
  1651. changeActivePalette: function(paletteConfig) {
  1652. var el = null;
  1653. if (this.getActivePalette()) {
  1654. var oldActivePaletteId = this.getActivePalette().text;
  1655. el = document.getElementById(oldActivePaletteId + '-img');
  1656. el.style.border = '';
  1657. }
  1658. this.setActivePalette(paletteConfig);
  1659. el = document.getElementById(paletteConfig.text + '-img');
  1660. el.style.border = '1px dotted black';
  1661. },
  1662. resetActivePalette: function() {
  1663. this.changeActivePalette({
  1664. text: 'select'
  1665. });
  1666. },
  1667. getPaletteConfig: function(p, t) {
  1668. var id = t.parentNode.id;
  1669. if (!id) {
  1670. return null;
  1671. }
  1672. var source = this.getSource();
  1673. var paletteConfig = this.getSource()[id];
  1674. if (!paletteConfig) {
  1675. return null;
  1676. }
  1677. this.changeActivePalette(paletteConfig);
  1678. if (paletteConfig.creatable === false) {
  1679. return null;
  1680. }
  1681. return paletteConfig;
  1682. }
  1683. });
  1684. App.PalettePanel = Ext.extend(Ext.Panel, {
  1685. initComponent: function() {
  1686. this.region = 'west';
  1687. this.title = '自定义图元库';
  1688. this.iconCls = 'tb-activity';
  1689. this.width = 110;
  1690. this.initPalette();
  1691. App.PalettePanel.superclass.initComponent.call(this);
  1692. },
  1693. initPalette: function() {
  1694. var paletteType = null;
  1695. if (!Gef.PALETTE_TYPE) {
  1696. paletteType = 'accordion';
  1697. } else {
  1698. paletteType = Gef.PALETTE_TYPE;
  1699. }
  1700. this.configLayout(paletteType);
  1701. this.configItems(paletteType);
  1702. },
  1703. createHtml: function(array, divId) {
  1704. if (divId) {
  1705. var html = '<div id="' + divId + '" unselectable="on">';
  1706. } else {
  1707. var html = '<div unselectable="on">';
  1708. }
  1709. for (var i = 0; i < array.length; i++) {
  1710. var item = array[i];
  1711. html += '<div id="' + item.name + '" class="paletteItem-' + item.name
  1712. + '" style="text-align:center;font-size:12px;cursor:pointer;" unselectable="on"><img width="32" height="32" id="'
  1713. + item.name + '-img" class="paletteItem-' + item.name
  1714. + '" src="' + item.image + '" unselectable="on"><br>'
  1715. + item.title + '</div>';
  1716. }
  1717. html += '</div>';
  1718. return html;
  1719. },
  1720. /**
  1721. * this.layout = 'accordion';
  1722. */
  1723. configLayout: function(type) {
  1724. if (!type || type == 'plain') {
  1725. //
  1726. } else if (type && type == 'accordion') {
  1727. this.layout = 'accordion';
  1728. }
  1729. },
  1730. configItems: function(type) {
  1731. if (type && type == 'accordion') {
  1732. this.createItemsForAccordion();
  1733. } else if (!type || type == 'plain') {
  1734. this.createItemsForHtml();
  1735. }
  1736. },
  1737. createItemsForAccordion: function() {
  1738. this.id = '__gef_jbs_palette__';
  1739. this.items = [{
  1740. title: '基本图元',
  1741. iconCls: 'tb-activity',
  1742. autoScroll: true,
  1743. html: this.createHtml(makePaletteArray1(tpls))
  1744. }, {
  1745. title: '高级图元',
  1746. iconCls: 'tb-activity',
  1747. autoScroll: true,
  1748. html: this.createHtml(makePaletteArray2(tpls))
  1749. }];
  1750. },
  1751. createItemsForHtml: function() {
  1752. this.autoScroll = true;
  1753. this.html = this.createHtml([
  1754. {name: 'select', image: 'select32', title: '选择'},
  1755. {name: 'transition', image: '32/flow_sequence', title: '连线'},
  1756. {name: 'start', image: '32/start_event_empty', title: '开始'},
  1757. {name: 'end', image: '32/end_event_terminate', title: '结束'},
  1758. {name: 'cancel', image: '32/end_event_cancel', title: '取消'},
  1759. {name: 'error', image: '32/end_event_error', title: '错误'},
  1760. {name: 'state', image: '32/task_wait', title: '等待'},
  1761. {name: 'task', image: '32/task_empty', title: '任务'},
  1762. {name: 'decision', image: '32/gateway_exclusive', title: '决策'},
  1763. {name: 'fork', image: '32/gateway_parallel', title: '并行'},
  1764. {name: 'join', image: '32/gateway_parallel', title: '汇聚'},
  1765. {name: 'java', image: '32/task_java', title: 'JAVA'},
  1766. {name: 'script', image: '32/task_java', title: '脚本'},
  1767. {name: 'hql', image: '32/task_hql', title: 'HQL'},
  1768. {name: 'sql', image: '32/task_sql', title: 'SQL'},
  1769. {name: 'mail', image: '32/task_empty', title: '邮件'},
  1770. {name: 'custom', image: '32/task_empty', title: '自定义'},
  1771. {name: 'subProcess', image: '32/task_empty', title: '子流程'},
  1772. {name: 'jms', image: '32/task_empty', title: 'JMS'},
  1773. {name: 'ruleDecision', image: '32/gateway_exclusive', title: '规则决策'},
  1774. {name: 'rules', image: '32/task_empty', title: '规则'},
  1775. {name: 'human', image: '32/task_empty', title: '人工节点'},
  1776. {name: 'auto', image: '32/task_empty', title: '自动节点'},
  1777. {name: 'counter-sign', image: '32/task_empty', title: '会签节点'}
  1778. ], '__gef_jbs_palette__');
  1779. }
  1780. });
  1781. Ext.ux.TwoCombo = Ext.extend(Ext.form.ComboBox, {
  1782. initComponent: function() {
  1783. this.readOnly = true;
  1784. this.displayField = 'text';
  1785. this.valueField = 'value';
  1786. this.triggerAction = 'all';
  1787. this.mode = 'local';
  1788. this.emptyText = 'Please Select...';
  1789. this.store = new Ext.data.SimpleStore({
  1790. fields: ['value', 'text']
  1791. });
  1792. this.store.loadData(this.data);
  1793. Ext.ux.TwoCombo.superclass.initComponent.call(this);
  1794. }
  1795. });
  1796. Ext.reg('twocombo', Ext.ux.TwoCombo);