[isidorus-cvs] r589 - branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Fri Jul 8 20:00:51 UTC 2011


Author: lgiessmann
Date: Fri Jul  8 13:00:49 2011
New Revision: 589

Log:
gdl-frontend: Widgets: fixed a bug in GdlVisibleObject.replaceStyleProperty(...), since GWT does not handle String.matches(...)

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Jul  8 10:29:08 2011	(r588)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Jul  8 13:00:49 2011	(r589)
@@ -11,6 +11,7 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.environment.MultipleHandlerRegistration;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.environment.Pattern;
 import us.isidor.gdl.anaToMia.Widgets.values.AutoNumUnitValue;
 import us.isidor.gdl.anaToMia.Widgets.values.AutoNumValue;
 import us.isidor.gdl.anaToMia.Widgets.values.BorderStyleValue;
@@ -105,15 +106,19 @@
 	
 	public static void replaceStyleProperty(Element elem, String styleName, String styleValue){
 		String oldStyle = elem.getAttribute("style");
-		//Window.alert(">> _" + oldStyle + "_<<" + " >> _" + styleName + "_<< => " + oldStyle.matches("(^| |;)" + styleName + " *:")); // TODO: remove
-		if(oldStyle.matches("(^| |;)" + styleName + " *:")){
-			Window.alert("!!!TEST!!!");
-			
-			elem.setAttribute("style", oldStyle.replaceFirst(styleName + ":.+;", styleName + ": " + styleValue + ";"));
-		} else {
-			elem.setAttribute("style", oldStyle + " " + styleName + ": " + styleValue + ";");
-		}
-			
+		String newValue = styleName + ": " + styleValue + ";";
+		
+		Pattern pattern1 = new Pattern("(^| )" + styleName + " *:[^;]");
+		Pattern pattern2 = new Pattern(";" + styleName + " *:[^;]");
+		if(pattern1.matches(oldStyle)){
+			elem.setAttribute("style", oldStyle.replaceFirst(pattern1.pattern(), newValue));
+		}else if(pattern2.matches(oldStyle)){
+			elem.setAttribute("style", oldStyle.replaceFirst(pattern1.pattern(), ";" + newValue));
+		}else{
+			String valueToAppend = styleName + ": " + styleValue + ";";
+			if(oldStyle.length() == 0) valueToAppend = " " + valueToAppend;
+			elem.setAttribute("style", oldStyle + valueToAppend);
+		}			
 	}
 	
 

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Fri Jul  8 10:29:08 2011	(r588)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Fri Jul  8 13:00:49 2011	(r589)
@@ -123,20 +123,6 @@
 			
 			GdlTitle tmp = new GdlTitle(tmpRepresentative);
 			this.mainPanel.add(tmp);
-			
-			
-			
-			
-			String oldStyle = "margin: 0px; width: 300px; max-idth: auto; min-width: auto; height: 300px; max-height: auto; min-height: auto; color: #000000; direction: rtl; text-align: left; line-height: normal; text-decoration: underline; font-style: normal; font-size: 15pt; font-weight: NORMAL; letter-spacing: normal; word-spacing: normal; font-size: 25pt; font-size: 25pt; width: 300px; max-idth: auto; min-width: auto; height: 300px; max-height: auto; min-height: auto; color: #000000; direction: rtl; text-align: left; line-height: ... word-spacing: normal; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; font-size: 25pt; width: 300px; max-idth: auto; min-width: auto; height: 300px; max-height: auto; min-height: auto; color: #000000; direction: rtl; text-align: left; line-height: normal; text-decoration: underline; font-style: normal; font-size: 15pt; font-weight: NORMAL; letter-spacing: normal; word-spacing: normal;";
-			
-			/*
-			String rex = "width";
-			Window.alert(" ==> " + oldStyle.matches("width"));
-			Window.alert(oldStyle.replaceAll(" width:[^;]*;", " WIDTH:xyz;"));
-			*/
-			
-			Pattern pattern = new Pattern("width");
-			Window.alert(">> " + pattern.matches(oldStyle));
 		}catch(Exception e){
 			e.printStackTrace();
 			Window.alert(">> e >> " + e.getClass() + " >> " + e.getMessage());




More information about the Isidorus-cvs mailing list