[isidorus-cvs] r817 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base button container text view

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Fri Sep 2 07:58:44 UTC 2011


Author: lgiessmann
Date: Fri Sep  2 00:58:42 2011
New Revision: 817

Log:
gdl-frontend: Widgets: added a new base-structure for the validation of user data

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlSpace.java
   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/button/GdlActionButton.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlInfo.java
   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/GdlTitle.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlDefaultTopicView.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlSpace.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlSpace.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlSpace.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -1,7 +1,6 @@
 package us.isidor.gdl.anaToMia.Widgets.base;
 
 import java.util.ArrayList;
-
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
@@ -39,4 +38,11 @@
 	public void fixValue(){
 		// has no effect on this element
 	}
+	
+	
+	@Override
+	public void validate() throws ExecutionException {
+		// this element has no editable content and is always valid
+		return;
+	}
 }

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	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -2297,4 +2297,10 @@
 		
 		return result;
 	}
+
+
+	// validates the entered user data, if it is invalid a ExecutionException is thrown 
+	public void validate() throws ExecutionException{
+		// TODO: implement
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -270,4 +270,11 @@
 	public void fixValue(){
 		// has no effect on this element
 	}
+	
+	
+	@Override
+	public void validate() throws ExecutionException {
+		// this element has no editable content and is always valid
+		return;
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -210,6 +210,136 @@
 			((ListWidget)((ButtonableObject)this.subElements.get(0)).getMainObject()).insertWidget(item, position);
 		}
 	}
+
+	
+	// this class wraps a list item, i.e. a div element within a li element
+	protected class ListItem{
+		private Element liElement = null;
+		private Element divElement = null;
+		private ArrayList<GdlVisibleObject> contents = new ArrayList<GdlVisibleObject>();
+		
+		
+		public ListItem(){
+			this.liElement = DOM.createElement("li");
+			this.divElement = DOM.createElement("div");
+			this.liElement.insertFirst(this.divElement);
+		}
+		
+		public ListItem(Element parentList){
+			this();
+			this.appendToList(parentList);
+		}
+		
+		// inserts the this instance into the passed list element,
+		// if this instance is not bound yet
+		public void appendToList(Element parentList){
+			if(parentList != null && this.liElement.getParentNode() == null){
+				Node lastChild = parentList.getLastChild();
+				if(lastChild != null){
+					parentList.insertAfter(this.liElement, lastChild);
+				} else {
+					parentList.insertFirst(this.liElement);
+				}
+			}
+		}
+		
+		
+		// inserts the this instance into the passed list element
+		// after the passed ListItem, if this instance is not bound yet
+		public void appendToList(Element parentList, ListItem previous){
+			if(parentList == null) return;
+			
+			if(previous == null){
+				this.appendToList(parentList);
+			}else{
+				parentList.insertAfter(this.liElement, previous.liElement);
+			}
+		}
+		
+		
+		// removes this instance from the set list
+		public void removeFromList(){
+			this.liElement.removeFromParent();
+		}
+		
+		// appends the content element to the inner div item
+		public void appendContentToListItem(GdlVisibleObject content){
+			if(content != null){
+				Node lastChild = this.divElement.getLastChild();
+				if(lastChild != null){
+					this.divElement.insertAfter(content.getElement(), lastChild);
+				} else {
+					this.divElement.insertFirst(content.getElement());
+				}
+				
+				contents.add(content);
+			}
+		}
+	
+		
+		public void validate() throws ExecutionException {
+			for (GdlVisibleObject content : this.contents) content.validate();
+		}
+	}
+	
+	
+	@Override
+	public void validate() throws ExecutionException {
+		for (Widget ctrl : this.subElements) {
+			((ListWidget)((ButtonableObject)ctrl).getMainObject()).validate();
+		}
+	}
+
+
+	@Override
+	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException, ExecutionException {
+		// TODO Auto-generated method stub
+		if(this.subElements.size() == 0) return null;
+		if(this.storedItems == null) this.storedItems = this.containsItems();
+		
+		// the ancestor element can be ignore, since the current idx can be looked up
+		// from the storedItem array list directly
+		int idx = -1;
+		for (Pair<Topic, Integer> pair : this.storedItems) if(pair.getFirst().equals(current)) idx = pair.getSecond();
+		
+		ListWidget list = (ListWidget)((ButtonableObject)this.subElements.get(0)).getMainObject();
+		GdlVisibleObject newObj = GdlInstantiator.instantiate(current, this.receivedData, GdlList.this);
+		list.insertWidget(newObj, idx);
+		
+		return newObj;
+	}
+	
+
+	// returns all topics that are bound to this tm representative topic via a
+	// contains association i an ordered list
+	@Override
+	public ArrayList<Topic> contains() throws InvalidGdlSchemaException {
+		ArrayList<Topic> result = new ArrayList<Topic>();
+		for (Pair<Topic, Integer> pair : TmHelper.listContains(super.getTmRepresentative()))
+			result.add(pair.getFirst());
+		
+		return result;
+	}
+	
+	
+	// returns an ordered list of items with their index
+	public ArrayList<Pair<Topic, Integer>> containsItems() throws InvalidGdlSchemaException{
+		return TmHelper.listContains(super.getTmRepresentative());
+	}
+	
+	
+	@Override
+	@Deprecated
+	public ArrayList<String> getSelectedValues(){
+		return new ArrayList<String>();
+	}
+	
+	
+	@Override
+	@Deprecated
+	public void fixValue(){
+		// has no effect on this element
+	}
 	
 	
 	// Wraps a ul an ol element as a widget based on a SimplePanel
@@ -253,10 +383,10 @@
 		
 		// inserts the passed widget directly before the first item that
 		// has a greater position index
-		public void insertWidget(Widget widget, int position){
+		public void insertWidget(GdlVisibleObject widget, int position){
 			ListItem previosItem = this.getItemBeforeIndex(position);
 			ListItem item = new ListItem(this.listElement);
-			item.appendContentToListItem(widget.getElement());
+			item.appendContentToListItem(widget);
 			this.appendListItem(item, previosItem);
 		}
 		
@@ -299,6 +429,13 @@
 		}
 		
 		
+		public void validate() throws ExecutionException {
+			for (Pair<ListItem, Integer> item: this.itemsAndIndexes) {
+				item.getFirst().validate();
+			}
+		}
+		
+		
 		public void setId(String id){
 			DOM.setElementAttribute(this.basePanel.getElement(), "id", id);
 		}
@@ -339,117 +476,4 @@
 			return this.addDomHandler(handler, MouseDownEvent.getType());
 		}
 	}
-	
-	
-	// this class wraps a list item, i.e. a div element within a li element
-	protected class ListItem{
-		private Element liElement = null;
-		private Element divElement = null;
-		
-		public ListItem(){
-			this.liElement = DOM.createElement("li");
-			this.divElement = DOM.createElement("div");
-			this.liElement.insertFirst(this.divElement);
-		}
-		
-		public ListItem(Element parentList){
-			this();
-			this.appendToList(parentList);
-		}
-		
-		// inserts the this instance into the passed list element,
-		// if this instance is not bound yet
-		public void appendToList(Element parentList){
-			if(parentList != null && this.liElement.getParentNode() == null){
-				Node lastChild = parentList.getLastChild();
-				if(lastChild != null){
-					parentList.insertAfter(this.liElement, lastChild);
-				} else {
-					parentList.insertFirst(this.liElement);
-				}
-			}
-		}
-		
-		
-		// inserts the this instance into the passed list element
-		// after the passed ListItem, if this instance is not bound yet
-		public void appendToList(Element parentList, ListItem previous){
-			if(parentList == null) return;
-			
-			if(previous == null){
-				this.appendToList(parentList);
-			}else{
-				parentList.insertAfter(this.liElement, previous.liElement);
-			}
-		}
-		
-		
-		// removes this instance from the set list
-		public void removeFromList(){
-			this.liElement.removeFromParent();
-		}
-		
-		// appends the content element to the inner div item
-		public void appendContentToListItem(Element content){
-			if(content != null){
-				Node lastChild = this.divElement.getLastChild();
-				if(lastChild != null){
-					this.divElement.insertAfter(content, lastChild);
-				} else {
-					this.divElement.insertFirst(content);
-				}
-			}
-		}
-	}
-
-
-	@Override
-	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException, ExecutionException {
-		// TODO Auto-generated method stub
-		if(this.subElements.size() == 0) return null;
-		if(this.storedItems == null) this.storedItems = this.containsItems();
-		
-		// the ancestor element can be ignore, since the current idx can be looked up
-		// from the storedItem array list directly
-		int idx = -1;
-		for (Pair<Topic, Integer> pair : this.storedItems) if(pair.getFirst().equals(current)) idx = pair.getSecond();
-		
-		ListWidget list = (ListWidget)((ButtonableObject)this.subElements.get(0)).getMainObject();
-		GdlVisibleObject newObj = GdlInstantiator.instantiate(current, this.receivedData, GdlList.this);
-		list.insertWidget(newObj, idx);
-		
-		return newObj;
-	}
-	
-
-	// returns all topics that are bound to this tm representative topic via a
-	// contains association i an ordered list
-	@Override
-	public ArrayList<Topic> contains() throws InvalidGdlSchemaException {
-		ArrayList<Topic> result = new ArrayList<Topic>();
-		for (Pair<Topic, Integer> pair : TmHelper.listContains(super.getTmRepresentative()))
-			result.add(pair.getFirst());
-		
-		return result;
-	}
-	
-	
-	// returns an ordered list of items with their index
-	public ArrayList<Pair<Topic, Integer>> containsItems() throws InvalidGdlSchemaException{
-		return TmHelper.listContains(super.getTmRepresentative());
-	}
-	
-	
-	@Override
-	@Deprecated
-	public ArrayList<String> getSelectedValues(){
-		return new ArrayList<String>();
-	}
-	
-	
-	@Override
-	@Deprecated
-	public void fixValue(){
-		// has no effect on this element
-	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -244,6 +244,14 @@
 	}
 	
 	
+	@Override
+	public void validate() throws ExecutionException {
+		for (Widget ctrl : this.subElements) {
+			((UnitWidget)((ButtonableObject)ctrl).getMainObject()).validate();
+		}
+	}
+	
+	
 	protected class UnitWidget extends Composite implements HasFocusHandlers, HasBlurHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseDownHandlers, HasMouseUpHandlers{
 		private CaptionPanel basePanel = new CaptionPanel();
 		private AbsolutePanel containerPanel = new AbsolutePanel();
@@ -370,5 +378,14 @@
 				e.printStackTrace();
 			}
 		}
+	
+		
+		public void validate() throws ExecutionException{
+			for (Widget ctrl : this.subElements) {
+				if(ctrl instanceof GdlVisibleObject){
+					((GdlVisibleObject)ctrl).validate();
+				}
+			}
+		}
 	}
 }
\ No newline at end of file

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlInfo.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlInfo.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlInfo.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -108,4 +108,11 @@
 	public ArrayList<String> getSelectedValues(){
 		return new ArrayList<String>();
 	}
+	
+	
+	@Override
+	public void validate() throws ExecutionException {
+		// this element has no editable content and is always valid
+		return;
+	}
 }

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	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -58,6 +58,13 @@
 	}
 	
 	
+	@Override
+	public void validate() throws ExecutionException {
+		// this element has no editable content and is always valid
+		return;
+	}
+	
+	
 	private ReferenceWidget createReference() throws InvalidGdlSchemaException, ExecutionException {
 		ReferenceWidget reference = new ReferenceWidget();
 		DOM.setElementAttribute(reference.getElement(), "id", this.getId() + "__GDL_" + this.subElements.size());

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -449,6 +449,13 @@
 	}
 	
 	
+	@Override
+	public void validate() throws ExecutionException {
+		// this element has no editable content and is always valid
+		return;
+	}
+	
+	
 	// this class represents the acutal content of this widget, i.e.
 	// it wraps a h1, h2, h3 or h4 element
 	protected class TitleWidget extends Composite implements HasMouseDownHandlers, HasMouseUpHandlers, HasMouseOverHandlers, HasMouseOutHandlers, HasBlurHandlers, HasFocusHandlers{

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -223,6 +223,13 @@
 		
 		return result;
 	}
+
+	
+	@Override
+	public void validate() throws ExecutionException {
+		for (Widget ctrl : this.subElements)
+			if(ctrl instanceof AssociationItem) ((AssociationItem)ctrl).validate();
+	}
 	
 
 	// This class represents a single association that is displayed.

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlDefaultTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlDefaultTopicView.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlDefaultTopicView.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -15,4 +15,5 @@
 	}
 	// TODO: implement
 	
+	
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java	Thu Sep  1 09:18:20 2011	(r816)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java	Fri Sep  2 00:58:42 2011	(r817)
@@ -125,4 +125,14 @@
 			return this.hiddenValues;
 		}
 	}
+	
+	
+	@Override
+	public void validate() throws ExecutionException {
+		for (Widget ctrl : this.subElements) {
+			if(ctrl instanceof GdlVisibleObject){
+				((GdlVisibleObject)ctrl).validate();
+			}
+		}
+	}
 }
\ No newline at end of file




More information about the Isidorus-cvs mailing list