Changeset 6203
- Timestamp:
- 2003-12-10T16:35:17+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/mem/MEMNode.java
r5593 r6203 37 37 package org.greenstone.gatherer.mem; 38 38 39 import java.io.*; 39 40 import java.util.*; 40 41 import javax.swing.tree.*; 42 import org.greenstone.gatherer.Configuration; 41 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 45 import org.greenstone.gatherer.collection.BasicCollectionConfiguration; 43 46 import org.greenstone.gatherer.mem.AttributeTableModel; 44 47 import org.greenstone.gatherer.msm.ElementWrapper; 45 48 import org.greenstone.gatherer.msm.MetadataSet; 46 49 import org.greenstone.gatherer.msm.MetadataSetManager; 50 import org.greenstone.gatherer.util.Utility; 47 51 import org.w3c.dom.*; 48 52 /** … … 54 58 private AttributeTableModel model = null; 55 59 private int type = 0; 60 private String text = null; 56 61 static final public int COLLECTION = 0; 57 62 static final public int ELEMENT = 1; … … 68 73 this.parent = parent; 69 74 this.type = type; 75 this.text = null; 70 76 } 71 77 … … 131 137 this.model = model; 132 138 } 139 133 140 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 } 138 179 } 139 180 else { 140 text = userObject.toString();181 text = "error"; 141 182 } 142 183 }
Note:
See TracChangeset
for help on using the changeset viewer.