Changeset 11181


Ignore:
Timestamp:
2006-02-01T10:44:44+13:00 (18 years ago)
Author:
kjdon
Message:

a few changes to do with netscape compatibililty and size estimation

File:
1 edited

Legend:

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

    r10659 r11181  
    9090    private JTextArea instructions_textarea;
    9191    /** A string array used to pass arguments to the phrase retrieval method. */
     92    private JCheckBox netscape_checkbox = null;
     93    JLabel netscape_label = null;
    9294    private JTextField title_field = null;
    9395    private JTextField estimated_size_field = null;
     
    102104    /** the error message if any */
    103105    private StringBuffer error_message = null;
    104     /** This is the size of the exported stuff on its own (no collections). */
    105     private long total_exported_size = 52000000;
     106    /** This is the size of the exported stuff on its own without
     107    netscape and no collections. */
     108    private long total_exported_size = 16250000;
     109    /** the size of netscape */
     110    private long netscape_size = 16500000;
    106111    /** The size of the export prompt screen. */
    107112    public static final Dimension SIZE = new Dimension(500, 500);
     
    151156    Dictionary.setText(estimated_size_label, "WriteCDImagePrompt.Size_Label");
    152157
     158    netscape_checkbox = new JCheckBox();
     159    netscape_checkbox.addActionListener(new NetscapeCheckBoxListener());
     160    netscape_label = new JLabel();
     161    Dictionary.setText(netscape_label, "WriteCDImagePrompt.Netscape_Compatibility");
     162   
    153163    scanForCollections();
    154164    list.setListData(all_collections);
     
    167177    ok_button.setEnabled(false);
    168178    //title.getDocument().addDocumentListener(new DocumentListener());
     179
     180    // work out the size of the extra images needed for netscape 4
     181    // this assumes that they'll be installed (lang pack).
     182    //exportcol.pl will crap out if they are not.
     183    netscape_size += getFileSize(new File(LocalGreenstone.getDirectoryPath()+File.separator+"images"));
    169184    }
    170185
     
    200215    title_pane.add(title_label, BorderLayout.WEST);
    201216    title_pane.add(title_field, BorderLayout.CENTER);
    202     instructions_pane.add(title_pane, BorderLayout.SOUTH);
     217    //  instructions_pane.add(title_pane, BorderLayout.SOUTH);
     218
     219    JPanel netscape_pane = new JPanel(new BorderLayout());
     220    netscape_pane.add(netscape_checkbox, BorderLayout.WEST);
     221    netscape_pane.add(netscape_label, BorderLayout.CENTER);
     222   
     223    JPanel grid_pane = new JPanel(new GridLayout(2,1));
     224    grid_pane.add(title_pane);
     225    grid_pane.add(netscape_pane);
     226    instructions_pane.add(grid_pane, BorderLayout.SOUTH);
    203227
    204228    // Central pane
     
    250274
    251275   
     276    protected long getFileSize(File file)
     277    {
     278    long file_size = 0;
     279   
     280    // Directory case
     281    if (file.isDirectory()) {
     282        File files[] = file.listFiles();
     283        for (int i = 0; i < files.length; i++) {
     284        file_size += getFileSize(files[i]);
     285        }
     286    }
     287    // File case
     288    else {
     289        file_size = file.length();
     290    }
     291   
     292    return file_size;
     293    }
     294
    252295    /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor.
    253296     * @see org.greenstone.gatherer.Configuration
     
    270313    cd_title = cd_title.replaceAll("\"","");
    271314
     315    boolean use_netscape = false;
     316    if (netscape_checkbox.isSelected()) {
     317        use_netscape = true;
     318    }
     319   
    272320    // Generate the exportcol.pl command
    273321    ArrayList command_parts_list = new ArrayList();
     
    278326    command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "exportcol.pl");
    279327
    280     if (Gatherer.isGsdlRemote) {
     328    //if (Gatherer.isGsdlRemote || !use_netscape) {
     329    if (!use_netscape) {
     330        // now we allow remote users to use the netscape version
    281331        command_parts_list.add("-nonetscape");
    282332    }
     
    432482    }
    433483
    434 
     484    private class NetscapeCheckBoxListener
     485    implements ActionListener {
     486    public void actionPerformed(ActionEvent e) {
     487        if (netscape_checkbox.isSelected()) {
     488        total_exported_size += netscape_size;
     489        } else {
     490        total_exported_size -= netscape_size;
     491        }
     492        // Update the size field
     493        estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
     494    }
     495    }
    435496    /** This private class listens for selection events in from the list and then displays the appropriate details for that collection.
    436497     */
     
    482543        // Update the size field
    483544        estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
    484     }
    485 
    486 
    487     private long getFileSize(File file)
    488     {
    489         long file_size = 0;
    490 
    491         // Directory case
    492         if (file.isDirectory()) {
    493         File files[] = file.listFiles();
    494         for (int i = 0; i < files.length; i++) {
    495             file_size += getFileSize(files[i]);
    496         }
    497         }
    498         // File case
    499         else {
    500         file_size = file.length();
    501         }
    502 
    503         return file_size;
    504545    }
    505546    }
Note: See TracChangeset for help on using the changeset viewer.