Changeset 8971 for trunk/gli/src/org/greenstone/gatherer/gems/GEMSNode.java
- Timestamp:
- 2005-02-07T10:36:51+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gems/GEMSNode.java
r8932 r8971 51 51 * @author John Thompson, Greenstone Digital Library, University of Waikato 52 52 * @version 2.3 53 * Modified 2/02/05 by Matthew Whyte 53 54 */ 54 55 public class GEMSNode … … 62 63 static final public int ROOT = 3; 63 64 static final public int SET = 4; 64 static final public int SUBELEMENT = 5;65 //static final public int SUBELEMENT = 5; 65 66 66 67 public GEMSNode() { 67 68 this.type = ROOT; 68 69 69 } 70 70 … … 107 107 } 108 108 109 public ElementWrapper getSubelement() {110 ElementWrapper result = null;111 if(type == SUBELEMENT) {112 result = (ElementWrapper) userObject;113 }114 return result;115 }116 117 109 public int getIndex(TreeNode node) { 118 110 if(children == null) { … … 147 139 } 148 140 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 } 199 160 } 200 else {201 text = "error";202 }203 }204 161 return text; 205 162 } 206 207 163 208 164 public void mapChildren() … … 221 177 } 222 178 } 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. 224 180 { 225 181 ArrayList subelements = this.getElement().getSubelements(); 226 182 for(int j = 0; j < subelements.size(); j++) 227 183 { 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)); 229 185 } 230 186 } 231 232 187 } 233 188 234 189 class GemsNodeMouseAdapter 235 190 extends MouseAdapter { 236 237 238 191 239 192 public void mouseClicked(MouseEvent e) { 240 193 JPopupMenu setPopup = new JPopupMenu("asdf"); 241 if (e.isPopupTrigger()) { 242 243 setPopup.show(e.getComponent(), 194 if (e.isPopupTrigger()) { 195 setPopup.show(e.getComponent(), 244 196 e.getX(), e.getY()); 245 246 247 } 197 } 248 198 } 249 199 … … 256 206 public void mousePressed(MouseEvent e) { 257 207 JPopupMenu setPopup = new JPopupMenu("asdf"); 258 if (e.isPopupTrigger()) { 259 260 setPopup.show(e.getComponent(), 208 if (e.isPopupTrigger()) { 209 setPopup.show(e.getComponent(), 261 210 e.getX(), e.getY()); 262 263 264 } 265 } 266 211 } 212 } 213 267 214 public void mouseReleased(MouseEvent e) { 268 215 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 } 276 220 } 277 278 279 221 } 280 281 222 }
Note:
See TracChangeset
for help on using the changeset viewer.