[isidorus-cvs] r615 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base container view
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Thu Jul 14 07:28:37 UTC 2011
Author: lgiessmann
Date: Thu Jul 14 00:28:35 2011
New Revision: 615
Log:
gdl-frontend: Widgets: implemented some helper methods that returns the start topic element of a container element and searches the descendant topic element of a containee topic
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/IGdlContainer.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/container/GdlList.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/view/GdlView.java
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 Wed Jul 13 12:32:30 2011 (r614)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Thu Jul 14 00:28:35 2011 (r615)
@@ -1,16 +1,5 @@
package us.isidor.gdl.anaToMia.Widgets.base;
-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.Construct;
-import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator;
-import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role;
-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.environment.Pair;
-import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes;
public class GdlPsis {
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlContainer.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlContainer.java Wed Jul 13 12:32:30 2011 (r614)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlContainer.java Thu Jul 14 00:28:35 2011 (r615)
@@ -1,7 +1,11 @@
package us.isidor.gdl.anaToMia.Widgets.base;
+import java.util.ArrayList;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
+
public interface IGdlContainer {
public void append(GdlVisibleObject widget) throws InvalidGdlSchemaException;
+ public ArrayList<Topic> contains() 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 Wed Jul 13 12:32:30 2011 (r614)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Jul 14 00:28:35 2011 (r615)
@@ -13,6 +13,7 @@
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;
import com.google.gwt.core.client.JsArray;
@@ -296,4 +297,74 @@
return result;
}
+
+
+ // returns all topics that are related to the passed topic via a contains assciation
+ public static ArrayList<Topic> topicContains(Topic container) {
+ if(container == null) return new ArrayList<Topic>();
+
+ TopicMap tm = container.getTopicMap();
+ Topic contains = getTopicByPsi(GdlPsis.AssociationType.gdlContains, tm);
+ Topic containerRoleType = getTopicByPsi(GdlPsis.RoleType.gdlContainer, tm);
+ Topic visibleObject = getTopicByPsi(GdlPsis.TopicType.gdlVisibleObject, tm);
+ Topic containeeRoleType = getTopicByPsi(GdlPsis.RoleType.gdlContainee, tm);
+ return getOtherPlayerOfBinaryAssociation(container, containerRoleType, contains, null, visibleObject, containeeRoleType);
+ }
+
+
+ // returns the topic that represetns the first item of a container, that means this item is
+ // not bound to an association o fthe type position in a role of the type descendant
+ public static Topic getFirstContainee(ArrayList<Topic> containees) throws InvalidGdlSchemaException {
+ if(containees == null || containees.size() == 0) return null;
+
+ ArrayList<Topic> topicsWithoutAncestor = new ArrayList<Topic>();
+ TopicMap tm = containees.get(0).getTopicMap();
+ Topic descendant = getTopicByPsi(GdlPsis.RoleType.gdlDescendant, tm);
+ Topic position = getTopicByPsi(GdlPsis.AssociationType.gdlPosition, tm);
+ Topic visibleObject = getTopicByPsi(GdlPsis.TopicType.gdlVisibleObject, tm);
+ Topic ancestor = getTopicByPsi(GdlPsis.RoleType.gdlAncestor, tm);
+ for (Topic containee : containees)
+ if(null == getOtherPlayerOfBinaryAssociation(containee, descendant, position, null, visibleObject, ancestor)) topicsWithoutAncestor.add(containee);
+
+ if(topicsWithoutAncestor.size() > 1){
+ String values = "";
+ for (Topic topic : topicsWithoutAncestor) values += ", " + getAnyIdOfTopic(topic);
+ if(values.length() >= 2) values = values.substring(2);
+ throw new InvalidGdlSchemaException("only one topic can be set as the start element of a container, but found: " + values);
+ } else if(topicsWithoutAncestor.size() == 1){
+ return topicsWithoutAncestor.get(0);
+ } else {
+ return null;
+ }
+ }
+
+
+ // returns the descendant of the current topic related via an contains association
+ public static Topic getNextContainer(Topic current, ArrayList<Topic> containees) throws InvalidGdlSchemaException{
+ if (current == null || containees == null || containees.size() == 0) return null;
+
+ TopicMap tm = current.getTopicMap();
+ Topic descendant = getTopicByPsi(GdlPsis.RoleType.gdlDescendant, tm);
+ Topic position = getTopicByPsi(GdlPsis.AssociationType.gdlPosition, tm);
+ Topic visibleObject = getTopicByPsi(GdlPsis.TopicType.gdlVisibleObject, tm);
+ Topic ancestor = getTopicByPsi(GdlPsis.RoleType.gdlAncestor, tm);
+ ArrayList<Topic> descendants = getOtherPlayerOfBinaryAssociation(current, ancestor, position, null, visibleObject, descendant);
+
+ ArrayList<Topic> descendantsContainedInContainees = new ArrayList<Topic>();
+ for (Topic topic : descendants)
+ if(containees.contains(topic) && !descendantsContainedInContainees.contains(topic)) descendantsContainedInContainees.add(topic);
+
+
+ if(descendantsContainedInContainees.size() > 1){
+ String top = getAnyIdOfTopic(current);
+ String bindings = "";
+ for (Topic topic : descendantsContainedInContainees) bindings += ", " + getAnyIdOfTopic(topic);
+ if(bindings.length() >= 2) bindings = bindings.substring(2);
+ throw new InvalidGdlSchemaException("the topic " + top + " must be bound to none or one descendant topics, but is bound to " + bindings);
+ }else if(descendantsContainedInContainees.size() == 1){
+ return descendantsContainedInContainees.get(0);
+ }else{
+ return null;
+ }
+ }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java Wed Jul 13 12:32:30 2011 (r614)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java Thu Jul 14 00:28:35 2011 (r615)
@@ -30,6 +30,8 @@
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis;
import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject;
+import us.isidor.gdl.anaToMia.Widgets.base.IGdlContainer;
+import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.FocusStyleHandler;
@@ -40,7 +42,7 @@
import us.isidor.gdl.anaToMia.Widgets.value.ListStyleTypeValue;
-public class GdlList extends GdlVisibleObject{
+public class GdlList extends GdlVisibleObject implements IGdlContainer {
// some constructors
protected GdlList() throws InvalidGdlSchemaException, ExecutionException {
super();
@@ -372,4 +374,19 @@
}
}
}
+
+
+ @Override
+ public void append(GdlVisibleObject widget) throws InvalidGdlSchemaException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ // returns all topics that are bound to this tm representative topic via a
+ // contains association
+ @Override
+ public ArrayList<Topic> contains() throws InvalidGdlSchemaException {
+ return TmHelper.topicContains(this.tmRepresentative);
+ }
}
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 Wed Jul 13 12:32:30 2011 (r614)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java Thu Jul 14 00:28:35 2011 (r615)
@@ -31,6 +31,7 @@
import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis;
import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject;
import us.isidor.gdl.anaToMia.Widgets.base.IGdlContainer;
+import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.FocusStyleHandler;
@@ -1256,6 +1257,14 @@
// TODO: implement
}
+
+ // returns all topics that are bound to this tm representative topic via a
+ // contains association
+ @Override
+ public ArrayList<Topic> contains() throws InvalidGdlSchemaException {
+ return TmHelper.topicContains(this.tmRepresentative);
+ }
+
// wraps a fieldset with a legend item that represent a group-element
protected class UnitWidget extends Composite implements HasFocusHandlers, HasBlurHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseDownHandlers, HasMouseUpHandlers{
@@ -1541,5 +1550,5 @@
return true;
}
}
- }
+ }
}
\ No newline at end of file
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 Wed Jul 13 12:32:30 2011 (r614)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java Thu Jul 14 00:28:35 2011 (r615)
@@ -90,6 +90,14 @@
// TODO: implement
// TODO: use GdlInstantiator
}
+
+
+ // returns all topics that are bound to this tm representative topic via a
+ // contains association
+ @Override
+ public ArrayList<Topic> contains() throws InvalidGdlSchemaException{
+ return TmHelper.topicContains(this.tmRepresentative);
+ }
public abstract TopicMap getContent();
More information about the Isidorus-cvs
mailing list