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

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Wed Jul 27 18:11:29 UTC 2011


Author: lgiessmann
Date: Wed Jul 27 11:11:28 2011
New Revision: 680

Log:
gdl-frontend: Widgets: implementd GdlInfo

Added:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlInfo.java
Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.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/base/TestClass.java
   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/environment/GdlInstantiator.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/TODO.txt
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt	Wed Jul 27 11:11:28 2011	(r680)
@@ -1,3 +1,4 @@
+* Implement GdlInfo
 * Implement TopicMaps data consumption
 * Implement TopicMaps data generation
 * Fix css-pseudo-class-handlers (=> Buttons)
\ No newline at end of file

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java	Wed Jul 27 11:11:28 2011	(r680)
@@ -57,6 +57,7 @@
 		public final static String gdlDefaultTmInstanceValue = gdl + "Default-TM-Instance-Value";
 		public final static String gdlDatatype = gdl + "Datatype";
 		public final static String gdlType = gdl + "Type";
+		public final static String gdlInfo = gdl + "Info";
 		public final static String gdlVariantNameScope = gdl + "Variant-Name-Scope";
 		public final static String gdlVariantNameReifier = gdl + "Variant-Name-Reifier";
 		public final static String gdlVariantNameIdentifiers = gdl + "Variant-Name-Identifiers";

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	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Wed Jul 27 11:11:28 2011	(r680)
@@ -13,6 +13,7 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.environment.MultipleHandlerRegistration;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.text.GdlInfo;
 import us.isidor.gdl.anaToMia.Widgets.value.AbsoluteNumValue;
 import us.isidor.gdl.anaToMia.Widgets.value.AutoNumUnitValue;
 import us.isidor.gdl.anaToMia.Widgets.value.AutoNumValue;
@@ -70,6 +71,7 @@
 	protected ArrayList<Widget> subElements = new ArrayList<Widget>();
 	protected ArrayList<Pair<Widget, ArrayList<EventHandler>>> eventHandlers = new ArrayList<Pair<Widget, ArrayList<EventHandler>>>();
 	protected ArrayList<Pair<Topic, Integer>> actionButtonsAndPositions = null;
+	protected ArrayList<GdlInfo> infoElements = new ArrayList<GdlInfo>();
 	
 
 	// some constructors
@@ -94,6 +96,18 @@
 		return this.tmRepresentative;
 	}
 	
+	
+	// sets all info elements as defined in the GDL
+	public void setInfoElements() throws InvalidGdlSchemaException, ExecutionException{
+		ArrayList<Topic> infos = TmHelper.topicContainsInfo(this.tmRepresentative);
+		
+		for (Topic info : infos){
+			GdlInfo elem = (GdlInfo)GdlInstantiator.instantiate(info);
+			this.infoElements.add(elem);
+			elem.setPosition(this.mainPanel);			
+		}
+	}
+	
 		
 	// this method should be invoked if a new sub-element is added to this instance
 	protected ButtonableObject addToContainerPanel(Widget widget) throws ExecutionException, InvalidGdlSchemaException{
@@ -1785,4 +1799,23 @@
 			Window.alert("could not apply the default CSS style >> " + e.getClass() + " >> " + e.getMessage());
 		}
 	}
+	
+	
+	// removes all GdlInfo elements. They must be remove explicitly, since they are
+	// bound to the root panel/body
+	public void clear(){
+		for (GdlInfo elem : this.infoElements)
+			elem.removeFromParent();
+	}
+	
+	
+	@Override
+	public void onAttach(){
+		super.onAttach();
+		try{
+			this.setInfoElements();
+		}catch(Exception e){
+			e.printStackTrace();
+		}
+	}
 }

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	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Wed Jul 27 11:11:28 2011	(r680)
@@ -51,10 +51,7 @@
 				}
 			});
 			
-			mainPanel.add(requestButton);
-			
-		
-			
+			mainPanel.add(requestButton);		
 		
 		/*
 		// only for testing

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	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Wed Jul 27 11:11:28 2011	(r680)
@@ -329,6 +329,19 @@
 	}
 	
 	
+	// returns all instances of gdl:Info that are related to the passed topic via a contains association
+	public static ArrayList<Topic> topicContainsInfo(Topic container) {
+		if(container == null) return new ArrayList<Topic>();	
+		TopicMap tm = container.getTopicMap();
+		Topic containsAssocType = getTopicByPsi(GdlPsis.AssociationType.gdlContains, tm);
+		Topic containerRoleType = getTopicByPsi(GdlPsis.RoleType.gdlContainer, tm);
+		Topic info = getTopicByPsi(GdlPsis.TopicType.gdlInfo, tm);
+		Topic containeeRoleType = getTopicByPsi(GdlPsis.RoleType.gdlContainee, tm);
+		
+		return getOtherPlayerOfBinaryAssociation(container, containerRoleType, containsAssocType, null, info, containeeRoleType);
+	}
+	
+	
 	// Returns all pairs of topics and string that are of type gdl:Action-Button and are
 	// bound to the passed topic via a gdl:contains and via a gdl:button-position association.
 	// The topic is the gdl:Action-Button instance, whereas the string is the value of the

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java	Wed Jul 27 11:11:28 2011	(r680)
@@ -24,6 +24,7 @@
 import us.isidor.gdl.anaToMia.Widgets.complexData.GdlVideo;
 import us.isidor.gdl.anaToMia.Widgets.container.GdlList;
 import us.isidor.gdl.anaToMia.Widgets.container.GdlUnit;
+import us.isidor.gdl.anaToMia.Widgets.text.GdlInfo;
 import us.isidor.gdl.anaToMia.Widgets.text.GdlListBox;
 import us.isidor.gdl.anaToMia.Widgets.text.GdlReference;
 import us.isidor.gdl.anaToMia.Widgets.text.GdlText;
@@ -44,6 +45,8 @@
 			return new GdlSpace(tmRepresentative);
 		}else if(TmHelper.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlTitle)){
 			return new GdlTitle(tmRepresentative);
+		}else if(TmHelper.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlInfo)){
+			return new GdlInfo(tmRepresentative);
 		}else if(TmHelper.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlReference)){
 			return new GdlReference(tmRepresentative);
 		}else if(TmHelper.isInstanceOf(tmRepresentative, GdlPsis.TopicType.gdlRadioButton)){

Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlInfo.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/text/GdlInfo.java	Wed Jul 27 11:11:28 2011	(r680)
@@ -0,0 +1,61 @@
+package us.isidor.gdl.anaToMia.Widgets.text;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
+import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
+import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
+public class GdlInfo extends GdlTextObject {
+	// some constructors
+	protected GdlInfo(){
+		super();
+	}
+	
+	
+	public GdlInfo(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
+		super(tmRepresentative);
+		RootPanel.get().add(this);
+		super.setGdlStyle();
+		// TODO: create an info element for each tm construct
+		this.createNewInfo().setText("Info");
+		this.hide();
+		this.setParentListener();
+	}
+	
+	
+	private Label createNewInfo() throws ExecutionException, InvalidGdlSchemaException{
+		Label lbl = new Label();
+		this.addToContainerPanel(lbl);
+		this.setGdlStyle(lbl);		
+		return lbl;
+	}
+	
+	
+	private void setParentListener(){
+		// TODO: implement
+	}
+	
+	
+	public void setPosition(Widget parent) throws InvalidGdlSchemaException{
+		int left = parent.getAbsoluteLeft();
+		int top = parent.getAbsoluteTop() + parent.getOffsetHeight();
+		DOM.setStyleAttribute(this.mainPanel.getElement(), "position", "absolute");
+		DOM.setStyleAttribute(this.mainPanel.getElement(), "top", top + "px");
+		DOM.setStyleAttribute(this.mainPanel.getElement(), "left", left + "px");
+		this.hide();
+	}
+	
+	
+	public void show() throws InvalidGdlSchemaException{
+		DOM.setStyleAttribute(this.mainPanel.getElement(), "display", this.getDisplay().getCssName());
+	}
+	
+	
+	public void hide(){
+		DOM.setStyleAttribute(this.mainPanel.getElement(), "display", "none");
+	}
+}

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	Wed Jul 27 08:46:22 2011	(r679)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Wed Jul 27 11:11:28 2011	(r680)
@@ -74,6 +74,8 @@
            {"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]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_reference_id"},{"type":"si:[gdl:float]", "value":"left"}]},
+    	   {"subject_identifiers":["[gdl:Info]"]},
+    	   {"subject_identifiers":["[doc:info-1]"], "instance_of":["si:[gdl:Info]"], "occurrences":[{"type":"si:[gdl:id]", "value":"info_1_id"}]},
     	   {"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:unit-1-text-delete-button]"], "instance_of":["si:[gdl:Delete-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_text_delete_button_id"}, {"type":"si:[gdl:font-size]", "value":"8px"}]},
     	   {"subject_identifiers":["[doc:unit-1-text-create-button]"], "instance_of":["si:[gdl:Create-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_text_create_button_id"}, {"type":"si:[gdl:font-size]", "value":"8px"}]},
@@ -210,5 +212,6 @@
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1-text]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-text-create-button]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1-text]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-text-delete-button]"}]},
                  {"type":"si:[gdl:button-position]", "roles":[{"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-crt-btn]"},{"type":"si:[gdl:action-button]", "player":"si:[doc:unit-1-text-create-button]"}]},
-                 {"type":"si:[gdl:button-position]", "roles":[{"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-del-btn]"},{"type":"si:[gdl:action-button]", "player":"si:[doc:unit-1-text-delete-button]"}]}
+                 {"type":"si:[gdl:button-position]", "roles":[{"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-del-btn]"},{"type":"si:[gdl:action-button]", "player":"si:[doc:unit-1-text-delete-button]"}]},
+                 {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1-reference]"},{"type":"si:[gdl:containee]", "player":"si:[doc:info-1]"}]}
                 ]}
\ No newline at end of file




More information about the Isidorus-cvs mailing list