Sidebar.js 156 KB

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