Ignore:
Timestamp:
2005-02-07T10:36:51+13:00 (19 years ago)
Author:
mdewsnip
Message:

More GEMS fixes, by Matthew Whyte. Can now create subelements of subelements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMSModel.java

    r8932 r8971  
    6666    }
    6767
    68     public void remove(String name, int type) {
    69     GEMSNode current = (GEMSNode) root;
    70     for(int i = 0; i < current.getChildCount(); i++) {
    71         GEMSNode child = (GEMSNode) current.getChildAt(i);
    72         if(child.toString().equals(name) && type == GEMSNode.SET) {
    73         // Place on AWT event thread to avoid errors.
    74         SynchronizedTreeModelTools.removeNodeFromParent(this, child);
    75         return;
    76         }
    77         // This may be the profiler root node, in which case we descend into its children if we're looking for collection file matches.
    78         else if(type == GEMSNode.COLLECTION && child.getType() == GEMSNode.PROFILER) {
    79         for(int j = 0; j < child.getChildCount(); j++) {
    80             GEMSNode inner_child = (GEMSNode) child.getChildAt(j);
    81             if(inner_child.toString().equals(name)) {
    82             // Place on AWT event thread to avoid errors.
    83             SynchronizedTreeModelTools.removeNodeFromParent(this, inner_child);
    84             return;
    85             }
    86         }
    87         }
    88         // If this is a set and we are looking for an element or subelement, then iterate through its children. Can't really do this recursively.
    89         else if((type == GEMSNode.ELEMENT || type == GEMSNode.SUBELEMENT) && child.getType() == GEMSNode.SET) {
    90         for(int j = 0; j < child.getChildCount(); j++) {
    91             GEMSNode inner_child = (GEMSNode) child.getChildAt(j);
    92             //Go through looking for element
    93             if(type == GEMSNode.ELEMENT)
    94             {
    95                 if(inner_child.toString().equals(name)) {
    96                 // Place on AWT event thread to avoid errors.
    97                 SynchronizedTreeModelTools.removeNodeFromParent(this, inner_child);
    98                 return;
    99                 }
    100             }
    101             //Go through element looking for subelement
    102             else if(type == GEMSNode.SUBELEMENT)
    103             {
    104                 for(int k = 0; k < inner_child.getChildCount(); k++)
    105                 {
    106                     //the subelements
    107                     GEMSNode innermost_child = (GEMSNode)inner_child.getChildAt(k);
    108                     if(innermost_child.toString().equals(name))
    109                     {
    110                         // Place on AWT event thread to avoid errors.
    111                         SynchronizedTreeModelTools.removeNodeFromParent(this, inner_child);
    112                         return;
    113                     }
    114                 }
    115             }
    116         }
    117         }
    118     }
    119 
    120     System.err.println("Tried to remove \'" + name + "\' from the tree, but could not find it!"); //This should not happen!
    121     }
    122 
    12368    /**
    12469       Remove a node from the tree.
Note: See TracChangeset for help on using the changeset viewer.