Changeset 6203


Ignore:
Timestamp:
2003-12-10T16:35:17+13:00 (20 years ago)
Author:
jmt12
Message:

Further to the changes yesterday, sources from within the collect folder now have their full name and short name in brackets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/mem/MEMNode.java

    r5593 r6203  
    3737package org.greenstone.gatherer.mem;
    3838
     39import java.io.*;
    3940import java.util.*;
    4041import javax.swing.tree.*;
     42import org.greenstone.gatherer.Configuration;
    4143import org.greenstone.gatherer.Dictionary;
    4244import org.greenstone.gatherer.Gatherer;
     45import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
    4346import org.greenstone.gatherer.mem.AttributeTableModel;
    4447import org.greenstone.gatherer.msm.ElementWrapper;
    4548import org.greenstone.gatherer.msm.MetadataSet;
    4649import org.greenstone.gatherer.msm.MetadataSetManager;
     50import org.greenstone.gatherer.util.Utility;
    4751import org.w3c.dom.*;
    4852/**
     
    5458    private AttributeTableModel model = null;
    5559    private int type = 0;
     60    private String text = null;
    5661    static final public int COLLECTION = 0;
    5762    static final public int ELEMENT    = 1;
     
    6873    this.parent = parent;
    6974    this.type = type;
     75    this.text = null;
    7076    }
    7177
     
    131137    this.model = model;
    132138    }
     139
    133140    public String toString() {
    134     String text = "error";
    135     if(userObject != null) {
    136         if(userObject instanceof ElementWrapper) {
    137         text = ((ElementWrapper)userObject).getName();
     141    if(text == null) {
     142        if(userObject != null) {
     143        if(userObject instanceof ElementWrapper) {
     144            text = ((ElementWrapper)userObject).getName();
     145        }
     146        // 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
     147        else if(type == COLLECTION) {
     148            try {
     149            boolean is_descendant = false;
     150            File source_path = new File((String)userObject);
     151            File collect_path = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     152            File current_path = source_path;
     153            while(!is_descendant && current_path != null) {
     154                is_descendant = current_path.equals(collect_path);
     155                current_path = current_path.getParentFile();
     156            }
     157            current_path = null;
     158            collect_path = null;
     159            // We've either found we are a descendant, or run out of path
     160            if(is_descendant) {
     161                // Create a basic config class
     162                BasicCollectionConfiguration config = new BasicCollectionConfiguration(new File(source_path, Utility.CONFIG_DIR));
     163                text = config.toString();
     164                config = null;
     165            }
     166            else {
     167                text = source_path.getAbsolutePath();
     168            }
     169            }
     170            catch(Exception exception) {
     171            Gatherer.println("Exception in MEMNode.toString() - exception is unexpected");
     172            Gatherer.printStackTrace(exception);
     173            text = userObject.toString();
     174            }
     175        }
     176        else {
     177            text = userObject.toString();
     178        }
    138179        }
    139180        else {
    140         text = userObject.toString();
     181        text = "error";
    141182        }
    142183    }
Note: See TracChangeset for help on using the changeset viewer.