- Timestamp:
- 2020-07-24T15:54:07+12:00 (4 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r34261 r34288 517 517 518 518 private class ReplaceTask 519 extends Thread 519 extends Thread implements FileCopiedSuccessListener 520 520 { 521 521 private CollectionTree collection_tree = null; … … 563 563 564 564 FileNode parent = (FileNode)collection_tree_node.getParent(); // store the original source's parent, need it several times after changing source 565 566 if(!isSameLeafName) {567 // If the file name of the replacing file is NOT the same as the one being replaced568 // copy the new file in - but don't bring metadata569 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY_FILE_ONLY);570 }571 572 if (Gatherer.isGsdlRemote) {573 String collection_name = CollectionManager.getLoadedCollectionName();574 Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection_name, collection_tree_node.getFile());575 Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, new File[] { new_file }, target_directory);576 }577 565 578 566 if(isSameLeafName) { 579 567 // If the file name of the replacing file IS the same as the one being replaced 580 // perform a COPY operation, which will copy across metadata too, after confirming whether the user really wants to replace the source with identically named targed 568 // perform a COPY operation, which will copy across metadata too, after confirming whether the user really wants to replace the source with identically named target 569 570 // (a) First, this instance of ReplaceTask and no other starts listening to whether the user 571 // DIDN'T CANCEL out of an identical filename copy operation and if this local file copy 572 // was a success. If so, on successful file copy event fired (only then), the source file 573 // from the workspace tree will also be uploaded to the remote GS3 574 file_queue.addFileCopiedSuccessListener(this); 575 576 // (b) Now can finally add the COPY job to the queue 581 577 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY); 578 582 579 } else { 583 // If the file name of the replacing file is NOT the same as the one being replaced, final step to finish off: 584 // do a replace of old file with new file 580 // If the file name of the replacing file is NOT the same as the one being replaced 581 // (a) copy the new file in - but don't bring metadata 582 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY_FILE_ONLY); 583 584 // (b) final step to finish off: do a replace of old file with new file 585 585 file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE); 586 586 } 587 587 588 588 589 //DebugStream.setDebugging(false, "FileManager.ReplaceTask"); 589 590 } 591 592 593 /** In order to detect that the user cancelled out of replacing an identically named target file, 594 * we now listen to events fired that the file was successfully copied across. Only then do we 595 * bother transferring the source file (from the workspace) into the target location in the 596 * collection on the remote file system. We don't do this if the user cancelled. 597 */ 598 public void fileCopiedSuccessfully(File new_file) { 599 600 //DebugStream.setDebugging(true, "FileManager.ReplaceTask.fileCopiedSuccessfully"); 601 602 if (Gatherer.isGsdlRemote) { 603 File target_directory = this.collection_tree_node.getFile().getParentFile(); 604 File collection_tree_node_file = this.collection_tree_node.getFile(); 605 606 String collection_name = CollectionManager.getLoadedCollectionName(); 607 Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection_name, collection_tree_node_file); 608 Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, new File[] { new_file }, target_directory); 609 } 610 611 // stop listening to further events fired now that we've handled this event successfully 612 file_queue.removeFileCopiedSuccessListener(this); 613 //DebugStream.setDebugging(false, "FileManager.ReplaceTask.fileCopiedSuccessfully"); 590 614 } 591 615 } -
main/trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r31293 r34288 69 69 private GProgressBar progress = null; 70 70 71 71 /** The objects listening for FileCopiedSuccess events. */ 72 private ArrayList file_copied_success_listeners = new ArrayList(); 73 72 74 /** Constructor. 73 75 */ … … 83 85 } 84 86 85 87 public void fireFileCopiedSuccessfully(File new_file) { 88 // Send the event off to all the matching Listeners 89 for (int i = 0; i < file_copied_success_listeners.size(); i++) { 90 ((FileCopiedSuccessListener) file_copied_success_listeners.get(i)).fileCopiedSuccessfully(new_file); 91 } 92 } 93 public void addFileCopiedSuccessListener(FileCopiedSuccessListener listener) { 94 file_copied_success_listeners.add(listener); 95 } 96 97 public void removeFileCopiedSuccessListener(FileCopiedSuccessListener listener) 98 { 99 file_copied_success_listeners.remove(listener); 100 } 101 86 102 /** Add a new job to the queue, specifiying as many arguments as is necessary to complete this type of job (ie delete needs no target information). 87 103 * @param id A long id unique to all jobs created by a single action. … … 410 426 try { 411 427 copyFile(source_file, target_file, true); 428 fireFileCopiedSuccessfully(source_file); 412 429 } 413 430 catch (FileAlreadyExistsException exception) { -
main/trunk/gli/src/org/greenstone/gatherer/gui/ConfigFileEditor.java
r34266 r34288 383 383 ElementOption elementToAdd = (ElementOption)chooseElementComboBox.getSelectedItem(); 384 384 addElementToConfigFile(elementToAdd); 385 385 //editor.setCaretPosition(0); 386 386 } 387 387 }
Note:
See TracChangeset
for help on using the changeset viewer.