Changeset 5525 for trunk/gli


Ignore:
Timestamp:
2003-09-19T15:03:09+12:00 (21 years ago)
Author:
mdewsnip
Message:

Added section numbers to contents pane.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/help/HelpFrame.java

    r5521 r5525  
    158158        // Traverse the document hierarchy, building a tree representing its structure
    159159        Node documentNode = document.getFirstChild();
    160         NodeList sections = documentNode.getChildNodes();
    161         for (int i = 0; i < sections.getLength(); i++) {
    162             Node section = sections.item(i);
    163             buildContentsHierarchy(rootNode, section);
     160
     161        int sectionNum = 0;
     162        NodeList children = documentNode.getChildNodes();
     163        for (int i = 0; i < children.getLength(); i++) {
     164            Node child = children.item(i);
     165            if (child.getNodeName().equals("Section")) {
     166            sectionNum++;
     167            buildContentsHierarchy(rootNode, sectionNum + "", child);
     168            }
    164169        }
    165170        }
     
    170175
    171176
    172     public void buildContentsHierarchy(MutableTreeNode parent, Node node)
    173     {
    174         // We're only interested in the Section nodes
    175         if (!node.getNodeName().equals("Section")) {
    176         return;
    177         }
    178 
     177    public void buildContentsHierarchy(MutableTreeNode parent, String pos, Node node)
     178    {
    179179        // Determine the section name
    180180        String sectionName = ((Element) node).getAttribute("name");
     
    186186        Node child = children.item(i);
    187187        if (child.getNodeName().equals("Title")) {
    188             sectionTitle = child.getFirstChild().getNodeValue();
     188            sectionTitle = pos + ": " + child.getFirstChild().getNodeValue();
    189189        }
    190190        }
     
    195195
    196196        // Apply recursively to the children of this node
     197        int sectionNum = 0;
    197198        for (int i = 0; i < children.getLength(); i++) {
    198199        Node child = children.item(i);
    199         buildContentsHierarchy(item, child);
     200        if (child.getNodeName().equals("Section")) {
     201            sectionNum++;
     202            buildContentsHierarchy(item, pos + "." + sectionNum, child);
     203        }
    200204        }
    201205    }
Note: See TracChangeset for help on using the changeset viewer.