Gaudenz Alder před 6 roky
rodič
revize
7ba056d3b0

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+18-MAR-2019: 10.5.0
+
+- Uses .drawio extension in desktop app
+- Removes spacers for rack layouts
+- Uses mxGraph 4.0.1 beta 2
+
 17-MAR-2019: 10.4.9
 
 - Adds comments for Google Drive (beta)

+ 1 - 1
VERSION

@@ -1 +1 @@
-10.4.9
+10.5.0

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 55 - 52
etc/mxgraph/mxClient.js


+ 1 - 1
src/main/webapp/cache.manifest

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 03/17/2019 11:30 AM
+# 03/18/2019 05:24 PM
 
 app.html
 index.html?offline=1

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 102 - 99
src/main/webapp/js/app.min.js


+ 3 - 3
src/main/webapp/js/diagramly/App.js

@@ -2095,7 +2095,7 @@ App.prototype.open = function()
 					
 					if (dot > 0)
 					{
-						filename = filename.substring(0, filename.length - 4) + '.xml';
+						filename = filename.substring(0, filename.length - 4) + '.drawio';
 					}
 					
 					this.fileLoaded((mxClient.IS_IOS) ?
@@ -2842,7 +2842,7 @@ App.prototype.pickFile = function(mode)
 					
 					if (dot)
 					{
-						filename = filename.substring(0, filename.length - 4) + '.xml';
+						filename = filename.substring(0, filename.length - 4) + '.drawio';
 					}
 					
 					this.fileLoaded((mode == App.MODE_BROWSER) ?
@@ -3851,7 +3851,7 @@ App.prototype.loadFile = function(id, sameWindow, file, success, force)
 								
 								if (!this.useCanvasForExport && ext == '.png')
 								{
-									ext = '.xml';
+									ext = '.drawio';
 								}
 
 								if (ext === '.svg' || ext === '.xml' ||

+ 14 - 14
src/main/webapp/js/diagramly/Dialogs.js

@@ -2758,7 +2758,7 @@ var NewDialog = function(editorUi, compact, showName, callback, createOnly, canc
 				editorUi.mode == App.MODE_BROWSER) ? mxResources.get('diagramName') : mxResources.get('filename')) + ':');
 	}
 	
-	var ext = '.xml';
+	var ext = '.drawio';
 	
 	if (editorUi.mode == App.MODE_GOOGLE && editorUi.drive != null)
 	{
@@ -3790,7 +3790,7 @@ var CreateDialog = function(editorUi, title, createFn, cancelFn, dlgTitle, btnLa
 				}
 				else if (newMode == App.MODE_DEVICE)
 				{
-					ext = '.xml';
+					ext = '.drawio';
 				}
 				
 				if (idx >= 0)
@@ -5271,7 +5271,7 @@ var RevisionDialog = function(editorUi, revs, restoreFn)
 		if (currentDoc != null)
 		{
     		var data = mxUtils.getXml(currentDoc.documentElement);
-			var filename = editorUi.getBaseFilename() + '.xml';
+			var filename = editorUi.getBaseFilename() + '.drawio';
     		
 	    	if (editorUi.isLocalFileSave())
 	    	{
@@ -8276,23 +8276,23 @@ var LibraryDialog = function(editorUi, name, library, initialImages, file, mode)
 
 	var btn = mxUtils.button(mxResources.get('export'), function()
 	{
-	    	var data = editorUi.createLibraryDataFromImages(images);
-	    	var filename = nameInput.value;
+    	var data = editorUi.createLibraryDataFromImages(images);
+    	var filename = nameInput.value;
 	    	
 		if (!/(\.xml)$/i.test(filename))
 		{
 			filename += '.xml';
 		}
 	    	
-	    	if (editorUi.isLocalFileSave())
-	    	{
-	    		editorUi.saveLocalFile(data, filename, 'text/xml', null, null, true);
-	    	}
-	    	else
-	    	{
-	    		new mxXmlRequest(SAVE_URL, 'filename=' + encodeURIComponent(filename) +
-	    			'&format=xml&xml=' + encodeURIComponent(data)).simulate(document, '_blank');
-	    	}
+    	if (editorUi.isLocalFileSave())
+    	{
+    		editorUi.saveLocalFile(data, filename, 'text/xml', null, null, true);
+    	}
+    	else
+    	{
+    		new mxXmlRequest(SAVE_URL, 'filename=' + encodeURIComponent(filename) +
+    			'&format=xml&xml=' + encodeURIComponent(data)).simulate(document, '_blank');
+    	}
 	});
 	
 	btn.setAttribute('id', 'btnDownload');

+ 12 - 19
src/main/webapp/js/diagramly/Editor.js

@@ -2602,6 +2602,11 @@
 						}
 					}
 					
+					if (typeof(prop.onChange) == 'function')
+					{
+						prop.onChange(graph, newVal);
+					}
+					
 					that.editorUi.fireEvent(new mxEventObject('styleChanged', 'keys', changedProps,
 						'values', changedVals, 'cells', graph.getSelectionCells()));
 				}
@@ -3481,41 +3486,28 @@
 		
 		this.layoutManager.getLayout = function(cell)
 		{
-			var state = this.graph.view.getState(cell);
-			var style = (state != null) ? state.style : this.graph.getCellStyle(cell);
+			// Workaround for possible invalid style after change and before view validation
+			var style = this.graph.getCellStyle(cell);
 			
 			// mxRackContainer may be undefined as it is dynamically loaded at render time
 			if (style != null)
 			{
-				if (typeof(mxRackContainer) != 'undefined' && style['childLayout'] == 'rack')
+				if (style['childLayout'] == 'rack')
 				{
 					var rackLayout = new mxStackLayout(this.graph, false);
 					
-					rackLayout.setChildGeometry = function(child, geo)
-					{
-						var unitSize = 20;
-						geo.height = Math.max(geo.height, unitSize);
-						
-						if (geo.height / unitSize > 1)
-						{
-							var mod = geo.height % unitSize;
-							geo.height += mod > unitSize / 2 ? (unitSize - mod) : -mod;
-						}
-				
-						this.graph.getModel().setGeometry(child, geo);
-					};
-				
 					rackLayout.fill = true;
-					rackLayout.unitSize = mxRackContainer.unitSize | 20;
+					rackLayout.gridSize = (typeof mxRackContainer !== 'undefined') ? mxRackContainer.unitSize : 20;
 					rackLayout.marginLeft = style['marginLeft'] || 0;
 					rackLayout.marginRight = style['marginRight'] || 0;
 					rackLayout.marginTop = style['marginTop'] || 0;
 					rackLayout.marginBottom = style['marginBottom'] || 0;
+					rackLayout.allowGaps = style['allowGaps'] || 0;
 					rackLayout.resizeParent = false;
 					
 					return rackLayout;
 				}
-				else if (typeof(mxTableLayout) != 'undefined' && style['childLayout'] == 'tableLayout')
+				else if (typeof mxTableLayout !== 'undefined' && style['childLayout'] == 'tableLayout')
 		        {
 		            var tableLayout = new mxTableLayout(this.graph);
 		            tableLayout.rows = style['tableRows'] || 2;
@@ -4148,6 +4140,7 @@
 	mxStencilRegistry.libraries['ios7icons'] = [STENCIL_PATH + '/ios7/icons.xml'];
 	mxStencilRegistry.libraries['ios7ui'] = [SHAPES_PATH + '/ios7/mxIOS7Ui.js', STENCIL_PATH + '/ios7/misc.xml'];
 	mxStencilRegistry.libraries['android'] = [SHAPES_PATH + '/mxAndroid.js', STENCIL_PATH + '/android/android.xml'];
+	mxStencilRegistry.libraries['electrical/miscellaneous'] = [SHAPES_PATH + '/mxElectrical.js', STENCIL_PATH + '/electrical/miscellaneous.xml'];
 	mxStencilRegistry.libraries['electrical/transmission'] = [SHAPES_PATH + '/mxElectrical.js', STENCIL_PATH + '/electrical/transmission.xml'];
 	mxStencilRegistry.libraries['electrical/logic_gates'] = [SHAPES_PATH + '/mxElectrical.js', STENCIL_PATH + '/electrical/logic_gates.xml'];
 	mxStencilRegistry.libraries['electrical/abstract'] = [SHAPES_PATH + '/mxElectrical.js', STENCIL_PATH + '/electrical/abstract.xml'];

+ 4 - 4
src/main/webapp/js/diagramly/EditorUi.js

@@ -9445,7 +9445,7 @@
 							{
 								if (!this.useCanvasForExport && /(\.png)$/i.test(name))
 								{
-									name = name.substring(0, name.length - 4) + '.xml';
+									name = name.substring(0, name.length - 4) + '.drawio';
 								}
 								
 								var handleResult = mxUtils.bind(this, function(xml)
@@ -9454,11 +9454,11 @@
 									
 									if (dot >= 0)
 									{
-										name = name.substring(0, name.lastIndexOf('.')) + '.xml';
+										name = name.substring(0, name.lastIndexOf('.')) + '.drawio';
 									}
 									else
 									{
-										name = name + '.xml';
+										name = name + '.drawio';
 									}
 									
 									if (xml.substring(0, 10) == '<mxlibrary')
@@ -9526,7 +9526,7 @@
 								{
 									if (/(\.json)$/i.test(name))
 									{
-										name = name.substring(0, name.length - 5) + '.xml';
+										name = name.substring(0, name.length - 5) + '.drawio';
 									}
 	
 									// LATER: Add import step that produces cells and use callback

+ 1 - 1
src/main/webapp/js/diagramly/ElectronApp.js

@@ -830,7 +830,7 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		if (filename.length > 0 && (!/(\.xml)$/i.test(filename) && !/(\.html)$/i.test(filename) &&
 			!/(\.svg)$/i.test(filename) && !/(\.png)$/i.test(filename) && !/(\.drawio)$/i.test(filename)))
 		{
-			filename += '.xml';
+			filename += '.drawio';
 		}
 		
 		var path = dialog.showSaveDialog({defaultPath: filename});

+ 2 - 2
src/main/webapp/js/diagramly/sidebar/Sidebar-Electrical.js

@@ -411,8 +411,8 @@
 					60, 60, '', 'Explosive Squib', null, null, this.getTagsForStencil(gnmess, 'explosive squib', dtmem).join(' ')),
 			this.createVertexTemplateEntry('verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#000000;strokeColor=#000000;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.miscellaneous.monocell_battery;', 
 					100, 60, '', 'Accumulator / Monocell Battery', null, null, this.getTagsForStencil(gnmess, 'accumulator monocell battery single cell', dtmem).join(' ')),
-			this.createVertexTemplateEntry('verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#000000;strokeColor=#000000;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.miscellaneous.multicell_battery;', 
-					100, 60, '', 'Multicell Battery', null, null, this.getTagsForStencil(gnmess, 'accumulator multicell battery multi multiple cell', dtmem).join(' ')),
+			this.createVertexTemplateEntry(mem + 'batteryStack;', 
+					100, 60, '', 'Battery Stack', null, null, this.getTagsForStencil(gnmess, 'battery stack', dtmess).join(' ')),
 			this.createVertexTemplateEntry('verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#000000;strokeColor=#000000;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.miscellaneous.multicell_battery_tapped;', 
 					100, 70, '', 'Multicell Battery Tapped', null, null, this.getTagsForStencil(gnmess, 'accumulator multicell battery tapped multi multiple cell', dtmem).join(' '))
 		]);

+ 2 - 2
src/main/webapp/js/diagramly/sidebar/Sidebar-Rack.js

@@ -11,8 +11,8 @@
 		
 		this.addPaletteFunctions('rackGeneral', 'Rack / General', false,
 		[
-			this.createVertexTemplateEntry(s + 'shape=mxgraph.rackGeneral.container;container=1;collapsible=0;childLayout=rack;marginLeft=9;marginRight=9;marginTop=21;marginBottom=22;textColor=#666666;numDisp=off;', 180, 228.6, '', 'Rack Cabinet', null, null, dt + 'cabinet'),
-			this.createVertexTemplateEntry(s + 'shape=mxgraph.rackGeneral.container;container=1;collapsible=0;childLayout=rack;marginLeft=33;marginRight=9;marginTop=21;marginBottom=22;textColor=#666666;numDisp=ascend;', 210, 228.6, '', 'Numbered Rack Cabinet', null, null, dt + 'cabinet numbered'),
+			this.createVertexTemplateEntry(s + 'shape=mxgraph.rackGeneral.container;container=1;collapsible=0;childLayout=rack;allowGaps=1;marginLeft=9;marginRight=9;marginTop=21;marginBottom=22;textColor=#666666;numDisp=off;', 180, 228.6, '', 'Rack Cabinet', null, null, dt + 'cabinet'),
+			this.createVertexTemplateEntry(s + 'shape=mxgraph.rackGeneral.container;container=1;collapsible=0;childLayout=rack;allowGaps=1;marginLeft=33;marginRight=9;marginTop=21;marginBottom=22;textColor=#666666;numDisp=ascend;', 210, 228.6, '', 'Numbered Rack Cabinet', null, null, dt + 'cabinet numbered'),
 			this.createVertexTemplateEntry(sr + 'text;', 160, 15, '', 'Spacing', null, null, dt + 'spacing'),
 			this.createVertexTemplateEntry(sr + 'shape=mxgraph.rackGeneral.plate;fillColor=#e8e8e8;', 160, 15, '', 'Cover Plate', null, null, dt + 'cover plate'),
 			this.createVertexTemplateEntry(sr + 'shape=mxgraph.rack.general.1u_rack_server;', 160, 15, '', 'Server', null, null, dt + 'server'),

+ 6 - 6
src/main/webapp/js/mxgraph/Graph.js

@@ -1728,8 +1728,8 @@ Graph.prototype.initLayoutManager = function()
 
 	this.layoutManager.getLayout = function(cell)
 	{
-		var state = this.graph.view.getState(cell);
-		var style = (state != null) ? state.style : this.graph.getCellStyle(cell);
+		// Workaround for possible invalid style after change and before view validation
+		var style = this.graph.getCellStyle(cell);
 		
 		if (style != null)
 		{
@@ -1784,10 +1784,10 @@ Graph.prototype.initLayoutManager = function()
 		return null;
 	};
 };
-	
-	/**
-	 * Returns the size of the page format scaled with the page size.
-	 */
+
+/**
+ * Returns the size of the page format scaled with the page size.
+ */
 Graph.prototype.getPageSize = function()
 {
 	return (this.pageVisible) ? new mxRectangle(0, 0, this.pageFormat.width * this.pageScale,

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 9 - 5
src/main/webapp/js/shapes.min.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 73 - 70
src/main/webapp/js/viewer.min.js


+ 84 - 0
src/main/webapp/shapes/mxElectrical.js

@@ -1552,3 +1552,87 @@ mxShapeElectricalMux.prototype.getConstraints = function(style, w, h)
 	return (constr);
 }
 
+//**********************************************************************************************************************************************************
+//Battery stack
+//**********************************************************************************************************************************************************
+/**
+* Extends mxShape.
+*/
+function mxShapeElectricalBatteryStack(bounds, fill, stroke, strokewidth)
+{
+	mxShape.call(this);
+	this.bounds = bounds;
+	this.fill = fill;
+	this.stroke = stroke;
+	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
+};
+
+/**
+* Extends mxShape.
+*/
+mxUtils.extend(mxShapeElectricalBatteryStack, mxShape);
+
+mxShapeElectricalBatteryStack.prototype.cst = {
+		SHAPE_BATTERY_STACK : 'mxgraph.electrical.miscellaneous.batteryStack'
+};
+
+/**
+* Function: paintVertexShape
+* 
+* Paints the vertex shape.
+*/
+mxShapeElectricalBatteryStack.prototype.paintVertexShape = function(c, x, y, w, h)
+{
+	c.translate(x, y);
+
+	var bw = h * 0.3;
+	var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
+	var dashed = mxUtils.getValue(this.style, mxConstants.STYLE_DASHED, '0');
+	
+	var bNum = Math.floor((w - 20) / bw);
+	var startX = (w - bNum * bw) * 0.5;
+
+	if (bNum > 0)
+	{
+		c.begin();
+		c.moveTo(0, h * 0.5);
+		c.lineTo(startX + bw * 0.2, h * 0.5);
+		c.moveTo(w - startX - bw * 0.2, h * 0.5);
+		c.lineTo(w, h * 0.5);
+		c.stroke();
+		
+		var currX = startX;
+		c.setFillColor(strokeColor);
+		
+		for (var i = 0; i < bNum; i++)
+		{
+
+			c.rect(currX + bw * 0.2, h * 0.25, bw * 0.2, h * 0.5);
+			c.fillAndStroke();
+			
+			c.begin();
+			c.moveTo(currX + bw * 0.8, 0);
+			c.lineTo(currX + bw * 0.8, h);
+			c.stroke();
+			
+			if (i > 0)
+			{
+				c.setDashed('1');
+				c.begin();
+				c.moveTo(currX - bw * 0.2, h * 0.5);
+				c.lineTo(currX + bw * 0.2, h * 0.5);
+				c.stroke();
+				c.setDashed(dashed);
+			}
+			
+			currX = currX + bw;
+		}
+	}
+};
+
+mxCellRenderer.registerShape(mxShapeElectricalBatteryStack.prototype.cst.SHAPE_BATTERY_STACK, mxShapeElectricalBatteryStack);
+
+mxShapeElectricalBatteryStack.prototype.constraints = [
+    new mxConnectionConstraint(new mxPoint(0, 0.5), true),
+    new mxConnectionConstraint(new mxPoint(1, 0.5), true)
+    ];

+ 5 - 1
src/main/webapp/shapes/rack/mxRack.js

@@ -42,7 +42,11 @@ mxRackContainer.prototype.cst =
 mxRackContainer.prototype.customProperties = [
 	{name: 'textColor', dispName: 'Numbers Color', type: 'color'},
 	{name: 'numDisp', dispName: 'Display Numbers', type: 'enum',
-		enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}]
+		enumList: [{val: 'off', dispName: 'Off'}, {val: 'ascend', dispName: 'Ascending'}, {val: 'descend', dispName: 'Descending'}],
+		onChange: function(graph, newValue)
+		{
+			graph.setCellStyles('marginLeft', (newValue == 'off') ? 9 : 33, graph.getSelectionCells());
+		}
 	}
 ];