1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186 |
- /**
- *$id:Action 。JS,V 2017-12-19
- *$author shen.zhi
- */
- /**
- * Construcs a new sidebar for the given editor.
- */
- function Sidebar(editorUi, container)
- {
- this.editorUi = editorUi;
- this.container = container;
- this.palettes = new Object();
- this.showTooltips = true;
- this.graph = new Graph(document.createElement('div'), null, null, this.editorUi.editor.graph.getStylesheet());
- this.graph.foldingEnabled = false;
- this.graph.autoScroll = false;
- this.graph.setTooltips(false);
- this.graph.setConnectable(false);
- this.graph.resetViewOnRootChange = false;
- this.graph.view.setTranslate(this.thumbBorder, this.thumbBorder);
- this.graph.setEnabled(false);
- // Workaround for VML rendering in IE8 standards mode where the container must be in the DOM
- // so that VML references can be restored via document.getElementById in mxShape.init.
- if (document.documentMode == 8)
- {
- document.body.appendChild(this.graph.container);
- }
-
- // Workaround for no rendering in 0 coordinate in FF 10
- if (this.shiftThumbs)
- {
- this.graph.view.canvas.setAttribute('transform', 'translate(1, 1)');
- }
-
- if (!mxClient.IS_TOUCH)
- {
- mxEvent.addListener(document, 'mouseup', mxUtils.bind(this, function()
- {
- this.showTooltips = true;
- }));
-
- // Enables tooltips after scroll
- mxEvent.addListener(container, 'scroll', mxUtils.bind(this, function()
- {
- this.showTooltips = true;
- }));
-
- mxEvent.addListener(document, 'mousedown', mxUtils.bind(this, function()
- {
- this.showTooltips = false;
- this.hideTooltip();
- }));
- mxEvent.addListener(document, 'mousemove', mxUtils.bind(this, function(evt)
- {
- var src = mxEvent.getSource(evt);
-
- while (src != null)
- {
- if (src == this.currentElt)
- {
- return;
- }
-
- src = src.parentNode;
- }
-
- this.hideTooltip();
- }));
- // Handles mouse leaving the window
- mxEvent.addListener(document, 'mouseout', mxUtils.bind(this, function(evt)
- {
- if (evt.toElement == null && evt.relatedTarget == null)
- {
- this.hideTooltip();
- }
- }));
- }
-
- this.init();
-
- //图像预fetches提示
- new Image().src = IMAGE_PATH + '/tooltip.png';
- };
- /**
- * 将所有工具栏的侧边栏。
- */
- Sidebar.prototype.init = function()
- {
- var dir = STENCIL_PATH;
-
- //this.addGeneralPalette(true);
- //this.addUmlPalette(true);
- //this.addBpmnPalette(dir, false);
- //this.addStencilPalette('flowchart', 'Flowchart', dir + '/flowchart.xml',';fillColor=#ffffff;strokeColor=#000000;strokeWidth=2');
- //this.addStencilPalette('basic', mxResources.get('basic'), dir + '/basic.xml',';fillColor=#ffffff;strokeColor=#000000;strokeWidth=2');
- //this.addStencilPalette('arrows', mxResources.get('arrows'), dir + '/arrows.xml',';fillColor=#ffffff;strokeColor=#000000;strokeWidth=2');
-
- this.addImagePalette('clipart', mxResources.get('clipart'), dir + '/clipart/', '_128x128.png',
- [ 'colud', 'Firewall_02', 'Server_Tower', 'serverDB', 'serverAuth',
- 'serverPrint', 'serverEmail', 'serverDisk', 'Router_Icon', 'routerFirewall', 'route1', 'atm', 'police',
- 'accessServer','SIP', 'sipProxy', 'ITP', 'CA', '3U', 'ipv6Route',
- '3layer', 'pbx', 'IDS', 'actionCheck', 'gateWayVPN', 'server1','server2','normalServer','IPSAN','H3Cswitch']);
-
- this.addImagePalette('clipartB', mxResources.get('clipartB'), dir + '/clipart/', '.png',
- [ 'pic1','pic2','pic3','pic4','pic5','pic6','pic7','pic8','pic9','pic10','pic11','pic12','pic13','pic14','pic15']);
- };
- /**
- * 指定工具提示应该是可见的。默认的是真的。
- */
- Sidebar.prototype.enableTooltips = !mxClient.IS_TOUCH;
- /**
- * 将缩略图1像素。
- */
- Sidebar.prototype.shiftThumbs = mxClient.IS_SVG || document.documentMode == 8;
- /**
- * 指定工具提示的延迟。默认是16像素。
- */
- Sidebar.prototype.tooltipBorder = 16;
- /**
- * 指定工具提示的延迟。默认是2像素。
- */
- Sidebar.prototype.thumbBorder = 2;
- /**
- * Specifies the delay for the tooltip. Default is 300 ms.
- */
- Sidebar.prototype.tooltipDelay = 300;
- /**
- * Specifies if edges should be used as templates if clicked. Default is true.
- */
- Sidebar.prototype.installEdges = true;
- /**
- * Specifies the URL of the gear image.
- */
- Sidebar.prototype.gearImage = STENCIL_PATH + '/clipart/Gear_128x128.png';
- /**
- * Specifies the width of the thumbnails.
- */
- Sidebar.prototype.thumbWidth = 26;
- /**
- * Specifies the height of the thumbnails.
- */
- Sidebar.prototype.thumbHeight = 26;
- /**
- * Adds all palettes to the sidebar.
- */
- Sidebar.prototype.showTooltip = function(elt, cells)
- {
- if (this.enableTooltips && this.showTooltips)
- {
- if (this.currentElt != elt)
- {
- if (this.thread != null)
- {
- window.clearTimeout(this.thread);
- this.thread = null;
- }
-
- var show = mxUtils.bind(this, function()
- {
- // Workaround for off-screen text rendering in IE
- var old = mxText.prototype.getTableSize;
-
- if (this.graph.dialect != mxConstants.DIALECT_SVG)
- {
- mxText.prototype.getTableSize = function(table)
- {
- var oldParent = table.parentNode;
-
- document.body.appendChild(table);
- var size = new mxRectangle(0, 0, table.offsetWidth, table.offsetHeight);
- oldParent.appendChild(table);
-
- return size;
- };
- }
-
- // Lazy creation of the DOM nodes and graph instance
- if (this.tooltip == null)
- {
- this.tooltip = document.createElement('div');
- this.tooltip.className = 'geSidebarTooltip';
- document.body.appendChild(this.tooltip);
-
- this.graph2 = new Graph(this.tooltip, null, null, this.editorUi.editor.graph.getStylesheet());
- this.graph2.view.setTranslate(this.tooltipBorder, this.tooltipBorder);
- this.graph2.resetViewOnRootChange = false;
- this.graph2.foldingEnabled = false;
- this.graph2.autoScroll = false;
- this.graph2.setTooltips(false);
- this.graph2.setConnectable(false);
- this.graph2.setEnabled(false);
-
- this.tooltipImage = mxUtils.createImage(IMAGE_PATH + '/tooltip.png');
- this.tooltipImage.style.position = 'absolute';
- this.tooltipImage.style.width = '14px';
- this.tooltipImage.style.height = '27px';
-
- document.body.appendChild(this.tooltipImage);
- }
-
- this.graph2.model.clear();
- this.graph2.addCells(cells);
-
- var bounds = this.graph2.getGraphBounds();
- var width = bounds.x + bounds.width + this.tooltipBorder;
- var height = bounds.y + bounds.height + this.tooltipBorder;
-
- if (mxClient.IS_QUIRKS)
- {
- width += 4;
- height += 4;
- }
-
- this.tooltip.style.display = 'block';
- this.tooltip.style.overflow = 'visible';
- this.tooltipImage.style.visibility = 'visible';
- this.tooltip.style.width = width + 'px';
- this.tooltip.style.height = height + 'px';
-
- var left = this.container.clientWidth + this.editorUi.splitSize + 3;
- var top = Math.max(0, (this.container.offsetTop + elt.offsetTop - this.container.scrollTop - height / 2 + 16));
- // Workaround for ignored position CSS style in IE9
- // (changes to relative without the following line)
- this.tooltip.style.position = 'absolute';
- this.tooltip.style.left = left + 'px';
- this.tooltip.style.top = top + 'px';
- this.tooltipImage.style.left = (left - 13) + 'px';
- this.tooltipImage.style.top = (top + height / 2 - 13) + 'px';
-
- mxText.prototype.getTableSize = old;
- });
- if (this.tooltip != null && this.tooltip.style.display != 'none')
- {
- show();
- }
- else
- {
- this.thread = window.setTimeout(show, this.tooltipDelay);
- }
- this.currentElt = elt;
- }
- }
- };
- /**
- * Hides the current tooltip.
- */
- Sidebar.prototype.hideTooltip = function()
- {
- if (this.thread != null)
- {
- window.clearTimeout(this.thread);
- this.thread = null;
- }
-
- if (this.tooltip != null)
- {
- this.tooltip.style.display = 'none';
- this.tooltipImage.style.visibility = 'hidden';
- this.currentElt = null;
- }
- };
- /**
- * Adds the general palette to the sidebar.
- */
- Sidebar.prototype.addGeneralPalette = function(expand)
- {
- this.addPalette('general', mxResources.get('general'), expand || true, mxUtils.bind(this, function(content)
- {
- content.appendChild(this.createVertexTemplate('swimlane', 200, 200, 'Container'));
- content.appendChild(this.createVertexTemplate('swimlane;horizontal=0', 200, 200, 'Pool'));
- content.appendChild(this.createVertexTemplate('text', 40, 26, 'Text'));
- content.appendChild(this.createVertexTemplate('icon;image=' + this.gearImage, 60, 60, 'Image'));
- content.appendChild(this.createVertexTemplate('label;image=' + this.gearImage, 140, 60, 'Label'));
- content.appendChild(this.createVertexTemplate(null, 120, 60));
- content.appendChild(this.createVertexTemplate('rounded=1', 120, 60));
- content.appendChild(this.createVertexTemplate('ellipse', 80, 80));
- content.appendChild(this.createVertexTemplate('ellipse;shape=doubleEllipse', 80, 80));
- content.appendChild(this.createVertexTemplate('triangle', 60, 80));
- content.appendChild(this.createVertexTemplate('rhombus', 80, 80));
- content.appendChild(this.createVertexTemplate('shape=hexagon', 120, 80));
- content.appendChild(this.createVertexTemplate('shape=actor;verticalLabelPosition=bottom;verticalAlign=top', 40, 60));
- content.appendChild(this.createVertexTemplate('ellipse;shape=cloud', 120, 80));
- content.appendChild(this.createVertexTemplate('shape=cylinder', 60, 80));
- content.appendChild(this.createVertexTemplate('line', 160, 10));
- content.appendChild(this.createVertexTemplate('line;direction=south', 10, 160));
- content.appendChild(this.createVertexTemplate('shape=xor', 60, 80));
- content.appendChild(this.createVertexTemplate('shape=or', 60, 80));
- content.appendChild(this.createVertexTemplate('shape=step', 120, 80));
- content.appendChild(this.createVertexTemplate('shape=tape', 120, 100));
- content.appendChild(this.createVertexTemplate('shape=cube', 120, 80));
- content.appendChild(this.createVertexTemplate('shape=note', 80, 100));
- content.appendChild(this.createVertexTemplate('shape=folder', 120, 120));
- content.appendChild(this.createVertexTemplate('shape=card', 60, 80));
- content.appendChild(this.createVertexTemplate('shape=plus', 20, 20));
- content.appendChild(this.createEdgeTemplate('edgeStyle=none;endArrow=none;', 100, 100));
- content.appendChild(this.createEdgeTemplate('edgeStyle=none', 100, 100));
- content.appendChild(this.createEdgeTemplate('edgeStyle=elbowEdgeStyle;elbow=horizontal', 100, 100));
- content.appendChild(this.createEdgeTemplate('edgeStyle=elbowEdgeStyle;elbow=vertical', 100, 100));
- content.appendChild(this.createEdgeTemplate('edgeStyle=entityRelationEdgeStyle', 100, 100));
- content.appendChild(this.createEdgeTemplate('edgeStyle=segmentEdgeStyle', 100, 100));
- content.appendChild(this.createEdgeTemplate('edgeStyle=orthogonalEdgeStyle', 100, 100));
- content.appendChild(this.createEdgeTemplate('shape=link', 100, 100));
- content.appendChild(this.createEdgeTemplate('arrow', 100, 100));
- }));
- };
- /**
- * Adds the general palette to the sidebar.
- */
- Sidebar.prototype.addUmlPalette = function(expand)
- {
- this.addPalette('uml', 'UML', expand || false, mxUtils.bind(this, function(content)
- {
- content.appendChild(this.createVertexTemplate('', 110, 50, 'Object'));
-
- var classCell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
- '<b>Class</b></p>' +
- '<hr/><div style="height:2px;"></div><hr/>', new mxGeometry(0, 0, 140, 60),
- 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1');
- classCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([classCell], 140, 60));
-
- var classCell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
- '<b>Class</b></p>' +
- '<hr/><p style="margin:0px;margin-left:4px;">+ field: Type</p><hr/>' +
- '<p style="margin:0px;margin-left:4px;">+ method(): Type</p>', new mxGeometry(0, 0, 160, 90),
- 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1');
- classCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([classCell], 160, 90));
-
- var classCell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;">' +
- '<i><<Interface>></i><br/><b>Interface</b></p>' +
- '<hr/><p style="margin:0px;margin-left:4px;">+ field1: Type<br/>' +
- '+ field2: Type</p>' +
- '<hr/><p style="margin:0px;margin-left:4px;">' +
- '+ method1(Type): Type<br/>' +
- '+ method2(Type, Type): Type</p>', new mxGeometry(0, 0, 190, 140),
- 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1');
- classCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([classCell], 190, 140));
- var classCell = new mxCell('Module', new mxGeometry(0, 0, 120, 60),
- 'shape=component;align=left;spacingLeft=36');
- classCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([classCell], 120, 60));
- var classCell = new mxCell('<<component>><br/><b>Component</b>', new mxGeometry(0, 0, 180, 90),
- 'overflow=fill;html=1');
- classCell.vertex = true;
- var classCell1 = new mxCell('', new mxGeometry(1, 0, 20, 20), 'shape=component;jettyWidth=8;jettyHeight=4;');
- classCell1.vertex = true;
- classCell1.connectable = false;
- classCell1.geometry.relative = true;
- classCell1.geometry.offset = new mxPoint(-30, 10);
- classCell.insert(classCell1);
-
- content.appendChild(this.createVertexTemplateFromCells([classCell], 180, 90));
- var classCell = new mxCell('<p style="margin:0px;margin-top:6px;text-align:center;"><b>Component</b></p>' +
- '<hr/><p style="margin:0px;margin-left:8px;">+ Attribute1: Type<br/>+ Attribute2: Type</p>', new mxGeometry(0, 0, 180, 90),
- 'verticalAlign=top;align=left;overflow=fill;html=1');
- classCell.vertex = true;
- var classCell1 = new mxCell('', new mxGeometry(1, 0, 20, 20), 'shape=component;jettyWidth=8;jettyHeight=4;');
- classCell1.vertex = true;
- classCell1.connectable = false;
- classCell1.geometry.relative = true;
- classCell1.geometry.offset = new mxPoint(-23, 3);
- classCell.insert(classCell1);
- content.appendChild(this.createVertexTemplateFromCells([classCell], 180, 90));
- content.appendChild(this.createVertexTemplate('shape=lollipop;direction=south;', 30, 10));
- var cardCell = new mxCell('Block', new mxGeometry(0, 0, 180, 120),
- 'verticalAlign=top;align=left;spacingTop=8;spacingLeft=2;spacingRight=12;shape=cube;size=10;direction=south;fontStyle=4;');
- cardCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([cardCell], 180, 120));
- content.appendChild(this.createVertexTemplate('shape=folder;fontStyle=1;spacingTop=10;tabWidth=40;tabHeight=14;tabPosition=left;', 70, 50,
- 'package'));
- var classCell = new mxCell('<p style="margin:0px;margin-top:4px;text-align:center;text-decoration:underline;">' +
- '<b>Object:Type</b></p><hr/>' +
- '<p style="margin:0px;margin-left:8px;">field1 = value1<br/>field2 = value2<br>field3 = value3</p>',
- new mxGeometry(0, 0, 160, 90),
- 'verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1');
- classCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([classCell], 160, 90));
- var tableCell = new mxCell('<table cellpadding="5" style="font-size:9pt;border:none;border-collapse:collapse;width:100%;">' +
- '<tr><td colspan="2" style="border:1px solid gray;background:#e4e4e4;">Tablename</td></tr>' +
- '<tr><td style="border:1px solid gray;">PK</td><td style="border:1px solid gray;">uniqueId</td></tr>' +
- '<tr><td style="border:1px solid gray;">FK1</td><td style="border:1px solid gray;">foreignKey</td></tr>' +
- '<tr><td style="border:1px solid gray;"></td><td style="border:1px solid gray;">fieldname</td></tr>' +
- '</table>', new mxGeometry(0, 0, 180, 99), 'verticalAlign=top;align=left;overflow=fill;html=1');
- tableCell.vertex = true;
- content.appendChild(this.createVertexTemplateFromCells([tableCell], 180, 99));
-
- content.appendChild(this.createVertexTemplate('shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top', 40, 80, 'Actor'));
- content.appendChild(this.createVertexTemplate('ellipse', 140, 70, 'Use Case'));
- var cardCell = new mxCell('', new mxGeometry(0, 0, 30, 30),
- 'ellipse;shape=startState;fillColor=#000000;strokeColor=#ff0000;');
- cardCell.vertex = true;
-
- var assoc2 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
- assoc2.geometry.setTerminalPoint(new mxPoint(15, 70), false);
- assoc2.edge = true;
-
- cardCell.insertEdge(assoc2, true);
-
- content.appendChild(this.createVertexTemplateFromCells([cardCell, assoc2], 30, 30));
-
- var cardCell = new mxCell('Activity', new mxGeometry(0, 0, 120, 40),
- 'rounded=1;arcSize=40;fillColor=#ffffc0;strokeColor=#ff0000;');
- cardCell.vertex = true;
-
- var assoc2 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
- assoc2.geometry.setTerminalPoint(new mxPoint(60, 80), false);
- assoc2.edge = true;
-
- cardCell.insertEdge(assoc2, true);
-
- content.appendChild(this.createVertexTemplateFromCells([cardCell, assoc2], 120, 40));
-
- var cardCell = new mxCell('<div style="margin-top:8px;"><b>Composite State</b><hr/>Subtitle</div>', new mxGeometry(0, 0, 160, 60),
- 'rounded=1;arcSize=40;overflow=fill;html=1;verticalAlign=top;fillColor=#ffffc0;strokeColor=#ff0000;');
- cardCell.vertex = true;
-
- var assoc2 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
- assoc2.geometry.setTerminalPoint(new mxPoint(80, 100), false);
- assoc2.edge = true;
-
- cardCell.insertEdge(assoc2, true);
-
- content.appendChild(this.createVertexTemplateFromCells([cardCell, assoc2], 160, 60));
-
- var cardCell = new mxCell('Condition', new mxGeometry(0, 0, 80, 40),
- 'rhombus;fillColor=#ffffc0;strokeColor=#ff0000;');
- cardCell.vertex = true;
-
- var assoc1 = new mxCell('no', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;align=left;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
- assoc1.geometry.setTerminalPoint(new mxPoint(120, 20), false);
- assoc1.geometry.relative = true;
- assoc1.geometry.x = -1;
- assoc1.edge = true;
-
- cardCell.insertEdge(assoc1, true);
-
- var assoc2 = new mxCell('yes', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;align=left;verticalAlign=top;endArrow=open;endSize=8;strokeColor=#ff0000;');
- assoc2.geometry.setTerminalPoint(new mxPoint(40, 80), false);
- assoc2.geometry.relative = true;
- assoc2.geometry.x = -1;
- assoc2.edge = true;
-
- cardCell.insertEdge(assoc2, true);
-
- content.appendChild(this.createVertexTemplateFromCells([cardCell, assoc1, assoc2], 80, 40));
-
- var cardCell = new mxCell('', new mxGeometry(0, 0, 200, 10),
- 'shape=line;strokeWidth=6;strokeColor=#ff0000;');
- cardCell.vertex = true;
-
- var assoc2 = new mxCell('', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=horizontal;verticalAlign=bottom;endArrow=open;endSize=8;strokeColor=#ff0000;');
- assoc2.geometry.setTerminalPoint(new mxPoint(100, 50), false);
- assoc2.edge = true;
-
- cardCell.insertEdge(assoc2, true);
-
- content.appendChild(this.createVertexTemplateFromCells([cardCell, assoc2], 200, 10));
- content.appendChild(this.createVertexTemplate('ellipse;shape=endState;fillColor=#000000;strokeColor=#ff0000', 30, 30));
-
- var classCell1 = new mxCell(':Object', new mxGeometry(0, 0, 100, 50));
- classCell1.vertex = true;
-
- var classCell2 = new mxCell('', new mxGeometry(40, 50, 20, 240), 'shape=line;direction=north;dashed=1');
- classCell2.vertex = true;
-
- content.appendChild(this.createVertexTemplateFromCells([classCell1, classCell2], 100, 290));
-
- var classCell1 = new mxCell('', new mxGeometry(100, 0, 20, 70));
- classCell1.vertex = true;
- var assoc1 = new mxCell('invoke', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=vertical;verticalAlign=bottom;endArrow=block;');
- assoc1.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc1.edge = true;
-
- classCell1.insertEdge(assoc1, false);
- content.appendChild(this.createVertexTemplateFromCells([classCell1, assoc1], 120, 70));
-
- var classCell1 = new mxCell('', new mxGeometry(100, 0, 20, 70));
- classCell1.vertex = true;
- var assoc1 = new mxCell('invoke', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=vertical;verticalAlign=bottom;endArrow=block;');
- assoc1.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc1.edge = true;
-
- classCell1.insertEdge(assoc1, false);
-
- var assoc2 = new mxCell('return', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=vertical;verticalAlign=bottom;dashed=1;endArrow=open;endSize=8;');
- assoc2.geometry.setTerminalPoint(new mxPoint(0, 70), false);
- assoc2.edge = true;
-
- classCell1.insertEdge(assoc2, true);
-
- var assoc3 = new mxCell('invoke', new mxGeometry(0, 0, 0, 0), 'edgeStyle=elbowEdgeStyle;elbow=vertical;align=left;endArrow=open;');
- assoc3.edge = true;
-
- classCell1.insertEdge(assoc3, true);
- classCell1.insertEdge(assoc3, false);
-
- content.appendChild(this.createVertexTemplateFromCells([classCell1, assoc1, assoc2, assoc3], 120, 70));
-
- var assoc = new mxCell('name', new mxGeometry(0, 0, 0, 0), 'endArrow=block;endFill=1;edgeStyle=orthogonalEdgeStyle;align=left;verticalAlign=top;');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.geometry.relative = true;
- assoc.geometry.x = -1;
- assoc.edge = true;
-
- var sourceLabel = new mxCell('1', new mxGeometry(-1, 0, 0, 0), 'resizable=0;align=left;verticalAlign=bottom;labelBackgroundColor=#ffffff;fontSize=10');
- sourceLabel.geometry.relative = true;
- sourceLabel.setConnectable(false);
- sourceLabel.vertex = true;
- assoc.insert(sourceLabel);
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('', new mxGeometry(0, 0, 0, 0), 'endArrow=none;edgeStyle=orthogonalEdgeStyle;');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- var sourceLabel = new mxCell('parent', new mxGeometry(-1, 0, 0, 0), 'resizable=0;align=left;verticalAlign=bottom;labelBackgroundColor=#ffffff;fontSize=10');
- sourceLabel.geometry.relative = true;
- sourceLabel.setConnectable(false);
- sourceLabel.vertex = true;
- assoc.insert(sourceLabel);
-
- var targetLabel = new mxCell('child', new mxGeometry(1, 0, 0, 0), 'resizable=0;align=right;verticalAlign=bottom;labelBackgroundColor=#ffffff;fontSize=10');
- targetLabel.geometry.relative = true;
- targetLabel.setConnectable(false);
- targetLabel.vertex = true;
- assoc.insert(targetLabel);
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('1', new mxGeometry(0, 0, 0, 0), 'endArrow=open;endSize=12;startArrow=diamondThin;startSize=14;startFill=0;edgeStyle=orthogonalEdgeStyle;align=left;verticalAlign=bottom;');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.geometry.relative = true;
- assoc.geometry.x = -1;
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('Relation', new mxGeometry(0, 0, 0, 0), 'endArrow=open;endSize=12;startArrow=diamondThin;startSize=14;startFill=0;edgeStyle=orthogonalEdgeStyle;');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- var sourceLabel = new mxCell('0..n', new mxGeometry(-1, 0, 0, 0), 'resizable=0;align=left;verticalAlign=top;labelBackgroundColor=#ffffff;fontSize=10');
- sourceLabel.geometry.relative = true;
- sourceLabel.setConnectable(false);
- sourceLabel.vertex = true;
- assoc.insert(sourceLabel);
-
- var targetLabel = new mxCell('1', new mxGeometry(1, 0, 0, 0), 'resizable=0;align=right;verticalAlign=top;labelBackgroundColor=#ffffff;fontSize=10');
- targetLabel.geometry.relative = true;
- targetLabel.setConnectable(false);
- targetLabel.vertex = true;
- assoc.insert(targetLabel);
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('Use', new mxGeometry(0, 0, 0, 0), 'endArrow=open;endSize=12;dashed=1');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('Extends', new mxGeometry(0, 0, 0, 0), 'endArrow=block;endSize=16;endFill=0;dashed=1');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('', new mxGeometry(0, 0, 0, 0), 'endArrow=block;startArrow=block;endFill=1;startFill=1');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
- }));
- };
- /**
- * Adds the BPMN library to the sidebar.
- */
- Sidebar.prototype.addBpmnPalette = function(dir, expand)
- {
- this.addStencilPalette('bpmn', 'BPMN', dir + '/bpmn.xml',
- ';fillColor=#ffffff;strokeColor=#000000;perimeter=ellipsePerimeter;',
- ['Cancel', 'Error', 'Link', 'Message', 'Compensation', 'Multiple', 'Rule', 'Timer'],
- function(content)
- {
- content.appendChild(this.createVertexTemplate('swimlane;horizontal=0;', 300, 160, 'Pool'));
-
- var classCell = new mxCell('Process', new mxGeometry(0, 0, 140, 60),
- 'rounded=1');
- classCell.vertex = true;
- var classCell1 = new mxCell('', new mxGeometry(1, 1, 30, 30), 'shape=mxgraph.bpmn.timer_start;perimeter=ellipsePerimeter;');
- classCell1.vertex = true;
- classCell1.geometry.relative = true;
- classCell1.geometry.offset = new mxPoint(-40, -15);
- classCell.insert(classCell1);
-
- content.appendChild(this.createVertexTemplateFromCells([classCell], 140, 60));
-
- var classCell = new mxCell('Process', new mxGeometry(0, 0, 140, 60),
- 'rounded=1');
- classCell.vertex = true;
- var classCell1 = new mxCell('', new mxGeometry(0.5, 1, 12, 12), 'shape=plus');
- classCell1.vertex = true;
- classCell1.connectable = false;
- classCell1.geometry.relative = true;
- classCell1.geometry.offset = new mxPoint(-6, -12);
- classCell.insert(classCell1);
-
- content.appendChild(this.createVertexTemplateFromCells([classCell], 140, 60));
-
- var classCell = new mxCell('Process', new mxGeometry(0, 0, 140, 60),
- 'rounded=1');
- classCell.vertex = true;
- var classCell1 = new mxCell('', new mxGeometry(0, 0, 20, 14), 'shape=message');
- classCell1.vertex = true;
- classCell1.connectable = false;
- classCell1.geometry.relative = true;
- classCell1.geometry.offset = new mxPoint(5, 5);
- classCell.insert(classCell1);
-
- content.appendChild(this.createVertexTemplateFromCells([classCell], 140, 60));
-
- var classCell = new mxCell('', new mxGeometry(0, 0, 60, 40), 'shape=message');
- classCell.vertex = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([classCell], 60, 40));
-
- var assoc = new mxCell('Sequence', new mxGeometry(0, 0, 0, 0), 'endArrow=block;endFill=1;endSize=6');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('Default', new mxGeometry(0, 0, 0, 0), 'startArrow=dash;startSize=8;endArrow=block;endFill=1;endSize=6');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('Conditional', new mxGeometry(0, 0, 0, 0), 'startArrow=diamondThin;startFill=0;startSize=14;endArrow=block;endFill=1;endSize=6');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('', new mxGeometry(0, 0, 0, 0), 'startArrow=oval;startFill=0;startSize=7;endArrow=block;endFill=0;endSize=10;dashed=1');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('', new mxGeometry(0, 0, 0, 0), 'startArrow=oval;startFill=0;startSize=7;endArrow=block;endFill=0;endSize=10;dashed=1');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- var sourceLabel = new mxCell('', new mxGeometry(0, 0, 20, 14), 'shape=message');
- sourceLabel.geometry.relative = true;
- sourceLabel.setConnectable(false);
- sourceLabel.vertex = true;
- sourceLabel.geometry.offset = new mxPoint(-10, -7);
- assoc.insert(sourceLabel);
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
-
- var assoc = new mxCell('', new mxGeometry(0, 0, 0, 0), 'shape=link');
- assoc.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- assoc.geometry.setTerminalPoint(new mxPoint(160, 0), false);
- assoc.edge = true;
-
- content.appendChild(this.createEdgeTemplateFromCells([assoc], 160, 0));
- }, 0.5);
- };
- /**
- * Creates and returns the given title element.
- */
- Sidebar.prototype.createTitle = function(label)
- {
- var elt = document.createElement('a');
- elt.setAttribute('href', 'javascript:void(0);');
- elt.className = 'geTitle';
- mxUtils.write(elt, label);
- return elt;
- };
- /**
- * Creates a thumbnail for the given cells.
- */
- Sidebar.prototype.createThumb = function(cells, width, height, parent)
- {
- // Workaround for off-screen text rendering in IE
- var old = mxText.prototype.getTableSize;
-
- if (this.graph.dialect != mxConstants.DIALECT_SVG)
- {
- mxText.prototype.getTableSize = function(table)
- {
- var oldParent = table.parentNode;
-
- document.body.appendChild(table);
- var size = new mxRectangle(0, 0, table.offsetWidth, table.offsetHeight);
- oldParent.appendChild(table);
-
- return size;
- };
- }
-
- var prev = mxImageShape.prototype.preserveImageAspect;
- mxImageShape.prototype.preserveImageAspect = false;
-
- this.graph.view.rendering = false;
- this.graph.view.setScale(1);
- this.graph.addCells(cells);
- var bounds = this.graph.getGraphBounds();
- var corr = (this.shiftThumbs) ? this.thumbBorder + 1 : this.thumbBorder;
- var s = Math.min((width - 1) / (bounds.x + bounds.width + corr),
- (height - 1) / (bounds.y + bounds.height + corr));
- this.graph.view.setScale(s);
- this.graph.view.rendering = true;
- this.graph.refresh();
- mxImageShape.prototype.preserveImageAspect = prev;
- bounds = this.graph.getGraphBounds();
- var dx = Math.max(0, Math.floor((width - bounds.width) / 2));
- var dy = Math.max(0, Math.floor((height - bounds.height) / 2));
-
- var node = null;
-
- // For supporting HTML labels in IE9 standards mode the container is cloned instead
- if (this.graph.dialect == mxConstants.DIALECT_SVG && !mxClient.IS_IE)
- {
- node = this.graph.view.getCanvas().ownerSVGElement.cloneNode(true);
- }
- // Workaround for VML rendering in IE8 standards mode
- else if (document.documentMode == 8)
- {
- node = this.graph.container.cloneNode(false);
- node.innerHTML = this.graph.container.innerHTML;
- }
- else
- {
- node = this.graph.container.cloneNode(true);
- }
-
- this.graph.getModel().clear();
-
- // Outer dimension is (32, 32)
- var dd = (this.shiftThumbs) ? 2 : 3;
- node.style.position = 'relative';
- node.style.overflow = 'visible';
- node.style.cursor = 'pointer';
- node.style.left = (dx + dd) + 'px';
- node.style.top = (dy + dd) + 'px';
- node.style.width = width + 'px';
- node.style.height = height + 'px';
-
- parent.appendChild(node);
- mxText.prototype.getTableSize = old;
- };
- /**
- * Creates and returns a new palette item for the given image.
- */
- Sidebar.prototype.createItem = function(cells)
- {
- var elt = document.createElement('a');
- elt.setAttribute('href', 'javascript:void(0);');
- elt.className = 'geItem';
-
- // Blocks default click action
- mxEvent.addListener(elt, 'click', function(evt)
- {
- mxEvent.consume(evt);
- });
- this.createThumb(cells, this.thumbWidth, this.thumbHeight, elt);
-
- return elt;
- };
- /**
- * Creates a drop handler for inserting the given cells.
- */
- Sidebar.prototype.createDropHandler = function(cells, allowSplit)
- {
- return function(graph, evt, target, x, y)
- {
- cells = graph.getImportableCells(cells);
-
- if (cells.length > 0)
- {
- var validDropTarget = (target != null) ?
- graph.isValidDropTarget(target, cells, evt) : false;
- var select = null;
-
- if (target != null && !validDropTarget)
- {
- target = null;
- }
-
- // Splits the target edge or inserts into target group
- if (allowSplit && graph.isSplitEnabled() && graph.isSplitTarget(target, cells, evt))
- {
- graph.splitEdge(target, cells, null, x, y);
- select = cells;
- }
- else if (cells.length > 0)
- {
- select = graph.importCells(cells, x, y, target);
- }
-
- if (select != null && select.length > 0)
- {
- graph.scrollCellToVisible(select[0]);
- graph.setSelectionCells(select);
- }
- }
- };
- };
- /**
- * Creates and returns a preview element for the given width and height.
- */
- Sidebar.prototype.createDragPreview = function(width, height)
- {
- var elt = document.createElement('div');
- elt.style.border = '1px dashed black';
- elt.style.width = width + 'px';
- elt.style.height = height + 'px';
-
- return elt;
- };
- /**
- * Creates a drag source for the given element.
- */
- Sidebar.prototype.createDragSource = function(elt, dropHandler, preview)
- {
- var dragSource = mxUtils.makeDraggable(elt, this.editorUi.editor.graph, dropHandler,
- preview, 0, 0, this.editorUi.editor.graph.autoscroll, true, true);
- // Allows drop into cell only if target is a valid root
- dragSource.getDropTarget = function(graph, x, y)
- {
- var target = mxDragSource.prototype.getDropTarget.apply(this, arguments);
-
- if (!graph.isValidRoot(target))
- {
- target = null;
- }
-
- return target;
- };
-
- return dragSource;
- };
- /**
- * Adds a handler for inserting the cell with a single click.
- */
- Sidebar.prototype.addClickHandler = function(elt, ds)
- {
- var graph = this.editorUi.editor.graph;
- var first = null;
-
- var md = (mxClient.IS_TOUCH) ? 'touchstart' : 'mousedown';
- mxEvent.addListener(elt, md, function(evt)
- {
- first = new mxPoint(mxEvent.getClientX(evt), mxEvent.getClientY(evt));
- });
-
- var oldMouseUp = ds.mouseUp;
- ds.mouseUp = function(evt)
- {
- if (!mxEvent.isPopupTrigger(evt) && this.currentGraph == null && first != null)
- {
- var tol = graph.tolerance;
-
- if (Math.abs(first.x - mxEvent.getClientX(evt)) <= tol &&
- Math.abs(first.y - mxEvent.getClientY(evt)) <= tol)
- {
- var gs = graph.getGridSize();
- ds.drop(graph, evt, null, gs, gs);
- }
- }
- oldMouseUp.apply(this, arguments);
- first = null;
- };
- };
- /**
- * Creates a drop handler for inserting the given cells.
- */
- Sidebar.prototype.createVertexTemplate = function(style, width, height, value)
- {
- var cells = [new mxCell((value != null) ? value : '', new mxGeometry(0, 0, width, height), style)];
- cells[0].vertex = true;
-
- return this.createVertexTemplateFromCells(cells, width, height);
- };
- /**
- * Creates a drop handler for inserting the given cells.
- */
- Sidebar.prototype.createVertexTemplateFromCells = function(cells, width, height)
- {
- var elt = this.createItem(cells);
- var ds = this.createDragSource(elt, this.createDropHandler(cells, true), this.createDragPreview(width, height));
- this.addClickHandler(elt, ds);
- // Uses guides for vertices only if enabled in graph
- ds.isGuidesEnabled = mxUtils.bind(this, function()
- {
- return this.editorUi.editor.graph.graphHandler.guidesEnabled;
- });
- // Shows a tooltip with the rendered cell
- if (!touchStyle)
- {
- mxEvent.addListener(elt, 'mousemove', mxUtils.bind(this, function(evt)
- {
- this.showTooltip(elt, cells);
- }));
- }
-
- return elt;
- };
- /**
- * Creates a drop handler for inserting the given cells.
- */
- Sidebar.prototype.createEdgeTemplate = function(style, width, height, value)
- {
- var cells = [new mxCell((value != null) ? value : '', new mxGeometry(0, 0, width, height), style)];
- cells[0].geometry.setTerminalPoint(new mxPoint(0, height), true);
- cells[0].geometry.setTerminalPoint(new mxPoint(width, 0), false);
- cells[0].edge = true;
-
- return this.createEdgeTemplateFromCells(cells, width, height);
- };
- /**
- * Creates a drop handler for inserting the given cells.
- */
- Sidebar.prototype.createEdgeTemplateFromCells = function(cells, width, height)
- {
- var elt = this.createItem(cells);
- this.createDragSource(elt, this.createDropHandler(cells, false), this.createDragPreview(width, height));
- // Installs the default edge
- var graph = this.editorUi.editor.graph;
- mxEvent.addListener(elt, 'click', mxUtils.bind(this, function(evt)
- {
- if (this.installEdges)
- {
- // Uses edge template for connect preview
- graph.connectionHandler.createEdgeState = function(me)
- {
- return graph.view.createState(cells[0]);
- };
-
- // Creates new connections from edge template
- graph.connectionHandler.factoryMethod = function()
- {
- return graph.cloneCells([cells[0]])[0];
- };
- }
-
- // Highlights the entry for 200ms
- elt.style.backgroundColor = '#ffffff';
-
- window.setTimeout(function()
- {
- elt.style.backgroundColor = '';
- }, 200);
-
- mxEvent.consume(evt);
- }));
- // Shows a tooltip with the rendered cell
- if (!touchStyle)
- {
- mxEvent.addListener(elt, 'mousemove', mxUtils.bind(this, function(evt)
- {
- this.showTooltip(elt, cells);
- }));
- }
-
- return elt;
- };
- /**
- * Adds the given palette.
- */
- Sidebar.prototype.addPalette = function(id, title, expanded, onInit)
- {
- var elt = this.createTitle(title);
- this.container.appendChild(elt);
-
- var div = document.createElement('div');
- div.className = 'geSidebar';
-
- if (expanded)
- {
- onInit(div);
- onInit = null;
- }
- else
- {
- div.style.display = 'none';
- }
-
- this.addFoldingHandler(elt, div, onInit);
-
- var outer = document.createElement('div');
- outer.appendChild(div);
- this.container.appendChild(outer);
-
- // Keeps references to the DOM nodes
- if (id != null)
- {
- this.palettes[id] = [elt, outer];
- }
- };
- /**
- * Create the given title element.
- */
- Sidebar.prototype.addFoldingHandler = function(title, content, funct)
- {
- var initialized = false;
- title.style.backgroundImage = (content.style.display == 'none') ?
- 'url(' + IMAGE_PATH + '/collapsed.gif)' : 'url(' + IMAGE_PATH + '/expanded.gif)';
- title.style.backgroundRepeat = 'no-repeat';
- title.style.backgroundPosition = '100% 50%';
-
- mxEvent.addListener(title, 'click', function(evt)
- {
- if (content.style.display == 'none')
- {
- if (!initialized)
- {
- initialized = true;
-
- if (funct != null)
- {
- funct(content);
- }
- }
-
- title.style.backgroundImage = 'url(' + IMAGE_PATH + '/expanded.gif)';
- content.style.display = 'block';
- }
- else
- {
- title.style.backgroundImage = 'url(' + IMAGE_PATH + '/collapsed.gif)';
- content.style.display = 'none';
- }
-
- mxEvent.consume(evt);
- });
- };
- /**
- * Removes the palette for the given ID.
- */
- Sidebar.prototype.removePalette = function(id)
- {
- var elts = this.palettes[id];
-
- if (elts != null)
- {
- this.palettes[id] = null;
-
- for (var i = 0; i < elts.length; i++)
- {
- this.container.removeChild(elts[i]);
- }
-
- return true;
- }
-
- return false;
- };
- /**
- * Adds the given image palette.
- */
- Sidebar.prototype.addImagePalette = function(id, title, prefix, postfix, items)
- {
- this.addPalette(id, title, true, mxUtils.bind(this, function(content)
- {
- for (var i = 0; i < items.length; i++)
- {
- var icon = prefix + items[i] + postfix;
- content.appendChild(this.createVertexTemplate('image;image=' + icon, 80, 80, ''));
- }
- }));
- };
- /**
- * Adds the given stencil palette.
- */
- Sidebar.prototype.addStencilPalette = function(id, title, stencilFile, style, ignore, onInit, scale)
- {
- scale = (scale != null) ? scale : 1;
-
- this.addPalette(id, title, false, mxUtils.bind(this, function(content)
- {
- if (style == null)
- {
- style = '';
- }
-
- if (onInit != null)
- {
- onInit.call(this, content);
- }
- mxStencilRegistry.loadStencilSet(stencilFile, mxUtils.bind(this, function(packageName, stencilName, displayName, w, h)
- {
- if (ignore == null || mxUtils.indexOf(ignore, stencilName) < 0)
- {
- content.appendChild(this.createVertexTemplate('shape=' + packageName + stencilName.toLowerCase() + style,
- Math.round(w * scale), Math.round(h * scale), ''));
- }
- }), true);
- }));
- };
|