Changeset 12423


Ignore:
Timestamp:
2006-08-09T14:34:06+12:00 (18 years ago)
Author:
shaoqun
Message:

enable the preview buton when there is a previouly built collecton and display the warning message

File:
1 edited

Legend:

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

    r12366 r12423  
    4848import org.greenstone.gatherer.cdm.Format;
    4949import org.greenstone.gatherer.cdm.Control;
     50import org.greenstone.gatherer.Configuration;
     51import org.greenstone.gatherer.shell.GShell;
     52import org.greenstone.gatherer.shell.GShellEvent;
     53import org.greenstone.gatherer.shell.GShellListener;
    5054
    5155public class FormatPane
    5256    extends BaseConfigPane
    53     implements PreviewButtonOwner {
     57    implements PreviewButtonOwner,GShellListener{
    5458   
    5559
    5660    /** The button for viewing the collection. */
    5761    private PreviewButton preview_button = null;
     62    private boolean buildCanceled = false;
    5863
    5964    /** The constructor. */
     
    7378    preview_button.setVariablePreview(true);
    7479    preview_button.setOwner(this);
     80
     81
     82
    7583    preview_button.addActionListener(new ActionListener() {
    7684        public void actionPerformed(ActionEvent event) {
    77             if (view != null) {
    78             view.loseFocus();
     85            if (view != null) {
     86            view.loseFocus();
     87            }
     88           
     89            if (buildCanceled){
     90            WarningDialog dialog = new WarningDialog("warning.ShowPreviousCollection", "ShowPreviousCollection.Title", Dictionary.get("ShowPreviousCollection.Message"), null, false);
     91            dialog.display();
     92                        dialog.dispose();
    7993            }
    8094        }
     
    8599    add(side_panel, BorderLayout.WEST);
    86100    }
     101
     102    public void gainFocus(){
     103
     104    if (Gatherer.c_man.built() && Configuration.library_url != null) {
     105        preview_button.setEnabled(true);
     106    } 
     107    else{
     108        preview_button.setEnabled(false);
     109    }   
     110   
     111    }
     112
     113
     114    /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
     115     * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
     116     */
     117    public synchronized void message(GShellEvent event) {
     118        // We don't care. 
     119    }
     120
     121   
     122    /** All implementation of GShellListener must include this method so the listener can be informed when a GShell begins its task. Implementation side-effect, not actually used.
     123     * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
     124     */
     125    public synchronized void processBegun(GShellEvent event) {
     126    buildCanceled = false;
     127    }
     128   
     129    /** All implementation of GShellListener must include this method so the listener can be informed when a GShell completes its task.
     130     * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
     131     */
     132    public synchronized void processComplete(GShellEvent event) {
     133    if(event.getStatus() == GShell.OK) {
     134        if(event.getType() == GShell.BUILD) {
     135            buildCanceled = false;
     136        }
     137    }     
     138    else {
     139        buildCanceled = true;   
     140    }
     141    }
     142
     143
    87144
    88145    protected Control getSubControls(String type) {
Note: See TracChangeset for help on using the changeset viewer.