[isidorus-cvs] r542 - 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 1 09:47:43 UTC 2011


Author: lgiessmann
Date: Fri Jul  1 02:47:43 2011
New Revision: 542

Log:
gdl-frontend: Widgets: implemented a method that gets the GDL border-color, border[-top,-right,-bottom,-left]-color properties

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  1 02:37:25 2011	(r541)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Jul  1 02:47:43 2011	(r542)
@@ -8,10 +8,15 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.values.AutoNumValue;
 import us.isidor.gdl.anaToMia.Widgets.values.ClearValue;
+import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
+import us.isidor.gdl.anaToMia.Widgets.values.NumUnitValue;
+
+import com.google.gwt.canvas.dom.client.CssColor;
 import com.google.gwt.core.client.JsArray;
 import com.google.gwt.dom.client.Style.Display;
 import com.google.gwt.dom.client.Style.Float;
 import com.google.gwt.dom.client.Style.VerticalAlign;
+import com.google.gwt.resources.css.ast.CssCompilerException;
 import com.google.gwt.user.client.ui.AbsolutePanel;
 import com.google.gwt.user.client.ui.Composite;
 
@@ -48,13 +53,17 @@
 	// a helper method that returns one occurrence of the type bound to the passed PSI.
 	// If more than one occurrence is available an InvalidGdlSchemaException is thrown.
 	// If nor occurrence is available the return value is null
-	private Occurrence getNoneOrOneOccurrence(String occurrenceType) throws InvalidGdlSchemaException{
+	private Occurrence getNoneOrOneUnscopedOccurrence(String occurrenceType) throws InvalidGdlSchemaException{
 		JsArray<Occurrence> occs = getOccurrences(occurrenceType);
+		ArrayList<Occurrence> unscopedOccs = new ArrayList<Occurrence>();
+		for(int i = 0; i != occs.length(); ++i){
+			if(occs.get(i).getScope().length() == 0) unscopedOccs.add(occs.get(i));
+		}
 		
-		if(occs.length() > 1){
-			throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to none or one occurrence of the type " + occurrenceType + "but is bound " + occs.length() + " times to it");
-		} else if(occs.length() == 1){
-			return occs.get(0);
+		if(unscopedOccs.size() > 1){
+			throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to none or one unscoped occurrence of the type " + occurrenceType + "but is bound " + unscopedOccs.size() + " times to it");
+		} else if(unscopedOccs.size() == 1){
+			return unscopedOccs.get(0);
 		} else {
 			return null;
 		}
@@ -104,7 +113,7 @@
 	// returns a Display instance of a gdl:display occurrence.
 	// If no gdl:display occurrence is set, the default value is returned
 	public Display getDisplay() throws InvalidGdlSchemaException {
-		Occurrence displayOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlId);
+		Occurrence displayOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlId);
 		
 		if(displayOcc != null){
 			String value = displayOcc.getValue().toLowerCase();
@@ -128,7 +137,7 @@
 	// returns an AutoNumValue instance of a gdl:z-index occurrence.
 	// If no gdl:z-index occurrence is set, the default value is returned
 	public AutoNumValue getZindex() throws InvalidGdlSchemaException {
-		Occurrence zOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlZindex);
+		Occurrence zOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlZindex);
 		if(zOcc != null){
 			return new AutoNumValue(zOcc.getValue());
 		} else {
@@ -140,7 +149,7 @@
 	// returns a Float instance of a gdl:float occurrence or the default value for
 	// this property if no gdl:float occurrence is available
 	public Float getFloat() throws InvalidGdlSchemaException {
-		Occurrence floatOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlFloat);
+		Occurrence floatOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFloat);
 		
 		if(floatOcc != null){
 			String value = floatOcc.getValue().toLowerCase();
@@ -162,7 +171,7 @@
 	// returns a ClearValue instance of a gdl:clear occurrence or the default value for
 	// this property if no gdl:clear occurrence is available
 	public ClearValue getClear() throws InvalidGdlSchemaException {
-		Occurrence clearOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlFloat);
+		Occurrence clearOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFloat);
 		
 		if(clearOcc != null){
 			try{
@@ -185,7 +194,7 @@
 		if(styleClass != null){
 			vaOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlVerticalAlign, styleClass);
 		} else {
-			vaOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlVerticalAlign);
+			vaOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlVerticalAlign);
 		}
 		
 		if(vaOcc == null && styleClass != null){
@@ -217,17 +226,226 @@
 	}
 
 	
+	// returns a NumUnitValue instance that represents the margin of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public NumUnitValue getMargin(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence marginOcc = null;
+		if(styleClass != null){
+			marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMargin, styleClass);
+		} else {
+			marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMargin);
+		}
+		
+		if(marginOcc == null && styleClass != null){
+			return null;
+		} else if(marginOcc == null) {
+			return new NumUnitValue();
+		} else {
+			return new NumUnitValue(marginOcc.getValue());
+		}
+	}
+	
+	
+	// returns a NumUnitValue instance that represents the margin-top of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public NumUnitValue getMarginTop(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence marginOcc = null;
+		if(styleClass != null){
+			marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginTop, styleClass);
+		} else {
+			marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginTop);
+		}
+		
+		if(marginOcc == null && styleClass != null){
+			return null;
+		} else if(marginOcc == null) {
+			return new NumUnitValue();
+		} else {
+			return new NumUnitValue(marginOcc.getValue());
+		}
+	}
+	
 	
-	// gdlMargin [gdl:hover | gdl:focus | gdl:active]
-	// gdlMarginTop [gdl:hover | gdl:focus | gdl:active]
-	// gdlMarginRight [gdl:hover | gdl:focus | gdl:active]
-	// gdlMarginBottom [gdl:hover | gdl:focus | gdl:active]
-	// gdlMarginLeft [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderColor [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderColorTop [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderColorRight [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderColorBottom [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderColorLeft [gdl:hover | gdl:focus | gdl:active]
+	// returns a NumUnitValue instance that represents the margin-right of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public NumUnitValue getMarginRight(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence marginOcc = null;
+		if(styleClass != null){
+			marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginRight, styleClass);
+		} else {
+			marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginRight);
+		}
+		
+		if(marginOcc == null && styleClass != null){
+			return null;
+		} else if(marginOcc == null) {
+			return new NumUnitValue();
+		} else {
+			return new NumUnitValue(marginOcc.getValue());
+		}
+	}
+	
+	
+	// returns a NumUnitValue instance that represents the margin-bottom of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public NumUnitValue getMarginBottom(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence marginOcc = null;
+		if(styleClass != null){
+			marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginBottom, styleClass);
+		} else {
+			marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginBottom);
+		}
+		
+		if(marginOcc == null && styleClass != null){
+			return null;
+		} else if(marginOcc == null) {
+			return new NumUnitValue();
+		} else {
+			return new NumUnitValue(marginOcc.getValue());
+		}
+	}
+	
+	
+	// returns a NumUnitValue instance that represents the margin-left of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public NumUnitValue getMarginLeft(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence marginOcc = null;
+		if(styleClass != null){
+			marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginLeft, styleClass);
+		} else {
+			marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginLeft);
+		}
+		
+		if(marginOcc == null && styleClass != null){
+			return null;
+		} else if(marginOcc == null) {
+			return new NumUnitValue();
+		} else {
+			return new NumUnitValue(marginOcc.getValue());
+		}
+	}
+
+
+	// returns a ColorValue instance that represents the color of this element's border.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public ColorValue getBorderColor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence colorOcc = null;
+		if(styleClass != null){
+			colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderColor, styleClass);
+		} else {
+			colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderColor);
+		}
+		
+		if(colorOcc == null && styleClass != null){
+			return null;
+		} else if(colorOcc == null) {
+			return new ColorValue();
+		} else {
+			return new ColorValue(colorOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the color of this element's border-top.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public ColorValue getBorderTopColor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence colorOcc = null;
+		if(styleClass != null){
+			colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopColor, styleClass);
+		} else {
+			colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopColor);
+		}
+		
+		if(colorOcc == null && styleClass != null){
+			return null;
+		} else if(colorOcc == null) {
+			return new ColorValue();
+		} else {
+			return new ColorValue(colorOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the color of this element's border-right.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public ColorValue getBorderRightColor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence colorOcc = null;
+		if(styleClass != null){
+			colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightColor, styleClass);
+		} else {
+			colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightColor);
+		}
+		
+		if(colorOcc == null && styleClass != null){
+			return null;
+		} else if(colorOcc == null) {
+			return new ColorValue();
+		} else {
+			return new ColorValue(colorOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the color of this element's border-bottom.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public ColorValue getBorderBottomColor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence colorOcc = null;
+		if(styleClass != null){
+			colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomColor, styleClass);
+		} else {
+			colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomColor);
+		}
+		
+		if(colorOcc == null && styleClass != null){
+			return null;
+		} else if(colorOcc == null) {
+			return new ColorValue();
+		} else {
+			return new ColorValue(colorOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the color of this element's border-left.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public ColorValue getBorderLeftColor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence colorOcc = null;
+		if(styleClass != null){
+			colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftColor, styleClass);
+		} else {
+			colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftColor);
+		}
+		
+		if(colorOcc == null && styleClass != null){
+			return null;
+		} else if(colorOcc == null) {
+			return new ColorValue();
+		} else {
+			return new ColorValue(colorOcc.getValue());
+		}
+	}
+
+
 	// gdlBorderStyle [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderStyleTop [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderStyleRight [gdl:hover | gdl:focus | gdl:active]

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  1 02:37:25 2011	(r541)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Fri Jul  1 02:47:43 2011	(r542)
@@ -2,6 +2,7 @@
 
 import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine;
 import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback;
+import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;




More information about the Isidorus-cvs mailing list