Browse Source

5.7.2.5 release

Gaudenz Alder 8 years ago
parent
commit
a80c939a6f

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+31-OCT-2016: 5.7.2.5
+
+- Makes recent colors persistent
+- Uses first unlocked layer for multiple pages
+
+28-OCT-2016: 5.7.2.4
+
+- Fixes Gliffy line imports with less than 2 waypoints
+
 28-OCT-2016: 5.7.2.3
 
 - Prepares multiple pages per file

+ 1 - 1
VERSION

@@ -1 +1 @@
-5.7.2.3
+5.7.2.5

+ 3 - 3
etc/build/build.xml

@@ -32,7 +32,7 @@
 		<echo file="${war.dir}/cache.manifest" append="false">CACHE MANIFEST${line.separator}${line.separator}</echo>
 		<echo file="${war.dir}/cache.manifest" append="true"># THIS FILE WAS GENERATED. DO NOT MODIFY!${line.separator}</echo>
 		<echo file="${war.dir}/cache.manifest" append="true"># ${time.stamp}${line.separator}${line.separator}</echo>
-    	<concat destfile="${war.dir}/cache.manifest" fixlastline="yes" append="yes">
+    	<concat destfile="${war.dir}/cache.manifest" fixlastline="yes" append="true">
     		<fileset dir="${basedir}" includes="cache.txt"/>
     	</concat>
     	
@@ -48,13 +48,13 @@
 
 		<delete file=".tmp1.js"/>
 		<copy file="${war.dir}/styles/default.xml" tofile=".tmp1.xml" overwrite="true"/>
-		<replaceregexp file=".tmp1.xml" match="\n" flags="g" replace=""/>
+		<replaceregexp file=".tmp1.xml" match="${line.separator}" flags="g" replace=""/>
 		<replaceregexp file=".tmp1.xml" match="\t" flags="g" replace=""/>
 		<replaceregexp file=".tmp1.xml" match="'" replace="\\\\'" byline="true"/>
 		
 		<delete file="Graph-Stylesheet.js"/>
 		<echo file="Graph-Stylesheet.js">Graph.prototype.defaultThemes[Graph.prototype.defaultThemeName] = mxUtils.parseXml('</echo>
-		<concat destfile="Graph-Stylesheet.js" fixlastline="no" append="yes">
+		<concat destfile="Graph-Stylesheet.js" fixlastline="no" append="true">
 			<file name=".tmp1.xml" />
     	</concat>
 		<echo file="Graph-Stylesheet.js" append="true">').documentElement;</echo>

+ 35 - 13
etc/sandstorm/server.c++

@@ -291,37 +291,60 @@ private:
     }
   }
 
-  kj::StringPtr inferContentType(kj::StringPtr filename) {
+  struct ContentType {
+    kj::StringPtr type;
+    kj::StringPtr encoding;
+
+    ContentType(kj::StringPtr type): type(type), encoding(nullptr) {}
+    ContentType(const char* type): type(type), encoding(nullptr) {}
+    ContentType() = default;
+  };
+
+  ContentType inferContentType(kj::StringPtr filename) {
+    ContentType result;
+    kj::String scratch;
+
+    if (filename.endsWith(".gz")) {
+      result.encoding = "gzip";
+      scratch = kj::str(filename.slice(0, filename.size() - 3));
+      filename = scratch;
+    }
+
     if (filename.endsWith(".html")) {
-      return "text/html; charset=UTF-8";
+      result.type = "text/html; charset=UTF-8";
     } else if (filename.endsWith(".js")) {
-      return "text/javascript; charset=UTF-8";
+      result.type = "text/javascript; charset=UTF-8";
     } else if (filename.endsWith(".css")) {
-      return "text/css; charset=UTF-8";
+      result.type = "text/css; charset=UTF-8";
     } else if (filename.endsWith(".png")) {
-      return "image/png";
+      result.type = "image/png";
     } else if (filename.endsWith(".gif")) {
-      return "image/gif";
+      result.type = "image/gif";
     } else if (filename.endsWith(".jpg") || filename.endsWith(".jpeg")) {
-      return "image/jpeg";
+      result.type = "image/jpeg";
     } else if (filename.endsWith(".svg")) {
-      return "image/svg+xml; charset=UTF-8";
+      result.type = "image/svg+xml; charset=UTF-8";
     } else if (filename.endsWith(".txt")) {
-      return "text/plain; charset=UTF-8";
+      result.type = "text/plain; charset=UTF-8";
     } else {
-      return "application/octet-stream";
+      result.type = "application/octet-stream";
     }
+
+    return result;
   }
 
   kj::Promise<void> readFile(
-      kj::StringPtr filename, GetContext context, kj::StringPtr contentType) {
+      kj::StringPtr filename, GetContext context, ContentType contentType) {
     KJ_IF_MAYBE(fd, tryOpen(filename, O_RDONLY)) {
       auto size = getFileSize(*fd, filename);
       kj::FdInputStream stream(kj::mv(*fd));
       auto response = context.getResults(capnp::MessageSize { size / sizeof(capnp::word) + 32, 0 });
       auto content = response.initContent();
       content.setStatusCode(sandstorm::WebSession::Response::SuccessCode::OK);
-      content.setMimeType(contentType);
+      content.setMimeType(contentType.type);
+      if (contentType.encoding != nullptr) {
+        content.setEncoding(contentType.encoding);
+      }
       stream.read(content.getBody().initBytes(size).begin(), size);
       return kj::READY_NOW;
     } else {
@@ -417,4 +440,3 @@ private:
 }  // anonymous namespace
 
 KJ_MAIN(ServerMain)
-

+ 1 - 1
etc/sandstorm/ssindex.html

@@ -305,7 +305,7 @@
 		}
 		else
 		{
-			mxscript('js/app.min.js');
+			mxscript('js/app.min.js.gz');
 			//mxscript('js/sandstorm/SandstormFile.js');
 		}
 		

+ 1 - 0
etc/sandstorm/stage.sh

@@ -25,6 +25,7 @@ mkdir -p build/.sandstorm/client/img
 cp -rf ../../war/img/* build/.sandstorm/client/img/
 mkdir -p build/.sandstorm/client/js
 cp -rf ../../war/js/* build/.sandstorm/client/js/
+gzip -c build/.sandstorm/client/js/app.min.js > build/.sandstorm/client/js/app.min.js.gz
 mkdir -p build/.sandstorm/client/mxgraph
 cp -rf ../../war/mxgraph/* build/.sandstorm/client/mxgraph/
 mkdir -p build/.sandstorm/client/plugins

+ 152 - 81
src/com/mxgraph/io/gliffy/importer/GliffyDiagramConverter.java

@@ -1,3 +1,7 @@
+/**
+ * Copyright (c) 2006-2016, JGraph Ltd
+ * Copyright (c) 2006-2016, Gaudenz Alder
+ */
 package com.mxgraph.io.gliffy.importer;
 
 import java.io.UnsupportedEncodingException;
@@ -26,7 +30,7 @@ import com.mxgraph.io.gliffy.model.Graphic.GliffyLine;
 import com.mxgraph.io.gliffy.model.Graphic.GliffyMindmap;
 import com.mxgraph.io.gliffy.model.Graphic.GliffyShape;
 import com.mxgraph.io.gliffy.model.Graphic.GliffySvg;
-import com.mxgraph.io.gliffy.model.Object;
+import com.mxgraph.io.gliffy.model.GliffyObject;
 import com.mxgraph.model.mxCell;
 import com.mxgraph.model.mxGeometry;
 import com.mxgraph.model.mxICell;
@@ -47,7 +51,8 @@ import com.mxgraph.view.mxGraphHeadless;
  * 
  * 
  */
-public class GliffyDiagramConverter {
+public class GliffyDiagramConverter
+{
 	Logger logger = Logger.getLogger("GliffyDiagramConverter");
 
 	private String diagramString;
@@ -56,7 +61,7 @@ public class GliffyDiagramConverter {
 
 	private mxGraphHeadless drawioDiagram;
 
-	private Map<Integer, Object> vertices;
+	private Map<Integer, GliffyObject> vertices;
 
 	/**
 	 * Constructs a new converter and starts a conversion.
@@ -64,17 +69,16 @@ public class GliffyDiagramConverter {
 	 * @param gliffyDiagramString
 	 *            JSON string of a gliffy diagram
 	 */
-	public GliffyDiagramConverter(String gliffyDiagramString) {
-		vertices = new LinkedHashMap<Integer, Object>();
-
+	public GliffyDiagramConverter(String gliffyDiagramString)
+	{
+		vertices = new LinkedHashMap<Integer, GliffyObject>();
 		this.diagramString = gliffyDiagramString;
-
 		drawioDiagram = new mxGraphHeadless();
-
 		start();
 	}
 
-	private void start() {
+	private void start()
+	{
 		// creates a diagram object from the JSON string
 		this.gliffyDiagram = new GsonBuilder().create().fromJson(diagramString, Diagram.class);
 
@@ -85,22 +89,27 @@ public class GliffyDiagramConverter {
 
 		drawioDiagram.getModel().beginUpdate();
 
-		try {
-
-			for (Object obj : gliffyDiagram.stage.getObjects()) {
+		try
+		{
+			for (GliffyObject obj : gliffyDiagram.stage.getObjects())
+			{
 				importObject(obj, obj.parent);
 			}
-
-		} finally {
+		}
+		finally
+		{
 			drawioDiagram.getModel().endUpdate();
 		}
 
 	}
 
 	@SuppressWarnings("unused")
-	private void correctLineEndings() {
+	private void correctLineEndings()
+	{
 		java.lang.Object[] edges = drawioDiagram.getAllEdges(new java.lang.Object[] { drawioDiagram.getDefaultParent() });
-		for (int i = 0; i < edges.length; i++) {
+
+		for (int i = 0; i < edges.length; i++)
+		{
 			mxCell edge = (mxCell) edges[i];
 
 			mxICell source = edge.getTerminal(true);
@@ -108,35 +117,44 @@ public class GliffyDiagramConverter {
 			mxPoint srcP = edge.getGeometry().getSourcePoint();
 			mxPoint trgtP = edge.getGeometry().getTargetPoint();
 
-			if (target != null) {
-				if (trgtP != null)
-					System.out.println(target.getGeometry().contains(trgtP.getX(), trgtP.getY()));
-				if (srcP != null)
-					System.out.println(source.getGeometry().contains(srcP.getX(), srcP.getY()));
-
-			}
+			// TODO should this be logging instead?
+//			if (target != null)
+//			{
+//				if (trgtP != null)
+//					System.out.println(target.getGeometry().contains(trgtP.getX(), trgtP.getY()));
+//				if (srcP != null)
+//					System.out.println(source.getGeometry().contains(srcP.getX(), srcP.getY()));
+//			}
 		}
 	}
 
 	/**
 	 * Imports the objects into the draw.io diagram. Recursively adds the children 
 	 */
-	private void importObject(Object obj, Object gliffyParent) {
-		
+	private void importObject(GliffyObject obj, GliffyObject gliffyParent)
+	{
 		mxCell parent = gliffyParent != null ? gliffyParent.mxObject : null;
 		
-		if (!obj.isLine()) {
+		if (!obj.isLine())
+		{
 			drawioDiagram.addCell(obj.mxObject, parent);
 
-			if (obj.hasChildren()) {
-				if (!obj.isSwimlane())// sort the children except for swimlanes, // their order value is "auto"
+			if (obj.hasChildren())
+			{
+				if (!obj.isSwimlane())
+				{
+					// sort the children except for swimlanes
+					// their order value is "auto"
 					sortObjectsByOrder(obj.children);
-
-				for (Object child : obj.children) {
+				}
+				
+				for (GliffyObject child : obj.children) {
 					importObject(child, obj);
 				}
 			}
-		} else {
+		}
+		else
+		{
 			// gets the terminal cells for the edge
 			mxCell startTerminal = getTerminalCell(obj, true);
 			mxCell endTerminal = getTerminalCell(obj, false);
@@ -147,20 +165,28 @@ public class GliffyDiagramConverter {
 		}
 	}
 
-	private void sortObjectsByOrder(Collection<Object> values) {
-		Collections.sort((List<Object>) values, new Comparator<Object>() {
-			public int compare(Object o1, Object o2) {
+	private void sortObjectsByOrder(Collection<GliffyObject> values)
+	{
+		Collections.sort((List<GliffyObject>) values, new Comparator<GliffyObject>()
+		{
+			public int compare(GliffyObject o1, GliffyObject o2)
+			{
 				Float o1o;
 				Float o2o;
-				try {
-					if(o1.order == null || o2.order == null)
+				try
+				{
+					if (o1.order == null || o2.order == null)
+					{
 						return 0;
-					
+					}
+
 					o1o = Float.parseFloat(o1.order);
 					o2o = Float.parseFloat(o2.order);
 					
 					return o1o.compareTo(o2o);
-				} catch (NumberFormatException e) {
+				}
+				catch (NumberFormatException e)
+				{
 					return o1.order.compareTo(o2.order);
 				} 
 
@@ -168,25 +194,31 @@ public class GliffyDiagramConverter {
 		});
 	}
 
-	private mxCell getTerminalCell(Object gliffyEdge, boolean start) {
+	private mxCell getTerminalCell(GliffyObject gliffyEdge, boolean start)
+	{
 		Constraints cons = gliffyEdge.getConstraints();
 
-		if (cons == null) {
+		if (cons == null)
+		{
 			return null;
 		}
+
 		Constraint con = start ? cons.getStartConstraint() : cons.getEndConstraint();
 
-		if (con == null) {
+		if (con == null)
+		{
 			return null;
 		}
 
 		ConstraintData cst = start ? con.getStartPositionConstraint() : con.getEndPositionConstraint();
 		int nodeId = cst.getNodeId();
-		Object gliffyEdgeTerminal = vertices.get(nodeId);
+		GliffyObject gliffyEdgeTerminal = vertices.get(nodeId);
 		
 		//edge could be terminated with another edge, so import it as a dangling edge
 		if(gliffyEdgeTerminal == null)
+		{
 			return null;
+		}
 		
 		mxCell mxEdgeTerminal = gliffyEdgeTerminal.getMxObject();
 		
@@ -196,32 +228,44 @@ public class GliffyDiagramConverter {
 	/**
 	 * 
 	 */
-	private void applyControlPoints(Object object, mxCell startTerminal, mxCell endTerminal) {
+	private void applyControlPoints(GliffyObject object, mxCell startTerminal, mxCell endTerminal)
+	{
 		mxCell cell = object.getMxObject();
 		mxGeometry geo = drawioDiagram.getModel().getGeometry(cell);
 		geo.setRelative(true);
 
 		List<float[]> points = object.getGraphic().getLine().controlPath;
+		
+		if (points.size() < 2)
+		{
+			return;
+		}
+
 		List<mxPoint> mxPoints = new ArrayList<mxPoint>();
 
-		for (float[] point : points) {
+		for (float[] point : points)
+		{
 			mxPoints.add(new mxPoint((int) point[0] + (int) object.x, (int) point[1] + (int) object.y));
 		}
 
-		if (startTerminal == null) {
+		if (startTerminal == null)
+		{
 			mxPoint first = mxPoints.get(0);
 			geo.setTerminalPoint(first, true);
 			mxPoints.remove(first);// remove first so it doesn't become a waypoint
 		}
 
-		if (endTerminal == null) {
+		if (endTerminal == null)
+		{
 			mxPoint last = mxPoints.get(mxPoints.size() - 1);
 			geo.setTerminalPoint(last, false);
 			mxPoints.remove(last);// remove last so it doesn't become a waypoint
 		}
 
 		if (!mxPoints.isEmpty())
+		{
 			geo.setPoints(mxPoints);
+		}
 
 		drawioDiagram.getModel().setGeometry(cell, geo);
 	}
@@ -230,20 +274,24 @@ public class GliffyDiagramConverter {
 	 * Creates a map of all vertices so they can be easily accessed when looking
 	 * up terminal cells for edges
 	 */
-	private void collectVerticesAndConvert(Map<Integer, Object> vertices, Collection<Object> objects, Object parent) {
-		
-		for (Object object : objects) {
-			
+	private void collectVerticesAndConvert(Map<Integer, GliffyObject> vertices, Collection<GliffyObject> objects, GliffyObject parent)
+	{
+		for (GliffyObject object : objects)
+		{
 			object.parent = parent;
 			
 			convertGliffyObject(object, parent);
 			
 			if(!object.isLine())
+			{
 				vertices.put(object.id, object);
+			}
 			
 			// don't collect for swimlanes and mindmaps, their children are treated differently
 			if (object.isGroup())
+			{
 				collectVerticesAndConvert(vertices, object.children, object);
+			}
 		}
 	}
 
@@ -253,7 +301,8 @@ public class GliffyDiagramConverter {
 	 * @return
 	 * @throws UnsupportedEncodingException
 	 */
-	public String getGraphXml() {
+	public String getGraphXml()
+	{
 		mxCodec codec = new mxCodec();
 		Element node = (Element) codec.encode(drawioDiagram.getModel());
 		node.setAttribute("style", "default-style2");
@@ -269,10 +318,11 @@ public class GliffyDiagramConverter {
 	 * 
 	 * 
 	 */
-	private mxCell convertGliffyObject(Object gliffyObject, Object parent) {
+	private mxCell convertGliffyObject(GliffyObject gliffyObject, GliffyObject parent)
+	{
 		mxCell cell = new mxCell();
 		
-		if(gliffyObject.isUnrecognizedGraphicType()) 
+		if (gliffyObject.isUnrecognizedGraphicType()) 
 		{
 			logger.warning("Unrecognized graphic type for object with ID : " + gliffyObject.id);
 			return cell;
@@ -284,23 +334,29 @@ public class GliffyDiagramConverter {
 		cell.setGeometry(geometry);
 		
 		String text;
-		Object textObject = null;
+		GliffyObject textObject = null;
 		String link = null;
 
 		Graphic graphic = null;
-		if (gliffyObject.isGroup()) {
+
+		if (gliffyObject.isGroup())
+		{
 			style.append("group;");
 			cell.setVertex(true);
-		} else {
+		}
+		else
+		{
 			// groups don't have graphic
 			graphic = gliffyObject.getGraphic();
 			textObject = gliffyObject.getTextObject();
 		}
 
-		if (graphic != null) {
+		if (graphic != null)
+		{
 			link = gliffyObject.getLink();
 
-			if (gliffyObject.isShape()) {
+			if (gliffyObject.isShape())
+			{
 				GliffyShape shape = graphic.Shape;
 				
 				cell.setVertex(true);
@@ -311,15 +367,19 @@ public class GliffyDiagramConverter {
 				style.append("strokeColor=" + shape.strokeColor).append(";");
 
 				if (shape.gradient)
+				{
 					style.append("gradientColor=#FFFFFF;gradientDirection=north;");
+				}
 
 				// opacity value is wrong for venn circles, so ignore it and use the one in the mapping
 				if (!gliffyObject.isVennsCircle())
+				{
 					style.append("opacity=" + shape.opacity * 100).append(";");
-
-				style.append(DashStyleMapping.get(shape.dashStyle));
-
-			} else if (gliffyObject.isLine()) {
+					style.append(DashStyleMapping.get(shape.dashStyle));
+				}
+			}
+			else if (gliffyObject.isLine())
+			{
 				GliffyLine line = graphic.Line;
 				
 				cell.setEdge(true);
@@ -332,29 +392,31 @@ public class GliffyDiagramConverter {
 
 				geometry.setX(0);
 				geometry.setY(0);
-				
-			} else if (gliffyObject.isText()) {
-				
+			}
+			else if (gliffyObject.isText())
+			{
 				textObject = gliffyObject;
 				cell.setVertex(true);
 				style.append("text;whiteSpace=wrap;html=1;nl2Br=0;");
 				cell.setValue(gliffyObject.getText());
 				
 				//if text is a child of a cell, use relative geometry and set X and Y to 0
-				if(gliffyObject.parent != null && !gliffyObject.parent.isGroup()) 
+				if (gliffyObject.parent != null && !gliffyObject.parent.isGroup()) 
 				{
 					mxGeometry parentGeometry = gliffyObject.parent.mxObject.getGeometry();
 					cell.setGeometry(new mxGeometry(0, 0, parentGeometry.getWidth(), parentGeometry.getHeight()));
 					cell.getGeometry().setRelative(true);
 				}
-				
-			} else if (gliffyObject.isImage()) {
+			}
+			else if (gliffyObject.isImage())
+			{
 				GliffyImage image = graphic.getImage();
 				cell.setVertex(true);
 				style.append("shape=" + StencilTranslator.translate(gliffyObject.uid)).append(";");
 				style.append("image=" + image.getUrl()).append(";");
 			}
-			else if (gliffyObject.isSvg()) {
+			else if (gliffyObject.isSvg())
+			{
 				GliffySvg svg = graphic.Svg;
 				cell.setVertex(true);
 				style.append("shape=image;aspect=fixed;");
@@ -364,21 +426,23 @@ public class GliffyDiagramConverter {
 			} 
 		} 
 		// swimlanes have children w/o uid so their children are converted here ad hoc
-		else if (gliffyObject.isSwimlane()) {
+		else if (gliffyObject.isSwimlane())
+		{
 			cell.setVertex(true);
 			style.append(StencilTranslator.translate(gliffyObject.uid)).append(";");
 
 			boolean vertical = true;
 			
-			if (gliffyObject.uid.startsWith(Object.H_SWIMLANE)) {
+			if (gliffyObject.uid.startsWith(GliffyObject.H_SWIMLANE))
+			{
 				vertical = false;
 				cell.getGeometry().setWidth(gliffyObject.height);
 				cell.getGeometry().setHeight(gliffyObject.width);
 				style.append("horizontal=0;");
 			}
 
-			Object header = gliffyObject.children.get(0);// first child is the header of the swimlane
-			Object headerText = header.children.get(0);
+			GliffyObject header = gliffyObject.children.get(0);// first child is the header of the swimlane
+			GliffyObject headerText = header.children.get(0);
 			
 			GliffyShape shape = header.graphic.getShape();
 			style.append("strokeWidth=" + shape.strokeWidth).append(";");
@@ -391,7 +455,7 @@ public class GliffyDiagramConverter {
 
 			for (int i = 1; i < gliffyObject.children.size(); i++) // rest of the children are lanes
 			{
-				Object gLane = gliffyObject.children.get(i);
+				GliffyObject gLane = gliffyObject.children.get(i);
 				gLane.parent = gliffyObject;
 
 				GliffyShape gs = gLane.graphic.getShape();
@@ -422,9 +486,10 @@ public class GliffyDiagramConverter {
 		 * 	Since mindmap object already converts to rectangle, rectangle object is removed and text object is put in it's place 
 		 * 
 		 */	
-		else if (gliffyObject.isMindmap()) {
-			Object rectangle = gliffyObject.children.get(0);
-			Object textObj = rectangle.children.get(0);
+		else if (gliffyObject.isMindmap())
+		{
+			GliffyObject rectangle = gliffyObject.children.get(0);
+			GliffyObject textObj = rectangle.children.get(0);
 			
 			GliffyMindmap mindmap = rectangle.graphic.Mindmap;
 			
@@ -436,7 +501,9 @@ public class GliffyDiagramConverter {
 			style.append(DashStyleMapping.get(mindmap.dashStyle));
 
 			if (mindmap.gradient)
+			{
 				style.append("gradientColor=#FFFFFF;gradientDirection=north;");
+			}
 
 			cell.setVertex(true);
 			
@@ -448,21 +515,23 @@ public class GliffyDiagramConverter {
 			gliffyObject.children.set(0, textObj);
 		}
 
-		if (gliffyObject.rotation != 0) {
+		if (gliffyObject.rotation != 0)
+		{
 			style.append("rotation=" + gliffyObject.rotation + ";");
 		}
 
-		if (!gliffyObject.isLine() && textObject != null) {
+		if (!gliffyObject.isLine() && textObject != null)
+		{
 			style.append(textObject.graphic.getText().getStyle());
 		}
 		
-		if(textObject != null) 
+		if (textObject != null) 
 		{
 			cell.setValue(textObject.getText());
 			style.append("html=1;nl2Br=0;whiteSpace=wrap");
 		}
 		
-		if(link != null) 
+		if (link != null) 
 		{
 			Document doc = mxDomUtils.createDocument();
 			Element uo = doc.createElement("UserObject");
@@ -470,7 +539,9 @@ public class GliffyDiagramConverter {
 			drawioDiagram.getModel().setValue(cell, uo);
 			
 			if(textObject != null)
+			{
 				uo.setAttribute("label", textObject.getText());
+			}
 		}
 
 		cell.setStyle(style.toString());

+ 6 - 8
src/com/mxgraph/io/gliffy/model/Object.java

@@ -1,8 +1,6 @@
 package com.mxgraph.io.gliffy.model;
 
-import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -12,7 +10,7 @@ import com.mxgraph.model.mxCell;
  * Class representing Gliffy diagram object
  * 
  */
-public class Object
+public class GliffyObject
 {
 	public static String SWIMLANE = "com.gliffy.shape.swimlanes.swimlanes_v1.default";
 
@@ -52,7 +50,7 @@ public class Object
 
 	public Graphic graphic;
 
-	public List<Object> children;
+	public List<GliffyObject> children;
 
 	public Constraints constraints;
 	
@@ -60,7 +58,7 @@ public class Object
 
 	public mxCell mxObject;// the mxCell this gliffy object got converted into
 
-	public Object parent = null;
+	public GliffyObject parent = null;
 
 	static
 	{
@@ -130,7 +128,7 @@ public class Object
 		
 	}
 
-	public Object()
+	public GliffyObject()
 	{
 	}
 
@@ -153,7 +151,7 @@ public class Object
 	 * 
 	 * @return
 	 */
-	public Object getTextObject()
+	public GliffyObject getTextObject()
 	{
 
 		if (isText())
@@ -165,7 +163,7 @@ public class Object
 			return null;
 		}
 
-		for (Object child : children)
+		for (GliffyObject child : children)
 		{
 			if (child.getGraphic() != null && child.getGraphic().getType().equals(Graphic.Type.TEXT))
 			{

+ 3 - 3
src/com/mxgraph/io/gliffy/model/Stage.java

@@ -17,7 +17,7 @@ public class Stage
 
 	private boolean drawingGuidesOn;
 
-	private List<Object> objects;
+	private List<GliffyObject> objects;
 
 	public Stage()
 	{
@@ -83,12 +83,12 @@ public class Stage
 		this.drawingGuidesOn = drawingGuidesOn;
 	}
 
-	public List<Object> getObjects()
+	public List<GliffyObject> getObjects()
 	{
 		return objects;
 	}
 
-	public void setObjects(List<Object> objects)
+	public void setObjects(List<GliffyObject> objects)
 	{
 		this.objects = objects;
 	}

+ 1 - 1
war/cache.manifest

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 10/28/2016 02:12 PM
+# 10/31/2016 09:16 AM
 
 /app.html
 /index.html?offline=1

File diff suppressed because it is too large
+ 49 - 46
war/js/app.min.js


File diff suppressed because it is too large
+ 4 - 4
war/js/atlas-viewer.min.js


File diff suppressed because it is too large
+ 176 - 173
war/js/atlas.min.js


+ 27 - 4
war/js/diagramly/App.js

@@ -65,6 +65,9 @@ App = function(editor, container, lightbox)
 		EditDataDialog.placeholderHelpLink = 'https://support.draw.io/questions/9338941';
 	}
 
+	// Gets recent colors from settings
+	ColorDialog.recentColors = mxSettings.getRecentColors(ColorDialog.recentColors);
+
 	// Handles opening files via drag and drop
 	this.addFileDropHandler([document]);
 	
@@ -186,6 +189,29 @@ App.getStoredMode = function()
 {
 	// Checks for local storage and SVG support
 	window.isSvgBrowser = window.isSvgBrowser || (navigator.userAgent.indexOf('MSIE') < 0 || document.documentMode >= 9);
+		
+	/**
+	 * Adds persistence for recent colors
+	 */
+	var colorDialogAddRecentColor = ColorDialog.addRecentColor;
+	
+	ColorDialog.addRecentColor = function(color, max)
+	{
+		colorDialogAddRecentColor.apply(this, arguments);
+		
+		mxSettings.setRecentColors(ColorDialog.recentColors);
+		mxSettings.save();
+	};
+	
+	var colorDialogResetRecentColors = ColorDialog.resetRecentColors;
+	
+	ColorDialog.resetRecentColors = function()
+	{
+		colorDialogResetRecentColors.apply(this, arguments);
+		
+		mxSettings.setRecentColors(ColorDialog.recentColors);
+		mxSettings.save();
+	};
 
 	if (!mxClient.IS_CHROMEAPP)
 	{
@@ -681,9 +707,6 @@ App.prototype.init = function()
 {
 	EditorUi.prototype.init.apply(this, arguments);
 	
-	var host = window.location.host;
-	
-	
 	/**
 	 * Overrides export dialog for using cloud storage save.
 	 */
@@ -4237,7 +4260,7 @@ App.prototype.fileLoaded = function(file)
 //		        	if (!this.isOffline())
 //		        	{
 //	        			var img = new Image();
-						var logDomain = window.DRAWIO_LOG_URL != null ? window.DRAWIO_LOG_URL : '';
+//						var logDomain = window.DRAWIO_LOG_URL != null ? window.DRAWIO_LOG_URL : '';
 //	        			img.src = logDomain + '/log?msg=storageMode:' + encodeURIComponent(file.getMode()) +
 //        				'&v=' + encodeURIComponent(EditorUi.VERSION);
 //		        	}

+ 15 - 0
war/js/diagramly/Pages.js

@@ -485,6 +485,21 @@ Graph.prototype.setViewState = function(state)
 		this.pasteCounter = 0;
 		this.mathEnabled = false;
 		this.connectionArrowsEnabled = true;
+		
+		// Selects first unlocked layer if one exists
+		var cell = this.getDefaultParent();
+		var style = this.getCellStyle(cell);
+		var index = 0;
+		
+		while (cell != null && mxUtils.getValue(this.getCellStyle(cell), 'locked', '0') == '1')
+		{
+			cell = this.model.getChildAt(this.model.root, index++);
+		}
+		
+		if (cell != null)
+		{
+			this.setDefaultParent(cell);
+		}
 	}
 	
 	// Implicit settings

+ 15 - 1
war/js/diagramly/Settings.js

@@ -12,6 +12,7 @@ var mxSettings =
 		libraries: Sidebar.prototype.defaultEntries,
 		customLibraries: [],
 		plugins: [],
+		recentColors: [],
 		formatWidth: '240',
 		currentEdgeStyle: Graph.prototype.defaultEdgeStyle,
 		currentVertexStyle: {},
@@ -21,7 +22,7 @@ var mxSettings =
 		showStartScreen: true,
 		gridColor: mxGraphView.prototype.gridColor,
 		autosave: true,
-		version: 12,
+		version: 13,
 		// Only defined and true for new settings which haven't been saved
 		isNew: true
 	},
@@ -104,6 +105,14 @@ var mxSettings =
 	{
 		this.settings.plugins = plugins;
 	},
+	getRecentColors: function()
+	{
+		return this.settings.recentColors;
+	},
+	setRecentColors: function(recentColors)
+	{
+		this.settings.recentColors = recentColors;
+	},
 	getFormatWidth: function()
 	{
 		return parseInt(this.settings.formatWidth);
@@ -178,6 +187,11 @@ var mxSettings =
 				this.settings.plugins = [];
 			}
 			
+			if (this.settings.recentColors == null)
+			{
+				this.settings.recentColors = [];
+			}
+			
 			if (this.settings.libraries == null)
 			{
 				this.settings.libraries = Sidebar.prototype.defaultEntries;

File diff suppressed because it is too large
+ 1 - 1
war/js/embed-static.min.js


+ 41 - 3
war/js/mxgraph/Dialogs.js

@@ -214,7 +214,16 @@ var ColorDialog = function(editorUi, color, apply, cancelFn)
 
 	var center = document.createElement('center');
 	
-	function addPresets(presets, rowLength, defaultColor)
+	function createRecentColorTable()
+	{
+		var table = addPresets((ColorDialog.recentColors.length == 0) ? ['FFFFFF'] :
+					ColorDialog.recentColors, 11, 'FFFFFF', true);
+		table.style.marginBottom = '8px';
+		
+		return table;
+	};
+	
+	function addPresets(presets, rowLength, defaultColor, addResetOption)
 	{
 		rowLength = (rowLength != null) ? rowLength : 12;
 		var table = document.createElement('table');
@@ -280,6 +289,28 @@ var ColorDialog = function(editorUi, color, apply, cancelFn)
 			tbody.appendChild(tr);
 		}
 		
+		if (addResetOption)
+		{
+			var td = document.createElement('td');
+			td.setAttribute('title', mxResources.get('reset'));
+			td.style.border = '1px solid black';
+			td.style.padding = '0px';
+			td.style.width = '16px';
+			td.style.height = '16px';
+			td.style.backgroundImage = 'url(\'' + Dialog.prototype.closeImage + '\')';
+			td.style.backgroundPosition = 'center center';
+			td.style.backgroundRepeat = 'no-repeat';
+			td.style.cursor = 'pointer';
+			
+			tr.appendChild(td);
+
+			mxEvent.addListener(td, 'click', function()
+			{
+				ColorDialog.resetRecentColors();
+				table.parentNode.replaceChild(createRecentColorTable(), table);
+			});
+		}
+		
 		center.appendChild(table);
 		
 		return table;
@@ -289,8 +320,7 @@ var ColorDialog = function(editorUi, color, apply, cancelFn)
 	mxUtils.br(div);
 	
 	// Adds recent colors
-	var table = addPresets((ColorDialog.recentColors.length == 0) ? ['FFFFFF'] : ColorDialog.recentColors, 12, 'FFFFFF');
-	table.style.marginBottom = '8px';
+	createRecentColorTable();
 		
 	// Adds presets
 	var table = addPresets(['E6D0DE', 'CDA2BE', 'B5739D', 'E1D5E7', 'C3ABD0', 'A680B8', 'D4E1F5', 'A9C4EB', '7EA6E0', 'D5E8D4', '9AC7BF', '67AB9F', 'D5E8D4', 'B9E0A5', '97D077', 'FFF2CC', 'FFE599', 'FFD966', 'FFF4C3', 'FFCE9F', 'FFB570', 'F8CECC', 'F19C99', 'EA6B66'], 12);
@@ -423,6 +453,14 @@ ColorDialog.addRecentColor = function(color, max)
 	}
 };
 
+/**
+ * Adds recent color for later use.
+ */
+ColorDialog.resetRecentColors = function()
+{
+	ColorDialog.recentColors = [];
+};
+
 /**
  * Constructs a new about dialog.
  */

File diff suppressed because it is too large
+ 1 - 1
war/js/reader.min.js


File diff suppressed because it is too large
+ 4 - 4
war/js/viewer.min.js