[isidorus-cvs] r657 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets/base src/us/isidor/gdl/anaToMia/Widgets/container war/gdl_widgets

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Fri Jul 22 08:31:08 UTC 2011


Author: lgiessmann
Date: Fri Jul 22 01:31:07 2011
New Revision: 657

Log:
gdl-frontend: Widgets: fixed a bug when searching for the first containee of a container; extended the test gdl file

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Thu Jul 21 02:55:39 2011	(r656)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Fri Jul 22 01:31:07 2011	(r657)
@@ -239,7 +239,7 @@
 			JsArray<Role> selection = assoc.getRoles(pair.getSecond());
 			int i = 0;
 			for(; i != selection.length(); ++i)
-				if(isInstanceOf(selection.get(i).getPlayer(), pair.getFirst())) break;
+				if(pair.getFirst() == null || isInstanceOf(selection.get(i).getPlayer(), pair.getFirst())) break;
 			
 			if(i == selection.length()) return false;
 		}
@@ -250,7 +250,7 @@
 			Role currentRole = roles.get(i);
 			int j = 0;
 			for(; j != rolePlayertypesAndTypes.size(); ++j)
-				if(currentRole.getType().equals(rolePlayertypesAndTypes.get(j).getSecond()) && isInstanceOf(currentRole.getPlayer(), rolePlayertypesAndTypes.get(j).getFirst())) break;
+				if(currentRole.getType().equals(rolePlayertypesAndTypes.get(j).getSecond()) && (isInstanceOf(currentRole.getPlayer(), rolePlayertypesAndTypes.get(j).getFirst()) || rolePlayertypesAndTypes.get(j).getFirst() == null)) break;
 			
 			if(j == rolePlayertypesAndTypes.size()) return false;
 		}
@@ -310,22 +310,11 @@
 		localRolePlayertypesAndTypes.add(new Pair<Topic, Topic>(typeOfTopic, roleType));
 			
 		for (Association assoc : allPotentialAssocs){
-			if(getAnyIdOfTopic(topic).equals("http://psi.test.org/gdl-test/unit-1")){ // TODO: remove
-				String str = "";
-				for (Pair<Topic, Topic> pair : localRolePlayertypesAndTypes)
-					str += ", [" + getAnyIdOfTopic(pair.getFirst()) + ", " + getAnyIdOfTopic(pair.getSecond()) + "]";
-				
-				Window.alert(str);
-			}
-			
 			if(hasRoles(assoc, localRolePlayertypesAndTypes)) assocsWoScope.add(assoc);
 		}
 			
 		for (Association assoc : assocsWoScope) if(hasThemes(assoc, scope)) result.add(assoc);
 		
-		
-		
-		
 		return result;
 	}
 
@@ -424,15 +413,7 @@
 		rolePlayertypesAndTypes.add(new Pair<Topic, Topic>(visibleObject, descendantRoleType));
 		rolePlayertypesAndTypes.add(new Pair<Topic, Topic>(position, descriptorRoleType));
 		ArrayList<Association> descendantAssocsOfContainer = TmHelper.getAssociationsOfTopic(container, ancestorRoleType, positionAssocType, null, rolePlayertypesAndTypes);
-		
-		if(getAnyIdOfTopic(container).equals("http://psi.test.org/gdl-test/unit-1")){ // TODO: remove
-			Association assoc = container.getRolesPlayed(ancestorRoleType, positionAssocType).get(0).getParent();
-			String str = "";
-			for(int i = 0; i != assoc.getRoles().length(); ++i)
-				str += ", [" + getAnyIdOfTopic(assoc.getRoles().get(i).getType()) + ", " + getAnyIdOfTopic(assoc.getRoles().get(i).getPlayer()) + "]";
-			Window.alert(getAnyIdOfTopic(container) + " >> " + descendantAssocsOfContainer.size() + " >> " + str);
-		}
-		
+				
 		ArrayList<Topic> validDescendants = new ArrayList<Topic>();
 		for (Association descendantAssociation : descendantAssocsOfContainer) {
 			JsArray<Role> descendantRoles = descendantAssociation.getRoles(descendantRoleType);
@@ -448,7 +429,7 @@
 			for (Topic topic : validDescendants) bindings += ", " + getAnyIdOfTopic(topic);
 			if(bindings.length() == 0) bindings = "[]";
 			else bindings = bindings.substring(2);
-			throw new InvalidGdlSchemaException("the topic " + top + " must be bound to exaclty one ancestor element, but found " + bindings);
+			throw new InvalidGdlSchemaException("the topic " + top + " must be bound to exaclty one descendant element, but found " + bindings);
 		}else {
 			return validDescendants.get(0);
 		}

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 21 02:55:39 2011	(r656)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java	Fri Jul 22 01:31:07 2011	(r657)
@@ -2,6 +2,7 @@
 
 import java.util.ArrayList;
 import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Window;
 import com.google.gwt.event.dom.client.BlurEvent;
 import com.google.gwt.event.dom.client.BlurHandler;
 import com.google.gwt.event.dom.client.FocusEvent;
@@ -22,6 +23,7 @@
 import com.google.gwt.event.dom.client.MouseUpHandler;
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.AbsolutePanel;
 import com.google.gwt.user.client.ui.CaptionPanel;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Widget;
@@ -40,6 +42,7 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.text.GdlTextObject;
 import us.isidor.gdl.anaToMia.Widgets.value.BorderStyleValue;
+import us.isidor.gdl.anaToMia.Widgets.value.TextDecorationValue;
 
 
 public class GdlUnit extends GdlTextObject implements IGdlContainer {	
@@ -60,7 +63,7 @@
 	// creates a unit element or returns the one, if there is a unit element
 	// in the subElements array
 	private void createUnit() throws InvalidGdlSchemaException, ExecutionException{
-		UnitWidget unit = new UnitWidget();
+		UnitWidget unit = new UnitWidget(this.getTmRepresentative());
 		ActiveStyleHandler asHandler = new ActiveStyleHandler(this);
 		FocusStyleHandler fsHandler = new FocusStyleHandler(this);
 		HoverStyleHandler hsHandler = new HoverStyleHandler(this);
@@ -133,12 +136,11 @@
 		}
 	}
 
-	
+
 	// sets all GDL styles that are defined by the topic map representative to tha passed widget
 	@Override
 	public void setGdlStyle(Widget widget) throws InvalidGdlSchemaException, ExecutionException {
 		super.setGdlStyle(widget);
-		
 		this.setUnitName(widget, this.getUnitName());
 	}
 
@@ -170,12 +172,14 @@
 	
 	protected class UnitWidget extends Composite implements HasFocusHandlers, HasBlurHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseDownHandlers, HasMouseUpHandlers{
 		private CaptionPanel basePanel = new CaptionPanel();
+		private AbsolutePanel containerPanel = new AbsolutePanel();
 		private Topic tmRepresentative = null;
 		private ArrayList<Widget> subElements = new ArrayList<Widget>();
 		
 		
 		private UnitWidget(){
 			initWidget(this.basePanel);
+			this.basePanel.add(this.containerPanel);
 		}
 		
 		
@@ -207,15 +211,15 @@
 			
 			this.subElements.add(newObj);
 			if(this.getTmRepresentative().equals(ancestor)){
-				this.basePanel.add(newObj);
+				this.containerPanel.add(newObj);
 			}
 			else{
 				Element elemBefore = oldObj.getElement();
 				Element elemAfter = DOM.getNextSibling(elemBefore);
 				// insert before seems to be a more accepted and stable
 				// way of inserting new child elements than insertAfter
-				if(elemAfter == null) this.basePanel.add(newObj);
-				else this.basePanel.getElement().insertBefore(newObj.getElement(), elemAfter);
+				if(elemAfter == null) this.containerPanel.add(newObj);
+				else this.containerPanel.getElement().insertBefore(newObj.getElement(), elemAfter);
 			}			
 			position.setAttributes(newObj);
 			return newObj;

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Thu Jul 21 02:55:39 2011	(r656)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Fri Jul 22 01:31:07 2011	(r657)
@@ -43,6 +43,8 @@
            {"subject_identifiers":["[gdl:unit-name]"], "instance_of":["si:[tmcl:occurrence-type]"]},
            {"subject_identifiers":["[gdl:height]"], "instance_of":["si:[tmcl:occurrence-type]"]},
            {"subject_identifiers":["[gdl:font-weight]"], "instance_of":["si:[tmcl:occurrence-type]"]},
+           {"subject_identifiers":["[gdl:float]"], "instance_of":["si:[tmcl:occurrence-type]"]},
+           {"subject_identifiers":["[gdl:clear]"], "instance_of":["si:[tmcl:occurrence-type]"]},
            {"subject_identifiers":["[doc:default-creator-topic-view-1]"], "instance_of":["si:[gdl:Default-Creator-Topic-View]"], "names":[{"value": "Def. Creator View 1", "type":"si:[gdl:view-name]"}], "occurrences":[{"type":"si:[gdl:id]", "value":"default_creator_topic_view_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:background-color]", "value":"#ccc"}, {"type":"si:[gdl:width]", "value":"500px"}, {"type":"si:[gdl:height]", "value":"600px"}]},
            {"subject_identifiers":["[gdl:View]"]},
            {"subject_identifiers":["[gdl:Text]"]},
@@ -56,8 +58,10 @@
            {"subject_identifiers":["[doc:text-1]"], "instance_of":["si:[gdl:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"text_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:readonly]", "value":"false", "datatype":"[xsd:boolean]"}]},
            {"subject_identifiers":["[doc:unit-1]"], "instance_of":["si:[gdl:Unit]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:unit-name]", "value":"unit 1"}, {"type":"si:[gdl:width]", "value":"400px"}, {"type":"si:[gdl:height]", "value":"200px"}, {"type":"si:[gdl:border-style]", "value":"dashed"}, {"type":"si:[gdl:border-width]", "value":"1px"}, {"type":"si:[gdl:text-decoration]", "value":"line-through"},{"type":"si:[gdl:background-color]", "value":"lime"}]},
            {"subject_identifiers":["[doc:title-1]"], "instance_of":["si:[gdl:Title]"], "occurrences":[{"type":"si:[gdl:id]", "value":"title_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:text-decoration]", "value":"underline"}, {"type":"si:[gdl:background-color]", "value":"#ccc"}, {"type":"si:[gdl:font-weight]", "value":"bold"}]},
-    	   {"subject_identifiers":["[doc:unit-1-reference]"], "instance_of":["si:[gdl:Reference]"]},
-    	   {"subject_identifiers":["[doc:pos-of-unit-1-reference]"], "instance_of":["si:[gdl:Reference]"]},
+    	   {"subject_identifiers":["[doc:unit-1-reference]"], "instance_of":["si:[gdl:Reference]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_reference_id"},{"type":"si:[gdl:float]", "value":"left"}]},
+    	   {"subject_identifiers":["[doc:unit-1-text]"], "instance_of":["si:[gdl:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_text_id"}, {"type":"si:[gdl:clear]","value":"right"}]},
+    	   {"subject_identifiers":["[doc:pos-of-unit-1-reference]"], "instance_of":["si:[gdl:Position]"]},
+    	   {"subject_identifiers":["[doc:pos-of-unit-1-text]"], "instance_of":["si:[gdl:Position]"]},
            {"subject_identifiers":["[doc:reference-1]"], "instance_of":["si:[gdl:Reference]"], "occurrences":[{"type":"si:[gdl:id]", "value":"reference_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:margin-left]", "value":"200px"}, {"type":"si:[gdl:background-color]", "value":"yellow"}]},
            {"subject_identifiers":["[doc:list-box-1]"], "instance_of":["si:[gdl:List-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"list_box_1_id", "datatype":"[xsd:ID]"}]},
            {"subject_identifiers":["[gdl:Value]"], "instance_of":["si:[tmcl:topic-type]"]},
@@ -159,5 +163,7 @@
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:person-list]"},{"type":"si:[gdl:containee]", "player":"si:[doc:list-item-2]"}, {"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-2]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:person-list]"},{"type":"si:[gdl:containee]", "player":"si:[doc:list-item-3]"}, {"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-3]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-reference]"}]},
-                 {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-reference]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-reference]"}]}
+                 {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-text]"}]},
+                 {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-reference]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-reference]"}]},
+                 {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-reference]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-reference]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-text]"}]}
                 ]}
\ No newline at end of file




More information about the Isidorus-cvs mailing list