- Timestamp:
- 2010-08-11T21:28:34+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTree.java
r22410 r22605 39 39 import org.greenstone.gatherer.gui.CreateShortcutPrompt; 40 40 import org.greenstone.gatherer.gui.tree.DragTree; 41 import org.greenstone.gatherer.util.Utility; 41 42 42 43 … … 217 218 private JMenuItem rename = null; 218 219 private JMenuItem replace = null; 220 private JMenuItem copy_collection = null; 221 private JMenuItem move_collection = null; 219 222 220 223 … … 343 346 // Or map any other level directories 344 347 else { 348 // --- Options for Documents In Greenstone Collections (greenstone_collections_node) --- 349 // all subfolder of Documents In Greenstone Collections can be copied and moved 350 WorkspaceTreeNode secondLevelNode = (WorkspaceTreeNode) path.getPathComponent(1); 351 352 if (secondLevelNode.toString().equals(Dictionary.get("Tree.World"))) { 353 // Can move and copy the collection folders across 354 copy_collection = new JMenuItem(Dictionary.get("Menu.Copy_Collection"), KeyEvent.VK_P); 355 copy_collection.addActionListener(this); 356 add(copy_collection); 357 358 move_collection = new JMenuItem(Dictionary.get("Menu.Move_Collection"), KeyEvent.VK_M); 359 move_collection.addActionListener(this); 360 add(move_collection); 361 } 362 345 363 create_shortcut = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_S); 346 364 create_shortcut.addActionListener(this); … … 386 404 Gatherer.f_man.openFileInExternalApplication(node.getFile()); 387 405 } 406 407 // Copy or move a collection from Documents in Greenstone Collections 408 else if (source == move_collection || source == copy_collection) { 409 410 JFileChooser chooser = new JFileChooser(Gatherer.getCollectDirectoryPath()); 411 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 412 chooser.setDialogTitle(Dictionary.get("FileActions.ChooseDestinationDirectory")); 413 int returnVal = chooser.showOpenDialog(Gatherer.g_man.gather_pane); 414 415 if(returnVal == JFileChooser.APPROVE_OPTION) { 416 417 // the node that the user rightclicked on ends up 418 // being the col's import folder 419 File sourceFolder = node.getFile(); 420 if(sourceFolder.getName().equals("import")) { 421 sourceFolder = sourceFolder.getParentFile(); 422 } 423 String target = chooser.getSelectedFile().getAbsolutePath(); 424 File targetFolder = new File(target+File.separator+sourceFolder.getName()); 425 426 // some sanity checks 427 if(targetFolder.equals(sourceFolder)) { // directory has not changed. No copy/move performed 428 JOptionPane.showMessageDialog(Gatherer.g_man, 429 "Can't move " + sourceFolder + " " + "to itself\n(" + targetFolder + ").", 430 "Source and destination directories are the same", 431 JOptionPane.ERROR_MESSAGE); 432 return; 433 } else if(targetFolder.exists()) { // option to overwrite or not 434 if(JOptionPane.showConfirmDialog(Gatherer.g_man, 435 "Directory " + targetFolder + " already exists. Overwrite?", 436 "Destination directory already exists", 437 JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) { 438 return; 439 } 440 // else can overwrite: delete the existing targetfolder before copying/moving 441 Utility.delete(targetFolder); 442 } 443 444 int operation = (source == move_collection) ? FileManager.MOVE : FileManager.COPY; 445 Gatherer.f_man.action(sourceFolder, targetFolder, operation); 446 } 447 } 388 448 } 389 449 }
Note:
See TracChangeset
for help on using the changeset viewer.