Index: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElement.java
===================================================================
--- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElement.java	(revision 565)
+++ trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElement.java	(revision 576)
@@ -18,14 +18,16 @@
     public static final long serialVersionUID = 1L;
 
-    /** the information about the original type before the mapping */
-    private String originalTypeInfo;
+    /** the specification of the GUI element */
+    private IGUIElementSpec specification;
 
-    /* (non-Javadoc)
-     * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElement#getParent()
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param specification
      */
-    @Override
-    public IGUIElement getParent() {
-        // TODO remove getParent Stuff
-        return null;
+    public AbstractDefaultGUIElement(IGUIElementSpec specification) {
+        this.specification = specification;
     }
 
@@ -33,9 +35,9 @@
      * (non-Javadoc)
      * 
-     * @see de.ugoe.cs.tasktree.guimodel.GUIElement#getOriginalTypeInfo()
+     * @see de.ugoe.cs.tasktree.guimodel.GUIElement#getSpecification()
      */
     @Override
-    public String getOriginalTypeInfo() {
-        return originalTypeInfo;
+    public IGUIElementSpec getSpecification() {
+        return specification;
     }
 
@@ -43,8 +45,21 @@
      * (non-Javadoc)
      * 
-     * @see GUIElement#setOriginalTypeInfo(String)
+     * @see GUIElement#equals(GUIElement)
      */
-    void setOriginalTypeInfo(String originalTypeInfo) {
-        this.originalTypeInfo = originalTypeInfo;
+    public boolean equals(IGUIElement other) {
+        if (this == other)
+        {
+            return true;
+        }
+        
+        if (!this.getClass().isInstance(other)) {
+            return false;
+        }
+        
+        AbstractDefaultGUIElement otherElem = (AbstractDefaultGUIElement) other;
+        
+        return
+            ((otherElem.specification == specification) ||
+             ((specification != null) && specification.equals(otherElem.specification)));
     }
 
Index: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElementFactory.java
===================================================================
--- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElementFactory.java	(revision 565)
+++ trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElementFactory.java	(revision 576)
@@ -20,5 +20,5 @@
  * @author 2012, last modified by $Author: patrick$
  */
-public abstract class AbstractDefaultGUIElementFactory {
+public abstract class AbstractDefaultGUIElementFactory implements IGUIElementFactory {
     
     /** */
@@ -53,11 +53,10 @@
      * @throws GUIModelConfigurationException
      */
-    protected IGUIElement instantiateGUIElementFromConfiguredMappings(String type,
-                                                                      Object... parameters)
+    protected IGUIElement instantiateGUIElementFromConfiguredMappings(IGUIElementSpec specification)
         throws GUIModelConfigurationException
     {
         Properties mappings = getMappingsFromConfiguration();
 
-        String className = mappings.getProperty(type);
+        String className = mappings.getProperty(specification.getType());
         if (className != null) {
             try {
@@ -72,41 +71,9 @@
                 }
 
-                Class<?>[] parameterTypes = new Class<?>[parameters.length];
-
-                for (int i = 0; i < parameters.length; i++) {
-                    parameterTypes[i] = parameters[i].getClass();
-
-                    if (Boolean.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = boolean.class;
-                    }
-                    else if (Integer.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = int.class;
-                    }
-                    else if (Double.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = double.class;
-                    }
-                    else if (Character.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = char.class;
-                    }
-                    else if (Byte.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = byte.class;
-                    }
-                    else if (Float.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = float.class;
-                    }
-                    else if (Long.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = long.class;
-                    }
-                    else if (Short.class.equals(parameterTypes[i])) {
-                        parameterTypes[i] = short.class;
-                    }
-                }
+                Class<?>[] parameterTypes = new Class<?>[1];
+                parameterTypes[0] = specification.getClass();
 
                 IGUIElement guiElement =
-                    (IGUIElement) clazz.getConstructor(parameterTypes).newInstance(parameters);
-
-                if (guiElement instanceof AbstractDefaultGUIElement) {
-                    ((AbstractDefaultGUIElement) guiElement).setOriginalTypeInfo(type);
-                }
+                    (IGUIElement) clazz.getConstructor(parameterTypes).newInstance(specification);
 
                 return guiElement;
Index: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIModel.java
===================================================================
--- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIModel.java	(revision 565)
+++ trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIModel.java	(revision 576)
@@ -8,26 +8,25 @@
 
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
- * TODO comment
+ * <p>
+ * The goal of a GUI model is to correctly l
+ * </p>
  * 
  * @version $Revision: $ $Date: 14.08.2012$
  * @author 2012, last modified by $Author: pharms$
  */
-public class GUIModel<T extends IGUIElement> {
+public class GUIModel {
     
     /**
      * 
      */
-    private Collection<T> guiElements = new ArrayList<T>();
-
+    private TreeNode root = new TreeNode();
+    
     /**
      * 
      */
-    private Map<T, List<T>> childRelations = new HashMap<T, List<T>>();
+    private List<TreeNode> allNodes = new ArrayList<TreeNode>();
 
     /**
@@ -38,129 +37,198 @@
      * @throws GUIModelException 
      */
-    public T checkAndIntegratePath(List<T> guiElementPath) throws GUIModelException {
-        T existingGuiElement = check(guiElementPath);
-        
-        if (existingGuiElement == null) {
-            T terminalGuiElement = null;
-            T child = null;
-            boolean doBreak = false;
-            for (int i = guiElementPath.size() - 1; ((i >= 0) && (!doBreak)); i--) {
-                T newElement = guiElementPath.get(i);
-                existingGuiElement = null;
+    public IGUIElement integratePath(List<? extends IGUIElementSpec> guiElementPath,
+                                     IGUIElementFactory              guiElementFactory)
+        throws GUIModelException
+    {
+        List<IGUIElementSpec> remainingPath = new ArrayList<IGUIElementSpec>();
+        
+        for (IGUIElementSpec spec : guiElementPath)
+        {
+            remainingPath.add(spec);
+        }
+        
+        return integratePath(root, remainingPath, guiElementFactory);
+    }
+
+    /**
+     * TODO: comment
+     *
+     * @param root
+     * @return
+     */
+    public List<IGUIElement> getChildren(IGUIElement guiElement) {
+        for (TreeNode node : allNodes) {
+            if (node.guiElement.equals(guiElement)) {
+                List<IGUIElement> result = new ArrayList<IGUIElement>();
                 
-                for (T candidate : guiElements) {
-                    if (candidate.equals(newElement)) {
-                        existingGuiElement = candidate;
-                        break;
+                if (node.children != null) {
+                    for (TreeNode child : node.children) {
+                      result.add(child.guiElement);
                     }
                 }
                 
-                // element not yet contained in model. Add it.
-                if (existingGuiElement == null)
-                {
-                    guiElements.add(newElement);
-                    existingGuiElement = newElement;
-                }
-                else
-                {
-                    doBreak = true;
-                }
+                return result;
+            }
+        }
+        
+        return null;
+    }
+
+    /**
+     * TODO: comment
+     *
+     * @return
+     */
+    public List<IGUIElement> getRootElements() {
+        List<IGUIElement> roots = new ArrayList<IGUIElement>();
+        for (TreeNode rootChild : root.children) {
+            roots.add(rootChild.guiElement);
+        }
+        return roots;
+    }
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param root2
+     * @param guiElementPath
+     * @param guiElementFactory
+     * @return
+     * @throws GUIModelException 
+     */
+    private IGUIElement integratePath(TreeNode                        parentNode,
+                                      List<? extends IGUIElementSpec> remainingPath,
+                                      IGUIElementFactory              guiElementFactory)
+        throws GUIModelException
+    {
+        IGUIElementSpec specToIntegrateElementFor = remainingPath.remove(0);
+        
+        List<TreeNode> matchingChildren = new ArrayList<TreeNode>();
+        int maximumSimilarity = 0;
+        
+        if (parentNode.children != null) {
+            for (TreeNode child : parentNode.children) {
+                int similarityLevel = getSimilarityLevel
+                    (specToIntegrateElementFor, child.guiElement.getSpecification());
                 
-                if (terminalGuiElement == null) {
-                    terminalGuiElement = existingGuiElement;
-                }
-                
-                if (child != null) {
-                    List<T> children = childRelations.get(existingGuiElement);
-                    if (children == null) {
-                        children = new ArrayList<T>();
-                        childRelations.put(existingGuiElement, children);
-                    }
-                    children.add(child);
-                }
-                child = existingGuiElement;
-            }
-            
-            existingGuiElement = terminalGuiElement;
-        }
-        
-        return existingGuiElement;
-    }
-
-    /**
-     * TODO: comment
-     *
-     * @param root
-     * @return
-     */
-    public List<T> getChildren(T guiElement) {
-        return childRelations.get(guiElement);
-    }
-
-    /**
-     * TODO: comment
-     *
-     * @return
-     */
-    public List<T> getRootElements() {
-        List<T> roots = new ArrayList<T>();
-        for (T guiElement : guiElements) {
-            if (guiElement.getParent() == null) {
-                roots.add(guiElement);
-            }
-        }
-        return roots;
-    }
-
-    /**
-     * TODO: comment
-     *
-     * @param guiElementPath
-     * @throws GUIModelException 
-     */
-    private T check(List<T> guiElementPath) throws GUIModelException {
-        T guiElementInModel = null;
-        
-        for (int i = 0; i < guiElementPath.size(); i++) {
-            guiElementInModel = null;
-            
-            T newElement = guiElementPath.get(i);
-            T newParent = (i > 0 ? guiElementPath.get(i - 1) : null);
-            
-            if ((newElement.getParent() != null) &&
-                (!newElement.getParent().equals(newParent)))
-            {
-                throw new GUIModelException
-                    ("new GUI element " + newElement + " denotes a parent element (" +
-                     newElement.getParent() + ") which is not identical to the parent element " +
-                     "denoted by the element path (" + newParent + ")");
-            }
-            
-            for (T existingElement : guiElements) {
-                if (existingElement.equals(newElement)) {
-                    if (guiElementInModel != null) {
+                if (similarityLevel >= maximumSimilarity) {
+                    if (maximumSimilarity == 100) {
                         throw new GUIModelException
-                            ("several GUI elements already existing in the model pretend to " +
-                             "match the new element " + newElement);
+                          ("several children of gui element " + parentNode.guiElement +
+                           " pretend to fully match specification " + specToIntegrateElementFor);
                     }
                     
-                    if ((existingElement.getParent() != newParent) &&
-                        ((existingElement.getParent() != null) &&
-                         (!existingElement.getParent().equals(newParent))))
-                    {
-                        throw new GUIModelException
-                            ("the new path denotes the GUI element " + newElement +
-                             " with parent " + newElement.getParent() + " that already exists in " +
-                             "the model with a distinct parent element (" +
-                             existingElement.getParent() + ")");
+                    if (maximumSimilarity != similarityLevel) {
+                        matchingChildren.clear();
+                        maximumSimilarity = similarityLevel;
                     }
                     
-                    guiElementInModel = existingElement;
+                    matchingChildren.add(child);
                 }
             }
         }
         
-        return guiElementInModel;
-    }
-
+        // we do not see something as matching if the similarity level is below 80%
+        if (maximumSimilarity < 80) {
+            matchingChildren.clear();
+        }
+        
+        // if we get here, the corresponding path does not exist yet. So create it
+        if (matchingChildren.size() == 0) {
+            matchingChildren.add
+                (parentNode.addChild
+                     (guiElementFactory.instantiateGUIElement(specToIntegrateElementFor)));
+        }
+        else if (matchingChildren.size() > 1) {
+            throw new GUIModelException
+              ("several children of gui element " + parentNode.guiElement +
+               " match the specification " + specToIntegrateElementFor + " at the same level. " +
+               "Can not decide which is the right one.");
+        }
+        
+        if (remainingPath.size() > 0) {
+            return integratePath(matchingChildren.get(0), remainingPath, guiElementFactory);
+        }
+        else {
+            return matchingChildren.get(0).guiElement;
+        }
+    }
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param spec1
+     * @param spec2
+     * @return
+     * @throws GUIModelException 
+     */
+    private int getSimilarityLevel(IGUIElementSpec spec1, IGUIElementSpec spec2)
+        throws GUIModelException
+    {
+        if (spec1 == spec2) {
+            return 100;
+        }
+        else if (spec1 != null) {
+            int level = spec1.getSimilarity(spec2);
+            
+            if ((level < 0) || (100 < level)) {
+               throw new GUIModelException("invalid tree node similarity provided (" + level +
+                                           "). Must be between 0 and 100."); 
+            }
+            
+            return level;
+        }
+        else {
+            return 0;
+        }
+    }
+
+    /**
+     * <p>
+     * TODO comment
+     * </p>
+     * 
+     * @version $Revision: $ $Date: 17.08.2012$
+     * @author 2012, last modified by $Author: pharms$
+     */
+    private class TreeNode
+    {
+        /** */
+        private IGUIElement guiElement;
+        
+        /** */
+        private List<TreeNode> children;
+        
+        /** */
+        //private TreeNode parent;
+        
+        /**
+         * <p>
+         * TODO: comment
+         * </p>
+         *
+         * @param guiElement
+         * @return
+         */
+        private TreeNode addChild(IGUIElement guiElement)
+        {
+            if (children == null)
+            {
+                children = new ArrayList<TreeNode>();
+            }
+            
+            TreeNode child = new TreeNode();
+            child.guiElement = guiElement;
+            //child.parent = this;
+            children.add(child);
+            
+            allNodes.add(child);
+            
+            return child;
+        }
+    }
 }
Index: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElement.java
===================================================================
--- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElement.java	(revision 565)
+++ trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElement.java	(revision 576)
@@ -20,10 +20,5 @@
      *
      */
-    public IGUIElement getParent();
-
-    /**
-     *
-     */
-    public String getOriginalTypeInfo();
+    public IGUIElementSpec getSpecification();
 
     /**
@@ -33,3 +28,7 @@
     public boolean equals(IGUIElement other);
 
+    /**
+     * 
+     */
+    public int hashCode();
 }
Index: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementFactory.java
===================================================================
--- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementFactory.java	(revision 576)
+++ trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementFactory.java	(revision 576)
@@ -0,0 +1,28 @@
+// Module    : $RCSfile: IGUIElementFactory.java,v $
+// Version   : $Revision: 0.0 $  $Author: pharms $  $Date: 17.08.2012 $
+// Project   : quest-core-events
+// Creation  : 2012 by pharms
+// Copyright : Patrick Harms, 2012
+package de.ugoe.cs.quest.eventcore.guimodel;
+
+/**
+ * <p>
+ * TODO comment
+ * </p>
+ * 
+ * @version $Revision: $ $Date: 17.08.2012$
+ * @author 2012, last modified by $Author: pharms$
+ */
+public interface IGUIElementFactory {
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param specification
+     * @return
+     */
+    public abstract IGUIElement instantiateGUIElement(IGUIElementSpec specification);
+    
+}
Index: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementSpec.java
===================================================================
--- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementSpec.java	(revision 576)
+++ trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementSpec.java	(revision 576)
@@ -0,0 +1,55 @@
+// Module    : $RCSfile: IGUIElementParameters.java,v $
+// Version   : $Revision: 0.0 $  $Author: pharms $  $Date: 17.08.2012 $
+// Project   : quest-core-events
+// Creation  : 2012 by pharms
+// Copyright : Patrick Harms, 2012
+package de.ugoe.cs.quest.eventcore.guimodel;
+
+/**
+ * <p>
+ * TODO comment
+ * </p>
+ * 
+ * @version $Revision: $ $Date: 17.08.2012$
+ * @author 2012, last modified by $Author: pharms$
+ */
+public interface IGUIElementSpec {
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @return
+     */
+    public String getType();
+    
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param otherParameters
+     * @return
+     */
+    public int getSimilarity(IGUIElementSpec otherParameters);
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param other
+     * @return
+     */
+    public boolean equals(IGUIElementSpec other);
+    
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @return
+     */
+    public int hashCode();
+}
