[isidorus-cvs] r1028 - trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Wed Oct 26 16:56:13 UTC 2011


Author: lgiessmann
Date: Wed Oct 26 09:56:05 2011
New Revision: 1028

Log:
gdl-frontend: Widgets: implemented the gdlt:Type semantics for generating content entered in GdlVisibleObject

Modified:
   trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java

Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Wed Oct 26 09:18:46 2011	(r1027)
+++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Wed Oct 26 09:56:05 2011	(r1028)
@@ -14,6 +14,7 @@
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TypedStub;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Variant;
 import us.isidor.gdl.anaToMia.Widgets.button.GdlActionButton;
 import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler;
@@ -2854,15 +2855,53 @@
 	}
 	
 	
+	// handles the getContent call for a Datatye value
 	// handles the getContent call for scope topics
-	private void getDatatypeContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
+	private void getDatatypeContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
 		// TODO: implement
 	}
 	
 	
+	// handles the getContent call for a type topic
 	// handles the getContent call for scope topics
-	private void getTypeContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
-		// TODO: implement
+	private void getTypeContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
+		Topic oldType = null;
+		Construct owner = null;
+		TopicMapsTypes ownerType = null;
+		if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){
+			if(!(carrier instanceof Topic)) throw new ExecutionException("The constraints " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()) + " are only valid when a topic is processed, but is: " + this.receivedData.getClass());
+			oldType = TmHelper.getConstrainedStatement(this.getRootConstraint());
+			JsArray<Name> names = ((Topic)carrier).getNames(oldType);
+			if(names.length() != 0) owner = names.get(0);
+			ownerType = TopicMapsTypes.Name;
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){
+			if(!(carrier instanceof Topic)) throw new ExecutionException("The constraints " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()) + " are only valid when a topic is processed, but is: " + this.receivedData.getClass());
+			oldType = TmHelper.getConstrainedStatement(this.getRootConstraint());
+			JsArray<Occurrence> occs = ((Topic)carrier).getOccurrences(oldType);
+			if(occs.length() != 0) owner = occs.get(0);
+			ownerType = TopicMapsTypes.Occurrence;
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicRoleConstraint)){
+			if(!(carrier instanceof Association)) throw new ExecutionException("The constraints " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()) + " are only valid when an association is processed, but is: " + this.receivedData.getClass());
+			oldType = TmHelper.getConstrainedRoleAndPlayerTypeOfConstraint(this.getRootConstraint()).getFirst();
+			Topic assocType = TmHelper.getConstrainedStatement(this.getRootConstraint());
+			JsArray<Role> roles = ((Topic)carrier).getRolesPlayed(oldType, assocType);
+			if(roles.length() != 0) owner = roles.get(0).getParent();
+			ownerType = TopicMapsTypes.Association;
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclAssociationRoleConstraint)){
+			if(!(carrier instanceof Association)) throw new ExecutionException("The constraints " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()) + " are only valid when an association is processed, but is: " + this.receivedData.getClass());
+			oldType = TmHelper.getConstraintRoleOfConstraint(this.getRootConstraint());
+			Topic assocType = TmHelper.getConstrainedStatement(this.getRootConstraint());
+			JsArray<Role> roles = ((Topic)carrier).getRolesPlayed(oldType, assocType);
+			if(roles.length() != 0) owner = roles.get(0);
+			ownerType = TopicMapsTypes.Role;
+		} else {
+			String constraints = PSIs.TMCL.tmclTopicNameConstraint + ", " + PSIs.TMCL.tmclTopicOccurrenceConstraint + ", " + PSIs.TMCL.tmclTopicRoleConstraint + ", " + PSIs.TMCL.tmclAssociationRoleConstraint;
+			throw new ExecutionException("The topic " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to the following root constraints: " + constraints);
+		}
+
+		Topic newType = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup());
+		if(!newType.equals(oldType))((TypedStub) owner).setType(newType);
+		contents.add(new Pair<Object, TopicMapsTypes>(owner, ownerType));
 	}
 	
 		




More information about the Isidorus-cvs mailing list