Ignore:
Timestamp:
03/04/14 10:57:55 (10 years ago)
Author:
pharms
Message:
  • adapted logging of GUI elements to ensure that all GUI elements on the same page are logged at least once
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorOutputWriter.java

    r1315 r1429  
    265265    /** 
    266266     * <p> 
    267      * dumps a GUI element starting with its parent GUI elements into the log file. Calls itself 
    268      * recursively to traverse for dumping the parents first. 
     267     * ensures that a GUI element, its parents as well as all other GUI elements on the same page 
     268     * are dumped 
    269269     * </p> 
    270270     * 
     
    274274        if (!loggedGUIElements.contains(guiElement)) { 
    275275             
    276             HtmlGUIElement parent = guiElement.getParent(); 
    277             String parentId = null; 
    278              
    279             if (parent != null) { 
    280                 ensureGuiElementDumped(parent); 
    281                 parentId = parent.getId(); 
    282             } 
    283              
     276            // determine the document as the whole document needs to be dumped. Ensure also that 
     277            // the server is dumped 
     278             
     279            HtmlGUIElement parent = guiElement; 
     280            HtmlDocument document = null; 
     281            HtmlServer server = null; 
     282             
     283            while (parent != null) { 
     284                if (parent instanceof HtmlDocument) { 
     285                    document = (HtmlDocument) parent; 
     286                } 
     287                else if (parent instanceof HtmlServer) { 
     288                    server = (HtmlServer) parent; 
     289                } 
     290                 
     291                parent = parent.getParent(); 
     292            } 
     293             
     294            if (server != null) { 
     295                dumpGuiElement(server); 
     296            } 
     297             
     298            if (document != null) { 
     299                dumpGuiStructure(document); 
     300            } 
     301        } 
     302    } 
     303 
     304    /** 
     305     * <p> 
     306     * dumps the GUI structure provided by the parameter into the log file. Calls itself 
     307     * recursively to traverse the GUI structure. 
     308     * </p> 
     309     * 
     310     * @param guiStructure the GUI structure to be logged 
     311     */ 
     312    private void dumpGuiStructure(HtmlGUIElement guiStructure) { 
     313        dumpGuiElement(guiStructure); 
     314         
     315        if (guiStructure.getChildren() != null) { 
     316            for (HtmlGUIElement child : guiStructure.getChildren()) { 
     317                dumpGuiStructure(child); 
     318            } 
     319        } 
     320    } 
     321 
     322    /** 
     323     * <p> 
     324     * dumps the GUI element provided by the parameter into the log file. 
     325     * </p> 
     326     * 
     327     * @param guiElement the GUI element to be logged 
     328     */ 
     329    private void dumpGuiElement(HtmlGUIElement guiElement) { 
     330        if (!loggedGUIElements.contains(guiElement)) { 
    284331            outputWriter.print("<component id=\""); 
    285332            outputWriter.print(guiElement.getId()); 
     
    301348            } 
    302349             
    303             dumpParam("parent", parentId); 
     350            if (guiElement.getParent() != null) { 
     351                dumpParam("parent", guiElement.getParent().getId()); 
     352            } 
    304353         
    305354            outputWriter.println("</component>"); 
Note: See TracChangeset for help on using the changeset viewer.