Sidebar.js 177 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424
  1. /**
  2. * Copyright (c) 2006-2012, JGraph Ltd
  3. */
  4. /**
  5. * Construcs a new sidebar for the given editor.
  6. */
  7. function Sidebar(editorUi, container)
  8. {
  9. this.editorUi = editorUi;
  10. this.container = container;
  11. this.palettes = new Object();
  12. this.taglist = new Object();
  13. this.showTooltips = true;
  14. this.graph = editorUi.createTemporaryGraph(this.editorUi.editor.graph.getStylesheet());
  15. this.graph.cellRenderer.minSvgStrokeWidth = this.minThumbStrokeWidth;
  16. this.graph.cellRenderer.antiAlias = this.thumbAntiAlias;
  17. this.graph.container.style.visibility = 'hidden';
  18. this.graph.foldingEnabled = false;
  19. document.body.appendChild(this.graph.container);
  20. this.pointerUpHandler = mxUtils.bind(this, function()
  21. {
  22. this.showTooltips = true;
  23. });
  24. mxEvent.addListener(document, (mxClient.IS_POINTER) ? 'pointerup' : 'mouseup', this.pointerUpHandler);
  25. this.pointerDownHandler = mxUtils.bind(this, function()
  26. {
  27. this.showTooltips = false;
  28. this.hideTooltip();
  29. });
  30. mxEvent.addListener(document, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown', this.pointerDownHandler);
  31. this.pointerMoveHandler = mxUtils.bind(this, function(evt)
  32. {
  33. var src = mxEvent.getSource(evt);
  34. while (src != null)
  35. {
  36. if (src == this.currentElt)
  37. {
  38. return;
  39. }
  40. src = src.parentNode;
  41. }
  42. this.hideTooltip();
  43. });
  44. mxEvent.addListener(document, (mxClient.IS_POINTER) ? 'pointermove' : 'mousemove', this.pointerMoveHandler);
  45. // Handles mouse leaving the window
  46. this.pointerOutHandler = mxUtils.bind(this, function(evt)
  47. {
  48. if (evt.toElement == null && evt.relatedTarget == null)
  49. {
  50. this.hideTooltip();
  51. }
  52. });
  53. mxEvent.addListener(document, (mxClient.IS_POINTER) ? 'pointerout' : 'mouseout', this.pointerOutHandler);
  54. // Enables tooltips after scroll
  55. mxEvent.addListener(container, 'scroll', mxUtils.bind(this, function()
  56. {
  57. this.showTooltips = true;
  58. this.hideTooltip();
  59. }));
  60. this.init();
  61. };
  62. /**
  63. * Adds all palettes to the sidebar.
  64. */
  65. Sidebar.prototype.init = function()
  66. {
  67. var dir = STENCIL_PATH;
  68. this.addSearchPalette(true);
  69. this.addGeneralPalette(true);
  70. this.addMiscPalette(false);
  71. this.addAdvancedPalette(false);
  72. this.addBasicPalette(dir);
  73. // this.setCurrentSearchEntryLibrary('arrows');
  74. // this.addStencilPalette('arrows', mxResources.get('arrows'), dir + '/arrows.xml',
  75. // ';whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#000000;strokeWidth=2');
  76. // this.setCurrentSearchEntryLibrary();
  77. // this.addUmlPalette(false);
  78. // this.addBpmnPalette(dir, false);
  79. // this.setCurrentSearchEntryLibrary('flowchart');
  80. // this.addStencilPalette('flowchart', 'Flowchart', dir + '/flowchart.xml',
  81. // ';whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#000000;strokeWidth=2');
  82. // this.setCurrentSearchEntryLibrary();
  83. this.setCurrentSearchEntryLibrary('wms');
  84. this.addStencilPalette('wms', '物流', dir + '/wms.xml',
  85. ';whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#000000;strokeWidth=2');
  86. this.setCurrentSearchEntryLibrary();
  87. // this.setCurrentSearchEntryLibrary('clipart');
  88. // this.addImagePalette('clipart', mxResources.get('clipart'), dir + '/clipart/', '_128x128.png',
  89. // ['Earth_globe', 'Empty_Folder', 'Full_Folder', 'Gear', 'Lock', 'Software', 'Virus', 'Email',
  90. // 'Database', 'Router_Icon', 'iPad', 'iMac', 'Laptop', 'MacBook', 'Monitor_Tower', 'Printer',
  91. // 'Server_Tower', 'Workstation', 'Firewall_02', 'Wireless_Router_N', 'Credit_Card',
  92. // 'Piggy_Bank', 'Graph', 'Safe', 'Shopping_Cart', 'Suit1', 'Suit2', 'Suit3', 'Pilot1',
  93. // 'Worker1', 'Soldier1', 'Doctor1', 'Tech1', 'Security1', 'Telesales1'], null,
  94. // {'Wireless_Router_N': 'wireless router switch wap wifi access point wlan',
  95. // 'Router_Icon': 'router switch'});
  96. this.setCurrentSearchEntryLibrary();
  97. };
  98. /**
  99. * Sets the default font size.
  100. */
  101. Sidebar.prototype.collapsedImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/collapsed.gif' : 'data:image/gif;base64,R0lGODlhDQANAIABAJmZmf///yH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjAgNjEuMTM0Nzc3LCAyMDEwLzAyLzEyLTE3OjMyOjAwICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozNUQyRTJFNjZGNUYxMUU1QjZEOThCNDYxMDQ2MzNCQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozNUQyRTJFNzZGNUYxMUU1QjZEOThCNDYxMDQ2MzNCQiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjFERjc3MEUxNkY1RjExRTVCNkQ5OEI0NjEwNDYzM0JCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjFERjc3MEUyNkY1RjExRTVCNkQ5OEI0NjEwNDYzM0JCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAQAAAQAsAAAAAA0ADQAAAhSMj6lrwAjcC1GyahV+dcZJgeIIFgA7';
  102. /**
  103. * Sets the default font size.
  104. */
  105. Sidebar.prototype.expandedImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/expanded.gif' : 'data:image/gif;base64,R0lGODlhDQANAIABAJmZmf///yH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjAgNjEuMTM0Nzc3LCAyMDEwLzAyLzEyLTE3OjMyOjAwICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoxREY3NzBERjZGNUYxMUU1QjZEOThCNDYxMDQ2MzNCQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoxREY3NzBFMDZGNUYxMUU1QjZEOThCNDYxMDQ2MzNCQiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjFERjc3MERENkY1RjExRTVCNkQ5OEI0NjEwNDYzM0JCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjFERjc3MERFNkY1RjExRTVCNkQ5OEI0NjEwNDYzM0JCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAQAAAQAsAAAAAA0ADQAAAhGMj6nL3QAjVHIu6azbvPtWAAA7';
  106. /**
  107. *
  108. */
  109. Sidebar.prototype.searchImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/search.png' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAEaSURBVHjabNGxS5VxFIfxz71XaWuQUJCG/gCHhgTD9VpEETg4aMOlQRp0EoezObgcd220KQiXmpretTAHQRBdojlQEJyukPdt+b1ywfvAGc7wnHP4nlZd1yKijQW8xzNc4Su+ZOYfQ3T6/f4YNvEJYzjELXp4VVXVz263+7cR2niBxAFeZ2YPi3iHR/gYERPDwhpOsd6sz8x/mfkNG3iOlWFhFj8y89J9KvzGXER0GuEaD42mgwHqUtoljbcRsTBCeINpfM/MgZLKPpaxFxGbOCqDXmILN7hoJrTKH+axhxmcYRxP0MIDnOBDZv5q1XUNIuJxifJp+UNV7t7BFM6xeic0RMQ4Bpl5W/ol7GISx/eEUUTECrbx+f8A8xhiZht9zsgAAAAASUVORK5CYII=';
  110. /**
  111. *
  112. */
  113. Sidebar.prototype.dragPreviewBorder = '1px dashed black';
  114. /**
  115. * Specifies if tooltips should be visible. Default is true.
  116. */
  117. Sidebar.prototype.enableTooltips = true;
  118. /**
  119. * Specifies the delay for the tooltip. Default is 16 px.
  120. */
  121. Sidebar.prototype.tooltipBorder = 16;
  122. /**
  123. * Specifies the delay for the tooltip. Default is 300 ms.
  124. */
  125. Sidebar.prototype.tooltipDelay = 300;
  126. /**
  127. * Specifies the delay for the drop target icons. Default is 200 ms.
  128. */
  129. Sidebar.prototype.dropTargetDelay = 200;
  130. /**
  131. * Specifies the URL of the gear image.
  132. */
  133. Sidebar.prototype.gearImage = STENCIL_PATH + '/clipart/Gear_128x128.png';
  134. /**
  135. * Specifies the width of the thumbnails.
  136. */
  137. Sidebar.prototype.thumbWidth = 42;
  138. /**
  139. * Specifies the height of the thumbnails.
  140. */
  141. Sidebar.prototype.thumbHeight = 42;
  142. /**
  143. * Specifies the width of the thumbnails.
  144. */
  145. Sidebar.prototype.minThumbStrokeWidth = 1;
  146. /**
  147. * Specifies the width of the thumbnails.
  148. */
  149. Sidebar.prototype.thumbAntiAlias = false;
  150. /**
  151. * Specifies the padding for the thumbnails. Default is 3.
  152. */
  153. Sidebar.prototype.thumbPadding = (document.documentMode >= 5) ? 2 : 3;
  154. /**
  155. * Specifies the delay for the tooltip. Default is 2 px.
  156. */
  157. Sidebar.prototype.thumbBorder = 2;
  158. /*
  159. * Experimental smaller sidebar entries
  160. */
  161. if (urlParams['sidebar-entries'] != 'large')
  162. {
  163. Sidebar.prototype.thumbPadding = (document.documentMode >= 5) ? 0 : 1;
  164. Sidebar.prototype.thumbBorder = 1;
  165. Sidebar.prototype.thumbWidth = 32;
  166. Sidebar.prototype.thumbHeight = 30;
  167. Sidebar.prototype.minThumbStrokeWidth = 1.3;
  168. Sidebar.prototype.thumbAntiAlias = true;
  169. }
  170. /**
  171. * Specifies the size of the sidebar titles.
  172. */
  173. Sidebar.prototype.sidebarTitleSize = 9;
  174. /**
  175. * Specifies if titles in the sidebar should be enabled.
  176. */
  177. Sidebar.prototype.sidebarTitles = false;
  178. /**
  179. * Specifies if titles in the tooltips should be enabled.
  180. */
  181. Sidebar.prototype.tooltipTitles = true;
  182. /**
  183. * Specifies if titles in the tooltips should be enabled.
  184. */
  185. Sidebar.prototype.maxTooltipWidth = 400;
  186. /**
  187. * Specifies if titles in the tooltips should be enabled.
  188. */
  189. Sidebar.prototype.maxTooltipHeight = 400;
  190. /**
  191. * Specifies if stencil files should be loaded and added to the search index
  192. * when stencil palettes are added. If this is false then the stencil files
  193. * are lazy-loaded when the palette is shown.
  194. */
  195. Sidebar.prototype.addStencilsToIndex = true;
  196. /**
  197. * Specifies the width for clipart images. Default is 80.
  198. */
  199. Sidebar.prototype.defaultImageWidth = 80;
  200. /**
  201. * Specifies the height for clipart images. Default is 80.
  202. */
  203. Sidebar.prototype.defaultImageHeight = 80;
  204. /**
  205. * Adds all palettes to the sidebar.
  206. */
  207. Sidebar.prototype.getTooltipOffset = function()
  208. {
  209. return new mxPoint(0, 0);
  210. };
  211. /**
  212. * Adds all palettes to the sidebar.
  213. */
  214. Sidebar.prototype.showTooltip = function(elt, cells, w, h, title, showLabel)
  215. {
  216. if (this.enableTooltips && this.showTooltips)
  217. {
  218. if (this.currentElt != elt)
  219. {
  220. if (this.thread != null)
  221. {
  222. window.clearTimeout(this.thread);
  223. this.thread = null;
  224. }
  225. var show = mxUtils.bind(this, function()
  226. {
  227. // Lazy creation of the DOM nodes and graph instance
  228. if (this.tooltip == null)
  229. {
  230. this.tooltip = document.createElement('div');
  231. this.tooltip.className = 'geSidebarTooltip';
  232. this.tooltip.style.zIndex = mxPopupMenu.prototype.zIndex - 1;
  233. document.body.appendChild(this.tooltip);
  234. this.graph2 = new Graph(this.tooltip, null, null, this.editorUi.editor.graph.getStylesheet());
  235. this.graph2.resetViewOnRootChange = false;
  236. this.graph2.foldingEnabled = false;
  237. this.graph2.gridEnabled = false;
  238. this.graph2.autoScroll = false;
  239. this.graph2.setTooltips(false);
  240. this.graph2.setConnectable(false);
  241. this.graph2.setEnabled(false);
  242. if (!mxClient.IS_SVG)
  243. {
  244. this.graph2.view.canvas.style.position = 'relative';
  245. }
  246. }
  247. this.graph2.model.clear();
  248. this.graph2.view.setTranslate(this.tooltipBorder, this.tooltipBorder);
  249. if (w > this.maxTooltipWidth || h > this.maxTooltipHeight)
  250. {
  251. this.graph2.view.scale = Math.round(Math.min(this.maxTooltipWidth / w, this.maxTooltipHeight / h) * 100) / 100;
  252. }
  253. else
  254. {
  255. this.graph2.view.scale = 1;
  256. }
  257. this.tooltip.style.display = 'block';
  258. this.graph2.labelsVisible = (showLabel == null || showLabel);
  259. var fo = mxClient.NO_FO;
  260. mxClient.NO_FO = Editor.prototype.originalNoForeignObject;
  261. // Applies current style for preview
  262. var temp = this.graph2.cloneCells(cells);
  263. this.editorUi.insertHandler(temp, null, this.graph2.model);
  264. this.graph2.addCells(temp);
  265. mxClient.NO_FO = fo;
  266. var bounds = this.graph2.getGraphBounds();
  267. var width = bounds.width + 2 * this.tooltipBorder + 4;
  268. var height = bounds.height + 2 * this.tooltipBorder;
  269. if (mxClient.IS_QUIRKS)
  270. {
  271. height += 4;
  272. this.tooltip.style.overflow = 'hidden';
  273. }
  274. else
  275. {
  276. this.tooltip.style.overflow = 'visible';
  277. }
  278. this.tooltip.style.width = width + 'px';
  279. var w2 = width;
  280. // Adds title for entry
  281. if (this.tooltipTitles && title != null && title.length > 0)
  282. {
  283. if (this.tooltipTitle == null)
  284. {
  285. this.tooltipTitle = document.createElement('div');
  286. this.tooltipTitle.style.borderTop = '1px solid gray';
  287. this.tooltipTitle.style.textAlign = 'center';
  288. this.tooltipTitle.style.width = '100%';
  289. this.tooltipTitle.style.overflow = 'hidden';
  290. this.tooltipTitle.style.position = 'absolute';
  291. this.tooltipTitle.style.paddingTop = '6px';
  292. this.tooltipTitle.style.bottom = '6px';
  293. this.tooltip.appendChild(this.tooltipTitle);
  294. }
  295. else
  296. {
  297. this.tooltipTitle.innerHTML = '';
  298. }
  299. this.tooltipTitle.style.display = '';
  300. mxUtils.write(this.tooltipTitle, title);
  301. // Allows for wider labels
  302. w2 = Math.min(this.maxTooltipWidth, Math.max(width, this.tooltipTitle.scrollWidth + 4));
  303. var ddy = this.tooltipTitle.offsetHeight + 10;
  304. height += ddy;
  305. if (mxClient.IS_SVG)
  306. {
  307. this.tooltipTitle.style.marginTop = (2 - ddy) + 'px';
  308. }
  309. else
  310. {
  311. height -= 6;
  312. this.tooltipTitle.style.top = (height - ddy) + 'px';
  313. }
  314. }
  315. else if (this.tooltipTitle != null && this.tooltipTitle.parentNode != null)
  316. {
  317. this.tooltipTitle.style.display = 'none';
  318. }
  319. // Updates width if label is wider
  320. if (w2 > width)
  321. {
  322. this.tooltip.style.width = w2 + 'px';
  323. }
  324. this.tooltip.style.height = height + 'px';
  325. var x0 = -Math.round(bounds.x - this.tooltipBorder) +
  326. ((w2 > width) ? (w2 - width) / 2 : 0);
  327. var y0 = -Math.round(bounds.y - this.tooltipBorder);
  328. var b = document.body;
  329. var d = document.documentElement;
  330. var off = this.getTooltipOffset();
  331. var bottom = Math.max(b.clientHeight || 0, d.clientHeight);
  332. var left = this.container.clientWidth + this.editorUi.splitSize + 3 + this.editorUi.container.offsetLeft + off.x;
  333. var top = Math.min(bottom - height - 20 /*status bar*/, Math.max(0, (this.editorUi.container.offsetTop +
  334. this.container.offsetTop + elt.offsetTop - this.container.scrollTop - height / 2 + 16))) + off.y;
  335. if (mxClient.IS_SVG)
  336. {
  337. if (x0 != 0 || y0 != 0)
  338. {
  339. this.graph2.view.canvas.setAttribute('transform', 'translate(' + x0 + ',' + y0 + ')');
  340. }
  341. else
  342. {
  343. this.graph2.view.canvas.removeAttribute('transform');
  344. }
  345. }
  346. else
  347. {
  348. this.graph2.view.drawPane.style.left = x0 + 'px';
  349. this.graph2.view.drawPane.style.top = y0 + 'px';
  350. }
  351. // Workaround for ignored position CSS style in IE9
  352. // (changes to relative without the following line)
  353. this.tooltip.style.position = 'absolute';
  354. this.tooltip.style.left = left + 'px';
  355. this.tooltip.style.top = top + 'px';
  356. });
  357. if (this.tooltip != null && this.tooltip.style.display != 'none')
  358. {
  359. show();
  360. }
  361. else
  362. {
  363. this.thread = window.setTimeout(show, this.tooltipDelay);
  364. }
  365. this.currentElt = elt;
  366. }
  367. }
  368. };
  369. /**
  370. * Hides the current tooltip.
  371. */
  372. Sidebar.prototype.hideTooltip = function()
  373. {
  374. if (this.thread != null)
  375. {
  376. window.clearTimeout(this.thread);
  377. this.thread = null;
  378. }
  379. if (this.tooltip != null)
  380. {
  381. this.tooltip.style.display = 'none';
  382. this.currentElt = null;
  383. }
  384. };
  385. /**
  386. * Hides the current tooltip.
  387. */
  388. Sidebar.prototype.addDataEntry = function(tags, width, height, title, data)
  389. {
  390. return this.addEntry(tags, mxUtils.bind(this, function()
  391. {
  392. return this.createVertexTemplateFromData(data, width, height, title);
  393. }));
  394. };
  395. /**
  396. * Adds the give entries to the search index.
  397. */
  398. Sidebar.prototype.addEntries = function(images)
  399. {
  400. for (var i = 0; i < images.length; i++)
  401. {
  402. (mxUtils.bind(this, function(img)
  403. {
  404. var data = img.data;
  405. var tags = (img.title != null) ? img.title : '';
  406. if (img.tags != null)
  407. {
  408. tags += ' ' + img.tags;
  409. }
  410. if (data != null && tags.length > 0)
  411. {
  412. this.addEntry(tags, mxUtils.bind(this, function()
  413. {
  414. data = this.editorUi.convertDataUri(data);
  415. var s = 'shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;';
  416. if (img.aspect == 'fixed')
  417. {
  418. s += 'aspect=fixed;'
  419. }
  420. return this.createVertexTemplate(s + 'image=' +
  421. data, img.w, img.h, '', img.title || '', false, false, true)
  422. }));
  423. }
  424. else if (img.xml != null && tags.length > 0)
  425. {
  426. this.addEntry(tags, mxUtils.bind(this, function()
  427. {
  428. var cells = this.editorUi.stringToCells(Graph.decompress(img.xml));
  429. return this.createVertexTemplateFromCells(
  430. cells, img.w, img.h, img.title || '', true, false, true);
  431. }));
  432. }
  433. }))(images[i]);
  434. }
  435. };
  436. /**
  437. * Hides the current tooltip.
  438. */
  439. Sidebar.prototype.setCurrentSearchEntryLibrary = function(id, lib)
  440. {
  441. this.currentSearchEntryLibrary = (id != null) ? {id: id, lib: lib} : null;
  442. };
  443. /**
  444. * Hides the current tooltip.
  445. */
  446. Sidebar.prototype.addEntry = function(tags, fn)
  447. {
  448. if (this.taglist != null && tags != null && tags.length > 0)
  449. {
  450. if (this.currentSearchEntryLibrary != null)
  451. {
  452. fn.parentLibraries = [this.currentSearchEntryLibrary];
  453. }
  454. // Replaces special characters
  455. var tmp = tags.toLowerCase().replace(/[\/\,\(\)]/g, ' ').split(' ');
  456. var tagList = [];
  457. var hash = {};
  458. // Finds unique tags
  459. for (var i = 0; i < tmp.length; i++)
  460. {
  461. if (hash[tmp[i]] == null)
  462. {
  463. hash[tmp[i]] = true;
  464. tagList.push(tmp[i]);
  465. }
  466. // Adds additional entry with removed trailing numbers
  467. var normalized = tmp[i].replace(/\.*\d*$/, '');
  468. if (normalized != tmp[i])
  469. {
  470. if (hash[normalized] == null)
  471. {
  472. hash[normalized] = true;
  473. tagList.push(normalized);
  474. }
  475. }
  476. }
  477. for (var i = 0; i < tagList.length; i++)
  478. {
  479. this.addEntryForTag(tagList[i], fn);
  480. }
  481. }
  482. return fn;
  483. };
  484. /**
  485. * Hides the current tooltip.
  486. */
  487. Sidebar.prototype.addEntryForTag = function(tag, fn)
  488. {
  489. if (tag != null && tag.length > 1)
  490. {
  491. var entry = this.taglist[tag];
  492. if (typeof entry !== 'object')
  493. {
  494. entry = {entries: []};
  495. this.taglist[tag] = entry;
  496. }
  497. entry.entries.push(fn);
  498. }
  499. };
  500. /**
  501. * Adds shape search UI.
  502. */
  503. Sidebar.prototype.searchEntries = function(searchTerms, count, page, success, error)
  504. {
  505. if (this.taglist != null && searchTerms != null)
  506. {
  507. var tmp = searchTerms.toLowerCase().split(' ');
  508. var dict = new mxDictionary();
  509. var max = (page + 1) * count;
  510. var results = [];
  511. var index = 0;
  512. for (var i = 0; i < tmp.length; i++)
  513. {
  514. if (tmp[i].length > 0)
  515. {
  516. var entry = this.taglist[tmp[i]];
  517. var tmpDict = new mxDictionary();
  518. if (entry != null)
  519. {
  520. var arr = entry.entries;
  521. results = [];
  522. for (var j = 0; j < arr.length; j++)
  523. {
  524. var entry = arr[j];
  525. // NOTE Array does not contain duplicates
  526. if ((index == 0) == (dict.get(entry) == null))
  527. {
  528. tmpDict.put(entry, entry);
  529. results.push(entry);
  530. if (i == tmp.length - 1 && results.length == max)
  531. {
  532. success(results.slice(page * count, max), max, true, tmp);
  533. return;
  534. }
  535. }
  536. }
  537. }
  538. else
  539. {
  540. results = [];
  541. }
  542. dict = tmpDict;
  543. index++;
  544. }
  545. }
  546. var len = results.length;
  547. success(results.slice(page * count, (page + 1) * count), len, false, tmp);
  548. }
  549. else
  550. {
  551. success([], null, null, tmp);
  552. }
  553. };
  554. /**
  555. * Adds shape search UI.
  556. */
  557. Sidebar.prototype.filterTags = function(tags)
  558. {
  559. if (tags != null)
  560. {
  561. var arr = tags.split(' ');
  562. var result = [];
  563. var hash = {};
  564. // Ignores tags with leading numbers, strips trailing numbers
  565. for (var i = 0; i < arr.length; i++)
  566. {
  567. // Removes duplicates
  568. if (hash[arr[i]] == null)
  569. {
  570. hash[arr[i]] = '1';
  571. result.push(arr[i]);
  572. }
  573. }
  574. return result.join(' ');
  575. }
  576. return null;
  577. };
  578. /**
  579. * Adds the general palette to the sidebar.
  580. */
  581. Sidebar.prototype.cloneCell = function(cell, value)
  582. {
  583. var clone = cell.clone();
  584. if (value != null)
  585. {
  586. clone.value = value;
  587. }
  588. return clone;
  589. };
  590. /**
  591. * Adds shape search UI.
  592. */
  593. Sidebar.prototype.showPopupMenuForEntry = function(elt, libs, evt)
  594. {
  595. // Hook for subclassers
  596. };
  597. /**
  598. * Adds shape search UI.
  599. */
  600. Sidebar.prototype.addSearchPalette = function(expand)
  601. {
  602. var elt = document.createElement('div');
  603. elt.style.visibility = 'hidden';
  604. this.container.appendChild(elt);
  605. var div = document.createElement('div');
  606. div.className = 'geSidebar';
  607. div.style.boxSizing = 'border-box';
  608. div.style.overflow = 'hidden';
  609. div.style.width = '100%';
  610. div.style.padding = '8px';
  611. div.style.paddingTop = '14px';
  612. div.style.paddingBottom = '0px';
  613. if (!expand)
  614. {
  615. div.style.display = 'none';
  616. }
  617. var inner = document.createElement('div');
  618. inner.style.whiteSpace = 'nowrap';
  619. inner.style.textOverflow = 'clip';
  620. inner.style.paddingBottom = '8px';
  621. inner.style.cursor = 'default';
  622. var input = document.createElement('input');
  623. input.setAttribute('placeholder', mxResources.get('searchShapes'));
  624. input.setAttribute('type', 'text');
  625. input.style.fontSize = '12px';
  626. input.style.overflow = 'hidden';
  627. input.style.boxSizing = 'border-box';
  628. input.style.border = 'solid 1px #d5d5d5';
  629. input.style.borderRadius = '4px';
  630. input.style.width = '100%';
  631. input.style.outline = 'none';
  632. input.style.padding = '6px';
  633. input.style.paddingRight = '20px';
  634. inner.appendChild(input);
  635. var cross = document.createElement('img');
  636. cross.setAttribute('src', Sidebar.prototype.searchImage);
  637. cross.setAttribute('title', mxResources.get('search'));
  638. cross.style.position = 'relative';
  639. cross.style.left = '-18px';
  640. if (mxClient.IS_QUIRKS)
  641. {
  642. input.style.height = '28px';
  643. cross.style.top = '-4px';
  644. }
  645. else
  646. {
  647. cross.style.top = '1px';
  648. }
  649. // Needed to block event transparency in IE
  650. cross.style.background = 'url(\'' + this.editorUi.editor.transparentImage + '\')';
  651. var find;
  652. inner.appendChild(cross);
  653. div.appendChild(inner);
  654. var center = document.createElement('center');
  655. var button = mxUtils.button(mxResources.get('moreResults'), function()
  656. {
  657. find();
  658. });
  659. button.style.display = 'none';
  660. // Workaround for inherited line-height in quirks mode
  661. button.style.lineHeight = 'normal';
  662. button.style.fontSize = '12px';
  663. button.style.padding = '6px 12px 6px 12px';
  664. button.style.marginTop = '4px';
  665. button.style.marginBottom = '8px';
  666. center.style.paddingTop = '4px';
  667. center.style.paddingBottom = '4px';
  668. center.appendChild(button);
  669. div.appendChild(center);
  670. var searchTerm = '';
  671. var active = false;
  672. var complete = false;
  673. var page = 0;
  674. var hash = new Object();
  675. // Count is dynamically updated below
  676. var count = 12;
  677. var clearDiv = mxUtils.bind(this, function()
  678. {
  679. active = false;
  680. this.currentSearch = null;
  681. var child = div.firstChild;
  682. while (child != null)
  683. {
  684. var next = child.nextSibling;
  685. if (child != inner && child != center)
  686. {
  687. child.parentNode.removeChild(child);
  688. }
  689. child = next;
  690. }
  691. });
  692. mxEvent.addListener(cross, 'click', function()
  693. {
  694. if (cross.getAttribute('src') == Dialog.prototype.closeImage)
  695. {
  696. cross.setAttribute('src', Sidebar.prototype.searchImage);
  697. cross.setAttribute('title', mxResources.get('search'));
  698. button.style.display = 'none';
  699. input.value = '';
  700. searchTerm = '';
  701. clearDiv();
  702. }
  703. input.focus();
  704. });
  705. find = mxUtils.bind(this, function()
  706. {
  707. // Shows 4 rows (minimum 4 results)
  708. count = 4 * Math.max(1, Math.floor(this.container.clientWidth / (this.thumbWidth + 10)));
  709. this.hideTooltip();
  710. if (input.value != '')
  711. {
  712. if (center.parentNode != null)
  713. {
  714. if (searchTerm != input.value)
  715. {
  716. clearDiv();
  717. searchTerm = input.value;
  718. hash = new Object();
  719. complete = false;
  720. page = 0;
  721. }
  722. if (!active && !complete)
  723. {
  724. button.setAttribute('disabled', 'true');
  725. button.style.display = '';
  726. button.style.cursor = 'wait';
  727. button.innerHTML = mxResources.get('loading') + '...';
  728. active = true;
  729. // Ignores old results
  730. var current = new Object();
  731. this.currentSearch = current;
  732. this.searchEntries(searchTerm, count, page, mxUtils.bind(this, function(results, len, more, terms)
  733. {
  734. if (this.currentSearch == current)
  735. {
  736. results = (results != null) ? results : [];
  737. active = false;
  738. page++;
  739. this.insertSearchHint(div, searchTerm, count, page, results, len, more, terms);
  740. // Allows to repeat the search
  741. if (results.length == 0 && page == 1)
  742. {
  743. searchTerm = '';
  744. }
  745. if (center.parentNode != null)
  746. {
  747. center.parentNode.removeChild(center);
  748. }
  749. for (var i = 0; i < results.length; i++)
  750. {
  751. (mxUtils.bind(this, function(result)
  752. {
  753. try
  754. {
  755. var elt = result();
  756. // Avoids duplicates in results
  757. if (hash[elt.innerHTML] == null)
  758. {
  759. hash[elt.innerHTML] = (result.parentLibraries != null) ? result.parentLibraries.slice() : [];
  760. div.appendChild(elt);
  761. }
  762. else if (result.parentLibraries != null)
  763. {
  764. hash[elt.innerHTML] = hash[elt.innerHTML].concat(result.parentLibraries);
  765. }
  766. mxEvent.addGestureListeners(elt, null, null, mxUtils.bind(this, function(evt)
  767. {
  768. var libs = hash[elt.innerHTML];
  769. if (mxEvent.isPopupTrigger(evt))
  770. {
  771. this.showPopupMenuForEntry(elt, libs, evt);
  772. }
  773. }));
  774. // Disables the built-in context menu
  775. mxEvent.disableContextMenu(elt);
  776. }
  777. catch (e)
  778. {
  779. // ignore
  780. }
  781. }))(results[i]);
  782. }
  783. if (more)
  784. {
  785. button.removeAttribute('disabled');
  786. button.innerHTML = mxResources.get('moreResults');
  787. }
  788. else
  789. {
  790. button.innerHTML = mxResources.get('reset');
  791. button.style.display = 'none';
  792. complete = true;
  793. }
  794. button.style.cursor = '';
  795. div.appendChild(center);
  796. }
  797. }), mxUtils.bind(this, function()
  798. {
  799. // TODO: Error handling
  800. button.style.cursor = '';
  801. }));
  802. }
  803. }
  804. }
  805. else
  806. {
  807. clearDiv();
  808. input.value = '';
  809. searchTerm = '';
  810. hash = new Object();
  811. button.style.display = 'none';
  812. complete = false;
  813. input.focus();
  814. }
  815. });
  816. mxEvent.addListener(input, 'keydown', mxUtils.bind(this, function(evt)
  817. {
  818. if (evt.keyCode == 13 /* Enter */)
  819. {
  820. find();
  821. mxEvent.consume(evt);
  822. }
  823. }));
  824. mxEvent.addListener(input, 'keyup', mxUtils.bind(this, function(evt)
  825. {
  826. if (input.value == '')
  827. {
  828. cross.setAttribute('src', Sidebar.prototype.searchImage);
  829. cross.setAttribute('title', mxResources.get('search'));
  830. }
  831. else
  832. {
  833. cross.setAttribute('src', Dialog.prototype.closeImage);
  834. cross.setAttribute('title', mxResources.get('reset'));
  835. }
  836. if (input.value == '')
  837. {
  838. complete = true;
  839. button.style.display = 'none';
  840. }
  841. else if (input.value != searchTerm)
  842. {
  843. button.style.display = 'none';
  844. complete = false;
  845. }
  846. else if (!active)
  847. {
  848. if (complete)
  849. {
  850. button.style.display = 'none';
  851. }
  852. else
  853. {
  854. button.style.display = '';
  855. }
  856. }
  857. }));
  858. // Workaround for blocked text selection in Editor
  859. mxEvent.addListener(input, 'mousedown', function(evt)
  860. {
  861. if (evt.stopPropagation)
  862. {
  863. evt.stopPropagation();
  864. }
  865. evt.cancelBubble = true;
  866. });
  867. // Workaround for blocked text selection in Editor
  868. mxEvent.addListener(input, 'selectstart', function(evt)
  869. {
  870. if (evt.stopPropagation)
  871. {
  872. evt.stopPropagation();
  873. }
  874. evt.cancelBubble = true;
  875. });
  876. var outer = document.createElement('div');
  877. outer.appendChild(div);
  878. this.container.appendChild(outer);
  879. // Keeps references to the DOM nodes
  880. this.palettes['search'] = [elt, outer];
  881. };
  882. /**
  883. * Adds the general palette to the sidebar.
  884. */
  885. Sidebar.prototype.insertSearchHint = function(div, searchTerm, count, page, results, len, more, terms)
  886. {
  887. if (results.length == 0 && page == 1)
  888. {
  889. var err = document.createElement('div');
  890. err.className = 'geTitle';
  891. err.style.cssText = 'background-color:transparent;border-color:transparent;' +
  892. 'color:gray;padding:6px 0px 0px 0px !important;margin:4px 8px 4px 8px;' +
  893. 'text-align:center;cursor:default !important';
  894. mxUtils.write(err, mxResources.get('noResultsFor', [searchTerm]));
  895. div.appendChild(err);
  896. }
  897. };
  898. /**
  899. * Adds the general palette to the sidebar.
  900. */
  901. Sidebar.prototype.addGeneralPalette = function(expand)
  902. {
  903. var lineTags = 'line lines connector connectors connection connections arrow arrows ';
  904. this.setCurrentSearchEntryLibrary('general', 'general');
  905. var fns = [
  906. this.createVertexTemplateEntry('rounded=0;whiteSpace=wrap;html=1;', 120, 60, '', 'Rectangle', null, null, 'rect rectangle box'),
  907. this.createVertexTemplateEntry('rounded=1;whiteSpace=wrap;html=1;', 120, 60, '', 'Rounded Rectangle', null, null, 'rounded rect rectangle box'),
  908. // Explicit strokecolor/fillcolor=none is a workaround to maintain transparent background regardless of current style
  909. this.createVertexTemplateEntry('text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;',
  910. 40, 20, 'Text', 'Text', null, null, 'text textbox textarea label'),
  911. this.createVertexTemplateEntry('text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;', 190, 120,
  912. '<h1>Heading</h1><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>',
  913. 'Textbox', null, null, 'text textbox textarea'),
  914. this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;', 120, 80, '', 'Ellipse', null, null, 'oval ellipse state'),
  915. this.createVertexTemplateEntry('whiteSpace=wrap;html=1;aspect=fixed;', 80, 80, '', 'Square', null, null, 'square'),
  916. this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;aspect=fixed;', 80, 80, '', 'Circle', null, null, 'circle'),
  917. this.createVertexTemplateEntry('shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;', 120, 60, '', 'Process', null, null, 'process task'),
  918. this.createVertexTemplateEntry('rhombus;whiteSpace=wrap;html=1;', 80, 80, '', 'Diamond', null, null, 'diamond rhombus if condition decision conditional question test'),
  919. this.createVertexTemplateEntry('shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;', 120, 60, '', 'Parallelogram'),
  920. this.createVertexTemplateEntry('shape=hexagon;perimeter=hexagonPerimeter2;whiteSpace=wrap;html=1;fixedSize=1;', 120, 80, '', 'Hexagon', null, null, 'hexagon preparation'),
  921. this.createVertexTemplateEntry('triangle;whiteSpace=wrap;html=1;', 60, 80, '', 'Triangle', null, null, 'triangle logic inverter buffer'),
  922. this.createVertexTemplateEntry('shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;', 60, 80, '', 'Cylinder', null, null, 'cylinder data database'),
  923. this.createVertexTemplateEntry('ellipse;shape=cloud;whiteSpace=wrap;html=1;', 120, 80, '', 'Cloud', null, null, 'cloud network'),
  924. this.createVertexTemplateEntry('shape=document;whiteSpace=wrap;html=1;boundedLbl=1;', 120, 80, '', 'Document'),
  925. this.createVertexTemplateEntry('shape=internalStorage;whiteSpace=wrap;html=1;backgroundOutline=1;', 80, 80, '', 'Internal Storage'),
  926. this.createVertexTemplateEntry('shape=cube;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;darkOpacity=0.05;darkOpacity2=0.1;', 120, 80, '', 'Cube'),
  927. this.createVertexTemplateEntry('shape=step;perimeter=stepPerimeter;whiteSpace=wrap;html=1;fixedSize=1;', 120, 80, '', 'Step'),
  928. this.createVertexTemplateEntry('shape=trapezoid;perimeter=trapezoidPerimeter;whiteSpace=wrap;html=1;fixedSize=1;', 120, 60, '', 'Trapezoid'),
  929. this.createVertexTemplateEntry('shape=tape;whiteSpace=wrap;html=1;', 120, 100, '', 'Tape'),
  930. this.createVertexTemplateEntry('shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;', 80, 100, '', 'Note'),
  931. this.createVertexTemplateEntry('shape=card;whiteSpace=wrap;html=1;', 80, 100, '', 'Card'),
  932. this.createVertexTemplateEntry('shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;', 120, 80, '', 'Callout', null, null, 'bubble chat thought speech message'),
  933. this.createVertexTemplateEntry('shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;', 30, 60, 'Actor', 'Actor', false, null, 'user person human stickman'),
  934. this.createVertexTemplateEntry('shape=xor;whiteSpace=wrap;html=1;', 60, 80, '', 'Or', null, null, 'logic or'),
  935. this.createVertexTemplateEntry('shape=or;whiteSpace=wrap;html=1;', 60, 80, '', 'And', null, null, 'logic and'),
  936. this.createVertexTemplateEntry('shape=dataStorage;whiteSpace=wrap;html=1;fixedSize=1;', 100, 80, '', 'Data Storage'),
  937. this.addEntry('curve', mxUtils.bind(this, function()
  938. {
  939. var cell = new mxCell('', new mxGeometry(0, 0, 50, 50), 'curved=1;endArrow=classic;html=1;');
  940. cell.geometry.setTerminalPoint(new mxPoint(0, 50), true);
  941. cell.geometry.setTerminalPoint(new mxPoint(50, 0), false);
  942. cell.geometry.points = [new mxPoint(50, 50), new mxPoint(0, 0)];
  943. cell.geometry.relative = true;
  944. cell.edge = true;
  945. return this.createEdgeTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Curve');
  946. })),
  947. this.createEdgeTemplateEntry('shape=flexArrow;endArrow=classic;startArrow=classic;html=1;', 50, 50, '', 'Bidirectional Arrow', null, lineTags + 'bidirectional'),
  948. this.createEdgeTemplateEntry('shape=flexArrow;endArrow=classic;html=1;', 50, 50, '', 'Arrow', null, lineTags + 'directional directed'),
  949. this.createEdgeTemplateEntry('endArrow=none;dashed=1;html=1;', 50, 50, '', 'Dashed Line', null, lineTags + 'dashed undirected no'),
  950. this.createEdgeTemplateEntry('endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;', 50, 50, '', 'Dotted Line', null, lineTags + 'dotted undirected no'),
  951. this.createEdgeTemplateEntry('endArrow=none;html=1;', 50, 50, '', 'Line', null, lineTags + 'simple undirected plain blank no'),
  952. this.createEdgeTemplateEntry('endArrow=classic;startArrow=classic;html=1;', 50, 50, '', 'Bidirectional Connector', null, lineTags + 'bidirectional'),
  953. this.createEdgeTemplateEntry('endArrow=classic;html=1;', 50, 50, '', 'Directional Connector', null, lineTags + 'directional directed'),
  954. this.createEdgeTemplateEntry('shape=link;html=1;', 100, 0, '', 'Link', null, lineTags + 'link'),
  955. this.addEntry(lineTags + 'edge title', mxUtils.bind(this, function()
  956. {
  957. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'endArrow=classic;html=1;');
  958. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  959. edge.geometry.setTerminalPoint(new mxPoint(100, 0), false);
  960. edge.geometry.relative = true;
  961. edge.edge = true;
  962. var cell0 = new mxCell('Label', new mxGeometry(0, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=center;verticalAlign=middle;');
  963. cell0.geometry.relative = true;
  964. cell0.setConnectable(false);
  965. cell0.vertex = true;
  966. edge.insert(cell0);
  967. return this.createEdgeTemplateFromCells([edge], 100, 0, 'Connector with Label');
  968. })),
  969. this.addEntry(lineTags + 'edge title multiplicity', mxUtils.bind(this, function()
  970. {
  971. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'endArrow=classic;html=1;');
  972. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  973. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  974. edge.geometry.relative = true;
  975. edge.edge = true;
  976. var cell0 = new mxCell('Label', new mxGeometry(0, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=center;verticalAlign=middle;');
  977. cell0.geometry.relative = true;
  978. cell0.setConnectable(false);
  979. cell0.vertex = true;
  980. edge.insert(cell0);
  981. var cell1 = new mxCell('Source', new mxGeometry(-1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=left;verticalAlign=bottom;');
  982. cell1.geometry.relative = true;
  983. cell1.setConnectable(false);
  984. cell1.vertex = true;
  985. edge.insert(cell1);
  986. return this.createEdgeTemplateFromCells([edge], 160, 0, 'Connector with 2 Labels');
  987. })),
  988. this.addEntry(lineTags + 'edge title multiplicity', mxUtils.bind(this, function()
  989. {
  990. var edge = new mxCell('Label', new mxGeometry(0, 0, 0, 0), 'endArrow=classic;html=1;');
  991. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  992. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  993. edge.geometry.relative = true;
  994. edge.edge = true;
  995. var cell0 = new mxCell('Label', new mxGeometry(0, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=center;verticalAlign=middle;');
  996. cell0.geometry.relative = true;
  997. cell0.setConnectable(false);
  998. cell0.vertex = true;
  999. edge.insert(cell0);
  1000. var cell1 = new mxCell('Source', new mxGeometry(-1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=left;verticalAlign=bottom;');
  1001. cell1.geometry.relative = true;
  1002. cell1.setConnectable(false);
  1003. cell1.vertex = true;
  1004. edge.insert(cell1);
  1005. var cell2 = new mxCell('Target', new mxGeometry(1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=right;verticalAlign=bottom;');
  1006. cell2.geometry.relative = true;
  1007. cell2.setConnectable(false);
  1008. cell2.vertex = true;
  1009. edge.insert(cell2);
  1010. return this.createEdgeTemplateFromCells([edge], 160, 0, 'Connector with 3 Labels');
  1011. })),
  1012. this.addEntry(lineTags + 'edge shape symbol message mail email', mxUtils.bind(this, function()
  1013. {
  1014. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'endArrow=classic;html=1;');
  1015. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  1016. edge.geometry.setTerminalPoint(new mxPoint(100, 0), false);
  1017. edge.geometry.relative = true;
  1018. edge.edge = true;
  1019. var cell = new mxCell('', new mxGeometry(0, 0, 20, 14), 'shape=message;html=1;outlineConnect=0;');
  1020. cell.geometry.relative = true;
  1021. cell.vertex = true;
  1022. cell.geometry.offset = new mxPoint(-10, -7);
  1023. edge.insert(cell);
  1024. return this.createEdgeTemplateFromCells([edge], 100, 0, 'Connector with Symbol');
  1025. }))
  1026. ];
  1027. this.addPaletteFunctions('general', mxResources.get('general'), (expand != null) ? expand : true, fns);
  1028. this.setCurrentSearchEntryLibrary();
  1029. };
  1030. /**
  1031. * Adds the general palette to the sidebar.
  1032. */
  1033. Sidebar.prototype.addMiscPalette = function(expand)
  1034. {
  1035. var sb = this;
  1036. var lineTags = 'line lines connector connectors connection connections arrow arrows '
  1037. this.setCurrentSearchEntryLibrary('general', 'misc');
  1038. var fns = [
  1039. this.createVertexTemplateEntry('text;strokeColor=none;fillColor=none;html=1;fontSize=24;fontStyle=1;verticalAlign=middle;align=center;', 100, 40, 'Title', 'Title', null, null, 'text heading title'),
  1040. this.createVertexTemplateEntry('text;strokeColor=none;fillColor=none;html=1;whiteSpace=wrap;verticalAlign=middle;overflow=hidden;', 100, 80,
  1041. '<ul><li>Value 1</li><li>Value 2</li><li>Value 3</li></ul>', 'Unordered List'),
  1042. this.createVertexTemplateEntry('text;strokeColor=none;fillColor=none;html=1;whiteSpace=wrap;verticalAlign=middle;overflow=hidden;', 100, 80,
  1043. '<ol><li>Value 1</li><li>Value 2</li><li>Value 3</li></ol>', 'Ordered List'),
  1044. this.addDataEntry('table', 180, 120, 'Table 1', '7ZjJTsMwEIafJleUhZZybVgucAFewDTT2pLjiewpaXl6xolLVQFqWBJArZRKns2xv5H7y4myvFxdW1HJWyxAR9lllOUWkdpRucpB6yiNVRFlF1GaxvyL0qsPokkTjSthwVCXgrQteBJ6Ca2ndTha6+BwUlR+SOLRu6aSSl7mRcLDWiqC+0rMfLzmTbDPkbB0r569K2Z7hoaEMmBDzQy1FpVTzWRthlS6uBFrXNLmNRtrGpYHlmD14RYbV9jfNWAJZNecUquCZMiYtBhiCWohN2WBTSxc61i81m6J8SBAex9g1h0gL5mU0HcwI2EWXVi+ZVVYrB6EXQAFR4XKENjLJ6bhgm+utM5Ro0du0PgXEVYhqGG+qX1EIiyDYQOY10kbKKMpP4wpj09G0Yh3k7OdbG1+fLqlHI0jy432c4BwVIPr3MD0aw08/YH+nfbbP2N89rZ/324NMsq5xppNqYoCTFfG2V7G454Qjw4c8WoX7wDEx0fiO3/wAyA/O+pAbzqw3m3TELIwOZQTdPZrsnB+4IiHl4UkPiIfWheS5CgMfQvDZEBhSD5xY/7fZyjZf63u7dD0fKv++5B/QRwO5ia8h3mP6sDm9tNeE9v58vcC'),
  1045. this.addDataEntry('table', 180, 120, 'Table 2', '7ZjBbqMwEIafhmuFISTptbTbS/eyrfbuBie2ZDzITEqyT79jMMlGWVTUBlqVSkTyjGeM+SbDLxPEab67t7yQPyETOojvgji1ANiM8l0qtA6iUGVBfBtEUUi/IPrRMcvq2bDgVhjskxA1CS9cb0XjaRwl7rV3lJIXboj82bluJOa0zVtGw0oqFI8FX7n5ih6CfCVyi4/qj3OFZK/AIFdGWJ+zAq15Uap6sSZCKp098D1ssb1Na7nobW4eKL/00Raqf02/f2FR7DoZ1C4P4F5ALtDuKaRSGUofsWw4hVKojWzTPLyQl41jc8g9IqWBp/p/wnF/wrRlVFz/EivkZtMH9jnMzELxxO1GoHcUoAwKe/dCNFpoa6V1ChpcTQwYdyOEwk9qsW5znwER8ha8B3NYtIaS3NBFmNLwKgkSepqUbHa06XLhFlMwJVr6J7g1BC+xEiX2LWD0tgLOLlC/2Vn9ftfDKGQXLaQxLvpYyHfXCIjpWkNFplRZJkxf2PGrsOcDsU46WV+2aT49690p5xHQzzvRx5NEf3j3j8B+8S0Rg0nE/rRMYyjGsrOVZl+0lRYfphjXnayTabEeXzFY2Ml+Pkn2Y0oGY9+aMbRmLEfUDHZ+EG+bafFFm4m9fiofrHvOD+Ut7eXEaH+AbnSfqK+nCX9A4SDz+DGxnjv51vgX'),
  1046. this.addDataEntry('table title', 180, 120, 'Table with Title 1', '7ZhRb6MwDMc/Da8nAmPdvZbu9nJ7WfcFMnAhUohR4o12n34OpKumrmqlDXa6VqJS/Lcdkp8bWSFK82Z9Z2Vb32MJOkpvozS3iDSMmnUOWkdJrMooXURJEvMvSv4c8IreG7fSgqFTEpIh4UXqZxiUR/mkYVAdbXRQXS1bP6Tem85ranitC8HDrlYEy1YW3t/xTlhzJC0t1auX0piFAg1JZcCGpAK1lq1T/WyLPqJWuvwrN/hM2/dsrfmKs5dhMT5balUZHhe8Sz/lPOwCLMH6IIleChjuABsgu+GQTpVUh4ibgVZcg6rqbVoWROkGoXrP3YHlQWD7Oed0j/NBxLxkUlI/QEHSVKfQ3odZWmwfpa2AgtCi8qhuX5iGC9pKaZ2jRl8Tg8a/iLANTg2rbe4TEmETDBvAvE/aQ8nm/DCmPP6VRRnvJmdb7Gx+fLilHI0jy/8EPwdIRx04OrWAyecF3ATEoUzH6nn1DeW8GrecxvjoXTm/XClksiuNHZu1KkswpyJPj56Z65EQZ2eOeP0R7wTEry/E+4RkOuSzS1sYuy3MJmwLN+dygmY/1hZ+nzni6duCiC/Ip+4LQlwaw9iNQYgJO4PYv2j/p4dIHL9mj3ZqRr5l//uQf6A7nM1V+AjzEdsDm7svgr3vwwfDNw=='),
  1047. this.addDataEntry('table title', 180, 150, 'Table with Title 2', '7Zhdb5swFIZ/DbcTHyVrbiFdb7Kbptq9Cw5YMj7IPi1kv37HYJK1FDWbQoOmSUSyz4dt3id+L/CitGrvNavL75Bz6UV3XpRqAOxHVZtyKb3QF7kXbbww9Onnhd8mskGX9WumucJzGsK+4YXJZ95HHtmT5H3U4EG6qClZbYfYZaOkxIrOuglo2JQC+a5mmc039CYUM8g07sRPG4p8CmSgkAnFtWvKQEpWG9GttukqSiHzLTvAMw77DLNkL1qeP0BjXLeGZkuLGde6p8V37qw2zaQoFI0zEsHumLiX5Bp5OylUF3Iq3XOoOOoDlTQix9JV3PZi+iUXRTm0xS7ITB8ojr0n3WngpH8fQzTCMEmAjoyCyQeeIVPFOTDGWuca6kemC44uUIOwUt29kBpHVYWUKUiwyBQouxFC7ZKS74feJ0CEaiDjhDku2okSJ/SQTKn/JfZiepuU5sFpTo8t15iCMqjpj2LX4Mxgww2eCzB8H+DBSewwfcQzugDOmxHO4KI8lbLVJ55/jMp/gwpI2r2EhqalyHOuztU8+vDS3MykcTzS+Ec3DP2Faz24U1+bGNpQqGLbd65mgNG+BvH7BZgLzupf8LO34JblZ6tP9LOvI5yX5bkcP1tdzc9uJ/1s4VrP52cTMK7gZ+v/fja3n60/0c8Cf8QzWvYl++s7tL6aoQXBpKMtXOz5HG2CxvyORtPTR4Uu9+qbwy8='),
  1048. this.addDataEntry('crossfunctional cross-functional cross functional flowchart swimlane table', 400, 400, 'Cross-Functional Flowchart', '7ZhRb5swEMc/DY+bMCRt97jQpi+tVC2fwINbbMnYyD4C6aefjaHpBrTRlNCoTALJPp9t+P25O5kgTvL6XtOCPaoMRBDfBXGilULfyusEhAiikGdBfBtEUWjvIFqPjJJmNCyoBonHTIj8hB0VJXiL3dyYL+tSpsiVpM55LVSVMqrROxvci9bZMFq4JtKfzrRKGRfZA92rEjtr11tpVT1wCcYOhM5ViTKXry0G7RYb/uwWXDgDw9wCuSW2WTGOsClo6gYri8uvIGhheLN1s4KGtNSG7+AHGL+Os0JdUJm1nUJxiaDvdhZQt/EvJXHTvpTbjAq+lbadgnO1hhYSaIR6FHRjainfg8oB9d66VDxD5j0WoRcjZMC3DP8yUuMN25e5B91so5VuWMa4J+P3FJW2JtLXrOK5oNLJxZTmz/blqXhNp3mO5cpe9smS8OsyWNp5ie2TQ99ezl1joqRBTXmDAajBCgxejprHKBcNK7fvBPIz3hOSRCcQctET8olRA+8JmSopIW2j8GOD6Sji8TDxepT4C9yTE1+OEo/mQ5xcTYn8ahR5PB/k0c2UyK9HC8SbX/mnLBAnqAlD8XK+onDTE+/fw+TiQF9fTin4Nl/O0xYAEs6X9LR5n5Ae6S7xv1lr/yf+4cQ/pN75Ej/pH88/UZyQkRPzR6R+0j9Bz4f0xMm/f8adD+qzZn/bPfw5bMb++LH4Gw=='),
  1049. this.createVertexTemplateEntry('text;html=1;strokeColor=#c0c0c0;fillColor=#ffffff;overflow=fill;rounded=0;', 280, 160,
  1050. '<table border="1" width="100%" height="100%" cellpadding="4" style="width:100%;height:100%;border-collapse:collapse;">' +
  1051. '<tr style="background-color:#A7C942;color:#ffffff;border:1px solid #98bf21;"><th align="left">Title 1</th><th align="left">Title 2</th><th align="left">Title 3</th></tr>' +
  1052. '<tr style="border:1px solid #98bf21;"><td>Value 1</td><td>Value 2</td><td>Value 3</td></tr>' +
  1053. '<tr style="background-color:#EAF2D3;border:1px solid #98bf21;"><td>Value 4</td><td>Value 5</td><td>Value 6</td></tr>' +
  1054. '<tr style="border:1px solid #98bf21;"><td>Value 7</td><td>Value 8</td><td>Value 9</td></tr>' +
  1055. '<tr style="background-color:#EAF2D3;border:1px solid #98bf21;"><td>Value 10</td><td>Value 11</td><td>Value 12</td></tr></table>', 'HTML Table 1'),
  1056. this.createVertexTemplateEntry('text;html=1;strokeColor=#c0c0c0;fillColor=none;overflow=fill;', 180, 140,
  1057. '<table border="0" width="100%" height="100%" style="width:100%;height:100%;border-collapse:collapse;">' +
  1058. '<tr><td align="center">Value 1</td><td align="center">Value 2</td><td align="center">Value 3</td></tr>' +
  1059. '<tr><td align="center">Value 4</td><td align="center">Value 5</td><td align="center">Value 6</td></tr>' +
  1060. '<tr><td align="center">Value 7</td><td align="center">Value 8</td><td align="center">Value 9</td></tr></table>', 'HTML Table 2'),
  1061. this.createVertexTemplateEntry('text;html=1;strokeColor=none;fillColor=none;overflow=fill;', 180, 140,
  1062. '<table border="1" width="100%" height="100%" style="width:100%;height:100%;border-collapse:collapse;">' +
  1063. '<tr><td align="center">Value 1</td><td align="center">Value 2</td><td align="center">Value 3</td></tr>' +
  1064. '<tr><td align="center">Value 4</td><td align="center">Value 5</td><td align="center">Value 6</td></tr>' +
  1065. '<tr><td align="center">Value 7</td><td align="center">Value 8</td><td align="center">Value 9</td></tr></table>', 'HTML Table 3'),
  1066. this.createVertexTemplateEntry('text;html=1;strokeColor=none;fillColor=none;overflow=fill;', 160, 140,
  1067. '<table border="1" width="100%" height="100%" cellpadding="4" style="width:100%;height:100%;border-collapse:collapse;">' +
  1068. '<tr><th align="center"><b>Title</b></th></tr>' +
  1069. '<tr><td align="center">Section 1.1\nSection 1.2\nSection 1.3</td></tr>' +
  1070. '<tr><td align="center">Section 2.1\nSection 2.2\nSection 2.3</td></tr></table>', 'HTML Table 4'),
  1071. this.addEntry('link hyperlink', mxUtils.bind(this, function()
  1072. {
  1073. var cell = new mxCell('Link', new mxGeometry(0, 0, 60, 40), 'text;html=1;strokeColor=none;fillColor=none;whiteSpace=wrap;align=center;verticalAlign=middle;fontColor=#0000EE;fontStyle=4;');
  1074. cell.vertex = true;
  1075. this.graph.setLinkForCell(cell, 'https://www.draw.io');
  1076. return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Link');
  1077. })),
  1078. this.addEntry('timestamp date time text label', mxUtils.bind(this, function()
  1079. {
  1080. var cell = new mxCell('%date{ddd mmm dd yyyy HH:MM:ss}%', new mxGeometry(0, 0, 160, 20), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;');
  1081. cell.vertex = true;
  1082. this.graph.setAttributeForCell(cell, 'placeholders', '1');
  1083. return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Timestamp');
  1084. })),
  1085. this.addEntry('variable placeholder metadata hello world text label', mxUtils.bind(this, function()
  1086. {
  1087. var cell = new mxCell('%name% Text', new mxGeometry(0, 0, 80, 20), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;');
  1088. cell.vertex = true;
  1089. this.graph.setAttributeForCell(cell, 'placeholders', '1');
  1090. this.graph.setAttributeForCell(cell, 'name', 'Variable');
  1091. return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Variable');
  1092. })),
  1093. this.createVertexTemplateEntry('shape=ext;double=1;rounded=0;whiteSpace=wrap;html=1;', 120, 80, '', 'Double Rectangle', null, null, 'rect rectangle box double'),
  1094. this.createVertexTemplateEntry('shape=ext;double=1;rounded=1;whiteSpace=wrap;html=1;', 120, 80, '', 'Double Rounded Rectangle', null, null, 'rounded rect rectangle box double'),
  1095. this.createVertexTemplateEntry('ellipse;shape=doubleEllipse;whiteSpace=wrap;html=1;', 100, 60, '', 'Double Ellipse', null, null, 'oval ellipse start end state double'),
  1096. this.createVertexTemplateEntry('shape=ext;double=1;whiteSpace=wrap;html=1;aspect=fixed;', 80, 80, '', 'Double Square', null, null, 'double square'),
  1097. this.createVertexTemplateEntry('ellipse;shape=doubleEllipse;whiteSpace=wrap;html=1;aspect=fixed;', 80, 80, '', 'Double Circle', null, null, 'double circle'),
  1098. this.createVertexTemplateEntry('rounded=1;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=4;hachureGap=8;hachureAngle=45;fillColor=#1ba1e2;sketch=1;', 120, 60, '', 'Rectangle Sketch', true, null, 'rectangle rect box text sketch comic retro'),
  1099. this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=2;hachureGap=8;fillColor=#990000;fillStyle=dots;sketch=1;', 120, 60, '', 'Ellipse Sketch', true, null, 'ellipse oval sketch comic retro'),
  1100. this.createVertexTemplateEntry('rhombus;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=-1;hachureGap=8;fillStyle=cross-hatch;fillColor=#006600;sketch=1;', 120, 60, '', 'Diamond Sketch', true, null, 'diamond sketch comic retro'),
  1101. this.createVertexTemplateEntry('html=1;whiteSpace=wrap;shape=isoCube2;backgroundOutline=1;isoAngle=15;', 90, 100, '', 'Isometric Cube', true, null, 'cube box iso isometric'),
  1102. this.createVertexTemplateEntry('html=1;whiteSpace=wrap;aspect=fixed;shape=isoRectangle;', 150, 90, '', 'Isometric Square', true, null, 'rectangle rect box iso isometric'),
  1103. this.createEdgeTemplateEntry('edgeStyle=isometricEdgeStyle;endArrow=none;html=1;', 50, 100, '', 'Isometric Edge 1'),
  1104. this.createEdgeTemplateEntry('edgeStyle=isometricEdgeStyle;endArrow=none;html=1;elbow=vertical;', 50, 100, '', 'Isometric Edge 2'),
  1105. this.createVertexTemplateEntry('shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;', 20, 120, '', 'Curly Bracket'),
  1106. this.createVertexTemplateEntry('line;strokeWidth=2;html=1;', 160, 10, '', 'Horizontal Line'),
  1107. this.createVertexTemplateEntry('line;strokeWidth=2;direction=south;html=1;', 10, 160, '', 'Vertical Line'),
  1108. this.createVertexTemplateEntry('line;strokeWidth=4;html=1;perimeter=backbonePerimeter;points=[];outlineConnect=0;', 160, 10, '', 'Horizontal Backbone', false, null, 'backbone bus network'),
  1109. this.createVertexTemplateEntry('line;strokeWidth=4;direction=south;html=1;perimeter=backbonePerimeter;points=[];outlineConnect=0;', 10, 160, '', 'Vertical Backbone', false, null, 'backbone bus network'),
  1110. this.createVertexTemplateEntry('shape=crossbar;whiteSpace=wrap;html=1;rounded=1;', 120, 20, '', 'Crossbar', false, null, 'crossbar distance measure dimension unit'),
  1111. this.createVertexTemplateEntry('shape=image;html=1;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=1;aspect=fixed;image=' + this.gearImage, 52, 61, '', 'Image (Fixed Aspect)', false, null, 'fixed image icon symbol'),
  1112. this.createVertexTemplateEntry('shape=image;html=1;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;image=' + this.gearImage, 50, 60, '', 'Image (Variable Aspect)', false, null, 'strechted image icon symbol'),
  1113. this.createVertexTemplateEntry('icon;html=1;image=' + this.gearImage, 60, 60, 'Icon', 'Icon', false, null, 'icon image symbol'),
  1114. this.createVertexTemplateEntry('label;whiteSpace=wrap;html=1;image=' + this.gearImage, 140, 60, 'Label', 'Label 1', null, null, 'label image icon symbol'),
  1115. this.createVertexTemplateEntry('label;whiteSpace=wrap;html=1;align=center;verticalAlign=bottom;spacingLeft=0;spacingBottom=4;imageAlign=center;imageVerticalAlign=top;image=' + this.gearImage, 120, 80, 'Label', 'Label 2', null, null, 'label image icon symbol'),
  1116. this.addEntry('shape group container', function()
  1117. {
  1118. var cell = new mxCell('Label', new mxGeometry(0, 0, 160, 70),
  1119. 'html=1;whiteSpace=wrap;container=1;recursiveResize=0;collapsible=0;');
  1120. cell.vertex = true;
  1121. var symbol = new mxCell('', new mxGeometry(20, 20, 20, 30), 'triangle;html=1;whiteSpace=wrap;');
  1122. symbol.vertex = true;
  1123. cell.insert(symbol);
  1124. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Shape Group');
  1125. }),
  1126. this.createVertexTemplateEntry('shape=partialRectangle;whiteSpace=wrap;html=1;left=0;right=0;fillColor=none;', 120, 60, '', 'Partial Rectangle'),
  1127. this.createVertexTemplateEntry('shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;left=1;top=0;fillColor=none;routingCenterX=-0.5;', 120, 60, '', 'Partial Rectangle'),
  1128. this.createEdgeTemplateEntry('edgeStyle=segmentEdgeStyle;endArrow=classic;html=1;', 50, 50, '', 'Manual Line', null, lineTags + 'manual'),
  1129. this.createEdgeTemplateEntry('shape=filledEdge;rounded=0;fixDash=1;endArrow=none;strokeWidth=10;fillColor=#ffffff;edgeStyle=orthogonalEdgeStyle;', 60, 40, '', 'Filled Edge'),
  1130. this.createEdgeTemplateEntry('edgeStyle=elbowEdgeStyle;elbow=horizontal;endArrow=classic;html=1;', 50, 50, '', 'Horizontal Elbow', null, lineTags + 'elbow horizontal'),
  1131. this.createEdgeTemplateEntry('edgeStyle=elbowEdgeStyle;elbow=vertical;endArrow=classic;html=1;', 50, 50, '', 'Vertical Elbow', null, lineTags + 'elbow vertical')
  1132. ];
  1133. this.addPaletteFunctions('misc', mxResources.get('misc'), (expand != null) ? expand : true, fns);
  1134. this.setCurrentSearchEntryLibrary();
  1135. };
  1136. /**
  1137. * Adds the container palette to the sidebar.
  1138. */
  1139. Sidebar.prototype.addAdvancedPalette = function(expand)
  1140. {
  1141. this.setCurrentSearchEntryLibrary('general', 'advanced');
  1142. this.addPaletteFunctions('advanced', mxResources.get('advanced'), (expand != null) ? expand : false, this.createAdvancedShapes());
  1143. this.setCurrentSearchEntryLibrary();
  1144. };
  1145. /**
  1146. * Adds the general palette to the sidebar.
  1147. */
  1148. Sidebar.prototype.addBasicPalette = function(dir)
  1149. {
  1150. this.setCurrentSearchEntryLibrary('basic');
  1151. this.addStencilPalette('basic', mxResources.get('basic'), dir + '/basic.xml',
  1152. ';whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#000000;strokeWidth=2',
  1153. null, null, null, null, [
  1154. this.createVertexTemplateEntry('shape=partialRectangle;whiteSpace=wrap;html=1;top=0;bottom=0;fillColor=none;', 120, 60, '', 'Partial Rectangle'),
  1155. this.createVertexTemplateEntry('shape=partialRectangle;whiteSpace=wrap;html=1;right=0;top=0;bottom=0;fillColor=none;routingCenterX=-0.5;', 120, 60, '', 'Partial Rectangle'),
  1156. this.createVertexTemplateEntry('shape=partialRectangle;whiteSpace=wrap;html=1;bottom=0;right=0;fillColor=none;', 120, 60, '', 'Partial Rectangle'),
  1157. this.createVertexTemplateEntry('shape=partialRectangle;whiteSpace=wrap;html=1;top=0;left=0;fillColor=none;', 120, 60, '', 'Partial Rectangle')
  1158. ]);
  1159. this.setCurrentSearchEntryLibrary();
  1160. };
  1161. /**
  1162. * Adds the container palette to the sidebar.
  1163. */
  1164. Sidebar.prototype.createAdvancedShapes = function()
  1165. {
  1166. // Avoids having to bind all functions to "this"
  1167. var sb = this;
  1168. // Reusable cells
  1169. var field = new mxCell('List Item', new mxGeometry(0, 0, 60, 26), 'text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1170. field.vertex = true;
  1171. return [
  1172. this.createVertexTemplateEntry('shape=tapeData;whiteSpace=wrap;html=1;perimeter=ellipsePerimeter;', 80, 80, '', 'Tape Data'),
  1173. this.createVertexTemplateEntry('shape=manualInput;whiteSpace=wrap;html=1;', 80, 80, '', 'Manual Input'),
  1174. this.createVertexTemplateEntry('shape=loopLimit;whiteSpace=wrap;html=1;', 100, 80, '', 'Loop Limit'),
  1175. this.createVertexTemplateEntry('shape=offPageConnector;whiteSpace=wrap;html=1;', 80, 80, '', 'Off Page Connector'),
  1176. this.createVertexTemplateEntry('shape=delay;whiteSpace=wrap;html=1;', 80, 40, '', 'Delay'),
  1177. this.createVertexTemplateEntry('shape=display;whiteSpace=wrap;html=1;', 80, 40, '', 'Display'),
  1178. this.createVertexTemplateEntry('shape=singleArrow;direction=west;whiteSpace=wrap;html=1;', 100, 60, '', 'Arrow Left'),
  1179. this.createVertexTemplateEntry('shape=singleArrow;whiteSpace=wrap;html=1;', 100, 60, '', 'Arrow Right'),
  1180. this.createVertexTemplateEntry('shape=singleArrow;direction=north;whiteSpace=wrap;html=1;', 60, 100, '', 'Arrow Up'),
  1181. this.createVertexTemplateEntry('shape=singleArrow;direction=south;whiteSpace=wrap;html=1;', 60, 100, '', 'Arrow Down'),
  1182. this.createVertexTemplateEntry('shape=doubleArrow;whiteSpace=wrap;html=1;', 100, 60, '', 'Double Arrow'),
  1183. this.createVertexTemplateEntry('shape=doubleArrow;direction=south;whiteSpace=wrap;html=1;', 60, 100, '', 'Double Arrow Vertical', null, null, 'double arrow'),
  1184. this.createVertexTemplateEntry('shape=actor;whiteSpace=wrap;html=1;', 40, 60, '', 'User', null, null, 'user person human'),
  1185. this.createVertexTemplateEntry('shape=cross;whiteSpace=wrap;html=1;', 80, 80, '', 'Cross'),
  1186. this.createVertexTemplateEntry('shape=corner;whiteSpace=wrap;html=1;', 80, 80, '', 'Corner'),
  1187. this.createVertexTemplateEntry('shape=tee;whiteSpace=wrap;html=1;', 80, 80, '', 'Tee'),
  1188. this.createVertexTemplateEntry('shape=datastore;whiteSpace=wrap;html=1;', 60, 60, '', 'Data Store', null, null, 'data store cylinder database'),
  1189. this.createVertexTemplateEntry('shape=orEllipse;perimeter=ellipsePerimeter;whiteSpace=wrap;html=1;backgroundOutline=1;', 80, 80, '', 'Or', null, null, 'or circle oval ellipse'),
  1190. this.createVertexTemplateEntry('shape=sumEllipse;perimeter=ellipsePerimeter;whiteSpace=wrap;html=1;backgroundOutline=1;', 80, 80, '', 'Sum', null, null, 'sum circle oval ellipse'),
  1191. this.createVertexTemplateEntry('shape=lineEllipse;perimeter=ellipsePerimeter;whiteSpace=wrap;html=1;backgroundOutline=1;', 80, 80, '', 'Ellipse with horizontal divider', null, null, 'circle oval ellipse'),
  1192. this.createVertexTemplateEntry('shape=lineEllipse;line=vertical;perimeter=ellipsePerimeter;whiteSpace=wrap;html=1;backgroundOutline=1;', 80, 80, '', 'Ellipse with vertical divider', null, null, 'circle oval ellipse'),
  1193. this.createVertexTemplateEntry('shape=sortShape;perimeter=rhombusPerimeter;whiteSpace=wrap;html=1;', 80, 80, '', 'Sort', null, null, 'sort'),
  1194. this.createVertexTemplateEntry('shape=collate;whiteSpace=wrap;html=1;', 80, 80, '', 'Collate', null, null, 'collate'),
  1195. this.createVertexTemplateEntry('shape=switch;whiteSpace=wrap;html=1;', 60, 60, '', 'Switch', null, null, 'switch router'),
  1196. this.addEntry('process bar', function()
  1197. {
  1198. return sb.createVertexTemplateFromData('zZXRaoMwFIafJpcDjbNrb2233rRQ8AkyPdPQaCRJV+3T7yTG2rUVBoOtgpDzn/xJzncCIdGyateKNeVW5iBI9EqipZLS9KOqXYIQhAY8J9GKUBrgT+jbRDZ02aBhCmrzEwPtDZ9MHKBXdkpmoDWKCVN9VptO+Kw+8kqwGqMkK7nIN6yTB7uTNizbD1FSSsVPsjYMC1qFKHxwIZZSSIVxLZ1/nJNar5+oQPMT7IYCrqUta1ENzuqGaeOFTArBGs3f3Vmtoo2Se7ja1h00kSoHK4bBIKUNy3hdoPYU0mF91i9mT8EEL2ocZ3gKa00ayWujLZY4IfHKFonVDLsRGgXuQ90zBmWgneyTk3yT1iArMKrDKUeem9L3ajHrbSXwohxsQd/ggOleKM7ese048J2/fwuim1uQGmhQCW8vQMkacP3GCQgBFMftHEsr7cYYe95CnmKTPMFbYD8CQ++DGQy+/M5X4ku5wHYmdIktfvk9tecpavThqS3m/0YtnqIWPTy1cD77K2wYjo+Ay317I74A', 296, 100, 'Process Bar');
  1199. }),
  1200. this.createVertexTemplateEntry('swimlane;', 200, 200, 'Container', 'Container', null, null, 'container swimlane lane pool group'),
  1201. this.addEntry('list group erd table', function()
  1202. {
  1203. var cell = new mxCell('List', new mxGeometry(0, 0, 140, 110),
  1204. 'swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;' +
  1205. 'resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;');
  1206. cell.vertex = true;
  1207. cell.insert(sb.cloneCell(field, 'Item 1'));
  1208. cell.insert(sb.cloneCell(field, 'Item 2'));
  1209. cell.insert(sb.cloneCell(field, 'Item 3'));
  1210. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'List');
  1211. }),
  1212. this.addEntry('list item entry value group erd table', function()
  1213. {
  1214. return sb.createVertexTemplateFromCells([sb.cloneCell(field, 'List Item')], field.geometry.width, field.geometry.height, 'List Item');
  1215. })
  1216. ];
  1217. };
  1218. /**
  1219. * Adds the general palette to the sidebar.
  1220. */
  1221. Sidebar.prototype.addUmlPalette = function(expand)
  1222. {
  1223. // Avoids having to bind all functions to "this"
  1224. var sb = this;
  1225. // Reusable cells
  1226. var field = new mxCell('+ field: type', new mxGeometry(0, 0, 100, 26), 'text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1227. field.vertex = true;
  1228. var divider = new mxCell('', new mxGeometry(0, 0, 40, 8), 'line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;');
  1229. divider.vertex = true;
  1230. // Default tags
  1231. var dt = 'uml static class ';
  1232. this.setCurrentSearchEntryLibrary('uml');
  1233. var fns = [
  1234. this.createVertexTemplateEntry('html=1;', 110, 50, 'Object', 'Object', null, null, dt + 'object instance'),
  1235. this.createVertexTemplateEntry('html=1;', 110, 50, '&laquo;interface&raquo;<br><b>Name</b>', 'Interface', null, null, dt + 'interface object instance annotated annotation'),
  1236. this.addEntry(dt + 'object instance', function()
  1237. {
  1238. var cell = new mxCell('Classname', new mxGeometry(0, 0, 160, 90),
  1239. 'swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;');
  1240. cell.vertex = true;
  1241. cell.insert(field.clone());
  1242. cell.insert(divider.clone());
  1243. cell.insert(sb.cloneCell(field, '+ method(type): type'));
  1244. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Class');
  1245. }),
  1246. this.addEntry(dt + 'section subsection', function()
  1247. {
  1248. var cell = new mxCell('Classname', new mxGeometry(0, 0, 140, 110),
  1249. 'swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;');
  1250. cell.vertex = true;
  1251. cell.insert(field.clone());
  1252. cell.insert(field.clone());
  1253. cell.insert(field.clone());
  1254. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Class 2');
  1255. }),
  1256. this.addEntry(dt + 'item member method function variable field attribute label', function()
  1257. {
  1258. return sb.createVertexTemplateFromCells([sb.cloneCell(field, '+ item: attribute')], field.geometry.width, field.geometry.height, 'Item 1');
  1259. }),
  1260. this.addEntry(dt + 'item member method function variable field attribute label', function()
  1261. {
  1262. var cell = new mxCell('item: attribute', new mxGeometry(0, 0, 120, field.geometry.height), 'label;fontStyle=0;strokeColor=none;fillColor=none;align=left;verticalAlign=top;overflow=hidden;' +
  1263. 'spacingLeft=28;spacingRight=4;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;imageWidth=16;imageHeight=16;image=' + sb.gearImage);
  1264. cell.vertex = true;
  1265. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Item 2');
  1266. }),
  1267. this.addEntry(dt + 'divider hline line separator', function()
  1268. {
  1269. return sb.createVertexTemplateFromCells([divider.clone()], divider.geometry.width, divider.geometry.height, 'Divider');
  1270. }),
  1271. this.addEntry(dt + 'spacer space gap separator', function()
  1272. {
  1273. var cell = new mxCell('', new mxGeometry(0, 0, 20, 14), 'text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=4;spacingRight=4;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;');
  1274. cell.vertex = true;
  1275. return sb.createVertexTemplateFromCells([cell.clone()], cell.geometry.width, cell.geometry.height, 'Spacer');
  1276. }),
  1277. this.createVertexTemplateEntry('text;align=center;fontStyle=1;verticalAlign=middle;spacingLeft=3;spacingRight=3;strokeColor=none;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;',
  1278. 80, 26, 'Title', 'Title', null, null, dt + 'title label'),
  1279. this.addEntry(dt + 'component', function()
  1280. {
  1281. var cell = new mxCell('&laquo;Annotation&raquo;<br/><b>Component</b>', new mxGeometry(0, 0, 180, 90), 'html=1;dropTarget=0;');
  1282. cell.vertex = true;
  1283. var symbol = new mxCell('', new mxGeometry(1, 0, 20, 20), 'shape=module;jettyWidth=8;jettyHeight=4;');
  1284. symbol.vertex = true;
  1285. symbol.geometry.relative = true;
  1286. symbol.geometry.offset = new mxPoint(-27, 7);
  1287. cell.insert(symbol);
  1288. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Component');
  1289. }),
  1290. this.addEntry(dt + 'component', function()
  1291. {
  1292. var cell = new mxCell('<p style="margin:0px;margin-top:6px;text-align:center;"><b>Component</b></p>' +
  1293. '<hr/><p style="margin:0px;margin-left:8px;">+ Attribute1: Type<br/>+ Attribute2: Type</p>', new mxGeometry(0, 0, 180, 90),
  1294. 'align=left;overflow=fill;html=1;dropTarget=0;');
  1295. cell.vertex = true;
  1296. var symbol = new mxCell('', new mxGeometry(1, 0, 20, 20), 'shape=component;jettyWidth=8;jettyHeight=4;');
  1297. symbol.vertex = true;
  1298. symbol.geometry.relative = true;
  1299. symbol.geometry.offset = new mxPoint(-24, 4);
  1300. cell.insert(symbol);
  1301. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Component with Attributes');
  1302. }),
  1303. this.createVertexTemplateEntry('verticalAlign=top;align=left;spacingTop=8;spacingLeft=2;spacingRight=12;shape=cube;size=10;direction=south;fontStyle=4;html=1;',
  1304. 180, 120, 'Block', 'Block', null, null, dt + 'block'),
  1305. this.createVertexTemplateEntry('shape=module;align=left;spacingLeft=20;align=center;verticalAlign=top;', 100, 50, 'Module', 'Module', null, null, dt + 'module component'),
  1306. this.createVertexTemplateEntry('shape=folder;fontStyle=1;spacingTop=10;tabWidth=40;tabHeight=14;tabPosition=left;html=1;', 70, 50,
  1307. 'package', 'Package', null, null, dt + 'package'),
  1308. this.createVertexTemplateEntry('verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;',
  1309. 160, 90, '<p style="margin:0px;margin-top:4px;text-align:center;text-decoration:underline;"><b>Object:Type</b></p><hr/>' +
  1310. '<p style="margin:0px;margin-left:8px;">field1 = value1<br/>field2 = value2<br>field3 = value3</p>', 'Object',
  1311. null, null, dt + 'object instance'),
  1312. this.createVertexTemplateEntry('verticalAlign=top;align=left;overflow=fill;html=1;',180, 90,
  1313. '<div style="box-sizing:border-box;width:100%;background:#e4e4e4;padding:2px;">Tablename</div>' +
  1314. '<table style="width:100%;font-size:1em;" cellpadding="2" cellspacing="0">' +
  1315. '<tr><td>PK</td><td>uniqueId</td></tr><tr><td>FK1</td><td>' +
  1316. 'foreignKey</td></tr><tr><td></td><td>fieldname</td></tr></table>', 'Entity', null, null, 'er entity table'),
  1317. this.addEntry(dt + 'object instance', function()
  1318. {
  1319. var cell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
  1320. '<b>Class</b></p>' +
  1321. '<hr size="1"/><div style="height:2px;"></div>', new mxGeometry(0, 0, 140, 60),
  1322. 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;');
  1323. cell.vertex = true;
  1324. return sb.createVertexTemplateFromCells([cell.clone()], cell.geometry.width, cell.geometry.height, 'Class 3');
  1325. }),
  1326. this.addEntry(dt + 'object instance', function()
  1327. {
  1328. var cell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
  1329. '<b>Class</b></p>' +
  1330. '<hr size="1"/><div style="height:2px;"></div><hr size="1"/><div style="height:2px;"></div>', new mxGeometry(0, 0, 140, 60),
  1331. 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;');
  1332. cell.vertex = true;
  1333. return sb.createVertexTemplateFromCells([cell.clone()], cell.geometry.width, cell.geometry.height, 'Class 4');
  1334. }),
  1335. this.addEntry(dt + 'object instance', function()
  1336. {
  1337. var cell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
  1338. '<b>Class</b></p>' +
  1339. '<hr size="1"/><p style="margin:0px;margin-left:4px;">+ field: Type</p><hr size="1"/>' +
  1340. '<p style="margin:0px;margin-left:4px;">+ method(): Type</p>', new mxGeometry(0, 0, 160, 90),
  1341. 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;');
  1342. cell.vertex = true;
  1343. return sb.createVertexTemplateFromCells([cell.clone()], cell.geometry.width, cell.geometry.height, 'Class 5');
  1344. }),
  1345. this.addEntry(dt + 'object instance', function()
  1346. {
  1347. var cell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
  1348. '<i>&lt;&lt;Interface&gt;&gt;</i><br/><b>Interface</b></p>' +
  1349. '<hr size="1"/><p style="margin:0px;margin-left:4px;">+ field1: Type<br/>' +
  1350. '+ field2: Type</p>' +
  1351. '<hr size="1"/><p style="margin:0px;margin-left:4px;">' +
  1352. '+ method1(Type): Type<br/>' +
  1353. '+ method2(Type, Type): Type</p>', new mxGeometry(0, 0, 190, 140),
  1354. 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;');
  1355. cell.vertex = true;
  1356. return sb.createVertexTemplateFromCells([cell.clone()], cell.geometry.width, cell.geometry.height, 'Interface 2');
  1357. }),
  1358. this.createVertexTemplateEntry('shape=providedRequiredInterface;html=1;verticalLabelPosition=bottom;', 20, 20, '', 'Provided/Required Interface', null, null, 'uml provided required interface lollipop notation'),
  1359. this.createVertexTemplateEntry('shape=requiredInterface;html=1;verticalLabelPosition=bottom;', 10, 20, '', 'Required Interface', null, null, 'uml required interface lollipop notation'),
  1360. this.addEntry('uml lollipop notation provided required interface', function()
  1361. {
  1362. return sb.createVertexTemplateFromData('zVTBrptADPyavVYEkt4b0uQd3pMq5dD2uAUD27dgZJwE8vX1spsQlETtpVWRIjFjex3PmFVJWvc70m31hjlYlXxWSUqI7N/qPgVrVRyZXCUbFceR/FS8fRJdjNGo1QQN/0lB7AuO2h7AM57oeLCBIDw0Obj8SCVrJK6wxEbbV8RWyIWQP4F52Juzq9AHRqEqrm2IQpN/IsKTwAYb8MzWWBuO9B0hL2E2BGsqIQyxvJ9rzApD7QBrYBokhcBqNsf5UbrzsLzmXUu/oJET42jwGat5QYcHyiDkTDLKy03TiRrFfSx08m+FrrQtUkOZvZdbFKThmwMfVhf4fQ43/W3uZriiPPT+KKhjwnf4anKuQv//wsg+NPJ7/9d9Xf7eVykwbeeMOFWGYd/qzEVO8tHP/Suw4a2ujXV/+gXsEdhkOgSC8os44BQt0tggicZHeG1N2QiXibhAV48epRayEDd8MT7Ct06TUaXVWq027tCuhcx5VZjebeeaoDNn/WMcb/p+j0AM/dNr6InLl4Lgzylsk6OCgRWYsuI592gNZh5OhgmcblPv7+1l+ws=',
  1363. 40, 10, 'Lollipop Notation');
  1364. }),
  1365. this.createVertexTemplateEntry('shape=umlBoundary;whiteSpace=wrap;html=1;', 100, 80, 'Boundary Object', 'Boundary Object', null, null, 'uml boundary object'),
  1366. this.createVertexTemplateEntry('ellipse;shape=umlEntity;whiteSpace=wrap;html=1;', 80, 80, 'Entity Object', 'Entity Object', null, null, 'uml entity object'),
  1367. this.createVertexTemplateEntry('ellipse;shape=umlControl;whiteSpace=wrap;html=1;', 70, 80, 'Control Object', 'Control Object', null, null, 'uml control object'),
  1368. this.createVertexTemplateEntry('shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;', 30, 60, 'Actor', 'Actor', false, null, 'uml actor'),
  1369. this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;', 140, 70, 'Use Case', 'Use Case', null, null, 'uml use case usecase'),
  1370. this.addEntry('uml activity state start', function()
  1371. {
  1372. var cell = new mxCell('', new mxGeometry(0, 0, 30, 30),
  1373. 'ellipse;html=1;shape=startState;fillColor=#000000;strokeColor=#ff0000;');
  1374. cell.vertex = true;
  1375. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
  1376. edge.geometry.setTerminalPoint(new mxPoint(15, 90), false);
  1377. edge.geometry.relative = true;
  1378. edge.edge = true;
  1379. cell.insertEdge(edge, true);
  1380. return sb.createVertexTemplateFromCells([cell, edge], 30, 90, 'Start');
  1381. }),
  1382. this.addEntry('uml activity state', function()
  1383. {
  1384. var cell = new mxCell('Activity', new mxGeometry(0, 0, 120, 40),
  1385. 'rounded=1;whiteSpace=wrap;html=1;arcSize=40;fontColor=#000000;fillColor=#ffffc0;strokeColor=#ff0000;');
  1386. cell.vertex = true;
  1387. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
  1388. edge.geometry.setTerminalPoint(new mxPoint(60, 100), false);
  1389. edge.geometry.relative = true;
  1390. edge.edge = true;
  1391. cell.insertEdge(edge, true);
  1392. return sb.createVertexTemplateFromCells([cell, edge], 120, 100, 'Activity');
  1393. }),
  1394. this.addEntry('uml activity composite state', function()
  1395. {
  1396. var cell = new mxCell('Composite State', new mxGeometry(0, 0, 160, 60),
  1397. 'swimlane;html=1;fontStyle=1;align=center;verticalAlign=middle;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=0;resizeLast=1;container=0;fontColor=#000000;collapsible=0;rounded=1;arcSize=30;strokeColor=#ff0000;fillColor=#ffffc0;swimlaneFillColor=#ffffc0;dropTarget=0;');
  1398. cell.vertex = true;
  1399. var cell1 = new mxCell('Subtitle', new mxGeometry(0, 0, 200, 26), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;whiteSpace=wrap;overflow=hidden;rotatable=0;fontColor=#000000;');
  1400. cell1.vertex = true;
  1401. cell.insert(cell1);
  1402. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
  1403. edge.geometry.setTerminalPoint(new mxPoint(80, 120), false);
  1404. edge.geometry.relative = true;
  1405. edge.edge = true;
  1406. cell.insertEdge(edge, true);
  1407. return sb.createVertexTemplateFromCells([cell, edge], 160, 120, 'Composite State');
  1408. }),
  1409. this.addEntry('uml activity condition', function()
  1410. {
  1411. var cell = new mxCell('Condition', new mxGeometry(0, 0, 80, 40), 'rhombus;whiteSpace=wrap;html=1;fillColor=#ffffc0;strokeColor=#ff0000;');
  1412. cell.vertex = true;
  1413. var edge1 = new mxCell('no', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;align=left;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
  1414. edge1.geometry.setTerminalPoint(new mxPoint(180, 20), false);
  1415. edge1.geometry.relative = true;
  1416. edge1.geometry.x = -1;
  1417. edge1.edge = true;
  1418. cell.insertEdge(edge1, true);
  1419. var edge2 = new mxCell('yes', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;align=left;verticalAlign=top;endArrow=open;endSize=8;strokeColor=#ff0000;');
  1420. edge2.geometry.setTerminalPoint(new mxPoint(40, 100), false);
  1421. edge2.geometry.relative = true;
  1422. edge2.geometry.x = -1;
  1423. edge2.edge = true;
  1424. cell.insertEdge(edge2, true);
  1425. return sb.createVertexTemplateFromCells([cell, edge1, edge2], 180, 100, 'Condition');
  1426. }),
  1427. this.addEntry('uml activity fork join', function()
  1428. {
  1429. var cell = new mxCell('', new mxGeometry(0, 0, 200, 10), 'shape=line;html=1;strokeWidth=6;strokeColor=#ff0000;');
  1430. cell.vertex = true;
  1431. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
  1432. edge.geometry.setTerminalPoint(new mxPoint(100, 80), false);
  1433. edge.geometry.relative = true;
  1434. edge.edge = true;
  1435. cell.insertEdge(edge, true);
  1436. return sb.createVertexTemplateFromCells([cell, edge], 200, 80, 'Fork/Join');
  1437. }),
  1438. this.createVertexTemplateEntry('ellipse;html=1;shape=endState;fillColor=#000000;strokeColor=#ff0000;', 30, 30, '', 'End', null, null, 'uml activity state end'),
  1439. this.createVertexTemplateEntry('shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;outlineConnect=0;', 100, 300, ':Object', 'Lifeline', null, null, 'uml sequence participant lifeline'),
  1440. this.createVertexTemplateEntry('shape=umlLifeline;participant=umlActor;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;verticalAlign=top;spacingTop=36;outlineConnect=0;',
  1441. 20, 300, '', 'Actor Lifeline', null, null, 'uml sequence participant lifeline actor'),
  1442. this.createVertexTemplateEntry('shape=umlLifeline;participant=umlBoundary;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;verticalAlign=top;spacingTop=36;outlineConnect=0;',
  1443. 50, 300, '', 'Boundary Lifeline', null, null, 'uml sequence participant lifeline boundary'),
  1444. this.createVertexTemplateEntry('shape=umlLifeline;participant=umlEntity;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;verticalAlign=top;spacingTop=36;outlineConnect=0;',
  1445. 40, 300, '', 'Entity Lifeline', null, null, 'uml sequence participant lifeline entity'),
  1446. this.createVertexTemplateEntry('shape=umlLifeline;participant=umlControl;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;verticalAlign=top;spacingTop=36;outlineConnect=0;',
  1447. 40, 300, '', 'Control Lifeline', null, null, 'uml sequence participant lifeline control'),
  1448. this.createVertexTemplateEntry('shape=umlFrame;whiteSpace=wrap;html=1;', 300, 200, 'frame', 'Frame', null, null, 'uml sequence frame'),
  1449. this.createVertexTemplateEntry('shape=umlDestroy;whiteSpace=wrap;html=1;strokeWidth=3;', 30, 30, '', 'Destruction', null, null, 'uml sequence destruction destroy'),
  1450. this.addEntry('uml sequence invoke invocation call activation', function()
  1451. {
  1452. var cell = new mxCell('', new mxGeometry(0, 0, 10, 80), 'html=1;points=[];perimeter=orthogonalPerimeter;');
  1453. cell.vertex = true;
  1454. var edge = new mxCell('dispatch', new mxGeometry(0, 0, 0, 0), 'html=1;verticalAlign=bottom;startArrow=oval;endArrow=block;startSize=8;');
  1455. edge.geometry.setTerminalPoint(new mxPoint(-60, 0), true);
  1456. edge.geometry.relative = true;
  1457. edge.edge = true;
  1458. cell.insertEdge(edge, false);
  1459. return sb.createVertexTemplateFromCells([cell, edge], 10, 80, 'Found Message');
  1460. }),
  1461. this.addEntry('uml sequence invoke call delegation synchronous invocation activation', function()
  1462. {
  1463. var cell = new mxCell('', new mxGeometry(0, 0, 10, 80), 'html=1;points=[];perimeter=orthogonalPerimeter;');
  1464. cell.vertex = true;
  1465. var edge1 = new mxCell('dispatch', new mxGeometry(0, 0, 0, 0), 'html=1;verticalAlign=bottom;endArrow=block;entryX=0;entryY=0;');
  1466. edge1.geometry.setTerminalPoint(new mxPoint(-70, 0), true);
  1467. edge1.geometry.relative = true;
  1468. edge1.edge = true;
  1469. cell.insertEdge(edge1, false);
  1470. var edge2 = new mxCell('return', new mxGeometry(0, 0, 0, 0), 'html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;exitX=0;exitY=0.95;');
  1471. edge2.geometry.setTerminalPoint(new mxPoint(-70, 76), false);
  1472. edge2.geometry.relative = true;
  1473. edge2.edge = true;
  1474. cell.insertEdge(edge2, true);
  1475. return sb.createVertexTemplateFromCells([cell, edge1, edge2], 10, 80, 'Synchronous Invocation');
  1476. }),
  1477. this.addEntry('uml sequence self call recursion delegation activation', function()
  1478. {
  1479. var cell = new mxCell('', new mxGeometry(0, 20, 10, 40), 'html=1;points=[];perimeter=orthogonalPerimeter;');
  1480. cell.vertex = true;
  1481. var edge = new mxCell('self call', new mxGeometry(0, 0, 0, 0), 'edgeStyle=orthogonalEdgeStyle;html=1;align=left;spacingLeft=2;endArrow=block;rounded=0;entryX=1;entryY=0;');
  1482. edge.geometry.setTerminalPoint(new mxPoint(5, 0), true);
  1483. edge.geometry.points = [new mxPoint(30, 0)];
  1484. edge.geometry.relative = true;
  1485. edge.edge = true;
  1486. cell.insertEdge(edge, false);
  1487. return sb.createVertexTemplateFromCells([cell, edge], 10, 60, 'Self Call');
  1488. }),
  1489. this.addEntry('uml sequence invoke call delegation callback activation', function()
  1490. {
  1491. // TODO: Check if more entries should be converted to compressed XML
  1492. return sb.createVertexTemplateFromData('xZRNT8MwDIZ/Ta6oaymD47rBTkiTuMAxW6wmIm0q19s6fj1OE3V0Y2iCA4dK8euP2I+riGxedUuUjX52CqzIHkU2R+conKpuDtaKNDFKZAuRpgl/In264J303qSRCDVdk5CGhJ20WwhKEFo62ChoqritxURkReNMTa2X80LkC68AmgoIkEWHpF3pamlXR7WIFwASdBeb7KXY4RIc5+KBQ/ZGkY4RYY5Egyl1zLqLmmyDXQ6Zx4n5EIf+HkB2BmAjrV3LzftPIPw4hgNn1pQ1a2tH5Cp2QK1miG7vNeu4iJe4pdeY2BtvbCQDGlAljMCQxBJotJ8rWCFYSWY3LvUdmZi68rvkkLiU6QnL1m1xAzHoBOdw61WEb88II9AW67/ydQ2wq1Cy1aAGvOrFfPh6997qDA3g+dxzv3nIL6MPU/8T+kMw8+m4QPgdfrEJNo8PSQj/+s58Ag==',
  1493. 10, 60, 'Callback');
  1494. }),
  1495. this.createVertexTemplateEntry('html=1;points=[];perimeter=orthogonalPerimeter;', 10, 80, '', 'Activation', null, null, 'uml sequence activation'),
  1496. // new 2.5.1 shapes ******************************************************************************
  1497. this.createVertexTemplateEntry('shape=partialRectangle;html=1;top=1;align=left;dashed=1;', 200, 20, 'Template1 signature', 'Template signature', null, null, 'template signature'),
  1498. this.createVertexTemplateEntry('shape=partialRectangle;html=1;top=1;align=left;dashed=1;', 200, 50, 'Template parameter 1\nTemplate parameter 2', 'Template signature', null, null, 'template signature'),
  1499. this.createVertexTemplateEntry('shape=note2;boundedLbl=1;whiteSpace=wrap;html=1;size=25;verticalAlign=top;align=center;', 120, 60, 'Comment1 body', 'Note', null, null, 'uml note'),
  1500. this.addEntry('uml sequence self call recursion delegation activation', function()
  1501. {
  1502. var cell = new mxCell('Constraint1 specification', new mxGeometry(0, 0, 160, 60), 'shape=note2;boundedLbl=1;whiteSpace=wrap;html=1;size=25;verticalAlign=top;align=center;');
  1503. cell.vertex = true;
  1504. var label = new mxCell('<<keyword>>', new mxGeometry(0, 0, cell.geometry.width, 25), 'resizeWidth=1;part=1;strokeColor=none;fillColor=none;align=left;spacingLeft=5;');
  1505. label.geometry.relative = true;
  1506. label.vertex = true;
  1507. cell.insert(label);
  1508. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Note');
  1509. }),
  1510. this.addEntry(dt + 'classifier', function()
  1511. {
  1512. var cell1 = new mxCell('&lt;&lt;keyword&gt;&gt;<br><b>Classifier1</b><br>{abstract}', new mxGeometry(0, 0, 140, 183),
  1513. 'swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=55;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;');
  1514. cell1.vertex = true;
  1515. var field1 = new mxCell('attributes',
  1516. new mxGeometry(0, 0, 140, 20), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1517. field1.vertex = true;
  1518. cell1.insert(field1);
  1519. var field2 = new mxCell('attribute1',
  1520. new mxGeometry(0, 0, 140, 20), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1521. field2.vertex = true;
  1522. cell1.insert(field2);
  1523. var field3 = new mxCell('inherited attribute2',
  1524. new mxGeometry(0, 0, 140, 20), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontColor=#808080;');
  1525. field3.vertex = true;
  1526. cell1.insert(field3);
  1527. var field4 = new mxCell('...',
  1528. new mxGeometry(0, 0, 140, 20), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1529. field4.vertex = true;
  1530. cell1.insert(field4);
  1531. cell1.insert(divider.clone());
  1532. var field5 = new mxCell('operations',
  1533. new mxGeometry(0, 0, 140, 20), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1534. field5.vertex = true;
  1535. cell1.insert(field5);
  1536. var field6 = new mxCell('operation1',
  1537. new mxGeometry(0, 0, 140, 20), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1538. field6.vertex = true;
  1539. cell1.insert(field6);
  1540. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1541. }),
  1542. this.createVertexTemplateEntry('shape=process;fixedSize=1;size=5;fontStyle=1;', 140, 40, 'Classifier1', 'Classifier', null, null, 'classifier'),
  1543. this.addEntry(dt + 'classifier', function()
  1544. {
  1545. var cell1 = new mxCell('Classifier1', new mxGeometry(0, 0, 140, 183),
  1546. 'swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;');
  1547. cell1.vertex = true;
  1548. var field1 = new mxCell('internal structure',
  1549. new mxGeometry(0, 0, 140, 30), 'html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;rotatable=0;points=[[0,0.5],[1,0.5]];resizeWidth=1;');
  1550. field1.vertex = true;
  1551. cell1.insert(field1);
  1552. var cell2 = new mxCell('', new mxGeometry(0, 0, 140, 140),
  1553. 'strokeColor=none;fillColor=none;');
  1554. cell2.vertex = true;
  1555. cell1.insert(cell2);
  1556. var field2 = new mxCell('property1',
  1557. new mxGeometry(0, 0, 100, 30), 'html=1;align=center;verticalAlign=middle;rotatable=0;');
  1558. field2.geometry.relative = true;
  1559. field2.geometry.offset = new mxPoint(20, 20);
  1560. field2.vertex = true;
  1561. cell2.insert(field2);
  1562. var field3 = new mxCell('property2',
  1563. new mxGeometry(0, 0, 100, 30), 'html=1;align=center;verticalAlign=middle;rotatable=0;');
  1564. field3.geometry.relative = true;
  1565. field3.geometry.offset = new mxPoint(20, 90);
  1566. field3.vertex = true;
  1567. cell2.insert(field3);
  1568. var assoc1 = new mxCell('connector1', new mxGeometry(0, 0, 0, 0), 'edgeStyle=none;endArrow=none;verticalAlign=middle;labelBackgroundColor=none;endSize=12;html=1;align=left;endFill=0;exitX=0.15;exitY=1;entryX=0.15;entryY=0;spacingLeft=4;');
  1569. assoc1.geometry.relative = true;
  1570. assoc1.edge = true;
  1571. field2.insertEdge(assoc1, true);
  1572. field3.insertEdge(assoc1, false);
  1573. cell2.insert(assoc1);
  1574. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1575. }),
  1576. this.createVertexTemplateEntry('fontStyle=1;', 140, 30, 'Association1', 'Association', null, null, 'association'),
  1577. this.addEntry(dt + 'classifier', function()
  1578. {
  1579. var cell1 = new mxCell('Instance1', new mxGeometry(0, 0, 140, 138),
  1580. 'swimlane;fontStyle=4;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;');
  1581. cell1.vertex = true;
  1582. var field1 = new mxCell('slot1',
  1583. new mxGeometry(0, 0, 140, 30), 'html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;rotatable=0;points=[[0,0.5],[1,0.5]];resizeWidth=1;');
  1584. field1.vertex = true;
  1585. cell1.insert(field1);
  1586. cell1.insert(divider.clone());
  1587. var field2 = new mxCell('internal structure',
  1588. new mxGeometry(0, 0, 140, 20), 'html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;rotatable=0;points=[[0,0.5],[1,0.5]];resizeWidth=1;');
  1589. field2.vertex = true;
  1590. cell1.insert(field2);
  1591. var cell2 = new mxCell('', new mxGeometry(0, 0, 140, 50),
  1592. 'strokeColor=none;fillColor=none;');
  1593. cell2.vertex = true;
  1594. cell1.insert(cell2);
  1595. var field3 = new mxCell('instance2',
  1596. new mxGeometry(0, 0, 80, 30), 'html=1;align=center;verticalAlign=middle;rotatable=0;');
  1597. field3.geometry.relative = true;
  1598. field3.geometry.offset = new mxPoint(30, 10);
  1599. field3.vertex = true;
  1600. cell2.insert(field3);
  1601. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1602. }),
  1603. this.createVertexTemplateEntry('fontStyle=0;', 120, 40, 'Instance1 value', 'Instance', null, null, 'instance'),
  1604. this.addEntry(dt + 'classifier', function()
  1605. {
  1606. var cell1 = new mxCell('&lt;&lt;enumeration&gt;&gt;<br><b>Enum1</b>', new mxGeometry(0, 0, 140, 70),
  1607. 'swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=40;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;');
  1608. cell1.vertex = true;
  1609. var field1 = new mxCell('literal1',
  1610. new mxGeometry(0, 0, 140, 30), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1611. field1.vertex = true;
  1612. cell1.insert(field1);
  1613. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1614. }),
  1615. this.addEntry(dt + 'classifier', function()
  1616. {
  1617. var cell1 = new mxCell('0..1', new mxGeometry(0, 0, 120, 50),
  1618. 'align=right;verticalAlign=top;spacingRight=2;');
  1619. cell1.vertex = true;
  1620. var field1 = new mxCell('Property1',
  1621. new mxGeometry(0, 1, 120, 30), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;resizeWidth=1;');
  1622. field1.geometry.relative = true;
  1623. field1.geometry.offset = new mxPoint(0, -30);
  1624. field1.vertex = true;
  1625. cell1.insert(field1);
  1626. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1627. }),
  1628. this.createVertexTemplateEntry('fontStyle=0;dashed=1;', 140, 30, 'Property1', 'Property', null, null, 'property'),
  1629. this.createVertexTemplateEntry('fontStyle=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;spacingLeft=2;', 30, 30, 'port1', 'Port', null, null, 'port'),
  1630. this.addEntry(dt + 'component', function()
  1631. {
  1632. var cell1 = new mxCell('', new mxGeometry(0, 0, 140, 200), 'fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;marginBottom=0;');
  1633. cell1.vertex = true;
  1634. var cell2 = new mxCell('Component', new mxGeometry(0, 0, 140, 40), 'html=1;align=left;spacingLeft=4;verticalAlign=top;strokeColor=none;fillColor=none;');
  1635. cell2.vertex = true;
  1636. cell1.insert(cell2);
  1637. var symbol = new mxCell('', new mxGeometry(1, 0, 16, 20), 'shape=module;jettyWidth=10;jettyHeight=4;');
  1638. symbol.vertex = true;
  1639. symbol.geometry.relative = true;
  1640. symbol.geometry.offset = new mxPoint(-25, 9);
  1641. cell2.insert(symbol);
  1642. cell1.insert(divider.clone());
  1643. var cell3 = new mxCell('provided interfaces', new mxGeometry(0, 0, 140, 25), 'html=1;align=center;spacingLeft=4;verticalAlign=top;strokeColor=none;fillColor=none;');
  1644. cell3.vertex = true;
  1645. cell1.insert(cell3);
  1646. var cell4 = new mxCell('Interface1', new mxGeometry(0, 0, 140, 25), 'html=1;align=left;spacingLeft=4;verticalAlign=top;strokeColor=none;fillColor=none;');
  1647. cell4.vertex = true;
  1648. cell1.insert(cell4);
  1649. cell1.insert(divider.clone());
  1650. var cell5 = new mxCell('required interfaces', new mxGeometry(0, 0, 140, 25), 'html=1;align=center;spacingLeft=4;verticalAlign=top;strokeColor=none;fillColor=none;');
  1651. cell5.vertex = true;
  1652. cell1.insert(cell5);
  1653. var cell6 = new mxCell('Interface2', new mxGeometry(0, 0, 140, 30), 'html=1;align=left;spacingLeft=4;verticalAlign=top;strokeColor=none;fillColor=none;');
  1654. cell6.vertex = true;
  1655. cell1.insert(cell6);
  1656. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Component');
  1657. }),
  1658. this.addEntry(dt + 'classifier', function()
  1659. {
  1660. var cell1 = new mxCell('', new mxGeometry(0, 0, 270, 230),
  1661. 'shape=ellipse;container=1;horizontal=1;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;html=1;dashed=1;collapsible=0;');
  1662. cell1.vertex = true;
  1663. var field1 = new mxCell('Collaboration1',
  1664. new mxGeometry(0, 0, 270, 30), 'html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;rotatable=0;points=[[0,0.5],[1,0.5]];resizeWidth=1;');
  1665. field1.vertex = true;
  1666. cell1.insert(field1);
  1667. var divider1 = new mxCell('', new mxGeometry(0.145, 0, 192, 8), 'line;strokeWidth=1;fillColor=none;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;dashed=1;resizeWidth=1;');
  1668. divider1.geometry.relative = true;
  1669. divider1.geometry.offset = new mxPoint(0, 30);
  1670. divider1.vertex = true;
  1671. cell1.insert(divider1);
  1672. var field2 = new mxCell('Classifier1',
  1673. new mxGeometry(0, 0, 100, 30), 'html=1;align=center;verticalAlign=middle;rotatable=0;');
  1674. field2.geometry.relative = true;
  1675. field2.geometry.offset = new mxPoint(85, 50);
  1676. field2.vertex = true;
  1677. cell1.insert(field2);
  1678. var field3 = new mxCell('Collaboration use 1',
  1679. new mxGeometry(0, 0, 140, 30), 'shape=ellipse;html=1;align=center;verticalAlign=middle;rotatable=0;dashed=1;');
  1680. field3.geometry.relative = true;
  1681. field3.geometry.offset = new mxPoint(65, 110);
  1682. field3.vertex = true;
  1683. cell1.insert(field3);
  1684. var assoc1 = new mxCell('property1', new mxGeometry(0, 0, 0, 0), 'edgeStyle=none;endArrow=none;verticalAlign=middle;labelBackgroundColor=none;endSize=12;html=1;align=left;endFill=0;spacingLeft=4;');
  1685. assoc1.geometry.relative = true;
  1686. assoc1.edge = true;
  1687. field2.insertEdge(assoc1, true);
  1688. field3.insertEdge(assoc1, false);
  1689. cell1.insert(assoc1);
  1690. var field4 = new mxCell('Classifier2',
  1691. new mxGeometry(0, 0, 100, 30), 'html=1;align=center;verticalAlign=middle;rotatable=0;');
  1692. field4.geometry.relative = true;
  1693. field4.geometry.offset = new mxPoint(85, 170);
  1694. field4.vertex = true;
  1695. cell1.insert(field4);
  1696. var assoc2 = new mxCell('property1', new mxGeometry(0, 0, 0, 0), 'edgeStyle=none;endArrow=none;verticalAlign=middle;labelBackgroundColor=none;endSize=12;html=1;align=left;endFill=0;spacingLeft=4;');
  1697. assoc2.geometry.relative = true;
  1698. assoc2.edge = true;
  1699. field3.insertEdge(assoc2, true);
  1700. field4.insertEdge(assoc2, false);
  1701. cell1.insert(assoc2);
  1702. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1703. }),
  1704. this.createVertexTemplateEntry('shape=folder;fontStyle=1;tabWidth=80;tabHeight=30;tabPosition=left;html=1;boundedLbl=1;', 150, 80,
  1705. 'Package1', 'Package', null, null, dt + 'package'),
  1706. this.addEntry(dt + 'package', function()
  1707. {
  1708. var cell1 = new mxCell('Package1', new mxGeometry(0, 0, 150, 100),
  1709. 'shape=folder;fontStyle=1;tabWidth=110;tabHeight=30;tabPosition=left;html=1;boundedLbl=1;labelInHeader=1;');
  1710. cell1.vertex = true;
  1711. var field1 = new mxCell('Packaged element1',
  1712. new mxGeometry(0, 0, 110, 30), 'html=1;');
  1713. field1.geometry.relative = true;
  1714. field1.geometry.offset = new mxPoint(20, 50);
  1715. field1.vertex = true;
  1716. cell1.insert(field1);
  1717. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Classifier');
  1718. }),
  1719. this.addEntry(dt + 'package', function()
  1720. {
  1721. var cell1 = new mxCell('Model1', new mxGeometry(0, 0, 150, 80),
  1722. 'shape=folder;fontStyle=1;tabWidth=110;tabHeight=30;tabPosition=left;html=1;boundedLbl=1;folderSymbol=triangle;');
  1723. cell1.vertex = true;
  1724. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Package');
  1725. }),
  1726. this.addEntry(dt + 'stereotype', function()
  1727. {
  1728. var cell1 = new mxCell('', new mxGeometry(0, 0, 160, 75),
  1729. 'shape=note2;size=25;childLayout=stackLayout;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;container=1;');
  1730. cell1.vertex = true;
  1731. var field1 = new mxCell('&lt;&lt;stereotype1&gt;&gt;',
  1732. new mxGeometry(0, 0, 160, 25), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1733. field1.vertex = true;
  1734. cell1.insert(field1);
  1735. var field2 = new mxCell('stereotype property 1',
  1736. new mxGeometry(0, 0, 160, 25), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1737. field2.vertex = true;
  1738. cell1.insert(field2);
  1739. var field3 = new mxCell('stereotype property 2',
  1740. new mxGeometry(0, 0, 160, 25), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1741. field3.vertex = true;
  1742. cell1.insert(field3);
  1743. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Stereotype');
  1744. }),
  1745. this.addEntry(dt + 'class', function()
  1746. {
  1747. var cell1 = new mxCell('Class1', new mxGeometry(0, 0, 140, 79),
  1748. 'swimlane;fontStyle=1;align=center;verticalAlign=middle;childLayout=stackLayout;horizontal=1;startSize=29;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;');
  1749. cell1.vertex = true;
  1750. var field1 = new mxCell('&lt;&lt;stereotype1&gt;&gt;',
  1751. new mxGeometry(0, 0, 140, 25), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1752. field1.vertex = true;
  1753. cell1.insert(field1);
  1754. var field2 = new mxCell('stereotype property 1',
  1755. new mxGeometry(0, 0, 140, 25), 'text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;');
  1756. field2.vertex = true;
  1757. cell1.insert(field2);
  1758. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'Class');
  1759. }),
  1760. this.createVertexTemplateEntry('text;html=1;align=center;', 200, 25,
  1761. '&lt;&lt;stereotype1, stereotype2...&gt;&gt;', 'Label', null, null, dt + 'label'),
  1762. this.createVertexTemplateEntry('ellipse;', 50, 25,
  1763. 'icon', 'Icon', null, null, dt + 'icon'),
  1764. this.addEntry(dt + 'region', function()
  1765. {
  1766. var cell1 = new mxCell('', new mxGeometry(60, 0, 10, 100),
  1767. 'line;strokeWidth=1;direction=south;html=1;dashed=1;dashPattern=20 20;');
  1768. cell1.vertex = true;
  1769. var cell2 = new mxCell('Region 1', new mxGeometry(0, 40, 60, 20),
  1770. 'text;align=right;');
  1771. cell2.vertex = true;
  1772. var cell3 = new mxCell('Region 2', new mxGeometry(70, 40, 60, 20),
  1773. 'text;align=left;');
  1774. cell3.vertex = true;
  1775. return sb.createVertexTemplateFromCells([cell1, cell2, cell3], 130, cell1.geometry.height, 'Region');
  1776. }),
  1777. this.addEntry(dt + 'State', function()
  1778. {
  1779. var cell1 = new mxCell('State1<br>[invariant1]<br>&lt;&lt;extended/final&gt;&gt;', new mxGeometry(0, 0, 140, 176),
  1780. 'swimlane;fontStyle=4;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=60;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;html=1;rounded=1;absoluteArcSize=1;arcSize=50;');
  1781. cell1.vertex = true;
  1782. var field1 = new mxCell('',
  1783. new mxGeometry(0, 0, 140, 50), 'fillColor=none;strokeColor=none;container=1;collapsible=0;');
  1784. field1.vertex = true;
  1785. cell1.insert(field1);
  1786. var field2 = new mxCell('State2',
  1787. new mxGeometry(30, 10, 80, 30), 'html=1;align=center;verticalAlign=middle;rounded=1;absoluteArcSize=1;arcSize=10;');
  1788. field2.vertex = true;
  1789. field1.insert(field2);
  1790. cell1.insert(divider.clone());
  1791. var field3 = new mxCell('behavior1',
  1792. new mxGeometry(0, 0, 140, 25), 'fillColor=none;strokeColor=none;align=left;verticalAlign=middle;spacingLeft=5;');
  1793. field3.vertex = true;
  1794. cell1.insert(field3);
  1795. cell1.insert(divider.clone());
  1796. var field4 = new mxCell('transition1',
  1797. new mxGeometry(0, 0, 140, 25), 'fillColor=none;strokeColor=none;align=left;verticalAlign=middle;spacingLeft=5;');
  1798. field4.vertex = true;
  1799. cell1.insert(field4);
  1800. return sb.createVertexTemplateFromCells([cell1], cell1.geometry.width, cell1.geometry.height, 'State');
  1801. }),
  1802. this.createVertexTemplateEntry('html=1;align=center;verticalAlign=top;rounded=1;absoluteArcSize=1;arcSize=10;dashed=1;', 140, 40,
  1803. 'State1', 'State', null, null, dt + 'state'),
  1804. this.createVertexTemplateEntry('html=1;align=center;verticalAlign=top;rounded=1;absoluteArcSize=1;arcSize=10;dashed=0;', 140, 40,
  1805. 'State', 'State', null, null, dt + 'state'),
  1806. this.createVertexTemplateEntry('shape=folder;align=center;verticalAlign=middle;fontStyle=0;tabWidth=100;tabHeight=30;tabPosition=left;html=1;boundedLbl=1;labelInHeader=1;rounded=1;absoluteArcSize=1;arcSize=10;', 140, 90,
  1807. 'State1', 'State', null, null, dt + 'state'),
  1808. this.createVertexTemplateEntry('html=1;align=center;verticalAlign=top;rounded=1;absoluteArcSize=1;arcSize=10;dashed=0;', 140, 40,
  1809. 'State1, State2, ...', 'State', null, null, dt + 'state'),
  1810. this.createVertexTemplateEntry('shape=umlState;rounded=1;verticalAlign=top;spacingTop=5;umlStateSymbol=collapseState;absoluteArcSize=1;arcSize=10;', 140, 60,
  1811. 'State1', 'State', null, null, dt + 'state'),
  1812. this.addEntry(dt + 'State', function()
  1813. {
  1814. var cell1 = new mxCell('State1', new mxGeometry(40, 0, 140, 50),
  1815. 'shape=umlState;rounded=1;verticalAlign=middle;align=center;absoluteArcSize=1;arcSize=10;umlStateConnection=connPointRefEntry;boundedLbl=1;');
  1816. cell1.vertex = true;
  1817. var field1 = new mxCell('Entry1',
  1818. new mxGeometry(0, 40, 50, 20), 'text;verticalAlign=middle;align=center;');
  1819. field1.vertex = true;
  1820. cell1.insert(field1);
  1821. return sb.createVertexTemplateFromCells([cell1, field1], 180, 60, 'State');
  1822. }),
  1823. this.addEntry(dt + 'State', function()
  1824. {
  1825. var cell1 = new mxCell('State1', new mxGeometry(40, 0, 140, 50),
  1826. 'shape=umlState;rounded=1;verticalAlign=middle;spacingTop=0;absoluteArcSize=1;arcSize=10;umlStateConnection=connPointRefExit;boundedLbl=1;');
  1827. cell1.vertex = true;
  1828. var field1 = new mxCell('Exit1',
  1829. new mxGeometry(0, 40, 50, 20), 'text;verticalAlign=middle;align=center;');
  1830. field1.vertex = true;
  1831. cell1.insert(field1);
  1832. return sb.createVertexTemplateFromCells([cell1, field1], 180, 60, 'State');
  1833. }),
  1834. this.createVertexTemplateEntry('ellipse;fillColor=#000000;strokeColor=none;', 30, 30,
  1835. '', 'Initial state', null, null, dt + 'initial state'),
  1836. this.createVertexTemplateEntry('ellipse;html=1;shape=endState;fillColor=#000000;strokeColor=#000000;', 30, 30,
  1837. '', 'Final state', null, null, dt + 'final state'),
  1838. this.createVertexTemplateEntry('ellipse;fillColor=#ffffff;strokeColor=#000000;', 30, 30,
  1839. 'H', 'Shallow History', null, null, dt + 'shallow history'),
  1840. this.createVertexTemplateEntry('ellipse;fillColor=#ffffff;strokeColor=#000000;', 30, 30,
  1841. 'H*', 'Deep History', null, null, dt + 'deep history'),
  1842. this.createVertexTemplateEntry('ellipse;fillColor=#ffffff;strokeColor=#000000;', 30, 30,
  1843. '', 'Entry Point', null, null, dt + 'entry point'),
  1844. this.createVertexTemplateEntry('shape=sumEllipse;perimeter=ellipsePerimeter;whiteSpace=wrap;html=1;backgroundOutline=1;', 30, 30,
  1845. '', 'Exit Point', null, null, dt + 'exit point'),
  1846. this.createVertexTemplateEntry('ellipse;fillColor=#000000;strokeColor=none;', 20, 20,
  1847. '', 'Junction', null, null, dt + 'junction'),
  1848. this.createVertexTemplateEntry('rhombus;', 30, 30,
  1849. '', 'Choice', null, null, dt + 'choice'),
  1850. this.createVertexTemplateEntry('shape=umlDestroy;', 30, 30,
  1851. '', 'Terminate', null, null, dt + 'terminate'),
  1852. this.createVertexTemplateEntry('html=1;points=[];perimeter=orthogonalPerimeter;fillColor=#000000;strokeColor=none;', 5, 80,
  1853. '', 'Join/Fork', null, null, dt + 'join fork'),
  1854. this.createVertexTemplateEntry('text;align=center;verticalAlign=middle;dashed=0;fillColor=#ffffff;strokeColor=#000000;', 140, 40,
  1855. 'OpaqueAction1 spec.', 'Opaque Action', null, null, dt + 'opaque action'),
  1856. // end of new shapes ******************************************************************************
  1857. this.createEdgeTemplateEntry('html=1;verticalAlign=bottom;startArrow=oval;startFill=1;endArrow=block;startSize=8;', 60, 0, 'dispatch', 'Found Message 1', null, 'uml sequence message call invoke dispatch'),
  1858. this.createEdgeTemplateEntry('html=1;verticalAlign=bottom;startArrow=circle;startFill=1;endArrow=open;startSize=6;endSize=8;', 80, 0, 'dispatch', 'Found Message 2', null, 'uml sequence message call invoke dispatch'),
  1859. this.createEdgeTemplateEntry('html=1;verticalAlign=bottom;endArrow=block;', 80, 0, 'dispatch', 'Message', null, 'uml sequence message call invoke dispatch'),
  1860. this.addEntry('uml sequence return message', function()
  1861. {
  1862. var edge = new mxCell('return', new mxGeometry(0, 0, 0, 0), 'html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;');
  1863. edge.geometry.setTerminalPoint(new mxPoint(80, 0), true);
  1864. edge.geometry.setTerminalPoint(new mxPoint(0, 0), false);
  1865. edge.geometry.relative = true;
  1866. edge.edge = true;
  1867. return sb.createEdgeTemplateFromCells([edge], 80, 0, 'Return');
  1868. }),
  1869. this.addEntry('uml relation', function()
  1870. {
  1871. var edge = new mxCell('name', new mxGeometry(0, 0, 0, 0), 'endArrow=block;endFill=1;html=1;edgeStyle=orthogonalEdgeStyle;align=left;verticalAlign=top;');
  1872. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  1873. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  1874. edge.geometry.relative = true;
  1875. edge.geometry.x = -1;
  1876. edge.edge = true;
  1877. var cell = new mxCell('1', new mxGeometry(-1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=left;verticalAlign=bottom;');
  1878. cell.geometry.relative = true;
  1879. cell.setConnectable(false);
  1880. cell.vertex = true;
  1881. edge.insert(cell);
  1882. return sb.createEdgeTemplateFromCells([edge], 160, 0, 'Relation 1');
  1883. }),
  1884. this.addEntry('uml association', function()
  1885. {
  1886. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'endArrow=none;html=1;edgeStyle=orthogonalEdgeStyle;');
  1887. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  1888. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  1889. edge.geometry.relative = true;
  1890. edge.edge = true;
  1891. var cell1 = new mxCell('parent', new mxGeometry(-1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=left;verticalAlign=bottom;');
  1892. cell1.geometry.relative = true;
  1893. cell1.setConnectable(false);
  1894. cell1.vertex = true;
  1895. edge.insert(cell1);
  1896. var cell2 = new mxCell('child', new mxGeometry(1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=right;verticalAlign=bottom;');
  1897. cell2.geometry.relative = true;
  1898. cell2.setConnectable(false);
  1899. cell2.vertex = true;
  1900. edge.insert(cell2);
  1901. return sb.createEdgeTemplateFromCells([edge], 160, 0, 'Association 1');
  1902. }),
  1903. this.addEntry('uml aggregation', function()
  1904. {
  1905. var edge = new mxCell('1', new mxGeometry(0, 0, 0, 0), 'endArrow=open;html=1;endSize=12;startArrow=diamondThin;startSize=14;startFill=0;edgeStyle=orthogonalEdgeStyle;align=left;verticalAlign=bottom;');
  1906. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  1907. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  1908. edge.geometry.relative = true;
  1909. edge.geometry.x = -1;
  1910. edge.geometry.y = 3;
  1911. edge.edge = true;
  1912. return sb.createEdgeTemplateFromCells([edge], 160, 0, 'Aggregation 1');
  1913. }),
  1914. this.addEntry('uml composition', function()
  1915. {
  1916. var edge = new mxCell('1', new mxGeometry(0, 0, 0, 0), 'endArrow=open;html=1;endSize=12;startArrow=diamondThin;startSize=14;startFill=1;edgeStyle=orthogonalEdgeStyle;align=left;verticalAlign=bottom;');
  1917. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  1918. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  1919. edge.geometry.relative = true;
  1920. edge.geometry.x = -1;
  1921. edge.geometry.y = 3;
  1922. edge.edge = true;
  1923. return sb.createEdgeTemplateFromCells([edge], 160, 0, 'Composition 1');
  1924. }),
  1925. this.addEntry('uml relation', function()
  1926. {
  1927. var edge = new mxCell('Relation', new mxGeometry(0, 0, 0, 0), 'endArrow=open;html=1;endSize=12;startArrow=diamondThin;startSize=14;startFill=0;edgeStyle=orthogonalEdgeStyle;');
  1928. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  1929. edge.geometry.setTerminalPoint(new mxPoint(160, 0), false);
  1930. edge.geometry.relative = true;
  1931. edge.edge = true;
  1932. var cell1 = new mxCell('0..n', new mxGeometry(-1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=left;verticalAlign=top;');
  1933. cell1.geometry.relative = true;
  1934. cell1.setConnectable(false);
  1935. cell1.vertex = true;
  1936. edge.insert(cell1);
  1937. var cell2 = new mxCell('1', new mxGeometry(1, 0, 0, 0), 'edgeLabel;resizable=0;html=1;align=right;verticalAlign=top;');
  1938. cell2.geometry.relative = true;
  1939. cell2.setConnectable(false);
  1940. cell2.vertex = true;
  1941. edge.insert(cell2);
  1942. return sb.createEdgeTemplateFromCells([edge], 160, 0, 'Relation 2');
  1943. }),
  1944. this.createEdgeTemplateEntry('endArrow=open;endSize=12;dashed=1;html=1;', 160, 0, 'Use', 'Dependency', null, 'uml dependency use'),
  1945. this.createEdgeTemplateEntry('endArrow=block;endSize=16;endFill=0;html=1;', 160, 0, 'Extends', 'Generalization', null, 'uml generalization extend'),
  1946. this.createEdgeTemplateEntry('endArrow=block;startArrow=block;endFill=1;startFill=1;html=1;', 160, 0, '', 'Association 2', null, 'uml association'),
  1947. this.createEdgeTemplateEntry('endArrow=open;startArrow=circlePlus;endFill=0;startFill=0;endSize=8;html=1;', 160, 0, '', 'Inner Class', null, 'uml inner class'),
  1948. this.createEdgeTemplateEntry('endArrow=open;startArrow=cross;endFill=0;startFill=0;endSize=8;startSize=10;html=1;', 160, 0, '', 'Terminate', null, 'uml terminate'),
  1949. this.createEdgeTemplateEntry('endArrow=block;dashed=1;endFill=0;endSize=12;html=1;', 160, 0, '', 'Implementation', null, 'uml realization implementation'),
  1950. this.createEdgeTemplateEntry('endArrow=diamondThin;endFill=0;endSize=24;html=1;', 160, 0, '', 'Aggregation 2', null, 'uml aggregation'),
  1951. this.createEdgeTemplateEntry('endArrow=diamondThin;endFill=1;endSize=24;html=1;', 160, 0, '', 'Composition 2', null, 'uml composition'),
  1952. this.createEdgeTemplateEntry('endArrow=open;endFill=1;endSize=12;html=1;', 160, 0, '', 'Association 3', null, 'uml association')
  1953. ];
  1954. this.addPaletteFunctions('uml', mxResources.get('uml'), expand || false, fns);
  1955. this.setCurrentSearchEntryLibrary();
  1956. };
  1957. /**
  1958. * Adds the BPMN library to the sidebar.
  1959. */
  1960. Sidebar.prototype.addBpmnPalette = function(dir, expand)
  1961. {
  1962. // Avoids having to bind all functions to "this"
  1963. var sb = this;
  1964. this.setCurrentSearchEntryLibrary('bpmn');
  1965. var fns =
  1966. [
  1967. this.createVertexTemplateEntry('shape=ext;rounded=1;html=1;whiteSpace=wrap;', 120, 80, 'Task', 'Process', null, null, 'bpmn task process'),
  1968. this.createVertexTemplateEntry('shape=ext;rounded=1;html=1;whiteSpace=wrap;double=1;', 120, 80, 'Transaction', 'Transaction', null, null, 'bpmn transaction'),
  1969. this.createVertexTemplateEntry('shape=ext;rounded=1;html=1;whiteSpace=wrap;dashed=1;dashPattern=1 4;', 120, 80, 'Event\nSub-Process', 'Event Sub-Process', null, null, 'bpmn event subprocess sub process sub-process'),
  1970. this.createVertexTemplateEntry('shape=ext;rounded=1;html=1;whiteSpace=wrap;strokeWidth=3;', 120, 80, 'Call Activity', 'Call Activity', null, null, 'bpmn call activity'),
  1971. this.addEntry('bpmn subprocess sub process sub-process', function()
  1972. {
  1973. var cell = new mxCell('Sub-Process', new mxGeometry(0, 0, 120, 80), 'html=1;whiteSpace=wrap;rounded=1;dropTarget=0;');
  1974. cell.vertex = true;
  1975. var cell1 = new mxCell('', new mxGeometry(0.5, 1, 14, 14), 'html=1;shape=plus;outlineConnect=0;');
  1976. cell1.vertex = true;
  1977. cell1.geometry.relative = true;
  1978. cell1.geometry.offset = new mxPoint(-7, -14);
  1979. cell.insert(cell1);
  1980. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Sub-Process');
  1981. }),
  1982. this.addEntry(this.getTagsForStencil('mxgraph.bpmn', 'loop', 'subprocess sub process sub-process looped').join(' '), function()
  1983. {
  1984. var cell = new mxCell('Looped\nSub-Process', new mxGeometry(0, 0, 120, 80), 'html=1;whiteSpace=wrap;rounded=1;dropTarget=0;');
  1985. cell.vertex = true;
  1986. var cell1 = new mxCell('', new mxGeometry(0.5, 1, 14, 14), 'html=1;shape=mxgraph.bpmn.loop;outlineConnect=0;');
  1987. cell1.vertex = true;
  1988. cell1.geometry.relative = true;
  1989. cell1.geometry.offset = new mxPoint(-15, -14);
  1990. cell.insert(cell1);
  1991. var cell2 = new mxCell('', new mxGeometry(0.5, 1, 14, 14), 'html=1;shape=plus;');
  1992. cell2.vertex = true;
  1993. cell2.geometry.relative = true;
  1994. cell2.geometry.offset = new mxPoint(1, -14);
  1995. cell.insert(cell2);
  1996. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Looped Sub-Process');
  1997. }),
  1998. this.addEntry('bpmn receive task', function()
  1999. {
  2000. var cell = new mxCell('Receive', new mxGeometry(0, 0, 120, 80), 'html=1;whiteSpace=wrap;rounded=1;dropTarget=0;');
  2001. cell.vertex = true;
  2002. var cell1 = new mxCell('', new mxGeometry(0, 0, 20, 14), 'html=1;shape=message;outlineConnect=0;');
  2003. cell1.vertex = true;
  2004. cell1.geometry.relative = true;
  2005. cell1.geometry.offset = new mxPoint(7, 7);
  2006. cell.insert(cell1);
  2007. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Receive Task');
  2008. }),
  2009. this.addEntry(this.getTagsForStencil('mxgraph.bpmn', 'user_task').join(' '), function()
  2010. {
  2011. var cell = new mxCell('User', new mxGeometry(0, 0, 120, 80), 'html=1;whiteSpace=wrap;rounded=1;dropTarget=0;');
  2012. cell.vertex = true;
  2013. var cell1 = new mxCell('', new mxGeometry(0, 0, 14, 14), 'html=1;shape=mxgraph.bpmn.user_task;outlineConnect=0;');
  2014. cell1.vertex = true;
  2015. cell1.geometry.relative = true;
  2016. cell1.geometry.offset = new mxPoint(7, 7);
  2017. cell.insert(cell1);
  2018. var cell2 = new mxCell('', new mxGeometry(0.5, 1, 14, 14), 'html=1;shape=plus;outlineConnect=0;');
  2019. cell2.vertex = true;
  2020. cell2.geometry.relative = true;
  2021. cell2.geometry.offset = new mxPoint(-7, -14);
  2022. cell.insert(cell2);
  2023. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'User Task');
  2024. }),
  2025. this.addEntry(this.getTagsForStencil('mxgraph.bpmn', 'timer_start', 'attached').join(' '), function()
  2026. {
  2027. var cell = new mxCell('Process', new mxGeometry(0, 0, 120, 80), 'html=1;whiteSpace=wrap;rounded=1;dropTarget=0;');
  2028. cell.vertex = true;
  2029. var cell1 = new mxCell('', new mxGeometry(1, 1, 30, 30), 'shape=mxgraph.bpmn.timer_start;perimeter=ellipsePerimeter;html=1;verticalLabelPosition=bottom;verticalAlign=top;outlineConnect=0;');
  2030. cell1.vertex = true;
  2031. cell1.geometry.relative = true;
  2032. cell1.geometry.offset = new mxPoint(-40, -15);
  2033. cell.insert(cell1);
  2034. return sb.createVertexTemplateFromCells([cell], 120, 95, 'Attached Timer Event 1');
  2035. }),
  2036. this.addEntry(this.getTagsForStencil('mxgraph.bpmn', 'timer_start', 'attached').join(' '), function()
  2037. {
  2038. var cell = new mxCell('Process', new mxGeometry(0, 0, 120, 80), 'html=1;whiteSpace=wrap;rounded=1;dropTarget=0;');
  2039. cell.vertex = true;
  2040. var cell1 = new mxCell('', new mxGeometry(1, 0, 30, 30), 'shape=mxgraph.bpmn.timer_start;perimeter=ellipsePerimeter;html=1;labelPosition=right;align=left;outlineConnect=0;');
  2041. cell1.vertex = true;
  2042. cell1.geometry.relative = true;
  2043. cell1.geometry.offset = new mxPoint(-15, 10);
  2044. cell.insert(cell1);
  2045. return sb.createVertexTemplateFromCells([cell], 135, 80, 'Attached Timer Event 2');
  2046. }),
  2047. this.createVertexTemplateEntry('swimlane;html=1;horizontal=0;startSize=20;', 320, 240, 'Pool', 'Pool', null, null, 'bpmn pool'),
  2048. this.createVertexTemplateEntry('swimlane;html=1;horizontal=0;swimlaneLine=0;', 300, 120, 'Lane', 'Lane', null, null, 'bpmn lane'),
  2049. this.createVertexTemplateEntry('shape=hexagon;html=1;whiteSpace=wrap;perimeter=hexagonPerimeter;rounded=0;', 60, 50, '', 'Conversation', null, null, 'bpmn conversation'),
  2050. this.createVertexTemplateEntry('shape=hexagon;html=1;whiteSpace=wrap;perimeter=hexagonPerimeter;strokeWidth=4;rounded=0;', 60, 50, '', 'Call Conversation', null, null, 'bpmn call conversation'),
  2051. this.addEntry('bpmn subconversation sub conversation sub-conversation', function()
  2052. {
  2053. var cell = new mxCell('', new mxGeometry(0, 0, 60, 50), 'shape=hexagon;whiteSpace=wrap;html=1;perimeter=hexagonPerimeter;rounded=0;dropTarget=0;');
  2054. cell.vertex = true;
  2055. var cell1 = new mxCell('', new mxGeometry(0.5, 1, 14, 14), 'html=1;shape=plus;');
  2056. cell1.vertex = true;
  2057. cell1.geometry.relative = true;
  2058. cell1.geometry.offset = new mxPoint(-7, -14);
  2059. cell.insert(cell1);
  2060. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Sub-Conversation');
  2061. }),
  2062. this.addEntry('bpmn data object', function()
  2063. {
  2064. var cell = new mxCell('', new mxGeometry(0, 0, 40, 60), 'shape=note;whiteSpace=wrap;size=16;html=1;dropTarget=0;');
  2065. cell.vertex = true;
  2066. var cell1 = new mxCell('', new mxGeometry(0, 0, 14, 14), 'html=1;shape=singleArrow;arrowWidth=0.4;arrowSize=0.4;outlineConnect=0;');
  2067. cell1.vertex = true;
  2068. cell1.geometry.relative = true;
  2069. cell1.geometry.offset = new mxPoint(2, 2);
  2070. cell.insert(cell1);
  2071. var cell2 = new mxCell('', new mxGeometry(0.5, 1, 14, 14), 'html=1;whiteSpace=wrap;shape=parallelMarker;outlineConnect=0;');
  2072. cell2.vertex = true;
  2073. cell2.geometry.relative = true;
  2074. cell2.geometry.offset = new mxPoint(-7, -14);
  2075. cell.insert(cell2);
  2076. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Data Object');
  2077. }),
  2078. this.createVertexTemplateEntry('shape=datastore;whiteSpace=wrap;html=1;', 60, 60, '', 'Data Store', null, null, 'bpmn data store'),
  2079. this.createVertexTemplateEntry('shape=plus;html=1;outlineConnect=0;', 14, 14, '', 'Sub-Process Marker', null, null, 'bpmn subprocess sub process sub-process marker'),
  2080. this.createVertexTemplateEntry('shape=mxgraph.bpmn.loop;html=1;outlineConnect=0;', 14, 14, '', 'Loop Marker', null, null, 'bpmn loop marker'),
  2081. this.createVertexTemplateEntry('shape=parallelMarker;html=1;outlineConnect=0;', 14, 14, '', 'Parallel MI Marker', null, null, 'bpmn parallel mi marker'),
  2082. this.createVertexTemplateEntry('shape=parallelMarker;direction=south;html=1;outlineConnect=0;', 14, 14, '', 'Sequential MI Marker', null, null, 'bpmn sequential mi marker'),
  2083. this.createVertexTemplateEntry('shape=mxgraph.bpmn.ad_hoc;fillColor=#000000;html=1;outlineConnect=0;', 14, 14, '', 'Ad Hoc Marker', null, null, 'bpmn ad hoc marker'),
  2084. this.createVertexTemplateEntry('shape=mxgraph.bpmn.compensation;html=1;outlineConnect=0;', 14, 14, '', 'Compensation Marker', null, null, 'bpmn compensation marker'),
  2085. this.createVertexTemplateEntry('shape=message;whiteSpace=wrap;html=1;outlineConnect=0;fillColor=#000000;strokeColor=#ffffff;strokeWidth=2;', 40, 30, '', 'Send Task', null, null, 'bpmn send task'),
  2086. this.createVertexTemplateEntry('shape=message;whiteSpace=wrap;html=1;outlineConnect=0;', 40, 30, '', 'Receive Task', null, null, 'bpmn receive task'),
  2087. this.createVertexTemplateEntry('shape=mxgraph.bpmn.user_task;html=1;outlineConnect=0;', 14, 14, '', 'User Task', null, null, this.getTagsForStencil('mxgraph.bpmn', 'user_task').join(' ')),
  2088. this.createVertexTemplateEntry('shape=mxgraph.bpmn.manual_task;html=1;outlineConnect=0;', 14, 14, '', 'Manual Task', null, null, this.getTagsForStencil('mxgraph.bpmn', 'user_task').join(' ')),
  2089. this.createVertexTemplateEntry('shape=mxgraph.bpmn.business_rule_task;html=1;outlineConnect=0;', 14, 14, '', 'Business Rule Task', null, null, this.getTagsForStencil('mxgraph.bpmn', 'business_rule_task').join(' ')),
  2090. this.createVertexTemplateEntry('shape=mxgraph.bpmn.service_task;html=1;outlineConnect=0;', 14, 14, '', 'Service Task', null, null, this.getTagsForStencil('mxgraph.bpmn', 'service_task').join(' ')),
  2091. this.createVertexTemplateEntry('shape=mxgraph.bpmn.script_task;html=1;outlineConnect=0;', 14, 14, '', 'Script Task', null, null, this.getTagsForStencil('mxgraph.bpmn', 'script_task').join(' ')),
  2092. this.createVertexTemplateEntry('html=1;shape=mxgraph.flowchart.annotation_2;align=left;labelPosition=right;', 50, 100, '', 'Annotation', null, null, this.getTagsForStencil('bpmn', 'annotation_1', 'bpmn business process model ').join(' ')),
  2093. this.addDataEntry('crossfunctional cross-functional cross functional flowchart swimlane table', 400, 400, 'Cross-Functional Flowchart', '7ZhRb5swEMc/DY+bMCRt97jQpi+tVC2fwINbbMnYyD4C6aefjaHpBrTRlNCoTALJPp9t+P25O5kgTvL6XtOCPaoMRBDfBXGilULfyusEhAiikGdBfBtEUWjvIFqPjJJmNCyoBonHTIj8hB0VJXiL3dyYL+tSpsiVpM55LVSVMqrROxvci9bZMFq4JtKfzrRKGRfZA92rEjtr11tpVT1wCcYOhM5ViTKXry0G7RYb/uwWXDgDw9wCuSW2WTGOsClo6gYri8uvIGhheLN1s4KGtNSG7+AHGL+Os0JdUJm1nUJxiaDvdhZQt/EvJXHTvpTbjAq+lbadgnO1hhYSaIR6FHRjainfg8oB9d66VDxD5j0WoRcjZMC3DP8yUuMN25e5B91so5VuWMa4J+P3FJW2JtLXrOK5oNLJxZTmz/blqXhNp3mO5cpe9smS8OsyWNp5ie2TQ99ezl1joqRBTXmDAajBCgxejprHKBcNK7fvBPIz3hOSRCcQctET8olRA+8JmSopIW2j8GOD6Sji8TDxepT4C9yTE1+OEo/mQ5xcTYn8ahR5PB/k0c2UyK9HC8SbX/mnLBAnqAlD8XK+onDTE+/fw+TiQF9fTin4Nl/O0xYAEs6X9LR5n5Ae6S7xv1lr/yf+4cQ/pN75Ej/pH88/UZyQkRPzR6R+0j9Bz4f0xMm/f8adD+qzZn/bPfw5bMb++LH4Gw=='),
  2094. this.addDataEntry('container swimlane pool horizontal', 480, 380, 'Horizontal Pool 1',
  2095. 'zZRLbsIwEIZP4709TlHXhJYNSEicwCIjbNWJkWNKwumZxA6IlrRUaisWlmb+eX8LM5mXzdyrnV66Ai2TL0zm3rkQrbLJ0VoG3BRMzhgAp8fgdSQq+ijfKY9VuKcAYsG7snuMyso5G8U6tDaJ9cGUVlXkTXUoacuZIHOjjS0WqnX7blYd1OZt8KYea3PE1bCI+CAtVUMq7/o5b46uCmroSn18WFMm+XCdse5GpLq0OPqAzejxvZQun6MrMfiWUg6mCDpmZM8RENdotjqVyUFUdRS259oLSzISztto5Se0i44gcHEn3i9A/IQB3GbQpmi69DskAn4BSTaGBB4Jicj+k8nTGBP5SExg8odMyL38eH3s6kM8AQ=='),
  2096. this.addDataEntry('container swimlane pool horizontal', 480, 360, 'Horizontal Pool 2',
  2097. 'zZTBbsIwDIafJvfU6dDOlI0LSEg8QUQtEi1tUBJGy9PPbcJQWTsxaZs4VLJ//07sT1WYKKpm6eRBrW2JhokXJgpnbYhR1RRoDAOuSyYWDIDTx+B1opr1VX6QDutwTwPEhndpjhiVjbUmij60Jon+pCsja8rmKlQ05SKjcKe0KVeytcfuLh/k7u2SzR16fcbNZZDsRlrLhlTenWedPts6SJMEOseFLTkph6Fj212RbGlwdAGbyeV7KW2+RFthcC1ZTroMKjry5wiIK9R7ldrELInSR2H/2XtlSUHCOY5WfEG76ggCz+7E+w2InzCAcQapIf0fAySzESQZ/AKSfAoJPCKS9mbzf0H0NIVIPDAiyP8QEaXX97CvDZ7LDw=='),
  2098. this.createVertexTemplateEntry('swimlane;startSize=20;horizontal=0;', 320, 120, 'Lane', 'Horizontal Swimlane', null, null, 'swimlane lane pool'),
  2099. this.addDataEntry('container swimlane pool horizontal', 360, 480, 'Vertical Pool 1',
  2100. 'xZRBbsIwEEVP4709ThFrQssGJKSewCIjbNXGyDEl4fSdxKa0NJFQVTULSzP/e+T5b2EmS9esgjrqja/QMvnMZBm8j6lyTYnWMuCmYnLJADgdBi8jruhdflQBD/GRAUgD78qeMClb720S69jaLNZn46w6ULfQ0dGWS0HlThtbrVXrT91bdVS7t2u3CFibC26vi4g7aaMaUjmpNBbiKxnUQyfkjTBEbEZT9VKOtELvMIaWrpxNFXW6IWcpOddo9jqPFfMsqjoJ+8/ZGyQqMqdhZvIHs3WHBrh4kNvvIsNw5Da7OdgXAgKGCMz+gEAxRgCmINDcxZ2CyNMYETkhESj+jwi1t1+r9759ah8='),
  2101. this.addDataEntry('container swimlane pool vertical', 380, 480, 'Vertical Pool 2',
  2102. 'xZTPbsIwDMafJvf86dDOlI0LSEg8QUQtEi1pUBJGy9PPbdJ1G1TqhXGoZH/219g/RSGitM3ay5PaugoMEW9ElN65mCLblGAM4VRXRKwI5xQ/wt8nqqyv0pP0UMc5Bp4Mn9KcISk750wSQ2xNFsNFWyNrzJYqWpxyxTA8KG2qjWzduTsrRHn4GLKlh6CvsBsGYX+krWxQpaiizcc9FjDnnaCc11dXR2lyxyjsuyPy3/Lg4CM0k8v3Ut58Dc5C9C22XHQVVeoQrwkQVaCPKtuKQZQhCcdv78gSg4zzPlpxg3bTEeSUzcR7Q2bWyvz+ytmQr8NPAow/ikAxRYA/kQAr/hPByxQC8cxLsHggAkzH56uv/XrdvgA='),
  2103. this.createVertexTemplateEntry('swimlane;startSize=20;', 120, 320, 'Lane', 'Vertical Swimlane', null, null, 'swimlane lane pool'),
  2104. this.createVertexTemplateEntry('rounded=1;arcSize=10;dashed=1;strokeColor=#000000;fillColor=none;gradientColor=none;dashPattern=8 3 1 3;strokeWidth=2;',
  2105. 200, 200, '', 'Group', null, null, this.getTagsForStencil('bpmn', 'group', 'bpmn business process model ').join(' ')),
  2106. this.createEdgeTemplateEntry('endArrow=block;endFill=1;endSize=6;html=1;', 100, 0, '', 'Sequence Flow', null, 'bpmn sequence flow'),
  2107. this.createEdgeTemplateEntry('startArrow=dash;startSize=8;endArrow=block;endFill=1;endSize=6;html=1;', 100, 0, '', 'Default Flow', null, 'bpmn default flow'),
  2108. this.createEdgeTemplateEntry('startArrow=diamondThin;startFill=0;startSize=14;endArrow=block;endFill=1;endSize=6;html=1;', 100, 0, '', 'Conditional Flow', null, 'bpmn conditional flow'),
  2109. this.createEdgeTemplateEntry('startArrow=oval;startFill=0;startSize=7;endArrow=block;endFill=0;endSize=10;dashed=1;html=1;', 100, 0, '', 'Message Flow 1', null, 'bpmn message flow'),
  2110. this.addEntry('bpmn message flow', function()
  2111. {
  2112. var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), 'startArrow=oval;startFill=0;startSize=7;endArrow=block;endFill=0;endSize=10;dashed=1;html=1;');
  2113. edge.geometry.setTerminalPoint(new mxPoint(0, 0), true);
  2114. edge.geometry.setTerminalPoint(new mxPoint(100, 0), false);
  2115. edge.geometry.relative = true;
  2116. edge.edge = true;
  2117. var cell = new mxCell('', new mxGeometry(0, 0, 20, 14), 'shape=message;html=1;outlineConnect=0;');
  2118. cell.geometry.relative = true;
  2119. cell.vertex = true;
  2120. cell.geometry.offset = new mxPoint(-10, -7);
  2121. edge.insert(cell);
  2122. return sb.createEdgeTemplateFromCells([edge], 100, 0, 'Message Flow 2');
  2123. }),
  2124. this.createEdgeTemplateEntry('shape=link;html=1;', 100, 0, '', 'Link', null, 'bpmn link')
  2125. ];
  2126. this.addPaletteFunctions('bpmn', 'BPMN ' + mxResources.get('general'), false, fns);
  2127. this.setCurrentSearchEntryLibrary();
  2128. };
  2129. /**
  2130. * Creates and returns the given title element.
  2131. */
  2132. Sidebar.prototype.createTitle = function(label)
  2133. {
  2134. var elt = document.createElement('a');
  2135. elt.setAttribute('title', mxResources.get('sidebarTooltip'));
  2136. elt.className = 'geTitle';
  2137. mxUtils.write(elt, label);
  2138. return elt;
  2139. };
  2140. /**
  2141. * Creates a thumbnail for the given cells.
  2142. */
  2143. Sidebar.prototype.createThumb = function(cells, width, height, parent, title, showLabel, showTitle, realWidth, realHeight)
  2144. {
  2145. this.graph.labelsVisible = (showLabel == null || showLabel);
  2146. var fo = mxClient.NO_FO;
  2147. mxClient.NO_FO = Editor.prototype.originalNoForeignObject;
  2148. this.graph.view.scaleAndTranslate(1, 0, 0);
  2149. this.graph.addCells(cells);
  2150. var bounds = this.graph.getGraphBounds();
  2151. var s = Math.floor(Math.min((width - 2 * this.thumbBorder) / bounds.width,
  2152. (height - 2 * this.thumbBorder) / bounds.height) * 100) / 100;
  2153. this.graph.view.scaleAndTranslate(s, Math.floor((width - bounds.width * s) / 2 / s - bounds.x),
  2154. Math.floor((height - bounds.height * s) / 2 / s - bounds.y));
  2155. var node = null;
  2156. // For supporting HTML labels in IE9 standards mode the container is cloned instead
  2157. if (this.graph.dialect == mxConstants.DIALECT_SVG && !mxClient.NO_FO &&
  2158. this.graph.view.getCanvas().ownerSVGElement != null)
  2159. {
  2160. node = this.graph.view.getCanvas().ownerSVGElement.cloneNode(true);
  2161. }
  2162. // LATER: Check if deep clone can be used for quirks if container in DOM
  2163. else
  2164. {
  2165. node = this.graph.container.cloneNode(false);
  2166. node.innerHTML = this.graph.container.innerHTML;
  2167. // Workaround for clipping in older IE versions
  2168. if (mxClient.IS_QUIRKS || document.documentMode == 8)
  2169. {
  2170. node.firstChild.style.overflow = 'visible';
  2171. }
  2172. }
  2173. this.graph.getModel().clear();
  2174. mxClient.NO_FO = fo;
  2175. // Catch-all event handling
  2176. if (mxClient.IS_IE6)
  2177. {
  2178. parent.style.backgroundImage = 'url(' + this.editorUi.editor.transparentImage + ')';
  2179. }
  2180. node.style.position = 'relative';
  2181. node.style.overflow = 'hidden';
  2182. node.style.left = this.thumbBorder + 'px';
  2183. node.style.top = this.thumbBorder + 'px';
  2184. node.style.width = width + 'px';
  2185. node.style.height = height + 'px';
  2186. node.style.visibility = '';
  2187. node.style.minWidth = '';
  2188. node.style.minHeight = '';
  2189. parent.appendChild(node);
  2190. // Adds title for sidebar entries
  2191. if (this.sidebarTitles && title != null && showTitle != false)
  2192. {
  2193. var border = (mxClient.IS_QUIRKS) ? 2 * this.thumbPadding + 2: 0;
  2194. parent.style.height = (this.thumbHeight + border + this.sidebarTitleSize + 8) + 'px';
  2195. var div = document.createElement('div');
  2196. div.style.fontSize = this.sidebarTitleSize + 'px';
  2197. div.style.color = '#303030';
  2198. div.style.textAlign = 'center';
  2199. div.style.whiteSpace = 'nowrap';
  2200. if (mxClient.IS_IE)
  2201. {
  2202. div.style.height = (this.sidebarTitleSize + 12) + 'px';
  2203. }
  2204. div.style.paddingTop = '4px';
  2205. mxUtils.write(div, title);
  2206. parent.appendChild(div);
  2207. }
  2208. return bounds;
  2209. };
  2210. /**
  2211. * Creates and returns a new palette item for the given image.
  2212. */
  2213. Sidebar.prototype.createItem = function(cells, title, showLabel, showTitle, width, height, allowCellsInserted)
  2214. {
  2215. var elt = document.createElement('a');
  2216. elt.className = 'geItem';
  2217. elt.style.overflow = 'hidden';
  2218. var border = (mxClient.IS_QUIRKS) ? 8 + 2 * this.thumbPadding : 2 * this.thumbBorder;
  2219. elt.style.width = (this.thumbWidth + border) + 'px';
  2220. elt.style.height = (this.thumbHeight + border) + 'px';
  2221. elt.style.padding = this.thumbPadding + 'px';
  2222. if (mxClient.IS_IE6)
  2223. {
  2224. elt.style.border = 'none';
  2225. }
  2226. // Blocks default click action
  2227. mxEvent.addListener(elt, 'click', function(evt)
  2228. {
  2229. mxEvent.consume(evt);
  2230. });
  2231. this.createThumb(cells, this.thumbWidth, this.thumbHeight, elt, title, showLabel, showTitle, width, height);
  2232. var bounds = new mxRectangle(0, 0, width, height);
  2233. if (cells.length > 1 || cells[0].vertex)
  2234. {
  2235. var ds = this.createDragSource(elt, this.createDropHandler(cells, true, allowCellsInserted,
  2236. bounds), this.createDragPreview(width, height), cells, bounds);
  2237. this.addClickHandler(elt, ds, cells);
  2238. // Uses guides for vertices only if enabled in graph
  2239. ds.isGuidesEnabled = mxUtils.bind(this, function()
  2240. {
  2241. return this.editorUi.editor.graph.graphHandler.guidesEnabled;
  2242. });
  2243. }
  2244. else if (cells[0] != null && cells[0].edge)
  2245. {
  2246. var ds = this.createDragSource(elt, this.createDropHandler(cells, false, allowCellsInserted,
  2247. bounds), this.createDragPreview(width, height), cells, bounds);
  2248. this.addClickHandler(elt, ds, cells);
  2249. }
  2250. // Shows a tooltip with the rendered cell
  2251. if (!mxClient.IS_IOS)
  2252. {
  2253. mxEvent.addGestureListeners(elt, null, mxUtils.bind(this, function(evt)
  2254. {
  2255. if (mxEvent.isMouseEvent(evt))
  2256. {
  2257. this.showTooltip(elt, cells, bounds.width, bounds.height, title, showLabel);
  2258. }
  2259. }));
  2260. }
  2261. return elt;
  2262. };
  2263. /**
  2264. * Creates a drop handler for inserting the given cells.
  2265. */
  2266. Sidebar.prototype.updateShapes = function(source, targets)
  2267. {
  2268. var graph = this.editorUi.editor.graph;
  2269. var sourceCellStyle = graph.getCellStyle(source);
  2270. var result = [];
  2271. graph.model.beginUpdate();
  2272. try
  2273. {
  2274. var cellStyle = graph.getModel().getStyle(source);
  2275. // Lists the styles to carry over from the existing shape
  2276. var styles = ['shadow', 'dashed', 'dashPattern', 'fontFamily', 'fontSize', 'fontColor', 'align', 'startFill',
  2277. 'startSize', 'endFill', 'endSize', 'strokeColor', 'strokeWidth', 'fillColor', 'gradientColor',
  2278. 'html', 'part', 'noEdgeStyle', 'edgeStyle', 'elbow', 'childLayout', 'recursiveResize',
  2279. 'container', 'collapsible', 'connectable', 'comic', 'sketch', 'fillWeight', 'hachureGap',
  2280. 'hachureAngle', 'jiggle', 'disableMultiStroke', 'disableMultiStrokeFill',
  2281. 'fillStyle', 'curveFitting', 'simplification', 'sketchStyle'];
  2282. for (var i = 0; i < targets.length; i++)
  2283. {
  2284. var targetCell = targets[i];
  2285. if ((graph.getModel().isVertex(targetCell) == graph.getModel().isVertex(source)) ||
  2286. (graph.getModel().isEdge(targetCell) == graph.getModel().isEdge(source)))
  2287. {
  2288. var style = graph.getCurrentCellStyle(targets[i]);
  2289. graph.getModel().setStyle(targetCell, cellStyle);
  2290. // Removes all children of composite cells
  2291. if (mxUtils.getValue(style, 'composite', '0') == '1')
  2292. {
  2293. var childCount = graph.model.getChildCount(targetCell);
  2294. for (var j = childCount; j >= 0; j--)
  2295. {
  2296. graph.model.remove(graph.model.getChildAt(targetCell, j));
  2297. }
  2298. }
  2299. // Replaces the participant style in the lifeline shape with the target shape
  2300. if (style[mxConstants.STYLE_SHAPE] == 'umlLifeline' &&
  2301. sourceCellStyle[mxConstants.STYLE_SHAPE] != 'umlLifeline')
  2302. {
  2303. graph.setCellStyles(mxConstants.STYLE_SHAPE, 'umlLifeline', [targetCell]);
  2304. graph.setCellStyles('participant', sourceCellStyle[mxConstants.STYLE_SHAPE], [targetCell]);
  2305. }
  2306. for (var j = 0; j < styles.length; j++)
  2307. {
  2308. var value = style[styles[j]];
  2309. if (value != null)
  2310. {
  2311. graph.setCellStyles(styles[j], value, [targetCell]);
  2312. }
  2313. }
  2314. result.push(targetCell);
  2315. }
  2316. }
  2317. }
  2318. finally
  2319. {
  2320. graph.model.endUpdate();
  2321. }
  2322. return result;
  2323. };
  2324. /**
  2325. * Creates a drop handler for inserting the given cells.
  2326. */
  2327. Sidebar.prototype.createDropHandler = function(cells, allowSplit, allowCellsInserted, bounds)
  2328. {
  2329. allowCellsInserted = (allowCellsInserted != null) ? allowCellsInserted : true;
  2330. return mxUtils.bind(this, function(graph, evt, target, x, y, force)
  2331. {
  2332. var elt = (force) ? null : ((mxEvent.isTouchEvent(evt) || mxEvent.isPenEvent(evt)) ?
  2333. document.elementFromPoint(mxEvent.getClientX(evt), mxEvent.getClientY(evt)) :
  2334. mxEvent.getSource(evt));
  2335. while (elt != null && elt != this.container)
  2336. {
  2337. elt = elt.parentNode;
  2338. }
  2339. if (elt == null && graph.isEnabled())
  2340. {
  2341. cells = graph.getImportableCells(cells);
  2342. if (cells.length > 0)
  2343. {
  2344. graph.stopEditing();
  2345. // Holding alt while mouse is released ignores drop target
  2346. var validDropTarget = (target != null && !mxEvent.isAltDown(evt)) ?
  2347. graph.isValidDropTarget(target, cells, evt) : false;
  2348. var select = null;
  2349. if (target != null && !validDropTarget)
  2350. {
  2351. target = null;
  2352. }
  2353. if (!graph.isCellLocked(target || graph.getDefaultParent()))
  2354. {
  2355. graph.model.beginUpdate();
  2356. try
  2357. {
  2358. x = Math.round(x);
  2359. y = Math.round(y);
  2360. // Splits the target edge or inserts into target group
  2361. if (allowSplit && graph.isSplitTarget(target, cells, evt))
  2362. {
  2363. var s = graph.view.scale;
  2364. var tr = graph.view.translate;
  2365. var tx = (x + tr.x) * s;
  2366. var ty = (y + tr.y) * s;
  2367. var clones = graph.cloneCells(cells);
  2368. graph.splitEdge(target, clones, null,
  2369. x - bounds.width / 2, y - bounds.height / 2,
  2370. tx, ty);
  2371. select = clones;
  2372. }
  2373. else if (cells.length > 0)
  2374. {
  2375. select = graph.importCells(cells, x, y, target);
  2376. }
  2377. // Executes parent layout hooks for position/order
  2378. if (graph.layoutManager != null)
  2379. {
  2380. var layout = graph.layoutManager.getLayout(target);
  2381. if (layout != null)
  2382. {
  2383. var s = graph.view.scale;
  2384. var tr = graph.view.translate;
  2385. var tx = (x + tr.x) * s;
  2386. var ty = (y + tr.y) * s;
  2387. for (var i = 0; i < select.length; i++)
  2388. {
  2389. layout.moveCell(select[i], tx, ty);
  2390. }
  2391. }
  2392. }
  2393. if (allowCellsInserted && (evt == null || !mxEvent.isShiftDown(evt)))
  2394. {
  2395. graph.fireEvent(new mxEventObject('cellsInserted', 'cells', select));
  2396. }
  2397. }
  2398. catch (e)
  2399. {
  2400. this.editorUi.handleError(e);
  2401. }
  2402. finally
  2403. {
  2404. graph.model.endUpdate();
  2405. }
  2406. if (select != null && select.length > 0)
  2407. {
  2408. graph.scrollCellToVisible(select[0]);
  2409. graph.setSelectionCells(select);
  2410. }
  2411. if (graph.editAfterInsert && evt != null && mxEvent.isMouseEvent(evt) &&
  2412. select != null && select.length == 1)
  2413. {
  2414. window.setTimeout(function()
  2415. {
  2416. graph.startEditing(select[0]);
  2417. }, 0);
  2418. }
  2419. }
  2420. }
  2421. mxEvent.consume(evt);
  2422. }
  2423. });
  2424. };
  2425. /**
  2426. * Creates and returns a preview element for the given width and height.
  2427. */
  2428. Sidebar.prototype.createDragPreview = function(width, height)
  2429. {
  2430. var elt = document.createElement('div');
  2431. elt.style.border = this.dragPreviewBorder;
  2432. elt.style.width = width + 'px';
  2433. elt.style.height = height + 'px';
  2434. return elt;
  2435. };
  2436. /**
  2437. * Creates a drag source for the given element.
  2438. */
  2439. Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCellIndex, evt)
  2440. {
  2441. var geo = this.getDropAndConnectGeometry(source, targets[dropCellIndex], direction, targets);
  2442. // Targets without the new edge for selection
  2443. var tmp = [];
  2444. if (geo != null)
  2445. {
  2446. var graph = this.editorUi.editor.graph;
  2447. var editingCell = null;
  2448. graph.model.beginUpdate();
  2449. try
  2450. {
  2451. var sourceGeo = graph.getCellGeometry(source);
  2452. var geo2 = graph.getCellGeometry(targets[dropCellIndex]);
  2453. // Handles special case where target should be ignored for stack layouts
  2454. var targetParent = graph.model.getParent(source);
  2455. var validLayout = true;
  2456. // Ignores parent if it has a stack layout or if it is a table or row
  2457. if (graph.layoutManager != null)
  2458. {
  2459. var layout = graph.layoutManager.getLayout(targetParent);
  2460. // LATER: Use parent of parent if valid layout
  2461. if (layout != null && layout.constructor == mxStackLayout)
  2462. {
  2463. validLayout = false;
  2464. }
  2465. }
  2466. // Checks if another container is at the drop location
  2467. var tmp = (graph.model.isEdge(source)) ? null : graph.view.getState(targetParent);
  2468. var dx = 0;
  2469. var dy = 0;
  2470. // Offsets by parent position
  2471. if (tmp != null)
  2472. {
  2473. var offset = tmp.origin;
  2474. dx = offset.x;
  2475. dy = offset.y;
  2476. var pt = geo.getTerminalPoint(false);
  2477. if (pt != null)
  2478. {
  2479. pt.x += offset.x;
  2480. pt.y += offset.y;
  2481. }
  2482. }
  2483. var useParent = !graph.isTableRow(source) && !graph.isTableCell(source) &&
  2484. (graph.model.isEdge(source) || (sourceGeo != null &&
  2485. !sourceGeo.relative && validLayout));
  2486. var tempTarget = graph.getCellAt((geo.x + dx + graph.view.translate.x) * graph.view.scale,
  2487. (geo.y + dy + graph.view.translate.y) * graph.view.scale, null, null, null, function(state, x, y)
  2488. {
  2489. return !graph.isContainer(state.cell);
  2490. });
  2491. if (tempTarget != null && tempTarget != targetParent)
  2492. {
  2493. tmp = graph.view.getState(tempTarget);
  2494. // Offsets by new parent position
  2495. if (tmp != null)
  2496. {
  2497. var offset = tmp.origin;
  2498. targetParent = tempTarget;
  2499. useParent = true;
  2500. if (!graph.model.isEdge(source))
  2501. {
  2502. geo.x -= offset.x - dx;
  2503. geo.y -= offset.y - dy;
  2504. }
  2505. }
  2506. }
  2507. else if (!validLayout || graph.isTableRow(source) || graph.isTableCell(source))
  2508. {
  2509. geo.x += dx;
  2510. geo.y += dy;
  2511. }
  2512. dx = geo2.x;
  2513. dy = geo2.y;
  2514. // Ignores geometry of edges
  2515. if (graph.model.isEdge(targets[dropCellIndex]))
  2516. {
  2517. dx = 0;
  2518. dy = 0;
  2519. }
  2520. targets = graph.importCells(targets, (geo.x - (useParent ? dx : 0)),
  2521. (geo.y - (useParent ? dy : 0)), (useParent) ? targetParent : null);
  2522. tmp = targets;
  2523. if (graph.model.isEdge(source))
  2524. {
  2525. // Adds new terminal to edge
  2526. // LATER: Push new terminal out radially from edge start point
  2527. graph.model.setTerminal(source, targets[dropCellIndex],
  2528. direction == mxConstants.DIRECTION_NORTH);
  2529. }
  2530. else if (graph.model.isEdge(targets[dropCellIndex]))
  2531. {
  2532. // Adds new outgoing connection to vertex and clears points
  2533. graph.model.setTerminal(targets[dropCellIndex], source, true);
  2534. var geo3 = graph.getCellGeometry(targets[dropCellIndex]);
  2535. geo3.points = null;
  2536. if (geo3.getTerminalPoint(false) != null)
  2537. {
  2538. geo3.setTerminalPoint(geo.getTerminalPoint(false), false);
  2539. }
  2540. else if (useParent && graph.model.isVertex(targetParent))
  2541. {
  2542. // Adds parent offset to other nodes
  2543. var tmpState = graph.view.getState(targetParent);
  2544. var offset = (tmpState.cell != graph.view.currentRoot) ?
  2545. tmpState.origin : new mxPoint(0, 0);
  2546. graph.cellsMoved(targets, offset.x, offset.y, null, null, true);
  2547. }
  2548. }
  2549. else
  2550. {
  2551. geo2 = graph.getCellGeometry(targets[dropCellIndex]);
  2552. dx = geo.x - Math.round(geo2.x);
  2553. dy = geo.y - Math.round(geo2.y);
  2554. geo.x = Math.round(geo2.x);
  2555. geo.y = Math.round(geo2.y);
  2556. graph.model.setGeometry(targets[dropCellIndex], geo);
  2557. graph.cellsMoved(targets, dx, dy, null, null, true);
  2558. tmp = targets.slice();
  2559. editingCell = (tmp.length == 1) ? tmp[0] : null;
  2560. targets.push(graph.insertEdge(null, null, '', source, targets[dropCellIndex],
  2561. graph.createCurrentEdgeStyle()));
  2562. }
  2563. if (evt == null || !mxEvent.isShiftDown(evt))
  2564. {
  2565. graph.fireEvent(new mxEventObject('cellsInserted', 'cells', targets));
  2566. }
  2567. }
  2568. catch (e)
  2569. {
  2570. this.editorUi.handleError(e);
  2571. }
  2572. finally
  2573. {
  2574. graph.model.endUpdate();
  2575. }
  2576. if (graph.editAfterInsert && evt != null && mxEvent.isMouseEvent(evt) &&
  2577. editingCell != null)
  2578. {
  2579. window.setTimeout(function()
  2580. {
  2581. graph.startEditing(editingCell);
  2582. }, 0);
  2583. }
  2584. }
  2585. return tmp;
  2586. };
  2587. /**
  2588. * Creates a drag source for the given element.
  2589. */
  2590. Sidebar.prototype.getDropAndConnectGeometry = function(source, target, direction, targets)
  2591. {
  2592. var graph = this.editorUi.editor.graph;
  2593. var view = graph.view;
  2594. var keepSize = targets.length > 1;
  2595. var geo = graph.getCellGeometry(source);
  2596. var geo2 = graph.getCellGeometry(target);
  2597. if (geo != null && geo2 != null)
  2598. {
  2599. geo2 = geo2.clone();
  2600. if (graph.model.isEdge(source))
  2601. {
  2602. var state = graph.view.getState(source);
  2603. var pts = state.absolutePoints;
  2604. var p0 = pts[0];
  2605. var pe = pts[pts.length - 1];
  2606. if (direction == mxConstants.DIRECTION_NORTH)
  2607. {
  2608. geo2.x = p0.x / view.scale - view.translate.x - geo2.width / 2;
  2609. geo2.y = p0.y / view.scale - view.translate.y - geo2.height / 2;
  2610. }
  2611. else
  2612. {
  2613. geo2.x = pe.x / view.scale - view.translate.x - geo2.width / 2;
  2614. geo2.y = pe.y / view.scale - view.translate.y - geo2.height / 2;
  2615. }
  2616. }
  2617. else
  2618. {
  2619. if (geo.relative)
  2620. {
  2621. var state = graph.view.getState(source);
  2622. geo = geo.clone();
  2623. geo.x = (state.x - view.translate.x) / view.scale;
  2624. geo.y = (state.y - view.translate.y) / view.scale;
  2625. }
  2626. var length = graph.defaultEdgeLength;
  2627. // Maintains edge length
  2628. if (graph.model.isEdge(target) && geo2.getTerminalPoint(true) != null &&
  2629. geo2.getTerminalPoint(false) != null)
  2630. {
  2631. var p0 = geo2.getTerminalPoint(true);
  2632. var pe = geo2.getTerminalPoint(false);
  2633. var dx = pe.x - p0.x;
  2634. var dy = pe.y - p0.y;
  2635. length = Math.sqrt(dx * dx + dy * dy);
  2636. geo2.x = geo.getCenterX();
  2637. geo2.y = geo.getCenterY();
  2638. geo2.width = 1;
  2639. geo2.height = 1;
  2640. if (direction == mxConstants.DIRECTION_NORTH)
  2641. {
  2642. geo2.height = length
  2643. geo2.y = geo.y - length;
  2644. geo2.setTerminalPoint(new mxPoint(geo2.x, geo2.y), false);
  2645. }
  2646. else if (direction == mxConstants.DIRECTION_EAST)
  2647. {
  2648. geo2.width = length
  2649. geo2.x = geo.x + geo.width;
  2650. geo2.setTerminalPoint(new mxPoint(geo2.x + geo2.width, geo2.y), false);
  2651. }
  2652. else if (direction == mxConstants.DIRECTION_SOUTH)
  2653. {
  2654. geo2.height = length
  2655. geo2.y = geo.y + geo.height;
  2656. geo2.setTerminalPoint(new mxPoint(geo2.x, geo2.y + geo2.height), false);
  2657. }
  2658. else if (direction == mxConstants.DIRECTION_WEST)
  2659. {
  2660. geo2.width = length
  2661. geo2.x = geo.x - length;
  2662. geo2.setTerminalPoint(new mxPoint(geo2.x, geo2.y), false);
  2663. }
  2664. }
  2665. else
  2666. {
  2667. // Try match size or ignore if width or height < 45 which
  2668. // is considered special enough to be ignored here
  2669. if (!keepSize && geo2.width > 45 && geo2.height > 45 &&
  2670. geo.width > 45 && geo.height > 45)
  2671. {
  2672. geo2.width = geo2.width * (geo.height / geo2.height);
  2673. geo2.height = geo.height;
  2674. }
  2675. geo2.x = geo.x + geo.width / 2 - geo2.width / 2;
  2676. geo2.y = geo.y + geo.height / 2 - geo2.height / 2;
  2677. if (direction == mxConstants.DIRECTION_NORTH)
  2678. {
  2679. geo2.y = geo2.y - geo.height / 2 - geo2.height / 2 - length;
  2680. }
  2681. else if (direction == mxConstants.DIRECTION_EAST)
  2682. {
  2683. geo2.x = geo2.x + geo.width / 2 + geo2.width / 2 + length;
  2684. }
  2685. else if (direction == mxConstants.DIRECTION_SOUTH)
  2686. {
  2687. geo2.y = geo2.y + geo.height / 2 + geo2.height / 2 + length;
  2688. }
  2689. else if (direction == mxConstants.DIRECTION_WEST)
  2690. {
  2691. geo2.x = geo2.x - geo.width / 2 - geo2.width / 2 - length;
  2692. }
  2693. // Adds offset to match cells without connecting edge
  2694. if (graph.model.isEdge(target) && geo2.getTerminalPoint(true) != null &&
  2695. target.getTerminal(false) != null)
  2696. {
  2697. var targetGeo = graph.getCellGeometry(target.getTerminal(false));
  2698. if (targetGeo != null)
  2699. {
  2700. if (direction == mxConstants.DIRECTION_NORTH)
  2701. {
  2702. geo2.x -= targetGeo.getCenterX();
  2703. geo2.y -= targetGeo.getCenterY() + targetGeo.height / 2;
  2704. }
  2705. else if (direction == mxConstants.DIRECTION_EAST)
  2706. {
  2707. geo2.x -= targetGeo.getCenterX() - targetGeo.width / 2;
  2708. geo2.y -= targetGeo.getCenterY();
  2709. }
  2710. else if (direction == mxConstants.DIRECTION_SOUTH)
  2711. {
  2712. geo2.x -= targetGeo.getCenterX();
  2713. geo2.y -= targetGeo.getCenterY() - targetGeo.height / 2;
  2714. }
  2715. else if (direction == mxConstants.DIRECTION_WEST)
  2716. {
  2717. geo2.x -= targetGeo.getCenterX() + targetGeo.width / 2;
  2718. geo2.y -= targetGeo.getCenterY();
  2719. }
  2720. }
  2721. }
  2722. }
  2723. }
  2724. }
  2725. return geo2;
  2726. };
  2727. /**
  2728. * Limits drop style to non-transparent source shapes.
  2729. */
  2730. Sidebar.prototype.isDropStyleEnabled = function(cells, firstVertex)
  2731. {
  2732. var result = true;
  2733. if (firstVertex != null && cells.length == 1)
  2734. {
  2735. var vstyle = this.graph.getCellStyle(cells[firstVertex]);
  2736. if (vstyle != null)
  2737. {
  2738. result = mxUtils.getValue(vstyle, mxConstants.STYLE_STROKECOLOR, mxConstants.NONE) != mxConstants.NONE ||
  2739. mxUtils.getValue(vstyle, mxConstants.STYLE_FILLCOLOR, mxConstants.NONE) != mxConstants.NONE;
  2740. }
  2741. }
  2742. return result;
  2743. };
  2744. /**
  2745. * Ignores swimlanes as drop style targets.
  2746. */
  2747. Sidebar.prototype.isDropStyleTargetIgnored = function(state)
  2748. {
  2749. return this.graph.isSwimlane(state.cell) || this.graph.isTableCell(state.cell) ||
  2750. this.graph.isTableRow(state.cell) || this.graph.isTable(state.cell);
  2751. };
  2752. /**
  2753. * Creates a drag source for the given element.
  2754. */
  2755. Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells, bounds)
  2756. {
  2757. // Checks if the cells contain any vertices
  2758. var ui = this.editorUi;
  2759. var graph = ui.editor.graph;
  2760. var freeSourceEdge = null;
  2761. var firstVertex = null;
  2762. var sidebar = this;
  2763. for (var i = 0; i < cells.length; i++)
  2764. {
  2765. if (firstVertex == null && graph.model.isVertex(cells[i]))
  2766. {
  2767. firstVertex = i;
  2768. }
  2769. else if (freeSourceEdge == null && graph.model.isEdge(cells[i]) &&
  2770. graph.model.getTerminal(cells[i], true) == null)
  2771. {
  2772. freeSourceEdge = i;
  2773. }
  2774. if (firstVertex != null && freeSourceEdge != null)
  2775. {
  2776. break;
  2777. }
  2778. }
  2779. var dropStyleEnabled = this.isDropStyleEnabled(cells, firstVertex);
  2780. var dragSource = mxUtils.makeDraggable(elt, graph, mxUtils.bind(this, function(graph, evt, target, x, y)
  2781. {
  2782. if (this.updateThread != null)
  2783. {
  2784. window.clearTimeout(this.updateThread);
  2785. }
  2786. if (cells != null && currentStyleTarget != null && activeArrow == styleTarget)
  2787. {
  2788. var tmp = graph.isCellSelected(currentStyleTarget.cell) ? graph.getSelectionCells() : [currentStyleTarget.cell];
  2789. var updatedCells = this.updateShapes((graph.model.isEdge(currentStyleTarget.cell)) ? cells[0] : cells[firstVertex], tmp);
  2790. graph.setSelectionCells(updatedCells);
  2791. }
  2792. else if (cells != null && activeArrow != null && currentTargetState != null && activeArrow != styleTarget)
  2793. {
  2794. var index = (graph.model.isEdge(currentTargetState.cell) || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
  2795. graph.setSelectionCells(this.dropAndConnect(currentTargetState.cell, cells, direction, index, evt));
  2796. }
  2797. else
  2798. {
  2799. dropHandler.apply(this, arguments);
  2800. }
  2801. if (this.editorUi.hoverIcons != null)
  2802. {
  2803. this.editorUi.hoverIcons.update(graph.view.getState(graph.getSelectionCell()));
  2804. }
  2805. }), preview, 0, 0, graph.autoscroll, true, true);
  2806. // Stops dragging if cancel is pressed
  2807. graph.addListener(mxEvent.ESCAPE, function(sender, evt)
  2808. {
  2809. if (dragSource.isActive())
  2810. {
  2811. dragSource.reset();
  2812. }
  2813. });
  2814. // Overrides mouseDown to ignore popup triggers
  2815. var mouseDown = dragSource.mouseDown;
  2816. dragSource.mouseDown = function(evt)
  2817. {
  2818. if (!mxEvent.isPopupTrigger(evt) && !mxEvent.isMultiTouchEvent(evt))
  2819. {
  2820. graph.stopEditing();
  2821. mouseDown.apply(this, arguments);
  2822. }
  2823. };
  2824. // Workaround for event redirection via image tag in quirks and IE8
  2825. function createArrow(img, tooltip)
  2826. {
  2827. var arrow = null;
  2828. if (mxClient.IS_IE && !mxClient.IS_SVG)
  2829. {
  2830. // Workaround for PNG images in IE6
  2831. if (mxClient.IS_IE6 && document.compatMode != 'CSS1Compat')
  2832. {
  2833. arrow = document.createElement(mxClient.VML_PREFIX + ':image');
  2834. arrow.setAttribute('src', img.src);
  2835. arrow.style.borderStyle = 'none';
  2836. }
  2837. else
  2838. {
  2839. arrow = document.createElement('div');
  2840. arrow.style.backgroundImage = 'url(' + img.src + ')';
  2841. arrow.style.backgroundPosition = 'center';
  2842. arrow.style.backgroundRepeat = 'no-repeat';
  2843. }
  2844. arrow.style.width = (img.width + 4) + 'px';
  2845. arrow.style.height = (img.height + 4) + 'px';
  2846. arrow.style.display = (mxClient.IS_QUIRKS) ? 'inline' : 'inline-block';
  2847. }
  2848. else
  2849. {
  2850. arrow = mxUtils.createImage(img.src);
  2851. arrow.style.width = img.width + 'px';
  2852. arrow.style.height = img.height + 'px';
  2853. }
  2854. if (tooltip != null)
  2855. {
  2856. arrow.setAttribute('title', tooltip);
  2857. }
  2858. mxUtils.setOpacity(arrow, (img == this.refreshTarget) ? 30 : 20);
  2859. arrow.style.position = 'absolute';
  2860. arrow.style.cursor = 'crosshair';
  2861. return arrow;
  2862. };
  2863. var currentTargetState = null;
  2864. var currentStateHandle = null;
  2865. var currentStyleTarget = null;
  2866. var activeTarget = false;
  2867. var arrowUp = createArrow(this.triangleUp, mxResources.get('connect'));
  2868. var arrowRight = createArrow(this.triangleRight, mxResources.get('connect'));
  2869. var arrowDown = createArrow(this.triangleDown, mxResources.get('connect'));
  2870. var arrowLeft = createArrow(this.triangleLeft, mxResources.get('connect'));
  2871. var styleTarget = createArrow(this.refreshTarget, mxResources.get('replace'));
  2872. // Workaround for actual parentNode not being updated in old IE
  2873. var styleTargetParent = null;
  2874. var roundSource = createArrow(this.roundDrop);
  2875. var roundTarget = createArrow(this.roundDrop);
  2876. var direction = mxConstants.DIRECTION_NORTH;
  2877. var activeArrow = null;
  2878. function checkArrow(x, y, bounds, arrow)
  2879. {
  2880. if (arrow.parentNode != null)
  2881. {
  2882. if (mxUtils.contains(bounds, x, y))
  2883. {
  2884. mxUtils.setOpacity(arrow, 100);
  2885. activeArrow = arrow;
  2886. }
  2887. else
  2888. {
  2889. mxUtils.setOpacity(arrow, (arrow == styleTarget) ? 30 : 20);
  2890. }
  2891. }
  2892. return bounds;
  2893. };
  2894. // Hides guides and preview if target is active
  2895. var dsCreatePreviewElement = dragSource.createPreviewElement;
  2896. // Stores initial size of preview element
  2897. dragSource.createPreviewElement = function(graph)
  2898. {
  2899. var elt = dsCreatePreviewElement.apply(this, arguments);
  2900. // Pass-through events required to tooltip on replace shape
  2901. if (mxClient.IS_SVG)
  2902. {
  2903. elt.style.pointerEvents = 'none';
  2904. }
  2905. this.previewElementWidth = elt.style.width;
  2906. this.previewElementHeight = elt.style.height;
  2907. return elt;
  2908. };
  2909. // Shows/hides hover icons
  2910. var dragEnter = dragSource.dragEnter;
  2911. dragSource.dragEnter = function(graph, evt)
  2912. {
  2913. if (ui.hoverIcons != null)
  2914. {
  2915. ui.hoverIcons.setDisplay('none');
  2916. }
  2917. dragEnter.apply(this, arguments);
  2918. };
  2919. var dragExit = dragSource.dragExit;
  2920. dragSource.dragExit = function(graph, evt)
  2921. {
  2922. if (ui.hoverIcons != null)
  2923. {
  2924. ui.hoverIcons.setDisplay('');
  2925. }
  2926. dragExit.apply(this, arguments);
  2927. };
  2928. dragSource.dragOver = function(graph, evt)
  2929. {
  2930. mxDragSource.prototype.dragOver.apply(this, arguments);
  2931. if (this.currentGuide != null && activeArrow != null)
  2932. {
  2933. this.currentGuide.hide();
  2934. }
  2935. if (this.previewElement != null)
  2936. {
  2937. var view = graph.view;
  2938. if (currentStyleTarget != null && activeArrow == styleTarget)
  2939. {
  2940. this.previewElement.style.display = (graph.model.isEdge(currentStyleTarget.cell)) ? 'none' : '';
  2941. this.previewElement.style.left = currentStyleTarget.x + 'px';
  2942. this.previewElement.style.top = currentStyleTarget.y + 'px';
  2943. this.previewElement.style.width = currentStyleTarget.width + 'px';
  2944. this.previewElement.style.height = currentStyleTarget.height + 'px';
  2945. }
  2946. else if (currentTargetState != null && activeArrow != null)
  2947. {
  2948. if (dragSource.currentHighlight != null && dragSource.currentHighlight.state != null)
  2949. {
  2950. dragSource.currentHighlight.hide();
  2951. }
  2952. var index = (graph.model.isEdge(currentTargetState.cell) || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
  2953. var geo = sidebar.getDropAndConnectGeometry(currentTargetState.cell, cells[index], direction, cells);
  2954. var geo2 = (!graph.model.isEdge(currentTargetState.cell)) ? graph.getCellGeometry(currentTargetState.cell) : null;
  2955. var geo3 = graph.getCellGeometry(cells[index]);
  2956. var parent = graph.model.getParent(currentTargetState.cell);
  2957. var dx = view.translate.x * view.scale;
  2958. var dy = view.translate.y * view.scale;
  2959. if (geo2 != null && !geo2.relative && graph.model.isVertex(parent) && parent != view.currentRoot)
  2960. {
  2961. var pState = view.getState(parent);
  2962. dx = pState.x;
  2963. dy = pState.y;
  2964. }
  2965. var dx2 = geo3.x;
  2966. var dy2 = geo3.y;
  2967. // Ignores geometry of edges
  2968. if (graph.model.isEdge(cells[index]))
  2969. {
  2970. dx2 = 0;
  2971. dy2 = 0;
  2972. }
  2973. // Shows preview at drop location
  2974. this.previewElement.style.left = ((geo.x - dx2) * view.scale + dx) + 'px';
  2975. this.previewElement.style.top = ((geo.y - dy2) * view.scale + dy) + 'px';
  2976. if (cells.length == 1)
  2977. {
  2978. this.previewElement.style.width = (geo.width * view.scale) + 'px';
  2979. this.previewElement.style.height = (geo.height * view.scale) + 'px';
  2980. }
  2981. this.previewElement.style.display = '';
  2982. }
  2983. else if (dragSource.currentHighlight.state != null &&
  2984. graph.model.isEdge(dragSource.currentHighlight.state.cell))
  2985. {
  2986. // Centers drop cells when splitting edges
  2987. this.previewElement.style.left = Math.round(parseInt(this.previewElement.style.left) -
  2988. bounds.width * view.scale / 2) + 'px';
  2989. this.previewElement.style.top = Math.round(parseInt(this.previewElement.style.top) -
  2990. bounds.height * view.scale / 2) + 'px';
  2991. }
  2992. else
  2993. {
  2994. this.previewElement.style.width = this.previewElementWidth;
  2995. this.previewElement.style.height = this.previewElementHeight;
  2996. this.previewElement.style.display = '';
  2997. }
  2998. }
  2999. };
  3000. var startTime = new Date().getTime();
  3001. var timeOnTarget = 0;
  3002. var prev = null;
  3003. // Gets source cell style to compare shape below
  3004. var sourceCellStyle = this.editorUi.editor.graph.getCellStyle(cells[0]);
  3005. // Allows drop into cell only if target is a valid root
  3006. dragSource.getDropTarget = mxUtils.bind(this, function(graph, x, y, evt)
  3007. {
  3008. // Alt means no targets at all
  3009. // LATER: Show preview where result will go
  3010. var cell = (!mxEvent.isAltDown(evt) && cells != null) ?
  3011. graph.getCellAt(x, y, null, null, null, function(state, x, y)
  3012. {
  3013. return graph.isContainer(state.cell);
  3014. }) : null;
  3015. // Uses connectable parent vertex if one exists
  3016. if (cell != null && !this.graph.isCellConnectable(cell) &&
  3017. !this.graph.model.isEdge(cell))
  3018. {
  3019. var parent = this.graph.getModel().getParent(cell);
  3020. if (this.graph.getModel().isVertex(parent) &&
  3021. this.graph.isCellConnectable(parent))
  3022. {
  3023. cell = parent;
  3024. }
  3025. }
  3026. // Ignores locked cells
  3027. if (graph.isCellLocked(cell))
  3028. {
  3029. cell = null;
  3030. }
  3031. var state = graph.view.getState(cell);
  3032. activeArrow = null;
  3033. var bbox = null;
  3034. // Time on target
  3035. if (prev != state)
  3036. {
  3037. startTime = new Date().getTime();
  3038. timeOnTarget = 0;
  3039. prev = state;
  3040. if (this.updateThread != null)
  3041. {
  3042. window.clearTimeout(this.updateThread);
  3043. }
  3044. if (state != null)
  3045. {
  3046. this.updateThread = window.setTimeout(function()
  3047. {
  3048. if (activeArrow == null)
  3049. {
  3050. prev = state;
  3051. dragSource.getDropTarget(graph, x, y, evt);
  3052. }
  3053. }, this.dropTargetDelay + 10);
  3054. }
  3055. }
  3056. else
  3057. {
  3058. timeOnTarget = new Date().getTime() - startTime;
  3059. }
  3060. // Shift means disabled, delayed on cells with children, shows after this.dropTargetDelay, hides after 2500ms
  3061. if (dropStyleEnabled && (timeOnTarget < 2500) && state != null && !mxEvent.isShiftDown(evt) &&
  3062. // If shape is equal or target has no stroke, fill and gradient then use longer delay except for images
  3063. (((mxUtils.getValue(state.style, mxConstants.STYLE_SHAPE) != mxUtils.getValue(sourceCellStyle, mxConstants.STYLE_SHAPE) &&
  3064. (mxUtils.getValue(state.style, mxConstants.STYLE_STROKECOLOR, mxConstants.NONE) != mxConstants.NONE ||
  3065. mxUtils.getValue(state.style, mxConstants.STYLE_FILLCOLOR, mxConstants.NONE) != mxConstants.NONE ||
  3066. mxUtils.getValue(state.style, mxConstants.STYLE_GRADIENTCOLOR, mxConstants.NONE) != mxConstants.NONE)) ||
  3067. mxUtils.getValue(sourceCellStyle, mxConstants.STYLE_SHAPE) == 'image') ||
  3068. timeOnTarget > 1500 || graph.model.isEdge(state.cell)) && (timeOnTarget > this.dropTargetDelay) &&
  3069. !this.isDropStyleTargetIgnored(state) && ((graph.model.isVertex(state.cell) && firstVertex != null) ||
  3070. (graph.model.isEdge(state.cell) && graph.model.isEdge(cells[0]))))
  3071. {
  3072. currentStyleTarget = state;
  3073. var tmp = (graph.model.isEdge(state.cell)) ? graph.view.getPoint(state) :
  3074. new mxPoint(state.getCenterX(), state.getCenterY());
  3075. tmp = new mxRectangle(tmp.x - this.refreshTarget.width / 2, tmp.y - this.refreshTarget.height / 2,
  3076. this.refreshTarget.width, this.refreshTarget.height);
  3077. styleTarget.style.left = Math.floor(tmp.x) + 'px';
  3078. styleTarget.style.top = Math.floor(tmp.y) + 'px';
  3079. if (styleTargetParent == null)
  3080. {
  3081. graph.container.appendChild(styleTarget);
  3082. styleTargetParent = styleTarget.parentNode;
  3083. }
  3084. checkArrow(x, y, tmp, styleTarget);
  3085. }
  3086. // Does not reset on ignored edges
  3087. else if (currentStyleTarget == null || !mxUtils.contains(currentStyleTarget, x, y) ||
  3088. (timeOnTarget > 1500 && !mxEvent.isShiftDown(evt)))
  3089. {
  3090. currentStyleTarget = null;
  3091. if (styleTargetParent != null)
  3092. {
  3093. styleTarget.parentNode.removeChild(styleTarget);
  3094. styleTargetParent = null;
  3095. }
  3096. }
  3097. else if (currentStyleTarget != null && styleTargetParent != null)
  3098. {
  3099. // Sets active Arrow as side effect
  3100. var tmp = (graph.model.isEdge(currentStyleTarget.cell)) ? graph.view.getPoint(currentStyleTarget) : new mxPoint(currentStyleTarget.getCenterX(), currentStyleTarget.getCenterY());
  3101. tmp = new mxRectangle(tmp.x - this.refreshTarget.width / 2, tmp.y - this.refreshTarget.height / 2,
  3102. this.refreshTarget.width, this.refreshTarget.height);
  3103. checkArrow(x, y, tmp, styleTarget);
  3104. }
  3105. // Checks if inside bounds
  3106. if (activeTarget && currentTargetState != null && !mxEvent.isAltDown(evt) && activeArrow == null)
  3107. {
  3108. // LATER: Use hit-detection for edges
  3109. bbox = mxRectangle.fromRectangle(currentTargetState);
  3110. if (graph.model.isEdge(currentTargetState.cell))
  3111. {
  3112. var pts = currentTargetState.absolutePoints;
  3113. if (roundSource.parentNode != null)
  3114. {
  3115. var p0 = pts[0];
  3116. bbox.add(checkArrow(x, y, new mxRectangle(p0.x - this.roundDrop.width / 2,
  3117. p0.y - this.roundDrop.height / 2, this.roundDrop.width, this.roundDrop.height), roundSource));
  3118. }
  3119. if (roundTarget.parentNode != null)
  3120. {
  3121. var pe = pts[pts.length - 1];
  3122. bbox.add(checkArrow(x, y, new mxRectangle(pe.x - this.roundDrop.width / 2,
  3123. pe.y - this.roundDrop.height / 2,
  3124. this.roundDrop.width, this.roundDrop.height), roundTarget));
  3125. }
  3126. }
  3127. else
  3128. {
  3129. var bds = mxRectangle.fromRectangle(currentTargetState);
  3130. // Uses outer bounding box to take rotation into account
  3131. if (currentTargetState.shape != null && currentTargetState.shape.boundingBox != null)
  3132. {
  3133. bds = mxRectangle.fromRectangle(currentTargetState.shape.boundingBox);
  3134. }
  3135. bds.grow(this.graph.tolerance);
  3136. bds.grow(HoverIcons.prototype.arrowSpacing);
  3137. var handler = this.graph.selectionCellsHandler.getHandler(currentTargetState.cell);
  3138. if (handler != null)
  3139. {
  3140. bds.x -= handler.horizontalOffset / 2;
  3141. bds.y -= handler.verticalOffset / 2;
  3142. bds.width += handler.horizontalOffset;
  3143. bds.height += handler.verticalOffset;
  3144. // Adds bounding box of rotation handle to avoid overlap
  3145. if (handler.rotationShape != null && handler.rotationShape.node != null &&
  3146. handler.rotationShape.node.style.visibility != 'hidden' &&
  3147. handler.rotationShape.node.style.display != 'none' &&
  3148. handler.rotationShape.boundingBox != null)
  3149. {
  3150. bds.add(handler.rotationShape.boundingBox);
  3151. }
  3152. }
  3153. bbox.add(checkArrow(x, y, new mxRectangle(currentTargetState.getCenterX() - this.triangleUp.width / 2,
  3154. bds.y - this.triangleUp.height, this.triangleUp.width, this.triangleUp.height), arrowUp));
  3155. bbox.add(checkArrow(x, y, new mxRectangle(bds.x + bds.width,
  3156. currentTargetState.getCenterY() - this.triangleRight.height / 2,
  3157. this.triangleRight.width, this.triangleRight.height), arrowRight));
  3158. bbox.add(checkArrow(x, y, new mxRectangle(currentTargetState.getCenterX() - this.triangleDown.width / 2,
  3159. bds.y + bds.height, this.triangleDown.width, this.triangleDown.height), arrowDown));
  3160. bbox.add(checkArrow(x, y, new mxRectangle(bds.x - this.triangleLeft.width,
  3161. currentTargetState.getCenterY() - this.triangleLeft.height / 2,
  3162. this.triangleLeft.width, this.triangleLeft.height), arrowLeft));
  3163. }
  3164. // Adds tolerance
  3165. if (bbox != null)
  3166. {
  3167. bbox.grow(10);
  3168. }
  3169. }
  3170. direction = mxConstants.DIRECTION_NORTH;
  3171. if (activeArrow == arrowRight)
  3172. {
  3173. direction = mxConstants.DIRECTION_EAST;
  3174. }
  3175. else if (activeArrow == arrowDown || activeArrow == roundTarget)
  3176. {
  3177. direction = mxConstants.DIRECTION_SOUTH;
  3178. }
  3179. else if (activeArrow == arrowLeft)
  3180. {
  3181. direction = mxConstants.DIRECTION_WEST;
  3182. }
  3183. if (currentStyleTarget != null && activeArrow == styleTarget)
  3184. {
  3185. state = currentStyleTarget;
  3186. }
  3187. var validTarget = (firstVertex == null || graph.isCellConnectable(cells[firstVertex])) &&
  3188. ((graph.model.isEdge(cell) && firstVertex != null) ||
  3189. (graph.model.isVertex(cell) && graph.isCellConnectable(cell)));
  3190. // Drop arrows shown after this.dropTargetDelay, hidden after 5 secs, switches arrows after 500ms
  3191. if ((currentTargetState != null && timeOnTarget >= 5000) ||
  3192. (currentTargetState != state &&
  3193. (bbox == null || !mxUtils.contains(bbox, x, y) ||
  3194. (timeOnTarget > 500 && activeArrow == null && validTarget))))
  3195. {
  3196. activeTarget = false;
  3197. currentTargetState = ((timeOnTarget < 5000 && timeOnTarget > this.dropTargetDelay) ||
  3198. graph.model.isEdge(cell)) ? state : null;
  3199. if (currentTargetState != null && validTarget)
  3200. {
  3201. var elts = [roundSource, roundTarget, arrowUp, arrowRight, arrowDown, arrowLeft];
  3202. for (var i = 0; i < elts.length; i++)
  3203. {
  3204. if (elts[i].parentNode != null)
  3205. {
  3206. elts[i].parentNode.removeChild(elts[i]);
  3207. }
  3208. }
  3209. if (graph.model.isEdge(cell))
  3210. {
  3211. var pts = state.absolutePoints;
  3212. if (pts != null)
  3213. {
  3214. var p0 = pts[0];
  3215. var pe = pts[pts.length - 1];
  3216. var tol = graph.tolerance;
  3217. var box = new mxRectangle(x - tol, y - tol, 2 * tol, 2 * tol);
  3218. roundSource.style.left = Math.floor(p0.x - this.roundDrop.width / 2) + 'px';
  3219. roundSource.style.top = Math.floor(p0.y - this.roundDrop.height / 2) + 'px';
  3220. roundTarget.style.left = Math.floor(pe.x - this.roundDrop.width / 2) + 'px';
  3221. roundTarget.style.top = Math.floor(pe.y - this.roundDrop.height / 2) + 'px';
  3222. if (graph.model.getTerminal(cell, true) == null)
  3223. {
  3224. graph.container.appendChild(roundSource);
  3225. }
  3226. if (graph.model.getTerminal(cell, false) == null)
  3227. {
  3228. graph.container.appendChild(roundTarget);
  3229. }
  3230. }
  3231. }
  3232. else
  3233. {
  3234. var bds = mxRectangle.fromRectangle(state);
  3235. // Uses outer bounding box to take rotation into account
  3236. if (state.shape != null && state.shape.boundingBox != null)
  3237. {
  3238. bds = mxRectangle.fromRectangle(state.shape.boundingBox);
  3239. }
  3240. bds.grow(this.graph.tolerance);
  3241. bds.grow(HoverIcons.prototype.arrowSpacing);
  3242. var handler = this.graph.selectionCellsHandler.getHandler(state.cell);
  3243. if (handler != null)
  3244. {
  3245. bds.x -= handler.horizontalOffset / 2;
  3246. bds.y -= handler.verticalOffset / 2;
  3247. bds.width += handler.horizontalOffset;
  3248. bds.height += handler.verticalOffset;
  3249. // Adds bounding box of rotation handle to avoid overlap
  3250. if (handler.rotationShape != null && handler.rotationShape.node != null &&
  3251. handler.rotationShape.node.style.visibility != 'hidden' &&
  3252. handler.rotationShape.node.style.display != 'none' &&
  3253. handler.rotationShape.boundingBox != null)
  3254. {
  3255. bds.add(handler.rotationShape.boundingBox);
  3256. }
  3257. }
  3258. arrowUp.style.left = Math.floor(state.getCenterX() - this.triangleUp.width / 2) + 'px';
  3259. arrowUp.style.top = Math.floor(bds.y - this.triangleUp.height) + 'px';
  3260. arrowRight.style.left = Math.floor(bds.x + bds.width) + 'px';
  3261. arrowRight.style.top = Math.floor(state.getCenterY() - this.triangleRight.height / 2) + 'px';
  3262. arrowDown.style.left = arrowUp.style.left
  3263. arrowDown.style.top = Math.floor(bds.y + bds.height) + 'px';
  3264. arrowLeft.style.left = Math.floor(bds.x - this.triangleLeft.width) + 'px';
  3265. arrowLeft.style.top = arrowRight.style.top;
  3266. if (state.style['portConstraint'] != 'eastwest')
  3267. {
  3268. graph.container.appendChild(arrowUp);
  3269. graph.container.appendChild(arrowDown);
  3270. }
  3271. graph.container.appendChild(arrowRight);
  3272. graph.container.appendChild(arrowLeft);
  3273. }
  3274. // Hides handle for cell under mouse
  3275. if (state != null)
  3276. {
  3277. currentStateHandle = graph.selectionCellsHandler.getHandler(state.cell);
  3278. if (currentStateHandle != null && currentStateHandle.setHandlesVisible != null)
  3279. {
  3280. currentStateHandle.setHandlesVisible(false);
  3281. }
  3282. }
  3283. activeTarget = true;
  3284. }
  3285. else
  3286. {
  3287. var elts = [roundSource, roundTarget, arrowUp, arrowRight, arrowDown, arrowLeft];
  3288. for (var i = 0; i < elts.length; i++)
  3289. {
  3290. if (elts[i].parentNode != null)
  3291. {
  3292. elts[i].parentNode.removeChild(elts[i]);
  3293. }
  3294. }
  3295. }
  3296. }
  3297. if (!activeTarget && currentStateHandle != null)
  3298. {
  3299. currentStateHandle.setHandlesVisible(true);
  3300. }
  3301. // Handles drop target
  3302. var target = ((!mxEvent.isAltDown(evt) || mxEvent.isShiftDown(evt)) &&
  3303. !(currentStyleTarget != null && activeArrow == styleTarget)) ?
  3304. mxDragSource.prototype.getDropTarget.apply(this, arguments) : null;
  3305. var model = graph.getModel();
  3306. if (target != null)
  3307. {
  3308. if (activeArrow != null || !graph.isSplitTarget(target, cells, evt))
  3309. {
  3310. // Selects parent group as drop target
  3311. while (target != null && !graph.isValidDropTarget(target, cells, evt) &&
  3312. model.isVertex(model.getParent(target)))
  3313. {
  3314. target = model.getParent(target);
  3315. }
  3316. if (target != null && (graph.view.currentRoot == target ||
  3317. (!graph.isValidRoot(target) &&
  3318. graph.getModel().getChildCount(target) == 0) ||
  3319. graph.isCellLocked(target) || model.isEdge(target) ||
  3320. !graph.isValidDropTarget(target, cells, evt)))
  3321. {
  3322. target = null;
  3323. }
  3324. }
  3325. }
  3326. return target;
  3327. });
  3328. dragSource.stopDrag = function()
  3329. {
  3330. mxDragSource.prototype.stopDrag.apply(this, arguments);
  3331. var elts = [roundSource, roundTarget, styleTarget, arrowUp, arrowRight, arrowDown, arrowLeft];
  3332. for (var i = 0; i < elts.length; i++)
  3333. {
  3334. if (elts[i].parentNode != null)
  3335. {
  3336. elts[i].parentNode.removeChild(elts[i]);
  3337. }
  3338. }
  3339. if (currentTargetState != null && currentStateHandle != null)
  3340. {
  3341. currentStateHandle.reset();
  3342. }
  3343. currentStateHandle = null;
  3344. currentTargetState = null;
  3345. currentStyleTarget = null;
  3346. styleTargetParent = null;
  3347. activeArrow = null;
  3348. };
  3349. return dragSource;
  3350. };
  3351. /**
  3352. * Adds a handler for inserting the cell with a single click.
  3353. */
  3354. Sidebar.prototype.itemClicked = function(cells, ds, evt, elt)
  3355. {
  3356. var graph = this.editorUi.editor.graph;
  3357. graph.container.focus();
  3358. // Alt+Click inserts and connects
  3359. if (mxEvent.isAltDown(evt) && graph.getSelectionCount() == 1 &&
  3360. graph.model.isVertex(graph.getSelectionCell()))
  3361. {
  3362. var firstVertex = null;
  3363. for (var i = 0; i < cells.length && firstVertex == null; i++)
  3364. {
  3365. if (graph.model.isVertex(cells[i]))
  3366. {
  3367. firstVertex = i;
  3368. }
  3369. }
  3370. if (firstVertex != null)
  3371. {
  3372. graph.setSelectionCells(this.dropAndConnect(graph.getSelectionCell(), cells,
  3373. (mxEvent.isMetaDown(evt) || mxEvent.isControlDown(evt)) ?
  3374. (mxEvent.isShiftDown(evt) ? mxConstants.DIRECTION_WEST : mxConstants.DIRECTION_NORTH) :
  3375. (mxEvent.isShiftDown(evt) ? mxConstants.DIRECTION_EAST : mxConstants.DIRECTION_SOUTH),
  3376. firstVertex, evt));
  3377. graph.scrollCellToVisible(graph.getSelectionCell());
  3378. }
  3379. }
  3380. // Shift+Click updates shape
  3381. else if (mxEvent.isShiftDown(evt) && !graph.isSelectionEmpty())
  3382. {
  3383. this.updateShapes(cells[0], graph.getSelectionCells());
  3384. graph.scrollCellToVisible(graph.getSelectionCell());
  3385. }
  3386. else
  3387. {
  3388. var pt = (mxEvent.isAltDown(evt)) ? graph.getFreeInsertPoint() :
  3389. graph.getCenterInsertPoint(graph.getBoundingBoxFromGeometry(cells, true));
  3390. ds.drop(graph, evt, null, pt.x, pt.y, true);
  3391. }
  3392. };
  3393. /**
  3394. * Adds a handler for inserting the cell with a single click.
  3395. */
  3396. Sidebar.prototype.addClickHandler = function(elt, ds, cells)
  3397. {
  3398. var graph = this.editorUi.editor.graph;
  3399. var oldMouseDown = ds.mouseDown;
  3400. var oldMouseMove = ds.mouseMove;
  3401. var oldMouseUp = ds.mouseUp;
  3402. var tol = graph.tolerance;
  3403. var first = null;
  3404. var sb = this;
  3405. ds.mouseDown =function(evt)
  3406. {
  3407. oldMouseDown.apply(this, arguments);
  3408. first = new mxPoint(mxEvent.getClientX(evt), mxEvent.getClientY(evt));
  3409. if (this.dragElement != null)
  3410. {
  3411. this.dragElement.style.display = 'none';
  3412. mxUtils.setOpacity(elt, 50);
  3413. }
  3414. };
  3415. ds.mouseMove = function(evt)
  3416. {
  3417. if (this.dragElement != null && this.dragElement.style.display == 'none' &&
  3418. first != null && (Math.abs(first.x - mxEvent.getClientX(evt)) > tol ||
  3419. Math.abs(first.y - mxEvent.getClientY(evt)) > tol))
  3420. {
  3421. this.dragElement.style.display = '';
  3422. mxUtils.setOpacity(elt, 100);
  3423. }
  3424. oldMouseMove.apply(this, arguments);
  3425. };
  3426. ds.mouseUp = function(evt)
  3427. {
  3428. try
  3429. {
  3430. if (!mxEvent.isPopupTrigger(evt) && this.currentGraph == null &&
  3431. this.dragElement != null && this.dragElement.style.display == 'none')
  3432. {
  3433. sb.itemClicked(cells, ds, evt, elt);
  3434. }
  3435. oldMouseUp.apply(ds, arguments);
  3436. mxUtils.setOpacity(elt, 100);
  3437. first = null;
  3438. // Blocks tooltips on this element after single click
  3439. sb.currentElt = elt;
  3440. }
  3441. catch (e)
  3442. {
  3443. ds.reset();
  3444. sb.editorUi.handleError(e);
  3445. }
  3446. };
  3447. };
  3448. /**
  3449. * Creates a drop handler for inserting the given cells.
  3450. */
  3451. Sidebar.prototype.createVertexTemplateEntry = function(style, width, height, value, title, showLabel, showTitle, tags)
  3452. {
  3453. tags = (tags != null && tags.length > 0) ? tags : ((title != null) ? title.toLowerCase() : '');
  3454. return this.addEntry(tags, mxUtils.bind(this, function()
  3455. {
  3456. return this.createVertexTemplate(style, width, height, value, title, showLabel, showTitle);
  3457. }));
  3458. }
  3459. /**
  3460. * Creates a drop handler for inserting the given cells.
  3461. */
  3462. Sidebar.prototype.createVertexTemplate = function(style, width, height, value, title, showLabel, showTitle, allowCellsInserted)
  3463. {
  3464. var cells = [new mxCell((value != null) ? value : '', new mxGeometry(0, 0, width, height), style)];
  3465. cells[0].vertex = true;
  3466. return this.createVertexTemplateFromCells(cells, width, height, title, showLabel, showTitle, allowCellsInserted);
  3467. };
  3468. /**
  3469. * Creates a drop handler for inserting the given cells.
  3470. */
  3471. Sidebar.prototype.createVertexTemplateFromData = function(data, width, height, title, showLabel, showTitle, allowCellsInserted)
  3472. {
  3473. var doc = mxUtils.parseXml(Graph.decompress(data));
  3474. var codec = new mxCodec(doc);
  3475. var model = new mxGraphModel();
  3476. codec.decode(doc.documentElement, model);
  3477. var cells = this.graph.cloneCells(model.root.getChildAt(0).children);
  3478. return this.createVertexTemplateFromCells(cells, width, height, title, showLabel, showTitle, allowCellsInserted);
  3479. };
  3480. /**
  3481. * Creates a drop handler for inserting the given cells.
  3482. */
  3483. Sidebar.prototype.createVertexTemplateFromCells = function(cells, width, height, title, showLabel, showTitle, allowCellsInserted)
  3484. {
  3485. // Use this line to convert calls to this function with lots of boilerplate code for creating cells
  3486. //console.trace('xml', Graph.compress(mxUtils.getXml(this.graph.encodeCells(cells))), cells);
  3487. return this.createItem(cells, title, showLabel, showTitle, width, height, allowCellsInserted);
  3488. };
  3489. /**
  3490. *
  3491. */
  3492. Sidebar.prototype.createEdgeTemplateEntry = function(style, width, height, value, title, showLabel, tags, allowCellsInserted)
  3493. {
  3494. tags = (tags != null && tags.length > 0) ? tags : title.toLowerCase();
  3495. return this.addEntry(tags, mxUtils.bind(this, function()
  3496. {
  3497. return this.createEdgeTemplate(style, width, height, value, title, showLabel, allowCellsInserted);
  3498. }));
  3499. };
  3500. /**
  3501. * Creates a drop handler for inserting the given cells.
  3502. */
  3503. Sidebar.prototype.createEdgeTemplate = function(style, width, height, value, title, showLabel, allowCellsInserted)
  3504. {
  3505. var cell = new mxCell((value != null) ? value : '', new mxGeometry(0, 0, width, height), style);
  3506. cell.geometry.setTerminalPoint(new mxPoint(0, height), true);
  3507. cell.geometry.setTerminalPoint(new mxPoint(width, 0), false);
  3508. cell.geometry.relative = true;
  3509. cell.edge = true;
  3510. return this.createEdgeTemplateFromCells([cell], width, height, title, showLabel, allowCellsInserted);
  3511. };
  3512. /**
  3513. * Creates a drop handler for inserting the given cells.
  3514. */
  3515. Sidebar.prototype.createEdgeTemplateFromCells = function(cells, width, height, title, showLabel, allowCellsInserted)
  3516. {
  3517. return this.createItem(cells, title, showLabel, true, width, height, allowCellsInserted);
  3518. };
  3519. /**
  3520. * Adds the given palette.
  3521. */
  3522. Sidebar.prototype.addPaletteFunctions = function(id, title, expanded, fns)
  3523. {
  3524. this.addPalette(id, title, expanded, mxUtils.bind(this, function(content)
  3525. {
  3526. for (var i = 0; i < fns.length; i++)
  3527. {
  3528. content.appendChild(fns[i](content));
  3529. }
  3530. }));
  3531. };
  3532. /**
  3533. * Adds the given palette.
  3534. */
  3535. Sidebar.prototype.addPalette = function(id, title, expanded, onInit)
  3536. {
  3537. var elt = this.createTitle(title);
  3538. this.container.appendChild(elt);
  3539. var div = document.createElement('div');
  3540. div.className = 'geSidebar';
  3541. // Disables built-in pan and zoom in IE10 and later
  3542. if (mxClient.IS_POINTER)
  3543. {
  3544. div.style.touchAction = 'none';
  3545. }
  3546. if (expanded)
  3547. {
  3548. onInit(div);
  3549. onInit = null;
  3550. }
  3551. else
  3552. {
  3553. div.style.display = 'none';
  3554. }
  3555. this.addFoldingHandler(elt, div, onInit);
  3556. var outer = document.createElement('div');
  3557. outer.appendChild(div);
  3558. this.container.appendChild(outer);
  3559. // Keeps references to the DOM nodes
  3560. if (id != null)
  3561. {
  3562. this.palettes[id] = [elt, outer];
  3563. }
  3564. return div;
  3565. };
  3566. /**
  3567. * Create the given title element.
  3568. */
  3569. Sidebar.prototype.addFoldingHandler = function(title, content, funct)
  3570. {
  3571. var initialized = false;
  3572. // Avoids mixed content warning in IE6-8
  3573. if (!mxClient.IS_IE || document.documentMode >= 8)
  3574. {
  3575. title.style.backgroundImage = (content.style.display == 'none') ?
  3576. 'url(\'' + this.collapsedImage + '\')' : 'url(\'' + this.expandedImage + '\')';
  3577. }
  3578. title.style.backgroundRepeat = 'no-repeat';
  3579. title.style.backgroundPosition = '0% 50%';
  3580. mxEvent.addListener(title, 'click', mxUtils.bind(this, function(evt)
  3581. {
  3582. if (content.style.display == 'none')
  3583. {
  3584. if (!initialized)
  3585. {
  3586. initialized = true;
  3587. if (funct != null)
  3588. {
  3589. // Wait cursor does not show up on Mac
  3590. title.style.cursor = 'wait';
  3591. var prev = title.innerHTML;
  3592. title.innerHTML = mxResources.get('loading') + '...';
  3593. window.setTimeout(function()
  3594. {
  3595. content.style.display = 'block';
  3596. title.style.cursor = '';
  3597. title.innerHTML = prev;
  3598. var fo = mxClient.NO_FO;
  3599. mxClient.NO_FO = Editor.prototype.originalNoForeignObject;
  3600. funct(content, title);
  3601. mxClient.NO_FO = fo;
  3602. }, (mxClient.IS_FF) ? 20 : 0);
  3603. }
  3604. else
  3605. {
  3606. content.style.display = 'block';
  3607. }
  3608. }
  3609. else
  3610. {
  3611. content.style.display = 'block';
  3612. }
  3613. title.style.backgroundImage = 'url(\'' + this.expandedImage + '\')';
  3614. }
  3615. else
  3616. {
  3617. title.style.backgroundImage = 'url(\'' + this.collapsedImage + '\')';
  3618. content.style.display = 'none';
  3619. }
  3620. mxEvent.consume(evt);
  3621. }));
  3622. // Prevents focus
  3623. if (!mxClient.IS_QUIRKS)
  3624. {
  3625. mxEvent.addListener(title, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown',
  3626. mxUtils.bind(this, function(evt)
  3627. {
  3628. evt.preventDefault();
  3629. }));
  3630. }
  3631. };
  3632. /**
  3633. * Removes the palette for the given ID.
  3634. */
  3635. Sidebar.prototype.removePalette = function(id)
  3636. {
  3637. var elts = this.palettes[id];
  3638. if (elts != null)
  3639. {
  3640. this.palettes[id] = null;
  3641. for (var i = 0; i < elts.length; i++)
  3642. {
  3643. this.container.removeChild(elts[i]);
  3644. }
  3645. return true;
  3646. }
  3647. return false;
  3648. };
  3649. /**
  3650. * Adds the given image palette.
  3651. */
  3652. Sidebar.prototype.addImagePalette = function(id, title, prefix, postfix, items, titles, tags)
  3653. {
  3654. var showTitles = titles != null;
  3655. var fns = [];
  3656. for (var i = 0; i < items.length; i++)
  3657. {
  3658. (mxUtils.bind(this, function(item, title, tmpTags)
  3659. {
  3660. if (tmpTags == null)
  3661. {
  3662. var slash = item.lastIndexOf('/');
  3663. var dot = item.lastIndexOf('.');
  3664. tmpTags = item.substring((slash >= 0) ? slash + 1 : 0, (dot >= 0) ? dot : item.length).replace(/[-_]/g, ' ');
  3665. }
  3666. fns.push(this.createVertexTemplateEntry('image;html=1;image=' + prefix + item + postfix,
  3667. this.defaultImageWidth, this.defaultImageHeight, '', title, title != null, null, this.filterTags(tmpTags)));
  3668. }))(items[i], (titles != null) ? titles[i] : null, (tags != null) ? tags[items[i]] : null);
  3669. }
  3670. this.addPaletteFunctions(id, title, false, fns);
  3671. };
  3672. /**
  3673. * Creates the array of tags for the given stencil. Duplicates are allowed and will be filtered out later.
  3674. */
  3675. Sidebar.prototype.getTagsForStencil = function(packageName, stencilName, moreTags)
  3676. {
  3677. var tags = packageName.split('.');
  3678. for (var i = 1; i < tags.length; i++)
  3679. {
  3680. tags[i] = tags[i].replace(/_/g, ' ')
  3681. }
  3682. tags.push(stencilName.replace(/_/g, ' '));
  3683. if (moreTags != null)
  3684. {
  3685. tags.push(moreTags);
  3686. }
  3687. return tags.slice(1, tags.length);
  3688. };
  3689. /**
  3690. * Adds the given stencil palette.
  3691. */
  3692. Sidebar.prototype.addStencilPalette = function(id, title, stencilFile, style, ignore, onInit, scale, tags, customFns, groupId)
  3693. {
  3694. scale = (scale != null) ? scale : 1;
  3695. if (this.addStencilsToIndex)
  3696. {
  3697. // LATER: Handle asynchronous loading dependency
  3698. var fns = [];
  3699. if (customFns != null)
  3700. {
  3701. for (var i = 0; i < customFns.length; i++)
  3702. {
  3703. fns.push(customFns[i]);
  3704. }
  3705. }
  3706. mxStencilRegistry.loadStencilSet(stencilFile, mxUtils.bind(this, function(packageName, stencilName, displayName, w, h)
  3707. {
  3708. if (ignore == null || mxUtils.indexOf(ignore, stencilName) < 0)
  3709. {
  3710. var tmp = this.getTagsForStencil(packageName, stencilName);
  3711. var tmpTags = (tags != null) ? tags[stencilName] : null;
  3712. if (tmpTags != null)
  3713. {
  3714. tmp.push(tmpTags);
  3715. }
  3716. fns.push(this.createVertexTemplateEntry('shape=' + packageName + stencilName.toLowerCase() + style,
  3717. Math.round(w * scale), Math.round(h * scale), '', stencilName.replace(/_/g, ' '), null, null,
  3718. this.filterTags(tmp.join(' '))));
  3719. }
  3720. }), true, true);
  3721. this.addPaletteFunctions(id, title, false, fns);
  3722. }
  3723. else
  3724. {
  3725. this.addPalette(id, title, false, mxUtils.bind(this, function(content)
  3726. {
  3727. if (style == null)
  3728. {
  3729. style = '';
  3730. }
  3731. if (onInit != null)
  3732. {
  3733. onInit.call(this, content);
  3734. }
  3735. if (customFns != null)
  3736. {
  3737. for (var i = 0; i < customFns.length; i++)
  3738. {
  3739. customFns[i](content);
  3740. }
  3741. }
  3742. mxStencilRegistry.loadStencilSet(stencilFile, mxUtils.bind(this, function(packageName, stencilName, displayName, w, h)
  3743. {
  3744. if (ignore == null || mxUtils.indexOf(ignore, stencilName) < 0)
  3745. {
  3746. content.appendChild(this.createVertexTemplate('shape=' + packageName + stencilName.toLowerCase() + style,
  3747. Math.round(w * scale), Math.round(h * scale), '', stencilName.replace(/_/g, ' '), true));
  3748. }
  3749. }), true);
  3750. }));
  3751. }
  3752. };
  3753. /**
  3754. * Adds the given stencil palette.
  3755. */
  3756. Sidebar.prototype.destroy = function()
  3757. {
  3758. if (this.graph != null)
  3759. {
  3760. if (this.graph.container != null && this.graph.container.parentNode != null)
  3761. {
  3762. this.graph.container.parentNode.removeChild(this.graph.container);
  3763. }
  3764. this.graph.destroy();
  3765. this.graph = null;
  3766. }
  3767. if (this.pointerUpHandler != null)
  3768. {
  3769. mxEvent.removeListener(document, (mxClient.IS_POINTER) ? 'pointerup' : 'mouseup', this.pointerUpHandler);
  3770. this.pointerUpHandler = null;
  3771. }
  3772. if (this.pointerDownHandler != null)
  3773. {
  3774. mxEvent.removeListener(document, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown', this.pointerDownHandler);
  3775. this.pointerDownHandler = null;
  3776. }
  3777. if (this.pointerMoveHandler != null)
  3778. {
  3779. mxEvent.removeListener(document, (mxClient.IS_POINTER) ? 'pointermove' : 'mousemove', this.pointerMoveHandler);
  3780. this.pointerMoveHandler = null;
  3781. }
  3782. if (this.pointerOutHandler != null)
  3783. {
  3784. mxEvent.removeListener(document, (mxClient.IS_POINTER) ? 'pointerout' : 'mouseout', this.pointerOutHandler);
  3785. this.pointerOutHandler = null;
  3786. }
  3787. };