Changeset 4674
- Timestamp:
- 2003-06-16T10:44:18+12:00 (21 years ago)
- Location:
- trunk/gli
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java
r4515 r4674 36 36 import org.greenstone.gatherer.valuetree.GValueNode; 37 37 import org.w3c.dom.*; 38 /** This class wraps around a DOM Document providing methods for accessing the data within. In this case the DOM represents a Greenstone Directory metadata file. It provides the necessary functionality to create a new metadata.xml file. 38 /** This class wraps around a DOM Document providing methods for accessing the data within. In this case the DOM represents a Greenstone Directory metadata file. It provides the necessary functionality to create a new metadata.xml file. 39 39 * @author John Thompson, Greenstone Digital Library, University of Waikato 40 40 * @version 2.3b … … 150 150 for(int l = 0; !will_accumulate && l < sibling_metadata_elements.getLength(); l++) { 151 151 Element sibling_metadata_element = (Element) sibling_metadata_elements.item(l); 152 will_accumulate = sibling_metadata_element.getAttribute(NAME_ATTRIBUTE).equals(metadata_element.getAttribute(NAME_ATTRIBUTE)); 152 // It appears that its possible that we can be asked to add the same metadata twice (especially after a copy action is cancelled then repeated). So we check if we have been asked to add exactly the same value twice. 153 if(sibling_metadata_element.getAttribute(NAME_ATTRIBUTE).equals(metadata_element.getAttribute(NAME_ATTRIBUTE))) { 154 // Check the values and return if they are the same. 155 //if(metadata_element.getAttribute(NAME_ATTRIBUTE).equalsIgnoreCase("dls.Title")) { 156 // Gatherer.println("Comparing:"); 157 // Gatherer.println("'" + metadata.getAbsoluteValue() + "'"); 158 // Gatherer.println(" with:"); 159 // Gatherer.println("'" + MSMUtils.getValue(sibling_metadata_element) + "'"); 160 //} 161 if(metadata.getAbsoluteValue().equals(MSMUtils.getValue(sibling_metadata_element))) { 162 // Gatherer.println("Value already exists: " + metadata); 163 return; 164 } 165 will_accumulate = true; 166 } 153 167 sibling_metadata_element = null; 154 168 } … … 187 201 } 188 202 /** Get all of the metadata, including directory level, associated with this file. */ 189 public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file ) {190 return getMetadata(filename, remove, metadatum_so_far, file, false);203 public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level) { 204 return getMetadata(filename, remove, metadatum_so_far, file, append_folder_level, false); 191 205 } 192 206 /** Retrieve the metadata associated with the given filename. Keep track of what metadata should be overwritten and what should be accumulated. Also make note of the source file, and remove the metadata if required. Finally if purge is set retrieve every piece of metadata in this file. */ 193 public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean purge) {207 public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level, boolean purge) { 194 208 ///ystem.err.println("Get metadata for " + filename); 195 209 ArrayList metadatum = null; … … 211 225 Element filename_element = (Element) filename_elements.item(j); 212 226 String filename_text = MSMUtils.getValue(filename_element); 213 if((filename != null && filename.matches(filename_text)) || filename_text.equals(DIRECTORY_FILENAME) || purge) {227 if((filename != null && filename.matches(filename_text)) || ((filename == null || append_folder_level) && filename_text.equals(DIRECTORY_FILENAME)) || purge) { 214 228 // If they match add all of the metadata found in the Description child element, remembering to abide by desired mode (accumulate vs. overwrite). 215 229 NodeList description_elements = fileset_element.getElementsByTagName(DESCRIPTION_ELEMENT); … … 236 250 ElementWrapper element = Gatherer.c_man.getCollection().msm.getElement(raw_element); 237 251 if (element != null) { 238 252 239 253 GValueNode value = Metadata.getDefaultValueNode(element, raw_value); 240 254 ///ystem.err.println("Miss. Create new metadata: " + raw_element + " -> " + raw_value + "\n"); … … 244 258 value = null; 245 259 element = null; 246 } 260 } 247 261 } 248 262 // check whether the metadata is null … … 251 265 if(filename != null) { 252 266 ///ystem.err.println("Filename = " + filename); 253 ///ystem.err.println("filename_text = " + filename_text); 267 ///ystem.err.println("filename_text = " + filename_text); 254 268 // If can only be file level if there is no folder path details in filename and if the filename matched the filename text node (it may have matched .* instead)! 255 269 if(filename.indexOf(File.separator) == -1 && filename.equals(filename_text)) { … … 267 281 } 268 282 metadata.setFile(file); 269 283 270 284 // If mode is overwrite, then remove any previous values for this metadata element. 271 285 if(mode.equals("accumulate")) { … … 285 299 } 286 300 mode = null; 287 301 288 302 // Add the completed metadata and clean up 289 303 ///ystem.err.println("Adding metadata: " + metadata); 290 304 metadatum.add(metadata); 291 305 292 306 // Having found our metadata check if the value from the xml matches the one from the gvaluenode. If not update it. This happens whenever hierarchy information is involved (indexes rapidly become obsolete). 293 307 // If remove was set, remove it. We can only remove pure file level metadata, or folder level iff we were asked for folder level. … … 378 392 Element description_element = (Element) description_elements.item(k); 379 393 NodeList metadata_elements = description_element.getElementsByTagName("Metadata"); 380 for(int l = 0; (!found || !make_next_metadata_element_overwrite) && l < metadata_elements.getLength(); l++) { 394 for(int l = 0; (!found || !make_next_metadata_element_overwrite) && l < metadata_elements.getLength(); l++) { 381 395 Element metadata_element = (Element) metadata_elements.item(l); 382 396 String element = metadata_element.getAttribute("name"); … … 428 442 Gatherer.printStackTrace(error); 429 443 } 430 } 444 } 431 445 432 446 /** Change the up to date flag. */ -
trunk/gli/src/org/greenstone/gatherer/msm/GDMManager.java
r4595 r4674 56 56 */ 57 57 public class GDMManager 58 extends HashMap 58 extends HashMap 59 59 implements MSMListener { 60 60 /** A list of the known metadata instances, thus we only store one of each unique metadata, and reference the rest. */ … … 84 84 } 85 85 } 86 /** Destructor necessary for clean exit, subsequent to saving of metadata.xml files. 86 /** Destructor necessary for clean exit, subsequent to saving of metadata.xml files. 87 87 * @see org.greenstone.gatherer.Gatherer 88 88 * @see org.greenstone.gatherer.collection.CollectionManager … … 154 154 /** Recover the metadata associated with a particular file. Note that this call is synchronized, so that all of the data holders don't need to be. */ 155 155 public synchronized ArrayList getMetadata(File file) { 156 return getMetadata(file, false); 156 return getMetadata(file, false, true); 157 } 158 159 /** Recover the metadata associated with a particular file excluding folder level metadata. Note that this call is synchronized, so that all of the data holders don't need to be. */ 160 public synchronized ArrayList getMetadataOnly(File file) { 161 return getMetadata(file, false, false); 157 162 } 158 163 159 164 public synchronized ArrayList getMetadata(File file, ElementWrapper element) { 160 ArrayList metadata = getMetadata(file, false );165 ArrayList metadata = getMetadata(file, false, true); 161 166 ArrayList values = new ArrayList(); 162 167 for(int i = 0; i < metadata.size(); i++) { … … 172 177 } 173 178 174 private ArrayList getMetadata(File file, boolean remove ) {179 private ArrayList getMetadata(File file, boolean remove, boolean append_folder_level) { 175 180 ArrayList metadata = null; 176 181 String filename = null; … … 181 186 GDMDocument document = getDocument(file); 182 187 if(document != null) { 183 metadata = document.getMetadata(filename, remove, metadata, file );188 metadata = document.getMetadata(filename, remove, metadata, file, append_folder_level); 184 189 document = null; 185 190 } … … 221 226 if(document != null) { 222 227 // There is one piece of slight of hand here. You can never remove metadata during a get all metadata. 223 metadata = document.getMetadata(a_search.filename, false, metadata, a_search.file );228 metadata = document.getMetadata(a_search.filename, false, metadata, a_search.file, true); 224 229 ///ystem.err.println("Current metadata: " + toString(metadata)); 225 230 document = null; … … 233 238 search_files = null; 234 239 return metadata; 235 } 240 } 236 241 237 242 public String toString(ArrayList list) { … … 244 249 } 245 250 text.append(")"); 246 return text.toString(); 251 return text.toString(); 247 252 } 248 253 … … 300 305 301 306 public ArrayList removeMetadata(File file) { 302 return getMetadata(file, true );303 } 304 305 /** Causes all currently loaded GDMDocuments to write themselves out. 307 return getMetadata(file, true, false); 308 } 309 310 /** Causes all currently loaded GDMDocuments to write themselves out. 306 311 * @see org.greenstone.gatherer.msm.GDMDocument 307 312 */ -
trunk/gli/src/org/greenstone/gatherer/msm/MetadataSetManager.java
r4673 r4674 579 579 mds_hashtable.put(family, mds_new); 580 580 } 581 fireSetChanged(mds_new);582 581 return true; 583 582 } … … 915 914 // And make back ups of all existing metadata set files. 916 915 File temp[] = file.listFiles(); 917 for(int i = 0; temp != null && i < temp.length; i++) {916 for(int i = temp.length - 1; i >= 0; i--) { 918 917 if(temp[i].getName().endsWith(".mds") || temp[i].getName().endsWith(".mdv")) { 919 918 File backup = new File(temp[i].getAbsolutePath() + "~"); -
trunk/gli/src/org/greenstone/gatherer/util/DragTreeSelectionModel.java
r4618 r4674 70 70 tree.addMouseListener(this); 71 71 } 72 72 73 73 public void addSelectionPath(TreePath path) { 74 74 if(!immediate) { … … 81 81 } 82 82 } 83 83 84 84 public void addSelectionPaths(TreePath paths[]) { 85 85 if(!immediate) { … … 90 90 temp_paths = null; 91 91 super.setSelectionPaths(paths); 92 } 93 } 94 92 } 93 } 94 95 95 public String getDetails() { 96 96 String suffix = null; … … 154 154 return suffix; 155 155 } 156 156 157 157 /** Any implementation of MouseListener must include this method so 158 158 * we can be informed when the mouse is clicked. … … 162 162 public void mouseClicked(MouseEvent event) { 163 163 } 164 164 165 165 /** Any implementation of MouseListener must include this method so 166 166 * we can be informed when the mouse enters a component. … … 170 170 public void mouseEntered(MouseEvent event) { 171 171 } 172 172 173 173 /** Any implementation of MouseListener must include this method so 174 174 * we can be informed when the mouse exits a component. … … 178 178 public void mouseExited(MouseEvent event) { 179 179 } 180 180 181 181 /** Any implementation of MouseListener must include this method so 182 182 * we can be informed when the mouse is pressed (start of click). … … 193 193 */ 194 194 public void mouseReleased(MouseEvent event) { 195 try { 195 196 switch(this.type) { 196 197 case 0: // this.ADD … … 217 218 break; 218 219 } 220 } 221 catch (Exception error) { 222 Gatherer.printStackTrace(error); 223 } 219 224 } 220 225 … … 222 227 immediate = value; 223 228 } 224 229 225 230 public void setSelectionPath(TreePath path) { 226 231 // Since this is only a single path we don't need to check whether its an appropriate selection. … … 234 239 } 235 240 } 236 241 237 242 public void setSelectionPaths(TreePath paths[]) { 238 243 if(!immediate) { … … 246 251 } 247 252 248 /** Ensure that the given path is appropriate to add to the current selection, preventing mixed selections of files and folder if required. We also must check that no path is a ancestor/descendant of another. 253 /** Ensure that the given path is appropriate to add to the current selection, preventing mixed selections of files and folder if required. We also must check that no path is a ancestor/descendant of another. 249 254 */ 250 255 private boolean isAppropriate(TreePath path) { … … 256 261 TreeNode current_node = (TreeNode) selection[i].getLastPathComponent(); 257 262 appropriate = appropriate && (mixed_selection || new_node.isLeaf() == current_node.isLeaf()); 258 appropriate = appropriate && !path.isDescendant(selection[i]) && !selection[i].isDescendant(path); 263 appropriate = appropriate && !path.isDescendant(selection[i]) && !selection[i].isDescendant(path); 259 264 } 260 265 } -
trunk/gli/src/org/greenstone/gatherer/util/EmailAddress.java
r4665 r4674 204 204 middle = new JPanel(); 205 205 field1 = new JTextField(user); 206 field1.setBackground( Gatherer.config.getColor("coloring.editable", false));206 field1.setBackground(Color.white); 207 207 at = new JLabel("@"); 208 208 field2 = new JTextField(host); 209 field2.setBackground( Gatherer.config.getColor("coloring.editable", false));209 field2.setBackground(Color.white); 210 210 // Add listeners 211 211 field1.addKeyListener(new UserListener());
Note:
See TracChangeset
for help on using the changeset viewer.