Changeset 37191
- Timestamp:
- 2023-01-28T15:43:52+13:00 (15 months ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionTree.java
r23455 r37191 151 151 private JMenuItem metaaudit = null; 152 152 private JMenuItem new_folder = null; 153 private JMenuItem new_file = null; 153 154 private JMenuItem new_dummy_doc = null; 154 155 private JMenuItem refresh = null; // for refreshing folder view … … 267 268 add(new_folder); 268 269 270 new_file = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_File")); 271 new_file.addActionListener(this); 272 add(new_file); 273 269 274 new_dummy_doc = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Dummy_Doc")); 270 275 new_dummy_doc.addActionListener(this); … … 358 363 add(new_folder); 359 364 365 366 new_file = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_File")); 367 new_file.addActionListener(this); 368 add(new_file); 369 360 370 new_dummy_doc = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Dummy_Doc")); 361 371 new_dummy_doc.addActionListener(this); … … 415 425 Gatherer.f_man.newFolder(collection_tree, node); 416 426 } 417 427 else if (source == new_file) { 428 Gatherer.f_man.newCollectionFile(collection_tree, node); 429 } 418 430 // New dummy doc 419 431 else if (source == new_dummy_doc) { -
main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r36237 r37191 68 68 public static final int FILE_TYPE = 0; 69 69 public static final int FOLDER_TYPE = 1; 70 70 71 protected static File startup_directory = null; 71 72 … … 509 510 } 510 511 512 public void newCollectionFile(CollectionTree collection_tree, CollectionTreeNode parent_node) 513 { 514 new ReplaceOrNewTask(collection_tree, parent_node, false ).start(); 515 } 516 511 517 public void replaceCollectionFile(CollectionTree collection_tree, CollectionTreeNode collection_tree_node) 512 518 { 513 519 // This must go in a separate thread because we need the progress bar to work (remote Greenstone server) 514 new Replace Task(collection_tree, collection_tree_node).start();515 } 516 517 518 private class Replace Task520 new ReplaceOrNewTask(collection_tree, collection_tree_node, true).start(); 521 } 522 523 524 private class ReplaceOrNewTask 519 525 extends Thread implements FileCopiedSuccessListener 520 526 { 521 527 private CollectionTree collection_tree = null; 522 528 private CollectionTreeNode collection_tree_node = null; 523 524 public ReplaceTask(CollectionTree collection_tree, CollectionTreeNode collection_tree_node) 529 private boolean replacing = false; 530 531 public ReplaceOrNewTask(CollectionTree collection_tree, CollectionTreeNode collection_tree_node, boolean replacing) 525 532 { 526 533 this.collection_tree = collection_tree; 527 this.collection_tree_node = collection_tree_node; 534 this.collection_tree_node = collection_tree_node; // either the file to replace, or the folder to go into 535 this.replacing = replacing; 528 536 } 529 537 … … 531 539 { 532 540 JFileChooser file_chooser = new JFileChooser(startup_directory); 533 file_chooser.setDialogTitle(Dictionary.get("ReplacePrompt.Title")); 541 if (replacing) { 542 file_chooser.setDialogTitle(Dictionary.get("ReplacePrompt.Title")); 543 } else { 544 file_chooser.setDialogTitle(Dictionary.get("NewPrompt.Title")); 545 } 534 546 File new_file = null; 535 547 int return_val = file_chooser.showOpenDialog(null); … … 554 566 // or remote file gets updated but file gone missing in client-GLI view until collection reopened. 555 567 boolean isSameLeafName = false; 556 if( collection_tree_node.getFile().getName().equals(new_file.getName())) {568 if(replacing && collection_tree_node.getFile().getName().equals(new_file.getName())) { 557 569 DebugStream.println(" @@@ File Replace: New file has the same name as existing."); 558 570 isSameLeafName = true; 559 571 } 560 572 561 File target_directory = collection_tree_node.getFile().getParentFile(); 573 File target_directory; 574 FileNode parent; // store the original source's parent, need it several times after changing source 575 if (replacing) { 576 target_directory = collection_tree_node.getFile().getParentFile(); 577 parent = (FileNode)collection_tree_node.getParent(); 578 } else { 579 target_directory = collection_tree_node.getFile(); 580 parent = collection_tree_node; 581 } 562 582 CollectionTreeNode new_collection_tree_node = new CollectionTreeNode(new File(target_directory, new_file.getName())); 563 583 564 FileNode parent = (FileNode)collection_tree_node.getParent(); // store the original source's parent, need it several times after changing source584 //FileNode parent = (FileNode)collection_tree_node.getParent(); // store the original source's parent, need it several times after changing source 565 585 566 586 if(isSameLeafName) { … … 585 605 // (b) copy the new file in - but don't bring metadata 586 606 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY_FILE_ONLY); 587 588 // (c) final step to finish off: do a replace of old file with new file 589 file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE); 590 } 607 608 if (replacing) { 609 // (c) final step to finish off: do a replace of old file with new file 610 file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE); 611 } 612 } 613 591 614 592 615 … … 605 628 606 629 if (Gatherer.isGsdlRemote) { 607 File target_directory = this.collection_tree_node.getFile().getParentFile(); 630 File target_directory; 631 if (this.replacing) { 632 target_directory = this.collection_tree_node.getFile().getParentFile(); 633 } else { 634 target_directory = this.collection_tree_node.getFile(); 635 } 608 636 File collection_tree_node_file = this.collection_tree_node.getFile(); 609 637 610 638 String collection_name = CollectionManager.getLoadedCollectionName(); 639 if (this.replacing) { 611 640 Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection_name, collection_tree_node_file); 641 } 612 642 Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, new File[] { new_file }, target_directory); 613 643 }
Note:
See TracChangeset
for help on using the changeset viewer.