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/GEMSNode.java

    r8932 r8971  
    5151 * @author John Thompson, Greenstone Digital Library, University of Waikato
    5252 * @version 2.3
     53 * Modified 2/02/05 by Matthew Whyte
    5354 */
    5455public class GEMSNode
     
    6263    static final public int ROOT       = 3;
    6364    static final public int SET        = 4;
    64     static final public int SUBELEMENT = 5;
     65    //static final public int SUBELEMENT = 5;
    6566
    6667    public GEMSNode() {
    6768    this.type = ROOT;
    68        
    6969    }
    7070
     
    107107    }
    108108
    109     public ElementWrapper getSubelement() {
    110     ElementWrapper result = null;
    111     if(type == SUBELEMENT) {
    112         result = (ElementWrapper) userObject;
    113     }
    114     return result;
    115     }
    116 
    117109    public int getIndex(TreeNode node) {
    118110    if(children == null) {
     
    147139    }
    148140
    149     public String toString() {
    150     if(text == null) {
    151         if(userObject != null) {
    152         if(userObject instanceof ElementWrapper) {
    153             text = ((ElementWrapper)userObject).getName();
    154         }
    155         // In the case of a 'collection' source path we need to examine the path closely. If it is a descendant of the greenstone collections path then supress everything but the collection name
    156 //      else if(type == COLLECTION) {
    157 //          try {
    158 //          boolean is_descendant = false;
    159 //          File source_path = new File((String)userObject);
    160 //          File collect_path;
    161 //          if (Gatherer.GS3) {
    162 //              collect_path = new File(Utility.getCollectDir(Configuration.gsdl3_path, Configuration.site_name));
    163 //          }  else {
    164 //              collect_path = new File(Utility.getCollectDir(Configuration.gsdl_path));
    165 //          }
    166 //          File current_path = source_path;
    167 //          while(!is_descendant && current_path != null) {
    168 //              is_descendant = current_path.equals(collect_path);
    169 //              current_path = current_path.getParentFile();
    170 //          }
    171 //          current_path = null;
    172 //          collect_path = null;
    173 //          // We've either found we are a descendant, or run out of path
    174 //          if(is_descendant) {
    175 //              // Create a basic config class
    176 //              File config_file = new File(source_path, Utility.CONFIG_FILE);
    177 //              if (config_file.exists()) {
    178 //              BasicCollectionConfiguration config = new BasicCollectionConfiguration(config_file);
    179 //              text = config.toString();
    180 //              config = null;
    181 //              } else {
    182 //              text = source_path.getAbsolutePath();
    183 //              }
    184 //              config_file = null;
    185 //          }
    186 //          else {
    187 //              text = source_path.getAbsolutePath();
    188 //          }
    189 //          }
    190 //          catch(Exception exception) {
    191 //          DebugStream.println("Exception in GEMSNode.toString() - exception is unexpected");
    192 //          DebugStream.printStackTrace(exception);
    193 //          text = userObject.toString();
    194 //          }
    195 //      }
    196         else {
    197             text = userObject.toString();
    198         }
     141    public String toString()
     142    {
     143    if(text == null)
     144        {
     145        if(userObject != null)
     146            {
     147            if(userObject instanceof ElementWrapper)
     148                {
     149                text = ((ElementWrapper)userObject).getName();
     150                }
     151            else
     152                {
     153                text = userObject.toString();
     154                }
     155            }
     156        else
     157            {
     158            text = "error";
     159            }
    199160        }
    200         else {
    201         text = "error";
    202         }
    203     }
    204161    return text;
    205162    }
    206 
    207163
    208164    public void mapChildren()
     
    221177            }
    222178        }
    223     if (type == ELEMENT) //Add subelements. This will need to be changed to cope with multiple levels of subelements.
     179    if (type == ELEMENT) //Add subelements. As elements and subelements are identical, this process continues.
    224180        {
    225181        ArrayList subelements = this.getElement().getSubelements();
    226182        for(int j = 0; j < subelements.size(); j++)
    227183            {
    228             children.add(new GEMSNode(SUBELEMENT, new ElementWrapper((Element)subelements.get(j)), this));
     184            children.add(new GEMSNode(ELEMENT, new ElementWrapper((Element)subelements.get(j)), this));
    229185            }
    230186        }
    231 
    232187    }
    233188   
    234189   class GemsNodeMouseAdapter
    235190    extends MouseAdapter {
    236        
    237        
    238        
     191       
    239192      public void mouseClicked(MouseEvent e) {
    240193        JPopupMenu setPopup = new JPopupMenu("asdf");
    241          if (e.isPopupTrigger()) {
    242                          
    243                      setPopup.show(e.getComponent(),
     194         if (e.isPopupTrigger()) {       
     195         setPopup.show(e.getComponent(),
    244196                           e.getX(), e.getY());
    245                    
    246                
    247             }
     197     }
    248198    }   
    249199   
     
    256206    public void mousePressed(MouseEvent e) {
    257207         JPopupMenu setPopup = new JPopupMenu("asdf");
    258          if (e.isPopupTrigger()) {
    259                          
    260                      setPopup.show(e.getComponent(),
     208         if (e.isPopupTrigger()) {               
     209         setPopup.show(e.getComponent(),
    261210                           e.getX(), e.getY());
    262                    
    263                
    264             }
    265     }
    266    
     211     }
     212    }
     213       
    267214    public void mouseReleased(MouseEvent e) {
    268215         JPopupMenu setPopup = new JPopupMenu("asdf");
    269          if (e.isPopupTrigger()) {
    270                          
    271                      setPopup.show(e.getComponent(),
    272                            e.getX(), e.getY());
    273                    
    274                
    275             }
     216         if (e.isPopupTrigger()) {                 
     217         setPopup.show(e.getComponent(),
     218                           e.getX(), e.getY());     
     219     }
    276220    } 
    277        
    278        
    279221   }
    280    
    281222}
Note: See TracChangeset for help on using the changeset viewer.