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

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Thu Jul 14 15:41:09 UTC 2011


Author: lgiessmann
Date: Thu Jul 14 08:41:08 2011
New Revision: 619

Log:
gdl-frontend: Widgets: implemented positioning of elements placed within GdlView instances

Added:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/value/PositionStyleValue.java
Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPosition.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/view/GdlView.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPosition.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPosition.java	Thu Jul 14 05:05:36 2011	(r618)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPosition.java	Thu Jul 14 08:41:08 2011	(r619)
@@ -3,6 +3,8 @@
 import java.util.ArrayList;
 
 import com.google.gwt.core.client.JsArray;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Widget;
 
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
@@ -107,4 +109,15 @@
 			throw new InvalidGdlSchemaException("a position style value must be one of static, relative or absolute, but is " + positionStyleOcc.getValue());
 		}
 	}
+	
+	
+	public void setAttributes(Widget widget) throws InvalidGdlSchemaException{
+		if(widget == null) return;
+		
+		DOM.setStyleAttribute(widget.getElement(), "position", this.getPositionStyle().getCssValue());
+		if(this.getTop() != null) DOM.setStyleAttribute(widget.getElement(), "top", this.getTop().getCssValue());
+		if(this.getRight() != null) DOM.setStyleAttribute(widget.getElement(), "right", this.getTop().getCssValue());
+		if(this.getBottom() != null) DOM.setStyleAttribute(widget.getElement(), "bottom", this.getTop().getCssValue());
+		if(this.getLeft() != null) DOM.setStyleAttribute(widget.getElement(), "left", this.getTop().getCssValue());
+	}
 }

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 Jul 14 05:05:36 2011	(r618)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java	Thu Jul 14 08:41:08 2011	(r619)
@@ -377,7 +377,7 @@
 
 
 	@Override
-	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException {
+	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException, ExecutionException {
 		// TODO Auto-generated method stub
 		
 		return null;

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 Jul 14 05:05:36 2011	(r618)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java	Thu Jul 14 08:41:08 2011	(r619)
@@ -1253,7 +1253,7 @@
 	
 	
 	@Override
-	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException {
+	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException, ExecutionException {
 		// TODO: implement
 		return null;
 	}

Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/value/PositionStyleValue.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/value/PositionStyleValue.java	Thu Jul 14 08:41:08 2011	(r619)
@@ -0,0 +1,14 @@
+package us.isidor.gdl.anaToMia.Widgets.value;
+
+public enum PositionStyleValue implements CssValue{
+	STATIC,
+	RELATIVE,
+	ABSOLUTE;
+	
+
+	@Override
+	public String getCssValue() {
+		return this.toString().toLowerCase();
+	}
+
+}

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 Jul 14 05:05:36 2011	(r618)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java	Thu Jul 14 08:41:08 2011	(r619)
@@ -4,18 +4,22 @@
 
 import com.google.gwt.core.client.JsArray;
 import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Widget;
 
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
+import us.isidor.gdl.anaToMia.Widgets.base.GdlPosition;
 import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis;
 import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject;
 import us.isidor.gdl.anaToMia.Widgets.base.IGdlContainer;
 import us.isidor.gdl.anaToMia.Widgets.base.IGdlHasValue;
 import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
+import us.isidor.gdl.anaToMia.Widgets.environment.GdlInstantiator;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 
 
@@ -85,13 +89,23 @@
 	// by using it's defined position style depending on the GdlVisibleObject
 	// represented by ancestor. If ancestor is null current is the first topic
 	@Override
-	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException {
-		// TODO: getFirstContainee => change the behavior of getting the first topic
+	public GdlVisibleObject append(Topic ancestor, Topic current) throws InvalidGdlSchemaException, ExecutionException {
+		if(ancestor == null || current == null) throw new ExecutionException("to append \"" + TmHelper.getAnyIdOfTopic(current) + "\" on \"" + TmHelper.getAnyIdOfTopic(ancestor) + "\" both topics must be present");
+		GdlPosition position = new GdlPosition(TmHelper.getPositionOf(ancestor, current));
 		
-		// TODO: implement
-
+		GdlVisibleObject newObj = GdlInstantiator.instantiate(current);
+		GdlVisibleObject oldObj = null;
+		for (Widget widget : super.subElements){
+			if(((GdlVisibleObject)widget).getTmRepresentative().equals(ancestor)){
+				oldObj = (GdlVisibleObject)widget;
+				break;
+			}
+		}
 		
-		return null;
+		if(this.getTmRepresentative().equals(ancestor))this.mainPanel.add(newObj);
+		else DOM.insertBefore(this.mainPanel.getElement(), newObj.getElement(), oldObj.getElement());
+		position.setAttributes(newObj);	
+		return newObj;
 	}
 	
 	




More information about the Isidorus-cvs mailing list