Changeset 13320


Ignore:
Timestamp:
2006-11-24T10:03:34+13:00 (17 years ago)
Author:
shaoqun
Message:

added a browse button for the export directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/ExportAsPrompt.java

    r13195 r13320  
    114114    private StringBuffer error_message = null;
    115115    /** The size of the export prompt screen. */
    116     public static final Dimension SIZE = new Dimension(500, 520); 
     116    public static final Dimension SIZE = new Dimension(500, 540); 
    117117    private GDefaultProgressMonitor progress_monitor;   
    118118
     
    120120    private JButton convert_xml_button2 = null;
    121121    private JButton convert_xml_button3 = null;
     122    private JButton folder_button = null;
    122123
    123124    private JPanel instructions_pane = null;
     
    238239    title_field.setToolTipText(Dictionary.get("ExportAsPrompt.Export_Name_Tooltip"));
    239240    title_label = new JLabel(Dictionary.get("ExportAsPrompt.Export_Name"));
     241
     242        folder_button = new GLIButton(Dictionary.get("ExportAsPrompt.Browse"),Dictionary.get("ExportAsPrompt.Browse_Tooltip"));
     243    folder_button.addActionListener(new FolderButtonListener());
     244   
    240245   
    241246    scanForCollections();
     
    301306    title_pane.add(title_label, BorderLayout.WEST);
    302307    title_pane.add(title_field, BorderLayout.CENTER);
     308        title_pane.add(folder_button, BorderLayout.EAST);
    303309        //apply xsl pane
    304310         
     
    342348
    343349        JPanel tmp_pane = new JPanel(new BorderLayout());
    344         tmp_pane.add(saveas_pane, BorderLayout.WEST);
     350        tmp_pane.add(saveas_pane, BorderLayout.NORTH);
    345351    tmp_pane.add(title_pane, BorderLayout.CENTER);
    346352
     
    407413    if (num_collections == 0) return;
    408414    cd_title = title_field.getText();
    409     cd_title = cd_title.trim();
    410     cd_title = cd_title.replaceAll("\"", "");
    411415
    412416    String export_type = (String) saveas_combobox.getSelectedItem();
     
    427431    command_parts_list.add("-exportdir");
    428432    String export_dir = LocalGreenstone.getTmpDirectoryPath();
    429         if (cd_title.equals("")) {
    430         export_dir += "exported_" + export_type;
     433        if (cd_title.equals("")) {
     434            export_dir += "exported_" + export_type;
    431435    }
    432436    else {
    433         export_dir += cd_title.replaceAll("\\s", "");
    434     }
    435     command_parts_list.add(export_dir);
     437        File cd_file = new File(cd_title);
     438            if (cd_file.isAbsolute())
     439        export_dir = cd_title + File.separator + "exported_" + export_type;
     440        else{
     441                cd_title = cd_title.replaceAll("\\s+","");
     442                cd_title = cd_title.replaceAll("\\\\+","/");
     443                cd_title = cd_title.replaceAll("/+","/");
     444                export_dir +=cd_title;
     445        }
     446    }
     447
     448        command_parts_list.add(export_dir);
    436449
    437450        if (!export_type.equals("METS") && xsl_file1 !=null){
     
    520533   
    521534    args[0] = coll_names.toString();
    522 
    523     args[1] = LocalGreenstone.getTmpDirectoryPath();
    524     if(cd_title.equals("")) {
    525         String export_type = (String)saveas_combobox.getSelectedItem();
    526         args[1] += "exported_" + export_type;
    527     } else {
    528         args[1] += "exported_"+cd_title.replaceAll("\\s","");
    529     }
     535   
     536    String export_type = (String) saveas_combobox.getSelectedItem();       
     537        args[1] = LocalGreenstone.getTmpDirectoryPath();
     538        if (cd_title.equals("")) {
     539           args[1] += "exported_" + export_type;
     540    }
     541    else {
     542        File cd_file = new File(cd_title);
     543            if (cd_file.isAbsolute())
     544        args[1] = cd_title + File.separator + "exported_" + export_type;
     545        else{
     546                cd_title = cd_title.replaceAll("\\s+","");
     547                cd_title = cd_title.replaceAll("\\\\+","/");
     548                cd_title = cd_title.replaceAll("/+","/");
     549                args[1] +=cd_title;
     550        }
     551    }
     552       
    530553
    531554    String title;
     
    877900     }
    878901
     902 private class FolderButtonListener implements ActionListener {
     903    public void actionPerformed(ActionEvent event) {
     904        JFileChooser chooser = new JFileChooser();
     905        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     906       
     907        int returnVal = chooser.showOpenDialog(prompt);       
     908       
     909        if(returnVal == JFileChooser.APPROVE_OPTION) {
     910        File folder_name = chooser.getSelectedFile();
     911        title_field.setText(folder_name.getPath());
     912        }
     913       
     914    }
     915 }
    879916}
    880917
     
    882919
    883920
     921
Note: See TracChangeset for help on using the changeset viewer.