You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2010/01/14 02:48:36 UTC

svn commit: r899029 - in /labs/magma/trunk/website-maps-google/src/main: java/org/apache/magma/website/htmlpieces/ resources/org/apache/magma/website/maps/

Author: simoneg
Date: Thu Jan 14 01:48:35 2010
New Revision: 899029

URL: http://svn.apache.org/viewvc?rev=899029&view=rev
Log:
LABS-503 : better support of options as html piece style

Modified:
    labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
    labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
    labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
    labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js

Modified: labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java?rev=899029&r1=899028&r2=899029&view=diff
==============================================================================
--- labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java (original)
+++ labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java Thu Jan 14 01:48:35 2010
@@ -3,14 +3,23 @@
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.magma.beans.MagMapBean;
 import org.apache.magma.beans.PropertyInfo;
+import org.apache.magma.lateconfig.LateConfigurable;
+import org.apache.magma.lateconfig.LateConfigurationTrigger;
 import org.apache.magma.settings.Settings;
 import org.apache.magma.validation.CompoundValidator;
 import org.apache.magma.validation.Validator;
 import org.apache.magma.validation.validators.MapBeanValidator;
 import org.apache.magma.website.Head;
 
+@LateConfigurable
 public class MapBeanHtmlFormPiece implements HtmlFormPiece<MagMapBean>, PropertyAwareHtmlPiece {
 
+	private String style;
+	
+	@LateConfigurationTrigger
+	public MapBeanHtmlFormPiece() {
+	}
+	
 	public String createFormInput(MagMapBean value, String id) {
 		StringBuilder ret = new StringBuilder();
 		String md = "";
@@ -31,7 +40,10 @@
 		return new MapBeanHtmlFormPiece();
 	}
 	
-	public void setInputStyle(String style) {}	
+	@LateConfigurable
+	public void setInputStyle(String style) {
+		this.style = style;
+	}	
 
 	public void formHead(MagMapBean value, String id, Head head) {
 		head.addJQuery();
@@ -53,12 +65,21 @@
 				options += "markers:" + validator.isPermitMarkers() + ",";
 				options += "routes:" + validator.isPermitRoutes() + ",";
 				options += "polygons:" + validator.isPermitPolygons() + ",";
-				options += "autocenter: true,";
-				options += "defaultcontrols: true";
+				if (this.style != null) {
+					options += this.style;
+				} else {
+					options += "autocenter: true,";
+					options += "defaultcontrols: true";
+				}
+				options += "}";
+			} else {
+				if (this.style != null) {
+					options = "{" + this.style + "}";
+				}
 			}
 		}
 
-		head.addRawScript("init-edit-" + id, "var mapeditor" + id + " = null; function initedit" + id + "() { mapeditor"+ id + "=new MapEditor('" + id + "edit','" + id + "editlist','" + id + "'" + (options == null ? "" : (",'" + options+ "'")) + "); }");
+		head.addRawScript("init-edit-" + id, "var mapeditor" + id + " = null; function initedit" + id + "() { mapeditor"+ id + "=new MapEditor('" + id + "edit','" + id + "editlist','" + id + "'" + (options == null ? "" : ("," + options)) + "); }");
 		head.addDoOnload("initedit" + id);		
 	}
 

Modified: labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java?rev=899029&r1=899028&r2=899029&view=diff
==============================================================================
--- labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java (original)
+++ labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java Thu Jan 14 01:48:35 2010
@@ -1,17 +1,31 @@
 package org.apache.magma.website.htmlpieces;
 
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.magma.basics.LocalizableString;
 import org.apache.magma.beans.MagMapBean;
+import org.apache.magma.lateconfig.LateConfigurable;
+import org.apache.magma.lateconfig.LateConfigurationTrigger;
 import org.apache.magma.settings.Settings;
 import org.apache.magma.website.Head;
 
+@LateConfigurable
 public class MapBeanHtmlOutputPiece implements HtmlOutputPiece<MagMapBean> {
 
+	private String style;
+
+	@LateConfigurationTrigger
+	public MapBeanHtmlOutputPiece() {}
+	
 	public HtmlOutputPiece<MagMapBean> createFor(Class<? extends MagMapBean> clazz) {
-		return this;
+		return new MapBeanHtmlOutputPiece();
 	}
 
-	public void setStyle(String style) {}	
+	@LateConfigurable
+	public void setStyle(String style) {
+		if (style != null) style = style.trim();
+		if (style.length() == 0) return;
+		this.style = style;
+	}	
 	
 	public boolean outputs(Class<?> clazz) {
 		return MagMapBean.class.isAssignableFrom(clazz);
@@ -27,7 +41,26 @@
 		val = val.replace('-', '_');
 		String md = value.getValue();
 		if (md == null) md = "";
-		head.addRawScript("init-" + val, "var " + val + "=null; function init" + val + "() { var mm = new MagMap();mm.init('" + val + "','" + StringEscapeUtils.escapeJavaScript(md) + "');" + val + "=mm; }");
+		String script = "";
+		script += "var " + val + "=null;";
+		script += "function init" + val + "() {";
+		script += "var mm = new MagMap();";
+		script += "mm.init('" + val + "','";
+		script += StringEscapeUtils.escapeJavaScript(md) + "'";
+		if (style != null) {
+			if (style.indexOf(':') != -1) {
+				script += ", {" + style + "}";
+			} else {
+				String i18nstr = new LocalizableString(this.style).toString();
+				if (i18nstr != null && !i18nstr.equals(this.style)) {
+					script += ", {" + i18nstr + "}";
+				}
+			}
+		}
+		script += ");";
+		script += val + "=mm;";
+		script += "}";
+		head.addRawScript("init-" + val, script);
 		head.addDoOnload("init" + val);
 	}
 

Modified: labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js?rev=899029&r1=899028&r2=899029&view=diff
==============================================================================
--- labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js (original)
+++ labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js Thu Jan 14 01:48:35 2010
@@ -28,6 +28,10 @@
 		  };
 	  } else {
 		  this.options = options;
+		  if (typeof(this.options.defaultcontrols) == 'undefined') this.options.defaultcontrols=true;
+		  if (typeof(this.options.autocenter) == 'undefined') this.options.autocenter=true;
+		  if (typeof(this.options.center) == 'undefined') this.options.center="0,0";
+		  if (typeof(this.options.zoom) == 'undefined') this.options.zoom=2;
 	  }
 	this.createMap();
 }
@@ -114,13 +118,17 @@
 		  this.map.setCenter(mapbounds.getCenter(), this.map.getBoundsZoomLevel(mapbounds)); 
 	  } else {
 		  var mapcenter = null;
+		  var mapzoom = 2;
 		  if (this.options.center) {
 			  var ll = this.options.center.split(",");
 			  mapcenter = new GLatLng(ll[0], ll[1]);
 		  } else {
 			  mapcenter = new GLatLng(0,0);
 		  }
-		  this.map.setCenter(mapcenter);
+		  if (this.options.zoom) {
+			  mapzoom = this.options.zoom;
+		  }
+		  this.map.setCenter(mapcenter, mapzoom);
 	  }	
 }
 

Modified: labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js?rev=899029&r1=899028&r2=899029&view=diff
==============================================================================
--- labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js (original)
+++ labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js Thu Jan 14 01:48:35 2010
@@ -20,6 +20,15 @@
 		  };
 	  } else {
 		  this.options = options;
+		  if (typeof(this.options.defaultcontrols) == 'undefined') this.options.defaultcontrols=true;
+		  if (typeof(this.options.autocenter) == 'undefined') this.options.autocenter=true;
+		  if (typeof(this.options.center) == 'undefined') this.options.center="0,0";
+		  if (typeof(this.options.zoom) == 'undefined') this.options.zoom=2;
+
+		  if (typeof(this.options.markers) == 'undefined') this.options.markers=true;
+		  if (typeof(this.options.polylines) == 'undefined') this.options.polylines=true;
+		  if (typeof(this.options.polygons) == 'undefined') this.options.polygons=true;
+		  if (typeof(this.options.routes) == 'undefined') this.options.routes=true;
 	  }
 	  this.geometries = {};
 	  this.shared_bounds = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org