Changeset 1860


Ignore:
Timestamp:
01/12/15 10:40:41 (9 years ago)
Author:
pharms
Message:
  • corrected parsing so that reused hashes can be handled
File:
1 edited

Legend:

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

    r1113 r1860  
    145145    /** 
    146146     * <p> 
     147     * maps the hashes of GUI elements stored in the logs to unique ids of GUI elements. 
     148     * This is required, as the same hash may be used for several GUI elements in the log files. 
     149     * </p> 
     150     */ 
     151    private Map<Long, Long> hashToGuiElementIdMapping = new HashMap<>(); 
     152 
     153    /** 
     154     * <p> 
     155     * counter to get unique GUI element ids 
     156     * </p> 
     157     */ 
     158    private long nextGuiElementId = 0; 
     159     
     160    /** 
     161     * <p> 
    147162     * internal handle to the parsed GUI structure, stored in a GUIElementTree 
    148163     * </p> 
     
    326341        if (qName.equals("sessions")) { 
    327342            currentSequence = new LinkedList<Event>(); 
    328             if (currentGUIElementTree == null) 
     343            if (currentGUIElementTree == null) { 
    329344                currentGUIElementTree = new GUIElementTree<Long>(); 
     345            } 
    330346        } 
    331347        if (qName.equals("newsession")) { 
     
    350366        } 
    351367        else if (qName.equals("componentNameChange")) { 
    352             long sourceHash = Long.parseLong(atts.getValue("hash"), 16); 
     368            Long sourceHash = Long.parseLong(atts.getValue("hash"), 16); 
    353369            String newName = atts.getValue("newName"); 
    354370            // int titleSource = Integer.parseInt(atts.getValue("titleSource")); 
    355             JFCGUIElement sourceElement = (JFCGUIElement) currentGUIElementTree.find(sourceHash); 
     371            Long guiElementId = hashToGuiElementIdMapping.get(sourceHash); 
     372            JFCGUIElement sourceElement = (JFCGUIElement) currentGUIElementTree.find(guiElementId); 
    356373            JFCGUIElementSpec sourceSpec = (JFCGUIElementSpec) sourceElement.getSpecification(); 
    357374            sourceSpec.setName(newName); 
     
    411428        } 
    412429        else if (qName.equals("component") && currentGUIElementHash != null) { 
     430            Long guiElementId = nextGuiElementId++; 
     431            Long parentGuiElementId = hashToGuiElementIdMapping.get(currentParentHash); 
     432             
    413433            try { 
    414                 currentGUIElementTree.add(currentGUIElementHash, currentParentHash, 
    415                                           currentGuiElementSpec); 
     434                // store a mapping of the hash to a unique id and use this id for the GUI element 
     435                hashToGuiElementIdMapping.put(currentGUIElementHash, guiElementId); 
     436                currentGUIElementTree.add(guiElementId, parentGuiElementId, currentGuiElementSpec); 
    416437            } 
    417438            catch (GUIModelException e) { 
     
    419440                                       currentGUIElementHash + ": " + e.getMessage(), e); 
    420441            } 
     442             
    421443            List<Event> unhandledEvents = eventsWithoutTargets.get(currentGUIElementHash); 
    422444            if (unhandledEvents != null) { 
    423                 JFCGUIElement guiElement = 
    424                     (JFCGUIElement) currentGUIElementTree.find(currentGUIElementHash); 
     445                JFCGUIElement guiElement = (JFCGUIElement) currentGUIElementTree.find(guiElementId); 
    425446                for (Event event : unhandledEvents) { 
    426447                    event.setTarget(guiElement); 
     
    429450                eventsWithoutTargets.remove(currentGUIElementHash); 
    430451            } 
     452             
    431453            currentGUIElementHash = null; 
    432454            currentParentHash = null; 
     
    435457        else if (currentEventId != null) { 
    436458            if (qName.equals("event")) { 
    437  
    438                 IGUIElement currentGUIElement; 
    439                 currentGUIElement = currentGUIElementTree.find(currentEventSource); 
     459                 
     460                IGUIElement currentGUIElement = null; 
     461                 
     462                if (hashToGuiElementIdMapping.containsKey(currentEventSource)) { 
     463                    long guiElementId = hashToGuiElementIdMapping.get(currentEventSource); 
     464                    currentGUIElement = currentGUIElementTree.find(guiElementId); 
     465                } 
     466                 
    440467                Event event; 
    441468                // in some rare cases the target GUI element of the event is not 
    442469                // known yet 
    443470                if (currentGUIElement == null) { 
    444                     event = new Event(instantiateInteraction(currentEventId, currentEventParameters)); 
     471                    event = new Event 
     472                        (instantiateInteraction(currentEventId, currentEventParameters)); 
     473                     
    445474                    List<Event> eventList = eventsWithoutTargets.get(currentEventSource); 
     475                     
    446476                    if (eventList == null) { 
    447477                        eventList = new ArrayList<Event>(); 
    448478                        eventsWithoutTargets.put(currentEventSource, eventList); 
    449479                    } 
     480                     
    450481                    eventList.add(event); 
    451482                } 
    452483                else { 
    453484                    event = new Event(instantiateInteraction(currentEventId, currentEventParameters), 
    454                                   currentGUIElement); 
     485                                      currentGUIElement); 
     486                     
    455487                    JFCGUIElement currentEventTarget = (JFCGUIElement) event.getTarget(); 
    456488                    currentEventTarget.markUsed(); 
    457489                } 
     490                 
    458491                event.setTimestamp(currentEventTimestamp); 
    459492                currentSequence.add(event); 
Note: See TracChangeset for help on using the changeset viewer.