Author: lgiessmann Date: Sun Jul 31 02:09:48 2011 New Revision: 693
Log: gdl-frontend: Widgets: implemented the method TmHelper.getDefaultLiteralValue(), TmHelper.getTmValues(), TmHelper.getLiteralValues()
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/IGdlHasValueGroup.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/base/Utils.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/TODO.txt ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Jul 28 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Sun Jul 31 02:09:48 2011 (r693) @@ -8,4 +8,5 @@ * GdlListBox * Implement TopicMaps data consumption * Implement TopicMaps data generation +* Implement HiddenValue * 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 Thu Jul 28 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Sun Jul 31 02:09:48 2011 (r693) @@ -7,17 +7,31 @@ // some psis of the TMDM public class TMDM{ - public final static String supertype = "http://psi.topicmaps.org/iso13250/model/supertype"; - public final static String subtype = "http://psi.topicmaps.org/iso13250/model/subtype"; - public final static String supertypeSubtype = "http://psi.topicmaps.org/iso13250/model/supertype-subtype"; + public final static String tmdm = "http://psi.topicmaps.org/iso13250/model/"; + public final static String supertype = tmdm + "supertype"; + public final static String subtype = tmdm + "subtype"; + public final static String supertypeSubtype = tmdm + "supertype-subtype"; }
// some psis of the TMCL public class TMCL { - public final static String topictype = "http://psi.topicmaps.org/tmcl/topic-type"; - public final static String constraint = "http://psi.topicmaps.org/tmcl/constraint"; + public final static String tmcl = "http://psi.topicmaps.org/tmcl/"; + public final static String tmclTopictype = tmcl + "topic-type"; + public final static String tmclNameType = tmcl + "name-type"; + public final static String tmclOccurrenceType = tmcl + "occurrence-type"; + public final static String tmclConstraint = tmcl + "constraint"; + public final static String tmclConstrained = tmcl + "constrained"; + public final static String tmclConstrainedStatement = tmcl + "constrained-statement"; + public final static String tmclRegularExpressionConstraint = tmcl + "regular-expression-constraint"; + public final static String tmclRegexp = tmcl + "regexp"; + public final static String tmclCardMin = tmcl + "card-min"; + public final static String tmclCardMax = tmcl + "card-max"; + public final static String tmclReifierConstraint = tmcl + "reifier-constraint"; + public final static String tmclScopeConstraint = tmcl + "scope-constraint"; + public final static String tmclTopicNameConstraint = tmcl + "topic-name-constraint"; + public final static String tmclTopicOccurrenceConstraint = tmcl + "topic-occurrence-constraint"; }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java Thu Jul 28 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java Sun Jul 31 02:09:48 2011 (r693) @@ -31,12 +31,13 @@ // i.e. is is one value of getDefaultTmValue(), getDefaultLiteralValue() public Topic getDefaultValue() throws InvalidGdlSchemaException; - // returns all possible topics that can be used as values for this value group, - // i.e. if no tm-values are bound to this value-group, all possible values are - // generated by examining the tmcl:constraint + // returns all possible topics that can be used as values for this value group. + // Note, since gdl:Default-TM-Value is treated as a usual value, + // default vaues are also returned by this function public ArrayList<Topic> getTmValues() throws InvalidGdlSchemaException; - // returns all possible literals that can be used as values for this value group + // returns all possible literals that can be used as values for this value group. + // Note, default literal values are also returned by this function public ArrayList<Topic> getLiteralValues() throws InvalidGdlSchemaException; // returns the literal value that is set on an item @@ -44,4 +45,13 @@ // returns the topic map construct that is set on an item public Construct getSetTmValue() throws InvalidGdlSchemaException; + + // returns the topic that can be used to satisfy the constraint, that is + // bound to the element's value group instance. Note, this method + // returns all topics of a topic map that can be used for a defined constraint + public ArrayList<Topic> getTmValuesForConstraint() throws InvalidGdlSchemaException; + + // returns a regular expression that must be satisfied to satisfy the + // constraint, that is bound to the element's value group instance + public String getLiteralValueForConstraint() throws InvalidGdlSchemaException; }
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 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Sun Jul 31 02:09:48 2011 (r693) @@ -10,10 +10,7 @@ import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ScopedStub; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; -import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis.AssociationType; -import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis.RoleType; import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis.TMDM; -import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis.TopicType; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; import us.isidor.gdl.anaToMia.Widgets.environment.Pair; import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes; @@ -272,27 +269,6 @@ } - // returns all topics that are instances of tm-value, which are also bound to this - // topic via a gdl:tm-binding association - public static ArrayList<Topic> getTmValues(Topic top){ - ArrayList<Topic> result = new ArrayList<Topic>(); - if(top == null) return result; - TopicMap tm = top.getTopicMap(); - Topic descriptor = getTopicByPsi(RoleType.gdlDescriptor, tm); - Topic tmBinding = getTopicByPsi(AssociationType.gdlTmBinding, tm); - Topic tmValue = getTopicByPsi(TopicType.gdlTmValue, tm); - - JsArray<Role> roles = top.getRolesPlayed(descriptor, tmBinding); - for(int i = 0; i != roles.length(); ++i){ - Association parent = roles.get(i).getParent(); - if(parent.getRoles().length() == 2 && parent.getRoles(descriptor).length() == 1 && - isInstanceOf(parent.getRoles(descriptor).get(0).getPlayer(), tmValue)) - result.add(parent.getRoles(descriptor).get(0).getPlayer()); - } - return result; - } - - // returns the associations that are bound to the topic "topic" and have the passed scope and roles public static ArrayList<Association> getAssociationsOfTopic(Topic topic, Topic roleType, Topic assocType, ArrayList<Topic> scope, ArrayList<Pair<Topic, Topic>> rolePlayertypesAndTypes){ ArrayList<Association> result = new ArrayList<Association>(); @@ -620,7 +596,7 @@ Topic valueGroupRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValueGroup, tm); Topic descriptorType = getTopicByPsi(GdlPsis.TopicType.gdlDescriptor, tm); Topic tmBindingAssocType = getTopicByPsi(GdlPsis.AssociationType.gdlTmBinding, tm); - Topic tmclConstraintType = getTopicByPsi(GdlPsis.TMCL.constraint, tm); + Topic tmclConstraintType = getTopicByPsi(GdlPsis.TMCL.tmclConstraint, tm); Topic tmConstructRoleType = getTopicByPsi(GdlPsis.RoleType.gdlTmConstruct, tm); ArrayList<Topic> tmclConstraints = getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, tmBindingAssocType, null, tmclConstraintType, tmConstructRoleType); @@ -643,15 +619,14 @@ Topic localCurrentConstraint = currentConstraint == null ? getConstraintOfValueGroup(valueGroup) : currentConstraint; TopicMap tm = valueGroup.getTopicMap(); - Topic tmclConstraint = getTopicByPsi(GdlPsis.TMCL.constraint, tm); + Topic tmclConstraintType = getTopicByPsi(GdlPsis.TMCL.tmclConstraint, tm); - if(isInstanceOf(localCurrentConstraint, tmclConstraint)) return tmclConstraint; + if(isInstanceOf(localCurrentConstraint, tmclConstraintType)) return localCurrentConstraint; 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); @@ -662,12 +637,12 @@ 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"); + else throw new InvalidGdlSchemaException("the value group " + getAnyIdOfTopic(valueGroup) + " must be bound to exaclty on root constraint of the type " + GdlPsis.TMCL.tmclConstraint + " but is unbound"); } }
- // returns the topic that represent the default tm value for the passed value group + // returns the topic that represents the default tm value for the passed value group public static Topic getDefaultTmValue(Topic valueGroup) throws InvalidGdlSchemaException { if(valueGroup == null) return null; @@ -681,19 +656,196 @@ if(defaultTmValues.size() == 1) return defaultTmValues.get(0); else if(defaultTmValues.size() == 0) return null; - else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(valueGroup) + " must be bound none or once to a DefaultTmValue, but is: " + defaultTmValues.size()); + else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(valueGroup) + " must be bound none or once to a " + GdlPsis.TopicType.gdlDefaultTmValue + ", but is: " + defaultTmValues.size()); } + // returns the topic that represents the default literal value for the passed value group public static Topic getDefaultLiteralValue(Topic valueGroup) throws InvalidGdlSchemaException{ + if(valueGroup == null) return null; + + TopicMap tm = valueGroup.getTopicMap(); + Topic valueBindingAssocTopic = getTopicByPsi(GdlPsis.AssociationType.gdlValueBinding, tm); + Topic valueGroupRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValueGroup, tm); + Topic valueRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValue, tm); + Topic defaultLiteralValueType = getTopicByPsi(GdlPsis.TopicType.gdlDefaultLiteralValue, tm); + + ArrayList<Topic> defaultTmValues = getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, valueBindingAssocTopic, null, defaultLiteralValueType, valueRoleType); + + if(defaultTmValues.size() == 1) return defaultTmValues.get(0); + else if(defaultTmValues.size() == 0) return null; + else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(valueGroup) + " must be bound none or once to a " + GdlPsis.TopicType.gdlDefaultLiteralValue + ", but is: " + defaultTmValues.size()); + } + + + // returns the topics that represent the tm values for the passed value group + public static ArrayList<Topic> getTmValues(Topic valueGroup) throws InvalidGdlSchemaException { + ArrayList<Topic> result = new ArrayList<Topic>(); + if(valueGroup == null) return result; + + TopicMap tm = valueGroup.getTopicMap(); + Topic valueBindingAssocTopic = getTopicByPsi(GdlPsis.AssociationType.gdlValueBinding, tm); + Topic valueGroupRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValueGroup, tm); + Topic valueRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValue, tm); + Topic tmValueType = getTopicByPsi(GdlPsis.TopicType.gdlTmValue, tm); + + return getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, valueBindingAssocTopic, null, tmValueType, valueRoleType); + } + + + // returns the topics that represent the literal value for the passed value group + public static ArrayList<Topic> getLiteralValues(Topic valueGroup){ + ArrayList<Topic> result = new ArrayList<Topic>(); + if(valueGroup == null) return result; + + TopicMap tm = valueGroup.getTopicMap(); + Topic valueBindingAssocTopic = getTopicByPsi(GdlPsis.AssociationType.gdlValueBinding, tm); + Topic valueGroupRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValueGroup, tm); + Topic valueRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValue, tm); + Topic literalValueType = getTopicByPsi(GdlPsis.TopicType.gdlLiteralValue, tm); + + return getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, valueBindingAssocTopic, null, literalValueType, valueRoleType); + } + + + // returns the topic that can be used to satisfy the passed constraint. + public static ArrayList<Topic> getTmValuesForConstraint(Topic constraint, Topic valueGroup) throws InvalidGdlSchemaException { + ArrayList<Topic> result = new ArrayList<Topic>(); + if(constraint == null || valueGroup == null) return result; + + if(isInstanceOf(constraint, GdlPsis.TopicType.gdlType)){ + return getTmValuesForTypeConstraint(constraint, valueGroup); + } else if(isInstanceOf(constraint, GdlPsis.TopicType.gdlVariantNameReifier)){ + return getTmValuesForVariantNameReifierConstraint(constraint); + } else if(isInstanceOf(constraint, GdlPsis.TopicType.gdlVariantNameScope)){ + return getTmValuesForVariantNameScopeConstraint(constraint); + } else if(isInstanceOf(constraint, GdlPsis.TopicType.gdlRolePlayer)){ + return getTmValuesForRolePlayerConstraint(constraint); + } else if(isInstanceOf(constraint, GdlPsis.TMCL.tmclReifierConstraint)){ + return getTmValuesForReifierConstraint(constraint); + } else if(isInstanceOf(constraint, GdlPsis.TMCL.tmclScopeConstraint)){ + return getTmValuesForScopeConstraint(constraint); + } + + return result; + } + + + // returns the topic that can be used to satisfy the passed role-player-constraint. + public static ArrayList<Topic> getTmValuesForScopeConstraint(Topic scopeConstraint){ + ArrayList<Topic> result = new ArrayList<Topic>(); + if(scopeConstraint == null) return result; // TODO: implement - return null; + + return result; } - public static ArrayList<Topic> getTmValue(Topic valueGroup) throws InvalidGdlSchemaException { + // returns the topic that can be used to satisfy the passed role-player-constraint. + public static ArrayList<Topic> getTmValuesForReifierConstraint(Topic reifierConstraint){ + ArrayList<Topic> result = new ArrayList<Topic>(); + if(reifierConstraint == null) return result; // TODO: implement - // TODO: if no tm-values are set, examine the tmcl constraint - return null; + + return result; + } + + + // returns the topic that can be used to satisfy the passed role-player-constraint. + public static ArrayList<Topic> getTmValuesForRolePlayerConstraint(Topic rolePlayerConstraint){ + ArrayList<Topic> result = new ArrayList<Topic>(); + if(rolePlayerConstraint == null) return result; + // TODO: implement + + return result; + } + + + // returns the topic that can be used to satisfy the passed type-constraint. + public static ArrayList<Topic> getTmValuesForTypeConstraint(Topic typeConstraint, Topic valueGroup) throws InvalidGdlSchemaException { + ArrayList<Topic> result = new ArrayList<Topic>(); + if(typeConstraint == null || valueGroup == null) return result; + + Topic rootConstraint = getRootConstraintOfValueGroup(valueGroup, typeConstraint); + if(rootConstraint == null) return result; + + if(isInstanceOf(rootConstraint, GdlPsis.TMCL.tmclTopicNameConstraint) || isInstanceOf(rootConstraint, GdlPsis.TMCL.tmclTopicOccurrenceConstraint)){ + + } else if(true /* TODO: association */){ + + } else if(true /* TODO: role */){ + + } + + return result; + } + + + // returns the topic that can be used to satisfy the passed variant-name-reifier-constraint. + public static ArrayList<Topic> getTmValuesForVariantNameReifierConstraint(Topic variantNameReifierConstraint){ + ArrayList<Topic> result = new ArrayList<Topic>(); + if(variantNameReifierConstraint == null) return result; + // TODO: implement + + return result; + } + + + // returns the topic that can be used to satisfy the passed variant-name-scope-constraint. + public static ArrayList<Topic> getTmValuesForVariantNameScopeConstraint(Topic variantNameScopeConstraint){ + ArrayList<Topic> result = new ArrayList<Topic>(); + if(variantNameScopeConstraint == null) return result; + // TODO: implement + + return result; + } + + + // returns the regular expression for a constraint. If no regular-expression constraint is set for the + // constrained-statement of the passed constraint, the value ".*" is returned + public static String getLiteralValueForConstraint(Topic constraint) throws InvalidGdlSchemaException { + String result = ".*"; + if(constraint == null) return result; + + TopicMap tm = constraint.getTopicMap(); + Topic constraintRoleType = getTopicByPsi(GdlPsis.TMCL.tmclConstraint, tm); + Topic constrainedStatementAssocType = getTopicByPsi(GdlPsis.TMCL.tmclConstrainedStatement, tm); + Topic constrainedRoleType = getTopicByPsi(GdlPsis.TMCL.tmclConstrained, tm); + Topic nameType = getTopicByPsi(GdlPsis.TMCL.tmclNameType, tm); + Topic occurrenceType = getTopicByPsi(GdlPsis.TMCL.tmclOccurrenceType, tm); + ArrayList<Topic> nameTypes = getOtherPlayerOfBinaryAssociation(constraint, constraintRoleType, constrainedStatementAssocType, null, nameType, constrainedRoleType); + ArrayList<Topic> occurrenceTypes = getOtherPlayerOfBinaryAssociation(constraint, constraintRoleType, constrainedStatementAssocType, null, occurrenceType, constrainedRoleType); + ArrayList<Topic> nameOrOccurrenceTypes = Utils.union(nameTypes, occurrenceTypes); + + if(nameOrOccurrenceTypes.size() == 0){ + return result; + } else if(nameOrOccurrenceTypes.size() > 1){ + throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(constraint) + " must be bound maximum once to a topic via a " + GdlPsis.TMCL.tmclConstrainedStatement + ", but is: " + nameOrOccurrenceTypes.size()); + } else { + Topic regularExpressionConstraintType = getTopicByPsi(GdlPsis.TMCL.tmclRegularExpressionConstraint, tm); + ArrayList<Topic> regularExpressionConstraints = getOtherPlayerOfBinaryAssociation(nameOrOccurrenceTypes.get(0), constrainedRoleType, constrainedStatementAssocType, null, regularExpressionConstraintType, constraintRoleType); + + if(regularExpressionConstraints.size() == 0) { + return ".*"; + } else if(regularExpressionConstraints.size() == 1){ + Topic regexpOccurrenceType = getTopicByPsi(GdlPsis.TMCL.tmclRegexp, tm); + Occurrence rex = getSingleOccurrence(regularExpressionConstraints.get(0), regexpOccurrenceType); + return rex.getValue(); + } else { + throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(nameOrOccurrenceTypes.get(0)) + " must be bound maximum once to a " + GdlPsis.TMCL.tmclRegularExpressionConstraint + ", but is: " + regularExpressionConstraints.size()); + } + } + } + + + // return the occurrence of the passed type, if the topic contains more than one such occurrences, + // this function throws a InvalidgdlSchemaException + public static Occurrence getSingleOccurrence(Topic topic, Topic occurrenceType) throws InvalidGdlSchemaException { + if(topic == null) return null; + + JsArray<Occurrence> occs = topic.getOccurrences(occurrenceType); + if(occs.length() > 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(topic) + " must contains maximum one occurrence of the type " + getAnyIdOfTopic(occurrenceType) + ", but conaints: " + occs.length()); + else if(occs.length() == 0) return null; + else return occs.get(0); } }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java Thu Jul 28 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java Sun Jul 31 02:09:48 2011 (r693) @@ -23,6 +23,17 @@ } + // returns an ArrayList that is a union of fst and snd + public static <T> ArrayList<T> union(ArrayList<T> fst, ArrayList<T> snd){ + ArrayList<T> result = new ArrayList<T>(); + + if(fst != null) for (T t : fst) if(!result.contains(t)) result.add(t); + if(snd != null) for (T t : fst) if(!result.contains(t)) result.add(t); + + return result; + } + + // returns true if the string consists only of digits public static boolean isDecNumber(String str){ if(str == null) return false;
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 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Sun Jul 31 02:09:48 2011 (r693) @@ -45,6 +45,12 @@ protected boolean rootConstraintTopicSet = false; protected Topic defaultTmValueTopic = null; protected boolean defaultTmValueTopicSet = false; + protected Topic defaultLiteralValueTopic = null; + protected boolean defaultLiteralValueTopicSet = false; + protected ArrayList<Topic> tmValueTopics = new ArrayList<Topic>(); + protected boolean tmValueTopicsSet = false; + protected ArrayList<Topic> literalValueTopics = new ArrayList<Topic>(); + protected boolean literalValueTopicsSet = false; // some constructors protected GdlText() throws InvalidGdlSchemaException, ExecutionException { @@ -574,7 +580,6 @@ // cols is only treated if width is not set if(widthOcc == null) DOM.setElementAttribute(widget.getElement(), "cols", String.valueOf(value)); } - // calls the super applies the GdlStyle for every TextArea item of this instance @@ -867,8 +872,13 @@
@Override public Topic getDefaultLiteralValue() throws InvalidGdlSchemaException { - // TODO Auto-generated method stub - return null; + if(this.defaultLiteralValueTopicSet){ + return this.defaultLiteralValueTopic; + } else { + this.defaultLiteralValueTopic = TmHelper.getDefaultLiteralValue(this.getValueGroup()); + this.defaultLiteralValueTopicSet = true; + return this.defaultLiteralValueTopic; + } } @@ -882,15 +892,25 @@
@Override public ArrayList<Topic> getTmValues() throws InvalidGdlSchemaException { - // TODO Auto-generated method stub - return null; + if(this.tmValueTopicsSet){ + return this.tmValueTopics; + } else { + this.tmValueTopics = TmHelper.getTmValues(this.getValueGroup()); + this.tmValueTopicsSet = true; + return this.tmValueTopics; + } }
@Override public ArrayList<Topic> getLiteralValues() throws InvalidGdlSchemaException { - // TODO Auto-generated method stub - return null; + if(this.literalValueTopicsSet){ + return this.literalValueTopics; + } else { + this.literalValueTopics = TmHelper.getLiteralValues(this.getValueGroup()); + this.literalValueTopicsSet = true; + return this.literalValueTopics; + } }
@@ -906,4 +926,16 @@ // TODO Auto-generated method stub return null; } + + + @Override + public ArrayList<Topic> getTmValuesForConstraint() throws InvalidGdlSchemaException { + return TmHelper.getTmValuesForConstraint(this.getConstraint(), this.getValueGroup()); + } + + + @Override + public String getLiteralValueForConstraint() throws InvalidGdlSchemaException { + return TmHelper.getLiteralValueForConstraint(this.getConstraint()); + } }
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 10:18:30 2011 (r692) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Sun Jul 31 02:09:48 2011 (r693) @@ -28,6 +28,7 @@ {"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":["[tmcl:regexp]"], "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":["[doc:person-name]"], "instance_of":["si:[tmcl:name-type]"]}, @@ -41,6 +42,7 @@ {"subject_identifiers":["[tmcl:constrained-topic-type]"], "instance_of":["si:[tmcl:role-type]"]}, {"subject_identifiers":["[gdl:value]"], "instance_of":["si:[tmcl:role-type]"]}, {"subject_identifiers":["[tmcl:topic-name-constraint]"], "instance_of":["si:[tmcl:topic-type]"]}, + {"subject_identifiers":["[tmcl:regular-expression-constraint]"], "instance_of":["si:[tmcl:topic-type]"]}, {"subject_identifiers":["[gdl:Value-Group]"]}, {"subject_identifiers":["[gdl:Text-Object]"]}, {"subject_identifiers":["[gdl:Type]"]}, @@ -100,6 +102,7 @@ {"subject_identifiers":["[doc:default-tm-value-person-name-type-constraint]"], "instance_of":["si:[gdl:Default-TM-Instance-Value]"]}, {"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:person-name-regexp-constraint]"], "instance_of":["si:[tmcl:regular-expression-constraint]"], "occurrences":[{"type":"si:[tmcl:regexp]", "value":"^[A-Z][a-z]+ [A-Z][a-z]+$"}]}, {"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"}]}, @@ -223,6 +226,7 @@ {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:Person]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:Director]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:Person]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:Poet]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:Person]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:Musician]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[tmcl:constraint]"},{"type":"si:[tmdm:subtype]", "player":"si:[tmcl:regular-expression-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]"}]}, @@ -279,5 +283,6 @@ {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:default-tm-value-person-name-type-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[doc:Poet]"}]}, {"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]"}]}, {"type":"si:[tmcl:constrained-statement]", "roles":[{"type":"si:[tmcl:constrained]", "player":"si:[doc:person-name]"},{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-constraint]"}]}, - {"type":"si:[tmcl:constrained-topic-type]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:Person]"}]} + {"type":"si:[tmcl:constrained-topic-type]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:Person]"}]}, + {"type":"si:[tmcl:constrained-statement]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[doc:person-name-regexp-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[doc:person-name]"}]} ]} \ No newline at end of file