[isidorus-cvs] r777 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: . base container environment text view
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Wed Aug 24 15:24:59 UTC 2011
Author: lgiessmann
Date: Wed Aug 24 08:24:57 2011
New Revision: 777
Log:
gdl-frontend: Widgets: implementedthe consulption of association in GdlEditorAssociationView => Changed the behavior of the GdlView-hierarchy
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/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/container/GdlUnit.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
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java
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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Wed Aug 24 08:24:57 2011 (r777)
@@ -1,4 +1,4 @@
-* finalise the GDL-Schema for creating and editing instances of tgm:Hash-Object => AssociationView + Hidden-Value (type-occurrence)
+* finalise the GDL-Schema for creating and editing instances of tgm:Hash-Object => Hidden-Value (type-occurrence) + otherrole
* Implement all IHasValueGroup to:
* GdlText
* GdlInfo
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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Wed Aug 24 08:24:57 2011 (r777)
@@ -710,7 +710,7 @@
ArrayList<Topic> constrainedNameTypes = getOtherPlayerOfBinaryAssociation(constraintTopic, constraintRoleType, constrainedStatementAssocType, null, nameType, constrainedRoleType);
ArrayList<Topic> constrainedOccurrenceTypes = getOtherPlayerOfBinaryAssociation(constraintTopic, constraintRoleType, constrainedStatementAssocType, null, occurrenceType, constrainedRoleType);
ArrayList<Topic> constrainedAssociationTypes = getOtherPlayerOfBinaryAssociation(constraintTopic, constraintRoleType, constrainedStatementAssocType, null, associationType, constrainedRoleType);
- ArrayList<Topic> constrainedStatements = Utils.merge(Utils.merge(constrainedNameTypes, constrainedOccurrenceTypes), constrainedAssociationTypes);
+ ArrayList<Topic> constrainedStatements = Utils.union(Utils.union(constrainedNameTypes, constrainedOccurrenceTypes), constrainedAssociationTypes);
if(constrainedStatements.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(constraintTopic) + " must be bound exactly once to a statement topic via a " + PSIs.TMCL.tmclConstrainedStatement + " association, but is: " + constrainedStatements.size());
else return constrainedStatements.get(0);
@@ -950,7 +950,7 @@
Topic constrainedStatementAssocType = getTopicByPsi(PSIs.TMCL.tmclConstrainedStatement, tm);
ArrayList<Topic> nameTypeTopics = getOtherPlayerOfBinaryAssociation(rootConstraint, constraintRoleType, constrainedStatementAssocType, null, nameType, constrainedRoleType);
ArrayList<Topic> occurrenceTypeTopics = getOtherPlayerOfBinaryAssociation(rootConstraint, constraintRoleType, constrainedStatementAssocType, null, occurrenceType, constrainedRoleType);
- ArrayList<Topic> typeTopics = Utils.merge(nameTypeTopics, occurrenceTypeTopics);
+ ArrayList<Topic> typeTopics = Utils.union(nameTypeTopics, occurrenceTypeTopics);
if(typeTopics.size() != 1){
throw new InvalidGdlSchemaException("the constraint " + getAnyIdOfTopic(rootConstraint) + " must be bound extactly once to an occurrence or name type, but is: " + typeTopics.size());
@@ -998,7 +998,7 @@
Topic occurrenceType = getTopicByPsi(PSIs.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.merge(nameTypes, occurrenceTypes);
+ ArrayList<Topic> nameOrOccurrenceTypes = Utils.union(nameTypes, occurrenceTypes);
if(nameOrOccurrenceTypes.size() == 0){
return result;
@@ -1030,7 +1030,7 @@
JsArray<Topic> topicTypes = topicInstance.getTypes();
for(int i = 0; i != topicTypes.length(); ++i){
ArrayList<Topic> resultForType = getTopicRoleConstraintsForTopicType(topicTypes.get(i));
- result = Utils.merge(result, resultForType);
+ result = Utils.union(result, resultForType);
}
return result;
@@ -1093,7 +1093,7 @@
ArrayList<Topic> resultIi = getOtherPlayerOfBinaryAssociation(tmValueOrvalueGroup, descriptorRoleType, displayByAssocType, null, tmConstruct, itemIdentifierConstraintType);
ArrayList<Topic> resultName = getOtherPlayerOfBinaryAssociation(tmValueOrvalueGroup, descriptorRoleType, displayByAssocType, null, tmConstruct, topicNameConstraintType);
- ArrayList<Topic> result = Utils.merge(Utils.merge(Utils.merge(resultPsi, resultSl), resultIi), resultName);
+ ArrayList<Topic> result = Utils.union(Utils.union(Utils.union(resultPsi, resultSl), resultIi), resultName);
if(result.size() > 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(tmValueOrvalueGroup) + " must be bound none or once to a tmcl:constraint via a " + PSIs.AssociationType.gdlDisplayBy + " assciation, but is: " + result.size());
else if(result.size() == 1) return result.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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java Wed Aug 24 08:24:57 2011 (r777)
@@ -23,7 +23,7 @@
// returns a list that contains a union of both lists
- public static <T> ArrayList<T> union(ArrayList<T> fst, ArrayList<T> snd){
+ public static <T> ArrayList<T> intersection(ArrayList<T> fst, ArrayList<T> snd){
ArrayList<T> result = new ArrayList<T>();
if(fst == null || snd == null) return result;
@@ -34,7 +34,7 @@
// returns an ArrayList that is a merged ArrayList of fst and snd
- public static <T> ArrayList<T> merge(ArrayList<T> fst, ArrayList<T> 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);
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java Wed Aug 24 08:24:57 2011 (r777)
@@ -215,7 +215,7 @@
ArrayList<Topic> nameConstraints = TmHelper.getOtherPlayerOfBinaryAssociation(this.tmRepresentative, descriptorRoleType, tmBindingAssocType, null, tmclTopicNameConstraintType, tmConstructRoleType);
ArrayList<Topic> variantConstraints = TmHelper.getOtherPlayerOfBinaryAssociation(this.tmRepresentative, descriptorRoleType, tmBindingAssocType, null, tmclVariantNameConstraintType, tmConstructRoleType);
ArrayList<Topic> occurrenceConstraints = TmHelper.getOtherPlayerOfBinaryAssociation(this.tmRepresentative, descriptorRoleType, tmBindingAssocType, null, tmclTopicOccurrenceConstraintType, tmConstructRoleType);
- ArrayList<Topic> allConstraints = Utils.merge(Utils.merge(nameConstraints, variantConstraints), occurrenceConstraints);
+ ArrayList<Topic> allConstraints = Utils.union(Utils.union(nameConstraints, variantConstraints), occurrenceConstraints);
if(allConstraints.size() > 1)
throw new InvalidGdlSchemaException("the topic " + TmHelper.getAnyIdOfTopic(this.tmRepresentative) + " can be bound only to one constraint, but is " + allConstraints.size());
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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlInstantiator.java Wed Aug 24 08:24:57 2011 (r777)
@@ -94,20 +94,15 @@
}else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.TopicType.gdlDefaultCreatorTopicView)){
return new GdlDefaultCreatorTopicView(tmRepresentative);
}else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.TopicType.gdlDefaultEditorTopicView)){
- if(!(receivedData instanceof Topic) && receivedData != null) throw new ExecutionException("receivedData must be of type Topic when used with " + PSIs.TopicType.gdlDefaultEditorTopicView);
return new GdlDefaultEditorTopicView(tmRepresentative, (Topic)receivedData);
}else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.TopicType.gdlSpecialCreatorTopicView)){
- if(!(receivedData instanceof Topic) && receivedData != null) throw new ExecutionException("receivedData must be of type Topic when used with " + PSIs.TopicType.gdlSpecialCreatorTopicView);
return new GdlSpecialCreatorTopicView(tmRepresentative);
}else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.TopicType.gdlSpecialEditorTopicView)){
- if(!(receivedData instanceof Topic) && receivedData != null) throw new ExecutionException("receivedData must be of type Topic when used with " + PSIs.TopicType.gdlSpecialEditorTopicView);
return new GdlSpecialEditorTopicView(tmRepresentative, (Topic)receivedData);
}else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.TopicType.gdlCreatorAssociationview)){
- if(!(receivedData instanceof Topic) && receivedData != null) throw new ExecutionException("receivedData must be of type Association when used with " + PSIs.TopicType.gdlCreatorAssociationview);
- return new GdlCreatorAssociationView(tmRepresentative, (Topic)receivedData);
+ return new GdlCreatorAssociationView(tmRepresentative, (Association)receivedData);
}else if(TmHelper.isInstanceOf(tmRepresentative, PSIs.TopicType.gdlEditorAssociationView)){
- if(!(receivedData instanceof Topic) && receivedData != null) throw new ExecutionException("receivedData must be of type Associaiton when used with " + PSIs.TopicType.gdlEditorAssociationView);
- return new GdlEditorAssociationView(tmRepresentative, (Topic)receivedData);
+ return new GdlEditorAssociationView(tmRepresentative, (Association)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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Wed Aug 24 08:24:57 2011 (r777)
@@ -131,6 +131,8 @@
this.createNewTextArea().setText(((Topic)this.receivedData).getOccurrences(occurrenceType).get(i).getValue());
} else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TopicType.gdlRolePlayer)){
this.createNewTextArea().setText("gdl:Role-Player instance");
+ // TODO: search role => role-type + role-player
+ // TODO: display the correponding value
}
// TODO: implement type, variant, datatype, associations, roles, ... constraints
}
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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Wed Aug 24 08:24:57 2011 (r777)
@@ -1,19 +1,25 @@
package us.isidor.gdl.anaToMia.Widgets.view;
import java.util.ArrayList;
+
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
-import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
+import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject;
+import us.isidor.gdl.anaToMia.Widgets.base.PSIs;
import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
+import us.isidor.gdl.anaToMia.Widgets.value.ContentOrientationValue;
public abstract class GdlAssociationView extends GdlView {
- protected ArrayList<Association> associationsToRepresent = null;
- protected boolean associationsToRepresentSet = false;
private ArrayList<Topic> associationRoleConstraints = new ArrayList<Topic>();
private boolean associationRoleConstraintsSet = false;
private ArrayList<Topic> topicRoleConstraints = new ArrayList<Topic>();
@@ -32,25 +38,28 @@
super();
}
-
- public GdlAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException {
- this();
- this.tmRepresentative = tmRepresentative;
- this.tm = this.tmRepresentative.getTopicMap();
- this.receivedData = receivedData;
- this.setId(this.getId());
- this.setGdlStyle();
- if(this instanceof GdlEditorAssociationView) this.associationsToRepresent = this.filterAssociations();
-
- ArrayList<Topic> objectsContained = this.contains();
-
- Topic currentTopic = this.getStartElement(objectsContained);
- Topic lastTopic = super.getTmRepresentative();
- while(currentTopic != null){
- this.append(lastTopic, currentTopic);
- lastTopic = currentTopic;
- currentTopic = TmHelper.getNextContainee(currentTopic, objectsContained);
- }
+
+ public GdlAssociationView(Topic tmRepresentative, Association receivedData) throws InvalidGdlSchemaException, ExecutionException {
+ super(tmRepresentative, receivedData);
+ }
+
+
+ // content orientation has no effect on a view, so here must the original method
+ // defined in GdlVisibleObject implemented
+ @Override
+ public void setContentOrientation(ContentOrientationValue value) throws InvalidGdlSchemaException, ExecutionException {
+ if(value == ContentOrientationValue.HORIZONTAL && this.containerPanel == null) this.containerPanel = new HorizontalPanel();
+ else if(this.containerPanel == null) this.containerPanel = new VerticalPanel();
+
+ this.mainPanel.add(this.containerPanel);
+ }
+
+
+ // Searches the topic that represents the first item that is placed within this view instance
+ // i.e. such an item must not have an association that is bound to it via a role of the type
+ // gdl:ancestor.
+ protected Topic getStartElement(ArrayList<Topic> containees) throws InvalidGdlSchemaException {
+ return TmHelper.getFirstContainee(super.getTmRepresentative(), containees);
}
@@ -155,77 +164,6 @@
}
- // returns all associations of the received topicthat have a
- // correct type determined by this association-view
- private ArrayList<Association> filterAssociationsByType() throws InvalidGdlSchemaException {
- ArrayList<Association> allAssociations = new ArrayList<Association>();
- if(this.receivedData != null)
- for(int i = 0; i != ((Topic)this.receivedData).getRolesPlayed().length(); ++i)
- allAssociations.add(((Topic)this.receivedData).getRolesPlayed().get(i).getParent());
-
- // collect only the associations that match the correct association type
- ArrayList<Association> filteredAssociationsByType = new ArrayList<Association>();
- for (Association assoc : allAssociations)
- if(assoc.getType().equals(this.getAssociationType())) filteredAssociationsByType.add(assoc);
-
- return filteredAssociationsByType;
- }
-
-
- // returns all associations contained in the ArrayList allAssociations
- // that have the only permitted role types
- private ArrayList<Association> filterAssociationsByRoleAndPlayerTypes(ArrayList<Association> allAssociations) throws InvalidGdlSchemaException {
- if(allAssociations == null) return new ArrayList<Association>();
-
- ArrayList<Association> filteredAssociationsByAssociationRoleConstraints = new ArrayList<Association>();
- for (Association assoc : allAssociations){
- JsArray<Role> roles = assoc.getRoles();
- int i = 0;
- for( ; i != roles.length(); ++i){
- Topic rt = roles.get(i).getType();
- Topic rp = roles.get(i).getPlayer();
-
- int j = 0;
- for( ; j != this.getRoleAndPlayerTypes().size(); ++j){
- Pair<Topic, Topic> pair = this.getRoleAndPlayerTypes().get(j);
- if(pair.getFirst().equals(rt) && TmHelper.isInstanceOf(rp, pair.getSecond())) break;
- }
-
- if(j == this.getRoleAndPlayerTypes().size()) break;
- }
-
- if(i == roles.length())filteredAssociationsByAssociationRoleConstraints.add(assoc);
- }
-
- return filteredAssociationsByAssociationRoleConstraints;
- }
-
-
- // throws an InvalidGdlSchemaException if passed one association does not satisfy
- // any defined role-combination-constraint
- private void checkAssociationsByRoleCombinations(ArrayList<Association> allAssociations) throws InvalidGdlSchemaException {
- if(this.getRoleCombinationConstraints().size() == 0) return;
-
- for (Association assoc : allAssociations) {
- JsArray<Role> roles = assoc.getRoles();
- if(roles.length() != 2) throw new InvalidGdlSchemaException("the association " + assoc + " violates the defined role-combination-constrains");
- Role fstRole = roles.get(0);
- Role sndRole = roles.get(1);
-
- int i = 0;
- for ( ; i != this.getValidRoleCombinations().size(); ++i) {
- Pair<Topic, Topic> fstCombi = this.getValidRoleCombinations().get(i).getFirst();
- Pair<Topic, Topic> sndCombi = this.getValidRoleCombinations().get(i).getSecond();
-
- if(fstRole.getType().equals(fstCombi.getFirst()) && TmHelper.isInstanceOf(fstRole.getPlayer(), fstCombi.getSecond()) && sndRole.getType().equals(sndCombi.getFirst()) && TmHelper.isInstanceOf(sndRole.getPlayer(), sndCombi.getSecond())) break;
- if(sndRole.getType().equals(fstCombi.getFirst()) && TmHelper.isInstanceOf(sndRole.getPlayer(), fstCombi.getSecond()) && fstRole.getType().equals(sndCombi.getFirst()) && TmHelper.isInstanceOf(fstRole.getPlayer(), sndCombi.getSecond())) break;
- }
-
- if(i == this.getValidRoleCombinations().size()) throw new InvalidGdlSchemaException("the association " + assoc + " violates the defined role-combination-constrains");
- }
- }
-
-
// Returns all valid role-player combinations for this association-view
public ArrayList<Pair<Pair<Topic, Topic>, Pair<Topic, Topic>>> getValidRoleCombinations() throws InvalidGdlSchemaException {
if(this.validRoleCombinationsSet){
@@ -241,23 +179,120 @@
return this.validRoleCombinations;
}
}
-
+
+
+ // This class represents a single association that is displayed.
+ // Further elements are created by caling the GdlInstantiator.instantiate
+ // method, the passed received argument is set ot the association that is
+ // represented by this class
+ protected class AssociationItem extends GdlView {
+ private int indexInParent = -1;
+
+
+ @SuppressWarnings("unused")
+ private AssociationItem(){
+ super();
+ }
+
+
+ public AssociationItem(Topic tmRepresentative, Association receivedData, int indexInParent) throws InvalidGdlSchemaException, ExecutionException{
+ super(tmRepresentative, receivedData);
+ this.indexInParent = indexInParent;
+
+ ArrayList<Topic> objectsContained = this.contains();
+
+ Topic currentTopic = this.getStartElement(objectsContained);
+ Topic lastTopic = super.getTmRepresentative();
+ while(currentTopic != null){
+ this.append(lastTopic, currentTopic);
+ lastTopic = currentTopic;
+ currentTopic = TmHelper.getNextContainee(currentTopic, objectsContained);
+ }
+ }
+
+
+ // this method should be invoked if a new sub-element is added to this instance.
+ // instances of GdlView does not organize their sub-elements in
+ // tables, sub-elements are placed directly on the mainpanel
+ @Override
+ protected ButtonableObject addToContainerPanel(Widget widget){
+ this.subElements.add(widget);
+ this.mainPanel.add(widget);
+ return null;
+ }
+
+
+ // returns the string value of a gdl:id occurrence
+ public String getId() throws InvalidGdlSchemaException {
+ JsArray<Occurrence> idOccs = getOccurrences(PSIs.OccurrenceType.gdlId);
+ if(idOccs.length() != 1){
+ throw new InvalidGdlSchemaException("The topic " + TmHelper.getAnyIdOfTopic(this.tmRepresentative) + " must be bound to exactly one occurrence of the type " + PSIs.OccurrenceType.gdlId + ", but is bound " + idOccs.length() + " times to it");
+ } else {
+ return idOccs.get(0).getValue() + "__GDL_" + this.indexInParent;
+ }
+ }
+
+
+ // sets all GDL styles that are defined by the topic map representative
+ @Override
+ protected void setGdlStyle() throws InvalidGdlSchemaException, ExecutionException {
+ // do nothing: all properties are set in the parent element
+ // and are ignored for this element
+ }
+
+
+ // sets all GDL styles that are defined by the topic map representative to tha passed widget
+ @Override
+ public void setGdlStyle(Widget widget) throws InvalidGdlSchemaException, ExecutionException {
+ String[] styleClasses = new String[]{null, PSIs.Scope.gdlActive, PSIs.Scope.gdlFocus, PSIs.Scope.gdlHover};
+ for (String styleClass : styleClasses) {
+ this.setVerticalAlign(widget, this.getVerticalAlign(styleClass), styleClass);
+
+ this.setBorderColor(widget, this.getBorderColor(styleClass), styleClass);
+ this.setBorderTopColor(widget, this.getBorderTopColor(styleClass), styleClass);
+ this.setBorderRightColor(widget, this.getBorderRightColor(styleClass), styleClass);
+ this.setBorderBottomColor(widget, this.getBorderBottomColor(styleClass), styleClass);
+ this.setBorderLeftColor(widget, this.getBorderLeftColor(styleClass), styleClass);
+
+ this.setBorderStyle(widget, this.getBorderStyle(styleClass), styleClass);
+ this.setBorderTopStyle(widget, this.getBorderTopStyle(styleClass), styleClass);
+ this.setBorderRightStyle(widget, this.getBorderRightStyle(styleClass), styleClass);
+ this.setBorderBottomStyle(widget, this.getBorderBottomStyle(styleClass), styleClass);
+ this.setBorderLeftStyle(widget, this.getBorderLeftStyle(styleClass), styleClass);
+
+ this.setBorderWidth(widget, this.getBorderWidth(styleClass), styleClass);
+ this.setBorderTopWidth(widget, this.getBorderTopWidth(styleClass), styleClass);
+ this.setBorderRightWidth(widget, this.getBorderRightWidth(styleClass), styleClass);
+ this.setBorderBottomWidth(widget, this.getBorderBottomWidth(styleClass), styleClass);
+ this.setBorderLeftWidth(widget, this.getBorderLeftWidth(styleClass), styleClass);
+
+ this.setBorderRadius(widget, this.getBorderRadius(styleClass), styleClass);
+ this.setBorderTopRightRadius(widget, this.getBorderTopRightRadius(styleClass), styleClass);
+ this.setBorderBottomRightRadius(widget, this.getBorderBottomRightRadius(styleClass), styleClass);
+ this.setBorderBottomLeftRadius(widget, this.getBorderBottomLeftRadius(styleClass), styleClass);
+ this.setBorderTopLeftRadius(widget, this.getBorderTopLeftRadius(styleClass), styleClass);
+
+ this.setCursor(widget, this.getCursor(styleClass), styleClass);
+
+ this.setWidth(widget, this.getWidth(styleClass), styleClass);
+ this.setMaxWidth(widget, this.getMaxWidth(styleClass), styleClass);
+ this.setMinWidth(widget, this.getMinWidth(styleClass), styleClass);
+
+ this.setHeight(widget, this.getHeight(styleClass), styleClass);
+ this.setMaxHeight(widget, this.getMaxHeight(styleClass), styleClass);
+ this.setMinHeight(widget, this.getMinHeight(styleClass), styleClass);
+
+ this.setBackgroundColor(widget, this.getBackgroundColor(styleClass), styleClass);
+ }
+ }
+
+
+ @Override
+ @Deprecated
+ public TopicMap getContent() {
+ // this item has no content that is a Topic Map item!
+ return null;
+ }
- // returns an array with associations that
- // must be represented by this association view
- private ArrayList<Association> filterAssociations() throws InvalidGdlSchemaException {
- ArrayList<Association> filteredAssociations = this.filterAssociationsByType();
- filteredAssociations = this.filterAssociationsByRoleAndPlayerTypes(filteredAssociations);
- this.checkAssociationsByRoleCombinations(filteredAssociations);
- this.associationsToRepresent = filteredAssociations;
- this.associationsToRepresentSet = true;
- return this.associationsToRepresent;
- }
-
-
- // Returns the associations that are represented by this associaton-view
- public ArrayList<Association> getAssociationsToRepresent() throws InvalidGdlSchemaException {
- if(this.associationsToRepresentSet) return this.associationsToRepresent;
- else return this.filterAssociations();
}
}
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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlCreatorAssociationView.java Wed Aug 24 08:24:57 2011 (r777)
@@ -1,5 +1,6 @@
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;
@@ -8,11 +9,11 @@
public class GdlCreatorAssociationView extends GdlAssociationView {
- public GdlCreatorAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException {
+ public GdlCreatorAssociationView(Topic tmRepresentative, Association receivedData) throws InvalidGdlSchemaException, ExecutionException {
super(tmRepresentative, receivedData);
// TODO Auto-generated constructor stub
}
-
+
@Override
public TopicMap getContent() {
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 Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlEditorAssociationView.java Wed Aug 24 08:24:57 2011 (r777)
@@ -1,19 +1,129 @@
package us.isidor.gdl.anaToMia.Widgets.view;
+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;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
+import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
public class GdlEditorAssociationView extends GdlAssociationView {
+ protected ArrayList<Association> associationsToRepresent = null;
+ protected boolean associationsToRepresentSet = false;
+
- public GdlEditorAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException {
+ public GdlEditorAssociationView(Topic tmRepresentative, Association receivedData) throws InvalidGdlSchemaException, ExecutionException {
super(tmRepresentative, receivedData);
- // TODO Auto-generated constructor stub
+
+ // create an association item for each association that must be represetned
+ // by this view
+ for (int i = 0; i != this.getAssociationsToRepresent().size(); ++i)
+ this.addToContainerPanel(new AssociationItem(this.tmRepresentative, this.getAssociationsToRepresent().get(i), i));
+ }
+
+
+ // returns all associations of the received topic that have a
+ // correct type determined by this association-view
+ private ArrayList<Association> filterAssociationsByType() throws InvalidGdlSchemaException {
+ ArrayList<Association> allAssociations = new ArrayList<Association>();
+ if(this.receivedData != null)
+ for(int i = 0; i != ((Topic)this.receivedData).getRolesPlayed().length(); ++i)
+ allAssociations.add(((Topic)this.receivedData).getRolesPlayed().get(i).getParent());
+
+ // collect only the associations that match the correct association type
+ ArrayList<Association> filteredAssociationsByType = new ArrayList<Association>();
+ for (Association assoc : allAssociations)
+ if(assoc.getType().equals(this.getAssociationType())) filteredAssociationsByType.add(assoc);
+
+ return filteredAssociationsByType;
+ }
+
+
+ // returns all associations contained in the ArrayList allAssociations
+ // that have the only permitted role types
+ private ArrayList<Association> filterAssociationsByRoleAndPlayerTypes(ArrayList<Association> allAssociations) throws InvalidGdlSchemaException {
+ if(allAssociations == null) return new ArrayList<Association>();
+
+ ArrayList<Association> filteredAssociationsByAssociationRoleConstraints = new ArrayList<Association>();
+ for (Association assoc : allAssociations){
+ JsArray<Role> roles = assoc.getRoles();
+ int i = 0;
+ for( ; i != roles.length(); ++i){
+ Topic rt = roles.get(i).getType();
+ Topic rp = roles.get(i).getPlayer();
+
+ int j = 0;
+ for( ; j != this.getRoleAndPlayerTypes().size(); ++j){
+ Pair<Topic, Topic> pair = this.getRoleAndPlayerTypes().get(j);
+ if(pair.getFirst().equals(rt) && TmHelper.isInstanceOf(rp, pair.getSecond())) break;
+ }
+
+ if(j == this.getRoleAndPlayerTypes().size()) break;
+ }
+
+ if(i == roles.length())filteredAssociationsByAssociationRoleConstraints.add(assoc);
+ }
+
+ return filteredAssociationsByAssociationRoleConstraints;
}
+
+ // throws an InvalidGdlSchemaException if passed one association does not satisfy
+ // any defined role-combination-constraint
+ private void checkAssociationsByRoleCombinations(ArrayList<Association> allAssociations) throws InvalidGdlSchemaException {
+ if(this.getRoleCombinationConstraints().size() == 0) return;
+
+ for (Association assoc : allAssociations) {
+ JsArray<Role> roles = assoc.getRoles();
+ if(roles.length() != 2) throw new InvalidGdlSchemaException("the association " + assoc + " violates the defined role-combination-constrains");
+ Role fstRole = roles.get(0);
+ Role sndRole = roles.get(1);
+
+ int i = 0;
+ for ( ; i != this.getValidRoleCombinations().size(); ++i) {
+ Pair<Topic, Topic> fstCombi = this.getValidRoleCombinations().get(i).getFirst();
+ Pair<Topic, Topic> sndCombi = this.getValidRoleCombinations().get(i).getSecond();
+
+ if(fstRole.getType().equals(fstCombi.getFirst()) && TmHelper.isInstanceOf(fstRole.getPlayer(), fstCombi.getSecond()) && sndRole.getType().equals(sndCombi.getFirst()) && TmHelper.isInstanceOf(sndRole.getPlayer(), sndCombi.getSecond())) break;
+ if(sndRole.getType().equals(fstCombi.getFirst()) && TmHelper.isInstanceOf(sndRole.getPlayer(), fstCombi.getSecond()) && fstRole.getType().equals(sndCombi.getFirst()) && TmHelper.isInstanceOf(fstRole.getPlayer(), sndCombi.getSecond())) break;
+ }
+
+ if(i == this.getValidRoleCombinations().size()) throw new InvalidGdlSchemaException("the association " + assoc + " violates the defined role-combination-constrains");
+ }
+ }
+
+
+ // 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;
+ }
+ }
+
+
+ // Returns the associations that are represented by this associaton-view
+ public ArrayList<Association> getAssociationsToRepresent() throws InvalidGdlSchemaException {
+ if(this.associationsToRepresentSet) return this.associationsToRepresent;
+ else return this.filterAssociations();
+ }
+
@Override
public String getViewName() {
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Wed Aug 24 08:24:57 2011 (r777)
@@ -1,13 +1,69 @@
package us.isidor.gdl.anaToMia.Widgets.view;
+import java.util.ArrayList;
+import com.google.gwt.user.client.ui.Widget;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
+import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject;
+import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+import us.isidor.gdl.anaToMia.Widgets.value.ContentOrientationValue;
public abstract class GdlTopicView extends GdlView {
public GdlTopicView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative, receivedData);
+
+ ArrayList<Topic> objectsContained = this.contains();
+
+ Topic currentTopic = this.getStartElement(objectsContained);
+ Topic lastTopic = super.getTmRepresentative();
+ while(currentTopic != null){
+ this.append(lastTopic, currentTopic);
+ lastTopic = currentTopic;
+ currentTopic = TmHelper.getNextContainee(currentTopic, objectsContained);
+ }
+ }
+
+
+ // this method should be invoked if a new sub-element is added to this instance.
+ // instances of GdlView does not organize their sub-elements in
+ // tables, sub-elements are placed directly on the mainpanel
+ @Override
+ protected ButtonableObject addToContainerPanel(Widget widget){
+ this.subElements.add(widget);
+ this.mainPanel.add(widget);
+ return null;
+ }
+
+
+ // content orientation has no effect on a view
+ @Override
+ public void setContentOrientation(ContentOrientationValue value) throws InvalidGdlSchemaException, ExecutionException {
+ // do nothing, no table is set for organizing content widgets, since a view does not organize
+ // its content in this manner
+ }
+
+
+ // Searches the topic that represents the first item that is placed within this view instance
+ // i.e. such an item must not have an association that is bound to it via a role of the type
+ // gdl:ancestor.
+ protected Topic getStartElement(ArrayList<Topic> containees) throws InvalidGdlSchemaException {
+ return TmHelper.getFirstContainee(super.getTmRepresentative(), containees);
+ }
+
+
+ // sets all GDL styles that are defined by the topic map representative.
+ // In contrast to visible-object, the styles are applied only on the main
+ // panel, since the view's sub-elements must be formatted with their own
+ // style properties
+ @Override
+ protected void setGdlStyle() throws InvalidGdlSchemaException, ExecutionException {
+ this.setDisplay(this.getDisplay());
+ this.setZindex(this.getZindex());
+ this.setFloat(this.getFloat());
+ this.setClear(this.getClear());
+ this.setGdlStyle(this.mainPanel);
}
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java Tue Aug 23 11:06:14 2011 (r776)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java Wed Aug 24 08:24:57 2011 (r777)
@@ -1,5 +1,6 @@
package us.isidor.gdl.anaToMia.Widgets.view;
+
import java.util.ArrayList;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.ui.Widget;
@@ -7,11 +8,10 @@
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
-import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject;
import us.isidor.gdl.anaToMia.Widgets.base.GdlPosition;
-import us.isidor.gdl.anaToMia.Widgets.base.PSIs;
import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject;
import us.isidor.gdl.anaToMia.Widgets.base.IGdlContainer;
+import us.isidor.gdl.anaToMia.Widgets.base.PSIs;
import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.GdlInstantiator;
@@ -27,26 +27,17 @@
public GdlView(Topic tmRepresentative, Construct receivedData) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative, receivedData);
- ArrayList<Topic> objectsContained = this.contains();
- Topic currentTopic = this.getStartElement(objectsContained);
- Topic lastTopic = super.getTmRepresentative();
- while(currentTopic != null){
- this.append(lastTopic, currentTopic);
- lastTopic = currentTopic;
- currentTopic = TmHelper.getNextContainee(currentTopic, objectsContained);
- }
}
- // this method should be invoked if a new sub-element is added to this instance.
- // instances ov GdlView does not organize their sub-elements in
- // tables, sub-elements are placed directly on the mainpanel
- @Override
- protected ButtonableObject addToContainerPanel(Widget widget){
- this.subElements.add(widget);
- this.mainPanel.add(widget);
- return null;
+
+ public String getViewName()throws InvalidGdlSchemaException {
+ JsArray<Name> viewNames = super.tmRepresentative.getNames(tm.getTopicBySubjectIdentifier(tm.createLocator(PSIs.NameType.gdlViewName)));
+ if(viewNames.length() != 1){
+ throw new InvalidGdlSchemaException("A view must be bound to a " + PSIs.NameType.gdlViewName + " instance");
+ }
+ return viewNames.get(0).getValue();
}
@@ -56,15 +47,6 @@
// do nothing, no table is set for organizing content widgets, since a view does not organize
// its content in this manner
}
-
-
- public String getViewName()throws InvalidGdlSchemaException {
- JsArray<Name> viewNames = super.tmRepresentative.getNames(tm.getTopicBySubjectIdentifier(tm.createLocator(PSIs.NameType.gdlViewName)));
- if(viewNames.length() != 1){
- throw new InvalidGdlSchemaException("A view must be bound to a " + PSIs.NameType.gdlViewName + " instance");
- }
- return viewNames.get(0).getValue();
- }
// Searches the topic that represents the first item that is placed within this view instance
@@ -75,20 +57,6 @@
}
- // sets all GDL styles that are defined by the topic map representative.
- // In contrast to visible-object, the styles are applied only on the main
- // panel, since the view's sub-elements must be formatted with their own
- // style properties
- @Override
- protected void setGdlStyle() throws InvalidGdlSchemaException, ExecutionException {
- this.setDisplay(this.getDisplay());
- this.setZindex(this.getZindex());
- this.setFloat(this.getFloat());
- this.setClear(this.getClear());
- this.setGdlStyle(this.mainPanel);
- }
-
-
// creates a GdlVisbleObject instance of the passed topic current and inserts it
// by using it's defined position style depending on the GdlVisibleObject
// represented by ancestor. If ancestor is null current is the first topic
More information about the Isidorus-cvs
mailing list