[isidorus-cvs] r592 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base text

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Sat Jul 9 06:26:36 UTC 2011


Author: lgiessmann
Date: Fri Jul  8 23:26:35 2011
New Revision: 592

Log:
gdl-frontend: Widgets: implemented some getter methods for the default values of the GdlReference object (cursor, color, text-decoration)

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/text/GdlReference.java

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 13:39:15 2011	(r591)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Fri Jul  8 23:26:35 2011	(r592)
@@ -6,6 +6,7 @@
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pattern;
 import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback;
+import us.isidor.gdl.anaToMia.Widgets.text.GdlReference;
 import us.isidor.gdl.anaToMia.Widgets.text.GdlTitle;
 import us.isidor.gdl.anaToMia.Widgets.values.CursorValue;
 import com.google.gwt.core.client.EntryPoint;
@@ -121,7 +122,7 @@
 			fsHover.addTheme(gdlHover);
 			
 			
-			GdlTitle tmp = new GdlTitle(tmpRepresentative);
+			GdlReference tmp = new GdlReference(tmpRepresentative);
 			this.mainPanel.add(tmp);
 		}catch(Exception e){
 			e.printStackTrace();

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java	Fri Jul  8 13:39:15 2011	(r591)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java	Fri Jul  8 23:26:35 2011	(r592)
@@ -11,9 +11,12 @@
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
 
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
+import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis;
 import us.isidor.gdl.anaToMia.Widgets.base.IGdlHasValue;
 import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
@@ -21,6 +24,9 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.HoverStyleHandler;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
+import us.isidor.gdl.anaToMia.Widgets.values.CursorValue;
+import us.isidor.gdl.anaToMia.Widgets.values.TextDecorationValue;
 
 public class GdlReference extends GdlTextObject implements IGdlHasValue{
 	// some constructors
@@ -30,12 +36,12 @@
 	
 	public GdlReference(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
 		super(tmRepresentative);
-		// TODO: create a ListBox element for each TM-elem
+		// TODO: create a Reference element for each TM-elem
 		this.createReference();
 	}
 	
 	
-	private Reference createReference() throws InvalidGdlSchemaException {
+	private Reference createReference() throws InvalidGdlSchemaException, ExecutionException {
 		Reference reference = new Reference();
 		DOM.setElementAttribute(reference.getElement(), "id", this.getId() + "__GDL_" + this.subElements.size());
 		super.addToContainerPanel(reference);
@@ -49,32 +55,105 @@
 		reference.addFocusHandler(fsHandler);
 		reference.addBlurHandler(fsHandler);
 		// TODO: register a click handler that handles the reference behavior
+		reference.setText("reference !!!"); // TODO: remove
+		super.setGdlStyle(reference);
 		return reference;
 	}
 	
 	
-	/* TODO: implement
-	   The default values of particular occurrences are set as follows:
-    	 gdl:text-decoration: underline
-    	 gdl:color (unscoped or scoped by gdl:hover and/or gdl:focus): #0000FF
-    	 gdl:color (scoped by gdl:active): #FF0000
-    	 gdl:cursor: pointer
-	 */
+	// returns a ColorValue instance that represents the text color of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null.
+	public ColorValue getColor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence colorOcc = null;
+		if(styleClass != null){
+			colorOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlColor, styleClass);
+		} else {
+			colorOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlColor);
+		}
+
+		if(colorOcc == null && (styleClass == null || styleClass.equals(GdlPsis.Scope.gdlFocus) || styleClass.equals(GdlPsis.Scope.gdlHover))){
+			return new ColorValue("#0000FF");
+		}else if(colorOcc == null && styleClass.equals(GdlPsis.Scope.gdlActive)){
+			return null;
+		}else {
+			return new ColorValue(colorOcc.getValue());
+		}
+	}
 	
 	
+	// returns a CursorValue instance that represents the cursor of this element.
+	// 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.
+	@Override
+	public CursorValue getCursor(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence cursorOcc = null;
+		if(styleClass != null){
+			cursorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlCursor, styleClass);
+		} else {
+			cursorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlCursor);
+		}
+
+		if(cursorOcc == null && styleClass != null){
+			return null;
+		} else if(cursorOcc == null) {
+			return CursorValue.POINTER;
+		} else {
+			try{
+				return CursorValue.valueOf(cursorOcc.getValue().toUpperCase().replace("-", "_"));
+			}catch(IllegalArgumentException e){
+				String values = "auto, default, crosshair, pointer, move, n-resize, ne-resize," +
+				"nw-resize, e-resize, se-resize, s-resize, sw-resize, w-resize," +
+				"text, wait, help, or progress";
+				throw new InvalidGdlSchemaException("cursor must be set to one of " + values + ", but is " + cursorOcc.getValue());
+			}
+		}	
+	}
+	
+	
+	// returns a TextDecoarionValue instance that represents the text-decoration of this element.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// or null.
+	@Override
+	public TextDecorationValue getTextDecoration(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence decorationOcc = null;
+		if(styleClass != null){
+			decorationOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlTextDecoration, styleClass);
+		} else {
+			decorationOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlTextDecoration);
+		}
+
+		if(decorationOcc == null && styleClass != null){
+			return null;
+		} else if(decorationOcc == null) {
+			return TextDecorationValue.UNDERLINE;
+		} else {
+			try{
+				return TextDecorationValue.valueOf(decorationOcc.getValue().toUpperCase());
+			}catch(IllegalArgumentException e){
+				throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlTextDecoration + " must be set to one of \"underline\", \"overline\", \"line-through\", \"blink\" or \"none\", but is \"" + decorationOcc.getValue() + "\"");
+			}
+		}
+	}
 	
 	
 	@Override
 	public ArrayList<String> getStringValue() {
-		// TODO Auto-generated method stub
-		return null;
+		ArrayList<String> result = new ArrayList<String>();
+		for (Widget widget : this.subElements) {
+			result.add(((Reference)widget).getText());
+		}
+		return result;
 	}
+	
 
 	@Override
 	public ArrayList<Pair<TopicMapsTypes, Object>> getTmValue() {
 		// TODO Auto-generated method stub
 		return null;
 	}
+	
 
 	@Override
 	public boolean validate() {
@@ -83,10 +162,6 @@
 	}
 	
 	
-	
-	
-	
-	
 	// this class wraps a Label that is used as 
 	protected class Reference extends Label implements HasFocusHandlers, HasBlurHandlers {
 		public Reference(){




More information about the Isidorus-cvs mailing list