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

Author: lgiessmann Date: Thu Aug 25 03:02:58 2011 New Revision: 779 Log: gdl-frontend: Widgets: implemented the consumption of role playes of GdlText within GdlAssociationView instances 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/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/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlCreatorAssociationView.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlEditorAssociationView.java 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 Wed Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java Thu Aug 25 03:02:58 2011 (r779) @@ -40,7 +40,7 @@ // 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 + // default values 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. @@ -66,7 +66,7 @@ // returns the Topic that represents the constraint, which is used to // determine the topic's display-schema - public Topic getDisplayByConstraintOfValueGroup() throws InvalidGdlSchemaException; + public Topic getDisplayByOfValueGroup() throws InvalidGdlSchemaException; // Returns a list of topics that represent the topic's preferred scope(s) 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 Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Aug 25 03:02:58 2011 (r779) @@ -651,7 +651,7 @@ // returns the constrained role and player types of the passed constraint - public static Pair<Topic, Topic> getConstraintRoleAndPlayerTypeOfConstraint(Topic topicRoleConstraint) throws InvalidGdlSchemaException { + public static Pair<Topic, Topic> getConstrainedRoleAndPlayerTypeOfConstraint(Topic topicRoleConstraint) throws InvalidGdlSchemaException { if(topicRoleConstraint == null) return null; TopicMap tm = topicRoleConstraint.getTopicMap(); @@ -668,25 +668,25 @@ // return a pair that contains again two pair instances, whereas each pair // represents a role type and a role player. The outer pair represents a valid // combination of roles of a role-combination-constraint. - public static Pair<Pair<Topic, Topic>, Pair<Topic, Topic>> getRoleCombinationsOfConstraint(Topic roleCombinationconstraint) throws InvalidGdlSchemaException { - if(roleCombinationconstraint == null) return null; + public static Pair<Pair<Topic, Topic>, Pair<Topic, Topic>> getRoleCombinationsOfConstraint(Topic roleCombinationConstraint) throws InvalidGdlSchemaException { + if(roleCombinationConstraint == null) return null; - TopicMap tm = roleCombinationconstraint.getTopicMap(); + TopicMap tm = roleCombinationConstraint.getTopicMap(); Topic constraintRoleType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm); Topic constrainedRoleAssocType = getTopicByPsi(PSIs.TMCL.tmclConstrainedRole, tm); Topic constrainedRoleType = getTopicByPsi(PSIs.TMCL.tmclConstrained, tm); - ArrayList<Topic> roleTypes = getOtherPlayerOfBinaryAssociation(roleCombinationconstraint, constraintRoleType, constrainedRoleAssocType, null, constrainedRoleType); - if(roleTypes.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationconstraint) + " must be bound exactly once to a role-type via a " + PSIs.TMCL.tmclConstrainedRole + ", but is: " + roleTypes.size()); + ArrayList<Topic> roleTypes = getOtherPlayerOfBinaryAssociation(roleCombinationConstraint, constraintRoleType, constrainedRoleAssocType, null, constrainedRoleType); + if(roleTypes.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationConstraint) + " must be bound exactly once to a role-type via a " + PSIs.TMCL.tmclConstrainedRole + ", but is: " + roleTypes.size()); Topic constrainedTopicTypeAssocType = getTopicByPsi(PSIs.TMCL.tmclConstrainedTopicType, tm); - ArrayList<Topic> playerTypes = getOtherPlayerOfBinaryAssociation(roleCombinationconstraint, constraintRoleType, constrainedTopicTypeAssocType, null, constrainedRoleType); - if(playerTypes.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationconstraint) + " must be bound exactly once to a topic-type via a " + PSIs.TMCL.tmclConstrainedTopicType + ", but is: " + playerTypes.size()); + ArrayList<Topic> playerTypes = getOtherPlayerOfBinaryAssociation(roleCombinationConstraint, constraintRoleType, constrainedTopicTypeAssocType, null, constrainedRoleType); + if(playerTypes.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationConstraint) + " must be bound exactly once to a topic-type via a " + PSIs.TMCL.tmclConstrainedTopicType + ", but is: " + playerTypes.size()); Topic otherConstrainedRoleAssocType = getTopicByPsi(PSIs.TMCL.tmclOtherConstrainedRole, tm); - ArrayList<Topic> otherRoleTypes = getOtherPlayerOfBinaryAssociation(roleCombinationconstraint, constraintRoleType, otherConstrainedRoleAssocType, null, constrainedRoleType); - if(otherRoleTypes.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationconstraint) + " must be bound exactly once to an other-role-type via a " + PSIs.TMCL.tmclOtherConstrainedRole + ", but is: " + otherRoleTypes.size()); + ArrayList<Topic> otherRoleTypes = getOtherPlayerOfBinaryAssociation(roleCombinationConstraint, constraintRoleType, otherConstrainedRoleAssocType, null, constrainedRoleType); + if(otherRoleTypes.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationConstraint) + " must be bound exactly once to an other-role-type via a " + PSIs.TMCL.tmclOtherConstrainedRole + ", but is: " + otherRoleTypes.size()); Topic otherConstrainedTopicTypeRoleType = getTopicByPsi(PSIs.TMCL.tmclOtherConstrainedTopicType, tm); - ArrayList<Topic> otherPlayerType = getOtherPlayerOfBinaryAssociation(roleCombinationconstraint, constraintRoleType, otherConstrainedTopicTypeRoleType, null, constrainedRoleType); - if(otherPlayerType.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationconstraint) + " must be bound exactly once to an other-topic-type via a " + PSIs.TMCL.tmclOtherConstrainedTopicType + ", but is: " + otherPlayerType.size()); + ArrayList<Topic> otherPlayerType = getOtherPlayerOfBinaryAssociation(roleCombinationConstraint, constraintRoleType, otherConstrainedTopicTypeRoleType, null, constrainedRoleType); + if(otherPlayerType.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(roleCombinationConstraint) + " must be bound exactly once to an other-topic-type via a " + PSIs.TMCL.tmclOtherConstrainedTopicType + ", but is: " + otherPlayerType.size()); Pair<Topic, Topic> firstRole = new Pair<Topic, Topic>(roleTypes.get(0), playerTypes.get(0)); Pair<Topic, Topic> secondRole = new Pair<Topic, Topic>(otherRoleTypes.get(0), otherPlayerType.get(0)); 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 Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java Thu Aug 25 03:02:58 2011 (r779) @@ -100,9 +100,9 @@ }else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.GDL.TopicType.gdlSpecialEditorTopicView)){ return new GdlSpecialEditorTopicView(tmRepresentative, (Topic)receivedData); }else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.GDL.TopicType.gdlCreatorAssociationview)){ - return new GdlCreatorAssociationView(tmRepresentative, (Association)receivedData); + return new GdlCreatorAssociationView(tmRepresentative, (Topic)receivedData); }else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.GDL.TopicType.gdlEditorAssociationView)){ - return new GdlEditorAssociationView(tmRepresentative, (Association)receivedData); + return new GdlEditorAssociationView(tmRepresentative, (Topic)receivedData); }else{ String values = ""; for(int i = 0; i != tmRepresentative.getTypes().length(); ++i){ 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 Wed Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Thu Aug 25 03:02:58 2011 (r779) @@ -14,10 +14,13 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.Widget; + +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Reifiable; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ReifiableStub; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; @@ -130,15 +133,23 @@ for(int i = 0; i != ((Topic)this.receivedData).getOccurrences(occurrenceType).length(); ++i) this.createNewTextArea().setText(((Topic)this.receivedData).getOccurrences(occurrenceType).get(i).getValue()); } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlRolePlayer)){ - this.createNewTextArea().setText("gdl:Role-Player instance"); - // TODO: search role => role-type + role-player - // TODO: display the correponding value + if(!(receivedData instanceof Association)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to an Association, but is: " + receivedData.getClass()); + if(this.getRootConstraint() == null || !TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicRoleConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a root constraint of the type " + PSIs.TMCL.tmclTopicRoleConstraint + ", but ist bound to the root topic: " + (this.getRootConstraint() == null ? "null" : TmHelper.getAnyIdOfTopic(this.getRootConstraint()))); + + Pair<Topic, Topic> roleAndPlayerType = TmHelper.getConstrainedRoleAndPlayerTypeOfConstraint(this.getRootConstraint()); + JsArray<Role> assocRoles = ((Association)this.receivedData).getRoles(roleAndPlayerType.getFirst()); + for(int i = 0; i != assocRoles.length(); ++i){ + if(TmHelper.isInstanceOf(assocRoles.get(i).getPlayer(), roleAndPlayerType.getSecond())){ + this.createNewTextArea().setText(this.getTopicRepresentation(assocRoles.get(i).getPlayer(), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup())); + } + } } // TODO: implement type, variant, datatype, associations, roles, ... constraints + // TODO: move method to GdlVisibleObject } - // sets the field for the set default value or sets at least one empty field + // sets the field for the set default value or sets at least one empty field (card-min) protected void setDefaultValue() throws InvalidGdlSchemaException, ExecutionException { if(this.getDefaultLiteralValue() != null && this.getDefaultTmValue() != null) throw new InvalidGdlSchemaException("the topic " + TmHelper.getAnyIdOfTopic(this.getValueGroup()) + " must be bound to maximal one " + PSIs.GDL.TopicType.gdlDefaultValue + ", but is: 2"); @@ -1052,7 +1063,7 @@ @Override - public Topic getDisplayByConstraintOfValueGroup() throws InvalidGdlSchemaException { + public Topic getDisplayByOfValueGroup() throws InvalidGdlSchemaException { if(this.displayByConstraintSet){ return this.displayByConstraint; } else { Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Wed Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Thu Aug 25 03:02:58 2011 (r779) @@ -39,7 +39,7 @@ } - public GdlAssociationView(Topic tmRepresentative, Association receivedData) throws InvalidGdlSchemaException, ExecutionException { + public GdlAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException { super(tmRepresentative, receivedData); } @@ -116,7 +116,7 @@ ArrayList<Pair<Topic, Topic>> roleTypesOfTopicRoleConstraints = new ArrayList<Pair<Topic, Topic>>(); for (Topic constraint : this.getTopicRoleConstraints()){ - Pair<Topic, Topic> roleAndPlayerType = TmHelper.getConstraintRoleAndPlayerTypeOfConstraint(constraint); + Pair<Topic, Topic> roleAndPlayerType = TmHelper.getConstrainedRoleAndPlayerTypeOfConstraint(constraint); if(!roleTypesOfTopicRoleConstraints.contains(roleAndPlayerType)) roleTypesOfTopicRoleConstraints.add(roleAndPlayerType); } Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlCreatorAssociationView.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlCreatorAssociationView.java Wed Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlCreatorAssociationView.java Thu Aug 25 03:02:58 2011 (r779) @@ -1,6 +1,5 @@ package us.isidor.gdl.anaToMia.Widgets.view; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; @@ -9,7 +8,7 @@ public class GdlCreatorAssociationView extends GdlAssociationView { - public GdlCreatorAssociationView(Topic tmRepresentative, Association receivedData) throws InvalidGdlSchemaException, ExecutionException { + public GdlCreatorAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException { super(tmRepresentative, receivedData); // TODO Auto-generated constructor stub } Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlEditorAssociationView.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlEditorAssociationView.java Wed Aug 24 08:47:02 2011 (r778) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlEditorAssociationView.java Thu Aug 25 03:02:58 2011 (r779) @@ -3,7 +3,6 @@ import java.util.ArrayList; import com.google.gwt.core.client.JsArray; - import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; @@ -19,13 +18,14 @@ protected boolean associationsToRepresentSet = false; - public GdlEditorAssociationView(Topic tmRepresentative, Association receivedData) throws InvalidGdlSchemaException, ExecutionException { + public GdlEditorAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException { super(tmRepresentative, receivedData); // create an association item for each association that must be represetned // by this view - for (int i = 0; i != this.getAssociationsToRepresent().size(); ++i) + for (int i = 0; i != this.getAssociationsToRepresent().size(); ++i){ this.addToContainerPanel(new AssociationItem(this.tmRepresentative, this.getAssociationsToRepresent().get(i), i)); + } } @@ -103,18 +103,12 @@ // returns an array with associations that // must be represented by this association view private ArrayList<Association> filterAssociations() throws InvalidGdlSchemaException { - if(this.receivedData instanceof Association){ - this.associationsToRepresent = new ArrayList<Association>(); - this.associationsToRepresent.add((Association)this.receivedData); - return this.associationsToRepresent; - } else { - ArrayList<Association> filteredAssociations = this.filterAssociationsByType(); - filteredAssociations = this.filterAssociationsByRoleAndPlayerTypes(filteredAssociations); - this.checkAssociationsByRoleCombinations(filteredAssociations); - this.associationsToRepresent = filteredAssociations; - this.associationsToRepresentSet = true; - return this.associationsToRepresent; - } + ArrayList<Association> filteredAssociations = this.filterAssociationsByType(); + filteredAssociations = this.filterAssociationsByRoleAndPlayerTypes(filteredAssociations); + this.checkAssociationsByRoleCombinations(filteredAssociations); + this.associationsToRepresent = filteredAssociations; + this.associationsToRepresentSet = true; + return this.associationsToRepresent; }
participants (1)
-
lgiessmann@common-lisp.net