Changeset 1722


Ignore:
Timestamp:
09/04/14 16:38:21 (10 years ago)
Author:
dmay
Message:

Implement new command, that generates Jacareto indices. Also, get rid of all previous index hacks.

Location:
trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java

    r1691 r1722  
    157157        // get the Java classname, ignore the package hierarchy if present 
    158158        String[] parts = getSpecification().getType().split("\\."); 
    159         String name = parts[parts.length - 1]; 
    160159 
    161160        // find the correct Jacareto index 
    162161        // jacareto indices start at 1 
    163         int jacIndex = getIndex() + 1; 
    164  
    165         // FIXME: some class specific hacks 
    166         if (name.equals("JFrame")) { 
    167             jacIndex++; 
    168         } 
    169         else if (name.equals("JLayeredPane")) { 
    170             jacIndex--; 
    171         } 
    172         else if (name.equals("JTextField")) { 
    173             jacIndex = 1; 
    174         } 
    175  
     162        int jacIndex = ((JFCGUIElementSpec) getSpecification()).getAltIndex() + 1; 
    176163        str = parts[parts.length - 1] + "_(" + jacIndex + ")"; 
    177164 
  • trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElementSpec.java

    r1080 r1722  
    7777    /** 
    7878     * <p> 
     79     * An alternative index of the specified GUI element in its parent element. Each element type is 
     80     * counted separately. This index is used for replaying programs such as Jacareto. 
     81     * </p> 
     82     */ 
     83    private int altIndex = -1; 
     84 
     85    /** 
     86     * <p> 
    7987     * Hash code of the GUI element. Used as unique identifier during its existence. 
    8088     * </p> 
     
    8896     */ 
    8997    private List<Integer> formerElementHashes = new ArrayList<Integer>(); 
    90      
     98 
    9199    /** 
    92100     * <p> 
     
    203211        JFCGUIElementSpec otherSpec = (JFCGUIElementSpec) other; 
    204212 
    205         return 
    206             (name == null ? otherSpec.name == null : name.equals(otherSpec.name)) && 
     213        return (name == null ? otherSpec.name == null : name.equals(otherSpec.name)) && 
    207214            (type == null ? otherSpec.type == null : type.equals(otherSpec.type)) && 
    208215            (icon == null ? otherSpec.icon == null : icon.equals(otherSpec.icon)) && 
     
    294301    /** 
    295302     * <p> 
     303     * Returns an alternative index of the specified GUI element in its parent element. Each element 
     304     * type is counted separately. 
     305     * </p> 
     306     *  
     307     * @return the index 
     308     */ 
     309    public int getAltIndex() { 
     310        return altIndex; 
     311    } 
     312 
     313    /** 
     314     * <p> 
    296315     * Returns the object hash of the specified GUI element. 
    297316     * </p> 
     
    301320    public int getElementHash() { 
    302321        return elementHash; 
     322    } 
     323 
     324    /** 
     325     * <p> 
     326     * Sets the alternative index. 
     327     * </p> 
     328     *  
     329     * @param newAltIndex 
     330     *            the index 
     331     */ 
     332    public void setAltIndex(int newAltIndex) { 
     333        altIndex = newAltIndex; 
    303334    } 
    304335 
     
    372403        this.elementHash = newElementHash; 
    373404    } 
    374      
     405 
    375406    /** 
    376407     * <p> 
    377408     * Sets the type hierarchy of the specified GUI element. 
     409     *  
    378410     * @param typeHierarchy 
    379      * </p> 
    380      */ 
    381     public void setTypeHierarchy(List<String> typeHierarchy){ 
    382         this.typeHierarchy = typeHierarchy; 
     411     *            </p> 
     412     */ 
     413    public void setTypeHierarchy(List<String> typeHierarchy) { 
     414        this.typeHierarchy = typeHierarchy; 
    383415    } 
    384416 
     
    423455    @Override 
    424456    public String[] getTypeHierarchy() { 
    425         if (typeHierarchy == null){ 
    426                 return new String[]{(getType())}; 
    427         } 
    428         else 
    429                 return typeHierarchy.toArray(new String[typeHierarchy.size()]); 
     457        if (typeHierarchy == null) { 
     458            return new String[] 
     459                { (getType()) }; 
     460        } 
     461        else 
     462            return typeHierarchy.toArray(new String[typeHierarchy.size()]); 
    430463    } 
    431464 
Note: See TracChangeset for help on using the changeset viewer.