1(function() 2{ 3 // Adds ER shapes 4 Sidebar.prototype.addErPalette = function() 5 { 6 // Avoids having to bind all functions to "this" 7 var sb = this; 8 9 // Reusable cells 10 var row = new mxCell('Item', new mxGeometry(0, 0, 40, 30), 'text;strokeColor=none;fillColor=none;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontSize=12;'); 11 row.vertex = true; 12 13 // Predefined dimensions 14 var w = 100; 15 var h = 100; 16 17 // Default tags 18 var dt = 'db database schema er entity relation table '; 19 20 function createEdge(style, m, n) 21 { 22 var edge = new mxCell('', new mxGeometry(0, 0, 0, 0), style); 23 edge.geometry.setTerminalPoint(new mxPoint(0, 0), true); 24 edge.geometry.setTerminalPoint(new mxPoint(160, 0), false); 25 edge.geometry.relative = true; 26 edge.edge = true; 27 28 if (m != null) 29 { 30 var cell1 = new mxCell(m, new mxGeometry(-1, 0, 0, 0), 'resizable=0;html=1;align=left;verticalAlign=bottom;'); 31 cell1.geometry.relative = true; 32 cell1.setConnectable(false); 33 cell1.vertex = true; 34 edge.insert(cell1); 35 } 36 37 if (n != null) 38 { 39 var cell2 = new mxCell(n, new mxGeometry(1, 0, 0, 0), 'resizable=0;html=1;align=right;verticalAlign=bottom;'); 40 cell2.geometry.relative = true; 41 cell2.setConnectable(false); 42 cell2.vertex = true; 43 edge.insert(cell2); 44 } 45 46 return edge; 47 }; 48 49 this.setCurrentSearchEntryLibrary('er'); 50 51 var fns = [ 52 this.addDataEntry(dt, 180, 160, 'Table 1', '7Zhvb5swEMY/DW8nwCNr3kL/aGomTW33AdxwAUuOTW2nkH36ncEkaihqooSQVZWI5DufL/bvCY8CHkmW1Z2iRf5LpsA9cuORRElpmtGySoBzL/RZ6pFrLwx9/Hjhbc9sUM/6BVUgzD4LwmbBK+UraDJP9JlDk9VmzV1W57SwQ1PPklgbqswj+2tzxMfEXApDmQCFiaCOOaeFZnV5k8kZT2d0LVembdRG8YJVkD7IUrtaJcsZNrO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30p3EjDGg6JSHxCUuhFuAZT1haqUDYWjRuS+LJUbklYWgiXx0XM56iJiE1GMaDHislGiv7aM/UUpVjscIFreusUT6THZT32NoQa7AdczEbis+4+CT04rBQstK8n/J87o65AcutjIWlUMCSwWcoUKFrSKOG/i5K7VFhcDAE3VHxeiooNwKcA5kVh7SypDpEXHqB4xpkVYe0NHDCelxtUrdW8Ca48bEz6enOcMckhbqHKQld9SbtmuCUKw02D8JUQIFoUDoNh0uediP3oU6ETThUMFvnPiERzgMwYfBN0X7qLOfFOhTxWRZl3G7BeLDFvFy4oQI1e8ZPkKsBbGQLzszTDEr+z6DzA4Oub79mkdYObi36tvr7bwuyejOFLcNaliXoU2VNP5U1/SVVswNVH7V8WcDN1T9ru/7y+NjcNmIqdTX2mRd/IH63K/L7Rzz7GTMYbv88/dnOj+kN'), 56 this.addDataEntry(dt + ' fk pk foreign key primary', 180, 30, 'Table Row 3', 'xVXbTsMwDP2avqKupYjnloEQQ0IMPiCsXhuRxSXxaMfX4zTpriCGxISUSjkntmuf00uUFovuxoimvscSVJSOo7QwiOR3i64ApaIklmWUXkVJEvMVJdffnI7607gRBjQdk5D4hHehluAZT1haqUDYWjRuS+LFUbklYWgqPxwXM56hJiE1GMajHislGiv7aM/UUpUTscIlDXUGlM9lB+UjtjbEGmwnXMyG4nMuPg29OCyUrDTvZzyfu2NuwHIrE2EpFLBk8BUKVOga0qihv4tSe1QYHAxB9614PRWUuwFcAJkVh7SypDpEXHqB4xpkVYe0NHDCelytUzdW8Ca48bUz6fHOcMckhXqEGQld9SbtmuCUKw02T8JUQIFoUDoNx+887VruQ50Im3CoYD7kviARLgbLwuDrov3UWc6LdSjisyzKuN2C8WiDeblwQwVq9oyfIFcD2MgWnJnHGZT8n0HnBwY93P3OIq0d3Fj0a/XjPfW33xbnDLJ6c4Utw1qWJehjZU1/lDU9karZgarPWr4t4fbqn7Udvjw+NreNmEldTXzmxZ742QnE73ZF3n7Es78xg+Hmz9Of7fyYPgE='), 57 this.addEntry(dt + ' list', function() 58 { 59 var cell = new mxCell('List', new mxGeometry(0, 0, 160, 110), 60 'swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;align=center;fontSize=14;'); 61 cell.vertex = true; 62 cell.insert(sb.cloneCell(row, 'Item 1')); 63 cell.insert(sb.cloneCell(row, 'Item 2')); 64 cell.insert(sb.cloneCell(row, 'Item 3')); 65 66 return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'List'); 67 }), 68 this.addEntry(dt + ' list', function() 69 { 70 return sb.createVertexTemplateFromCells([row.clone()], row.geometry.width, row.geometry.height, 'List Item 1'); 71 }), 72 this.addEntry(dt + 'table row', function() 73 { 74 var cell = new mxCell(row.value, new mxGeometry(0, 0, 90, row.geometry.height), 'shape=partialRectangle;fillColor=none;align=left;verticalAlign=middle;strokeColor=none;spacingLeft=34;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;dropTarget=0;'); 75 cell.vertex = true; 76 77 var cell1 = sb.cloneCell(row, ''); 78 cell1.connectable = false; 79 cell1.style = 'shape=partialRectangle;top=0;left=0;bottom=0;fillColor=none;stokeWidth=1;dashed=1;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[];portConstraint=eastwest;part=1;' 80 cell1.geometry.width = 30; 81 cell.insert(cell1); 82 83 return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'List Item 2'); 84 }), 85 this.addEntry(dt + 'table row divider hline line separator', function() 86 { 87 var divider = new mxCell('', new mxGeometry(0, 0, 60, 10), 'line;strokeWidth=1;rotatable=0;dashed=0;labelPosition=right;align=left;verticalAlign=middle;spacingTop=0;spacingLeft=6;points=[];portConstraint=eastwest;'); 88 divider.vertex = true; 89 90 return sb.createVertexTemplateFromCells([divider], divider.geometry.width, divider.geometry.height, 'List Item 3'); 91 }), 92 this.addEntry(dt + 'table', function() 93 { 94 var cell = new mxCell('Entity', new mxGeometry(0, 0, 160, 120), 95 'swimlane;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;rounded=1;fontSize=14;fontStyle=0;strokeWidth=2;resizeParent=0;resizeLast=1;shadow=0;dashed=0;align=center;'); 96 cell.vertex = true; 97 98 var cell1 = new mxCell('+Attribute1\n+Attribute2\n+Attribute3', new mxGeometry(0, 30, 160, 90), 99 'align=left;strokeColor=none;fillColor=none;spacingLeft=4;fontSize=12;verticalAlign=top;resizable=0;rotatable=0;part=1;'); 100 cell1.vertex = true; 101 102 cell.insert(cell1); 103 104 return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Entity'); 105 }), 106 this.createVertexTemplateEntry('whiteSpace=wrap;html=1;align=center;', 100, 40, 'Entity', 'Entity', null, null, dt), 107 this.createVertexTemplateEntry('rounded=1;arcSize=10;whiteSpace=wrap;html=1;align=center;', 100, 40, 'Entity', 'Entity (Rounded)', null, null, dt + 'chen'), 108 this.createVertexTemplateEntry('shape=ext;margin=3;double=1;whiteSpace=wrap;html=1;align=center;', 100, 40, 'Entity', 'Weak Entity', null, null, dt + 'chen'), 109 this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;align=center;', 110 100, 40, 'Attribute', 'Attribute', null, null, dt + 'attribute chen'), 111 this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;align=center;fontStyle=4;', 112 100, 40, 'Attribute', 'Key Attribute', null, null, dt + 'attribute key chen'), 113 this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;align=center;', 114 100, 40, '<span style="border-bottom: 1px dotted">Attribute</span>', 'Weak Key Attribute', null, null, dt + 'attribute key weak chen'), 115 this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;align=center;dashed=1;', 116 100, 40, 'Attribute', 'Derived Attribute', null, null, dt + 'attribute derived chen'), 117 this.createVertexTemplateEntry('ellipse;shape=doubleEllipse;margin=3;whiteSpace=wrap;html=1;align=center;', 118 100, 40, 'Attribute', 'Multivalue Attribute', null, null, dt + 'attribute multivalue chen'), 119 this.createVertexTemplateEntry('shape=associativeEntity;whiteSpace=wrap;html=1;align=center;', 120 140, 60, 'Associative\nEntity', 'Associative Entity', null, null, dt + 'associative entity chen'), 121 this.createVertexTemplateEntry('shape=rhombus;perimeter=rhombusPerimeter;whiteSpace=wrap;html=1;align=center;', 122 120, 60, 'Relationship', 'Relationship', null, null, dt + 'chen'), 123 this.createVertexTemplateEntry('shape=rhombus;double=1;perimeter=rhombusPerimeter;whiteSpace=wrap;html=1;align=center;', 124 120, 60, 'Relationship', 'Identifying Relationship', null, null, dt + 'chen'), 125 this.createVertexTemplateEntry('ellipse;shape=cloud;whiteSpace=wrap;html=1;align=center;', 100, 60, 'Cloud', 'Cloud', null, null, dt + 'cloud'), 126 this.addEntry(dt + 'hierarchy', function() 127 { 128 var cell = new mxCell('', new mxGeometry(0, 0, 100, 100), 'rounded=1;absoluteArcSize=1;html=1;arcSize=10;'); 129 cell.vertex = true; 130 131 var cell1 = new mxCell('main', new mxGeometry(0, 0, 50, 100), 'html=1;shape=mxgraph.er.anchor;whiteSpace=wrap;'); 132 cell1.vertex = true; 133 cell.insert(cell1); 134 135 var cell2 = new mxCell('sub', new mxGeometry(50, 5, 45, 90), 'rounded=1;absoluteArcSize=1;html=1;arcSize=10;whiteSpace=wrap;points=[];strokeColor=inherit;fillColor=inherit;'); 136 cell2.vertex = true; 137 cell.insert(cell2); 138 139 return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Hierarchy'); 140 }), 141 this.createVertexTemplateEntry('shape=note;size=20;whiteSpace=wrap;html=1;', w, h, 'Note', 'Note', null, null, dt + 'note'), 142 this.addEntry(dt + 'relation chen', function() 143 { 144 return sb.createEdgeTemplateFromCells( 145 [createEdge('endArrow=none;html=1;rounded=0;')], 146 160, 0, 'Untitled Relation'); 147 }), 148 this.addEntry(dt + 'mandatory participation chen', function() 149 { 150 return sb.createEdgeTemplateFromCells( 151 [createEdge('endArrow=none;html=1;rounded=0;', null, '1')], 152 160, 0, 'Mandatory Participation (0:1)'); 153 }), 154 this.addEntry(dt + 'mandatory participation chen', function() 155 { 156 return sb.createEdgeTemplateFromCells( 157 [createEdge('endArrow=none;html=1;rounded=0;', null, 'N')], 158 160, 0, 'Mandatory Participation (0:N)'); 159 }), 160 this.addEntry(dt + 'mandatory participation chen', function() 161 { 162 return sb.createEdgeTemplateFromCells( 163 [createEdge('endArrow=none;html=1;rounded=0;', 'M', 'N')], 164 160, 0, 'Mandatory Participation (M:N)'); 165 }), 166 this.addEntry(dt + 'optional participation chen', function() 167 { 168 return sb.createEdgeTemplateFromCells( 169 [createEdge('endArrow=none;html=1;rounded=0;dashed=1;dashPattern=1 2;', null, '1')], 170 160, 0, 'Optional Participation (0:1)'); 171 }), 172 this.addEntry(dt + 'optional participation chen', function() 173 { 174 return sb.createEdgeTemplateFromCells( 175 [createEdge('endArrow=none;html=1;rounded=0;dashed=1;dashPattern=1 2;', null, 'N')], 176 160, 0, 'Optional Participation (0:N)'); 177 }), 178 this.addEntry(dt + 'optional participation chen', function() 179 { 180 return sb.createEdgeTemplateFromCells( 181 [createEdge('endArrow=none;html=1;rounded=0;dashed=1;dashPattern=1 2;', 'M', 'N')], 182 160, 0, 'Optional Participation (M:N)'); 183 }), 184 this.addEntry(dt + 'recursive relationship chen', function() 185 { 186 return sb.createEdgeTemplateFromCells( 187 [createEdge('shape=link;html=1;rounded=0;', null, '1')], 188 160, 0, 'Recursive Relationship (0:1)'); 189 }), 190 this.addEntry(dt + 'recursive relationship chen', function() 191 { 192 return sb.createEdgeTemplateFromCells( 193 [createEdge('shape=link;html=1;rounded=0;', null, 'N')], 194 160, 0, 'Recursive Relationship (0:N)'); 195 }), 196 this.addEntry(dt + 'recursive relationship chen', function() 197 { 198 return sb.createEdgeTemplateFromCells( 199 [createEdge('shape=link;html=1;rounded=0;', 'M', 'N')], 200 160, 0, 'Recursive Relationship (M:N)'); 201 }), 202 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERzeroToMany;endFill=1;', w, h, '', '0 to Many Optional', null, dt + 'zero many optional'), 203 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERoneToMany;', w, h, '', '1 to Many', null, dt + 'one many'), 204 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERmandOne;', w, h, '', '1 Mandatory', null, dt + 'one mandatory'), 205 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERmandOne;startArrow=ERmandOne;', w, h, '', '1 to 1', null, dt + 'one'), 206 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERone;endFill=1;', w, h, '', '1', null, dt + 'one'), 207 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERzeroToOne;endFill=1;', w, h, '', '0 to 1', null, dt + 'zero one'), 208 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERmany;', w, h, '', 'Many', null, dt + 'many'), 209 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERmany;startArrow=ERmany;', w, h, '', 'Many to Many', null, dt + 'many'), 210 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERzeroToMany;startArrow=ERzeroToOne;', w, h, '', '1 Optional to Many Optional', null, dt + 'one optional many'), 211 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERzeroToMany;startArrow=ERmandOne;', w, h, '', '1 Mandatory to Many Optional', null, dt + 'one mandatory many optional'), 212 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERzeroToOne;startArrow=ERmandOne;', w, h, '', '1 Mandatory to 1 Optional', null, dt + 'one mandatory optional'), 213 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERoneToMany;startArrow=ERmandOne;', w, h, '', '1 Mandatory to Many Mandatory', null, dt + 'one mandatory many'), 214 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERoneToMany;startArrow=ERzeroToOne;', w, h, '', '1 Optional to Many Mandatory', null, dt + 'one optional mandatory many'), 215 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERoneToMany;startArrow=ERoneToMany;', w, h, '', 'Many Mandatory to Many Mandatory', null, dt + 'mandatory many'), 216 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERoneToMany;startArrow=ERzeroToMany;', w, h, '', 'Many Optional to Many Mandatory', null, dt + 'mandatory many optional'), 217 this.createEdgeTemplateEntry('edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERzeroToMany;endFill=1;startArrow=ERzeroToMany;', w, h, '', 'Many Optional to Many Optional', null, dt + 'many optional') 218 ]; 219 220 this.addPaletteFunctions('er', mxResources.get('entityRelation'), false, fns); 221 222 this.setCurrentSearchEntryLibrary(); 223 224 }; 225 226})(); 227