Changeset 5892


Ignore:
Timestamp:
2003-11-19T14:02:42+13:00 (20 years ago)
Author:
kjdon
Message:

added a preview button to the create pane

File:
1 edited

Legend:

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

    r5872 r5892  
    107107    /** The button for stopping the building processes. */
    108108    private JButton cancel_button = null;
     109    /** The button for viewing the collection. */
     110    private JButton preview_button = null;
    109111    /** The label displaying the number of documents in this collection. */
    110112    private JLabel document_count = null;
     
    131133    /** An array used to pass arguments with dictionary calls. */
    132134    private String args[] = null;
     135    /** The homepage address of the current collection */
     136    private String homepage = null;
    133137    /** The size of the buttons at the bottom of the screen. */
    134     static private Dimension BUTTON_SIZE = new Dimension(386, 50);
     138    static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);
    135139    /** The size of the labels on the progress pane. */
    136140    static private Dimension LABEL_SIZE = new Dimension(140, 25);
     
    209213    cancel_button.setPreferredSize(BUTTON_SIZE);
    210214    Dictionary.registerBoth(cancel_button, "CreatePane.Cancel_Build", "CreatePane.Cancel_Build_Tooltip");
     215
     216    preview_button = new JButton();
     217    preview_button.addActionListener(new PreviewButtonListener());
     218    preview_button.setEnabled(false);
     219    preview_button.setPreferredSize(BUTTON_SIZE);
     220    Dictionary.registerBoth(preview_button, "CreatePane.Preview_Collection", "CreatePane.Preview_Collection_Tooltip");
    211221    }
    212222
     
    220230    public void collectionChanged(boolean ready) {
    221231    ///ystem.err.println("Collection changed... ");
    222     if(Gatherer.c_man != null && ready) {
    223         Collection current_collection = Gatherer.c_man.getCollection();
    224         if (current_collection != previous_collection) {
    225         this.options_pane = new OptionsPane(current_collection.build_options);
    226         previous_collection = current_collection;
    227         }
    228         tree.valueChanged(null);
     232    if(Gatherer.c_man == null || !ready) {
     233        return;
     234    }
     235    Collection current_collection = Gatherer.c_man.getCollection();
     236    if (current_collection != previous_collection) {
     237        this.options_pane = new OptionsPane(current_collection.build_options);
     238        previous_collection = current_collection;
     239    }
     240    tree.valueChanged(null);
     241   
     242    // now do the preview stuff
     243    if (!Gatherer.c_man.built()) {
     244        preview_button.setEnabled(false);
     245    } else if (Gatherer.config.exec_address == null) {
     246        preview_button.setEnabled(false);
     247    } else {
     248        // set up the home page for the current collection
     249        String extra_args = "";
     250        String build_type = current_collection.getCollectionType();
     251        if (build_type.equals("mgpp")) {
     252        // we need some more args on the url
     253        String search_types = current_collection.getSearchTypes();
     254        if (search_types.equals("")) {
     255            extra_args = "&ct=1&qt=0&qto=3";
     256        } else if (search_types.equals("plain")) {
     257            extra_args = "&ct=1&qt=0&qto=1";
     258        } else if (search_types.equals("form")) {
     259            extra_args = "&ct=1&qt=1&qto=2";
     260        } else if (search_types.equals("plain,form")) {
     261            extra_args = "&ct=1&qt=0&qto=3";
     262        } else if (search_types.equals("form,plain")) {
     263            extra_args = "&ct=1&qt=1&qto=3";
     264        }
     265        }
     266       
     267        homepage = Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + current_collection.getName()+extra_args;
     268        preview_button.setEnabled(true);
    229269    }
    230270    }
     
    293333    button_pane.add(build_button);
    294334    button_pane.add(cancel_button);
     335    button_pane.add(preview_button);
    295336
    296337    this.setLayout(new BorderLayout());
     
    367408        cancel_button.setEnabled(false);
    368409        build_button.setEnabled(true);
     410        preview_button.setEnabled(true);
    369411        int status = event.getStatus();
    370412        document.setSpecialCharacter(OptionsPane.SUCCESSFUL);
     
    378420        cancel_button.setEnabled(false);
    379421        build_button.setEnabled(true);
     422        preview_button.setEnabled(false);
    380423        document.setSpecialCharacter(OptionsPane.UNSUCCESSFUL);
    381424        options_pane.resetFileEntry();
     
    400443        build_button.setEnabled(false);
    401444        cancel_button.setEnabled(true);
     445        preview_button.setEnabled(false);
    402446        // Create a new log document and assign it to the two textareas
    403447        document = options_pane.createNewLogDocument();
     
    432476        build_button.setEnabled(true);
    433477        cancel_button.setEnabled(false);
     478        preview_button.setEnabled(false);
    434479        processing = false;
    435480        document.setSpecialCharacter(OptionsPane.CANCELLED);
     
    445490    }
    446491    }
     492
     493    private class PreviewButtonListener
     494    implements ActionListener {
     495   
     496    public void actionPerformed(ActionEvent event) {
     497        Gatherer.self.spawnBrowser(homepage);
     498
     499    }
     500    }
     501   
    447502    /** The OptionTree is simply a tree structure that has a root node labelled "Options" and then has a child node for each available options screen. These screens are either combinations of the available import and build arguments, or a message log detailing the shell processes progress. */
    448503    private class OptionTree
Note: See TracChangeset for help on using the changeset viewer.