[isidorus-cvs] r1025 - 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 12:02:48 UTC 2011


Author: lgiessmann
Date: Wed Oct 26 05:02:37 2011
New Revision: 1025

Log:
gdl-frontend: Widgets: implemented the gdlt:Variant-Name-Scope 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 04:53:30 2011	(r1024)
+++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Wed Oct 26 05:02:37 2011	(r1025)
@@ -2737,6 +2737,31 @@
 		contents.add(new Pair<Object, TopicMapsTypes>(changedRole, TopicMapsTypes.Role));
 	}
 	
+	
+	// handles the getContent call for scope topics of variant-names
+	private void getVariantNameScopeContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
+		if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass());
+		ArrayList<Variant> possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint());		
+		if(possibleVariants.size() != 0){
+			Variant variant = possibleVariants.get(0);
+			JsArray<Topic> scopes = variant.getScope();
+			
+			if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex));
+
+			if(scopes.length() > selectedValueIndex){
+				Topic oldScope = scopes.get(selectedValueIndex);
+				Topic newScope = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup());
+				
+				if(!oldScope.equals(newScope)){
+					variant.removeTheme(oldScope);
+					variant.addTheme(newScope);
+				}
+			}
+
+			contents.add(new Pair<Object, TopicMapsTypes>(variant, TopicMapsTypes.Variant));
+		}
+	}
+	
 		
 	// returns the actual data that is hold by this instance
 	public ArrayList<Pair<Object, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException {
@@ -2765,7 +2790,7 @@
 			} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlType)){
 				// TODO: implement
 			} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameScope)){
-				// TODO: implement
+				this.getVariantNameScopeContent(result, validate, (Topic)localCarrier, idx);
 			} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameReifier)){
 				this.getVariantReifierContent(result, validate, (Topic)localCarrier, idx);
 			} else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameIdentifiers)){




More information about the Isidorus-cvs mailing list