Ignore:
Timestamp:
05/19/17 11:31:29 (7 years ago)
Author:
pharms
Message:
  • refactored GUI model so that hierarchical event target structures can also be used and created by plugins not being strictly for GUIs
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/HierarchicalEventTargetGroup.java

    r2120 r2146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.eventcore.guimodel; 
     15package de.ugoe.cs.autoquest.eventcore; 
    1616 
    1717import java.util.Collections; 
     
    2121/** 
    2222 * <p> 
    23  * This class is a dummy GUI element to represent groups of GUI elements. A group of GUI elements 
    24  * can be integrated in any GUI model using the method 
    25  * {@link GUIModel#groupGUIElements(java.util.List, String)}. A group has the same behavior as 
    26  * any other parent GUI element. 
     23 * This class is a dummy hierarchical event target to represent groups of event targets. A group of 
     24 * event targets can be integrated in any hierarchical event target model using the method 
     25 * {@link HierarchicalEventTargetModel#groupEventTargets(List, String, IEventTargetFactory)}. A 
     26 * group has the same behavior as any other parent hierarchical event target. 
    2727 * </p> 
    2828 *  
    2929 * @author Patrick Harms 
    3030 */ 
    31 public class GUIElementGroup extends AbstractDefaultGUIElement { 
     31public class HierarchicalEventTargetGroup extends AbstractDefaultHierarchicalEventTarget { 
    3232 
    3333    /** 
     
    3939     
    4040    /** 
    41      * the list of grouped GUIElements 
     41     * the list of grouped event targets 
    4242     */ 
    43     private List<IGUIElement> groupedGUIElements = new LinkedList<IGUIElement>(); 
     43    private List<IHierarchicalEventTarget> groupedEventTargets = 
     44        new LinkedList<IHierarchicalEventTarget>(); 
    4445 
    4546    /** 
    4647     * <p> 
    47      * instantiates a GUI element group with a name and its optional parent GUI element 
     48     * instantiates an event target group with a name and its optional parent event target 
    4849     * </p> 
    4950     * 
    50      * @param groupName the name of the GUI element group 
    51      * @param parent    the optional parent GUI element of the group 
    52      * @param guiModel  the GUI model to which the group will belong 
     51     * @param groupName        the name of the event target group 
     52     * @param parent           the optional parent event target of the group 
     53     * @param eventTargetModel the event target model to which the group will belong 
    5354     */ 
    54     public GUIElementGroup(String groupName, IGUIElement parent, GUIModel guiModel) { 
     55    public HierarchicalEventTargetGroup(String                          groupName, 
     56                                        IHierarchicalEventTarget        parent, 
     57                                        HierarchicalEventTargetModel<?> eventTargetModel) 
     58    { 
    5559        super(new GroupSpecification(groupName), parent); 
    56         super.setGUIModel(guiModel); 
    57     } 
    58  
    59     /* (non-Javadoc) 
    60      * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(IGUIElementSpec) 
    61      */ 
    62     @Override 
    63     public final void updateSpecification(IGUIElementSpec furtherSpec) { 
    64         // do nothing 
     60        super.setEventTargetModel(eventTargetModel); 
    6561    } 
    6662 
     
    9086 
    9187    /* (non-Javadoc) 
    92      * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getView() 
     88     * @see IHierarchicalEventTarget#updateSpecification(IEventTargetSpec) 
    9389     */ 
    9490    @Override 
    95     public IGUIView getView() { 
    96         return null; 
    97     } 
    98  
    99     /* (non-Javadoc) 
    100      * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
    101      */ 
    102     @Override 
    103     public double getDistanceTo(IGUIElement otherElement) { 
    104         if (equals(otherElement)) { 
    105             return 0.0; 
    106         } 
    107         else if (super.getParent() != null) { 
    108             return super.getParent().getDistanceTo(otherElement); 
    109         } 
    110         else { 
    111             return 1.0; 
    112         } 
     91    public void updateSpecification(IEventTargetSpec furtherSpec) { 
     92        // do nothing 
    11393    } 
    11494 
    11595    /** 
    11696     * <p> 
    117      * returns the list of GUI elements belonging to this group. 
     97     * returns the list of event targets belonging to this group. 
    11898     * </p> 
    11999     *  
    120      * @return the GUI elements belonging to this group 
     100     * @return the event targets belonging to this group 
    121101     *  
    122102     */ 
    123     public List<IGUIElement> getGroupedElements() { 
    124         return Collections.unmodifiableList(groupedGUIElements); 
     103    public List<IHierarchicalEventTarget> getGroupedEventTargets() { 
     104        return Collections.unmodifiableList(groupedEventTargets); 
    125105    } 
    126106     
    127107    /** 
    128108     * <p> 
    129      * allows adding a new GUI element to the group 
     109     * allows adding a new event target to the group 
    130110     * </p> 
    131111     * 
    132      * @param guiElement the new member of the group 
     112     * @param eventTarget the new member of the group 
    133113     */ 
    134     void addToGroup(IGUIElement guiElement) { 
    135         this.groupedGUIElements.add(guiElement); 
     114    void addToGroup(IHierarchicalEventTarget eventTarget) { 
     115        this.groupedEventTargets.add(eventTarget); 
    136116    } 
    137117     
    138118    /** 
    139119     * <p> 
    140      * internally required GUI element specification for a GUI element group. This is just a wrapper 
    141      * for a name of a GUI element group 
     120     * internally required event target specification for an event target group. This is just a 
     121     * wrapper for a name of an event target group 
    142122     * </p> 
    143123     *  
    144124     * @author Patrick Harms 
    145125     */ 
    146     private static class GroupSpecification implements IGUIElementSpec { 
     126    private static class GroupSpecification implements IEventTargetSpec { 
    147127         
    148128        /** 
     
    155135        /** 
    156136         * <p> 
    157          * the name of the GUI element group represented by this specification 
     137         * the name of the event target group represented by this specification 
    158138         * </p> 
    159139         */ 
     
    174154 
    175155        /* (non-Javadoc) 
    176          * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getType() 
     156         * @see IEventTargetSpec#getSimilarity(IEventTargetSpec) 
    177157         */ 
    178158        @Override 
    179         public String getType() { 
    180             return "GUI element group"; 
    181         } 
    182  
    183         /* (non-Javadoc) 
    184          * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getTypeHierarchy() 
    185          */ 
    186         @Override 
    187         public String[] getTypeHierarchy() { 
    188             return new String[] { getType() }; 
    189         } 
    190  
    191         /* (non-Javadoc) 
    192          * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec) 
    193          */ 
    194         @Override 
    195         public boolean getSimilarity(IGUIElementSpec other) { 
     159        public boolean getSimilarity(IEventTargetSpec other) { 
    196160            return 
    197161                (other instanceof GroupSpecification) && 
Note: See TracChangeset for help on using the changeset viewer.