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

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Thu Jul 28 11:44:53 UTC 2011


Author: lgiessmann
Date: Thu Jul 28 04:44:52 2011
New Revision: 689

Log:
gdl-frontend: Widgets: implemented the static method TmHelper.getRootConstraintOfValueGroup(Topic valueGroup) that can be used by all visible elements to retrieve the bound tmcl contraint instance to their gdl:Value-Group instance

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/text/GdlText.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 28 03:31:02 2011	(r688)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Thu Jul 28 04:44:52 2011	(r689)
@@ -633,4 +633,36 @@
 		else if (gdlConstraints.size() == 1) return gdlConstraints.get(0);
 		else return null;
 	}
+
+
+	// returns the root constraint of a gdl:Value-Group instance, i.e. a tmcl constraint.
+	// E.g. a value group may be bound to a gdl:Type constraint and this constraint may be bound
+	// to a tmcl:constraint, the root constraint is the instance of the tmcl:constraint
+	public static Topic getRootConstraintOfValueGroup(Topic valueGroup, Topic currentConstraint) throws InvalidGdlSchemaException {
+		if(valueGroup == null) return null;
+		
+		Topic localCurrentConstraint = currentConstraint == null ? getConstraintOfValueGroup(valueGroup) : currentConstraint;
+		TopicMap tm = valueGroup.getTopicMap();
+		Topic tmclConstraint = getTopicByPsi(GdlPsis.TMCL.constraint, tm); 
+		
+		if(isInstanceOf(localCurrentConstraint, tmclConstraint)) return tmclConstraint;
+		else {
+			// get next constraint and invoke this method recursively
+			Topic descriptorRoleType = getTopicByPsi(GdlPsis.RoleType.gdlDescriptor, tm);
+			Topic tmBindingAssocType = getTopicByPsi(GdlPsis.AssociationType.gdlTmBinding, tm);
+			Topic tmConstructRoleType = getTopicByPsi(GdlPsis.RoleType.gdlTmConstruct, tm);
+			Topic tmclConstraintType = getTopicByPsi(GdlPsis.TMCL.constraint, tm);
+			Topic gdlDescriptor = getTopicByPsi(GdlPsis.TopicType.gdlDescriptor, tm);
+			
+			ArrayList<Topic> nextTmclConstraints = getOtherPlayerOfBinaryAssociation(localCurrentConstraint, descriptorRoleType, tmBindingAssocType, null, tmclConstraintType, tmConstructRoleType);
+			ArrayList<Topic> nextGdlConstraints = getOtherPlayerOfBinaryAssociation(localCurrentConstraint, descriptorRoleType, tmBindingAssocType, null, gdlDescriptor, tmConstructRoleType);
+			
+			if(nextTmclConstraints.size() > 1 || nextGdlConstraints.size() > 1 || (nextTmclConstraints.size() == 1 && nextGdlConstraints.size() == 1))
+				throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(localCurrentConstraint) + " can be bound only to one constraint, but is " + (nextTmclConstraints.size() + nextGdlConstraints.size()));
+			
+			if(nextTmclConstraints.size() == 1) return nextTmclConstraints.get(0);
+			else if(nextGdlConstraints.size() == 1) return getRootConstraintOfValueGroup(valueGroup, nextGdlConstraints.get(0));
+			else throw new InvalidGdlSchemaException("the value group " + getAnyIdOfTopic(valueGroup) + " must be bound to exaclty on root constraint of the type " + GdlPsis.TMCL.constraint + " but is unbound");
+		}
+	}
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java	Thu Jul 28 03:31:02 2011	(r688)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java	Thu Jul 28 04:44:52 2011	(r689)
@@ -39,6 +39,10 @@
 	protected ArrayList<HandlerRegistration> passwordKeyPressRegistrations = null;
 	protected Topic valueGroupTopic = null;
 	protected boolean valueGroupTopicSet = false;
+	protected Topic constraintTopic = null;
+	protected boolean constraintTopicSet = false;
+	protected Topic rootConstraintTopic = null;
+	protected boolean rootConstraintTopicSet = false;
 	
 	// some constructors
 	protected GdlText() throws InvalidGdlSchemaException, ExecutionException {
@@ -821,14 +825,24 @@
 	@Override
 	public Topic getConstraint() throws InvalidGdlSchemaException {
 		Topic valueGroup = this.getValueGroup();
-		return valueGroup == null ? null : TmHelper.getConstraintOfValueGroup(valueGroup);
+		if(valueGroup != null) this.constraintTopic = TmHelper.getConstraintOfValueGroup(valueGroup);
+		this.constraintTopicSet = true;
+		return this.constraintTopic; 
 	}
 	
 	
 	@Override
 	public Topic getRootConstraint() throws InvalidGdlSchemaException {
-		// TODO Auto-generated method stub
-		return null;
+		Topic valueGroup = this.getValueGroup();
+		this.rootConstraintTopicSet = true;
+		if(valueGroup == null) {
+			this.rootConstraintTopicSet = true;
+			return null;
+		} else {
+			this.rootConstraintTopic = TmHelper.getRootConstraintOfValueGroup(valueGroup, this.getConstraint());
+			this.rootConstraintTopicSet = true;
+			return this.rootConstraintTopic;
+		}
 	}
 
 

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 28 03:31:02 2011	(r688)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm	Thu Jul 28 04:44:52 2011	(r689)
@@ -26,8 +26,12 @@
            {"subject_identifiers":["[gdl:view-name]"], "instance_of":["si:[tmcl:name-type]"]},
            {"subject_identifiers":["[gdl:Descriptor]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[gdl:border-width]"], "instance_of":["si:[tmcl:occurrence-type]"]},
+           {"subject_identifiers":["[tmcl:card-max]"], "instance_of":["si:[tmcl:occurrence-type]"]},
+           {"subject_identifiers":["[tmcl:card-min]"], "instance_of":["si:[tmcl:occurrence-type]"]},
            {"subject_identifiers":["[doc:test-schema]"], "instance_of":["si:[gdl:Schema]"], "names":[{"value": "Test GDL Schema", "type":"si:[gdl:schema-name]"}]},
            {"subject_identifiers":["[gdl:Visible-Object]"]},
+           {"subject_identifiers":["[tmcl:constraint]"], "instance_of":["si:[tmcl:topic-type]"]},
+           {"subject_identifiers":["[tmcl:topic-name-constraint]"], "instance_of":["si:[tmcl:topic-type]"]},
            {"subject_identifiers":["[gdl:Value-Group]"]},
            {"subject_identifiers":["[gdl:Text-Object]"]},
            {"subject_identifiers":["[gdl:Type]"]},
@@ -69,6 +73,7 @@
            {"subject_identifiers":["[gdl:Reference]"]},
            {"subject_identifiers":["[gdl:List]"]},
            {"subject_identifiers":["[doc:person-name-type-constraint]"], "instance_of":["si:[gdl:Type]"]},
+           {"subject_identifiers":["[doc:person-name-constraint]"], "instance_of":["si:[tmcl:topic-name-constraint]"], "occurrences":[{"type":"si:[tmcl:card-min]", "value":"1"}, {"type":"si:[tmcl:card-max]", "value":"1"}]},
            {"subject_identifiers":["[doc:unit-1-radio-button]"], "instance_of":["si:[gdl:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_radio_button_id"},{"type":"si:[gdl:content-orientation]", "value":"horizontal"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin-left]", "value":"15pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]},
            {"subject_identifiers":["[doc:unit-1-check-box]"], "instance_of":["si:[gdl:Check-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_check_box_id"},{"type":"si:[gdl:content-orientation]", "value":"vertical"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin]", "value":"30pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]},
            {"subject_identifiers":["[doc:unit-1-action-button]"], "instance_of":["si:[gdl:Action-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_action_button"}]},
@@ -173,6 +178,7 @@
                  {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Action-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Create-Button]"}]},
                  {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Descriptor]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Value-Group]"}]},
                  {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Descriptor]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Type]"}]},
+                 {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[tmcl:constraint]"},{"type":"si:[tmdm:subtype]", "player":"si:[tmcl:topic-name-constraint]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-1]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-2]"}]},
                  {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-editor-topic-view]"}]},
@@ -223,5 +229,6 @@
                  {"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]"}]},
                  {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[doc:value-group-person-name]"},{"type":"si:[gdl:descriptor]", "player":"si:[doc:text-1]"}]},
-                 {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[doc:value-group-person-name]"},{"type":"si:[gdl:tm-construct]", "player":"si:[doc:person-name-type-constraint]"}]}
+                 {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[doc:value-group-person-name]"},{"type":"si:[gdl:tm-construct]", "player":"si:[doc:person-name-type-constraint]"}]},
+                 {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:person-name-type-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[doc:person-name-constraint]"}]}
                 ]}
\ No newline at end of file




More information about the Isidorus-cvs mailing list