Ignore:
Timestamp:
2010-08-11T21:28:34+12:00 (14 years ago)
Author:
ak19
Message:

Ticket #152: Allowing different paths to collect dir so that GLI can work with collect dirs on pen drives. NONE OF THESE CHANGES ARE FOR Client-GLI AS YET. 1. Preferences (Connection tab), Open and New Collection dialogs allow one to change the current collect directory containing the collections to select from. 2. New Collection dialog allows one to base a new collection on an existing collection in a collect dir other than the current collect dir. 3. Collections in the Documents in Greenstone Collections Workspace Tree Node now have two additional rightclick options: to move and copy these collections to another location.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTree.java

    r22410 r22605  
    3939import org.greenstone.gatherer.gui.CreateShortcutPrompt;
    4040import org.greenstone.gatherer.gui.tree.DragTree;
     41import org.greenstone.gatherer.util.Utility;
    4142
    4243
     
    217218    private JMenuItem rename = null;
    218219    private JMenuItem replace = null;
     220    private JMenuItem copy_collection = null;
     221    private JMenuItem move_collection = null;
    219222
    220223
     
    343346        // Or map any other level directories
    344347        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
    345363            create_shortcut = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_S);
    346364            create_shortcut.addActionListener(this);
     
    386404        Gatherer.f_man.openFileInExternalApplication(node.getFile());
    387405        }
     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        }
    388448    }
    389449    }
Note: See TracChangeset for help on using the changeset viewer.