Changeset 6533 for trunk/gli/src


Ignore:
Timestamp:
2004-01-16T15:52:11+13:00 (20 years ago)
Author:
jmt12
Message:

Finished the design of a new 'simple' creating/progress pane, including merging the two progress bars into one

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
6 edited

Legend:

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

    r6389 r6533  
    9595    static private Dimension ARGUMENT_SIZE = new Dimension(800,90);
    9696    /** The size of the buttons at the bottom of the screen. */
    97     static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);
     97    static private Dimension BUTTON_SIZE = new Dimension (256, 40);//(386, 50);
    9898    /** The size of the labels on the progress pane. */
    9999    static private Dimension LABEL_SIZE = new Dimension(140, 25);
     
    128128    /** The button for viewing the collection. */
    129129    private JButton preview_button = null;
     130    private JButton simple_build_button;
     131    private JButton simple_cancel_button;
     132    private JButton simple_preview_button;
    130133    /** The label displaying the number of documents in this collection. */
    131134    private JLabel document_count = null;
     
    136139    /** The label alongside the import progress bar gets some special treatment so... */
    137140    private JLabel progress_import_label = null;
    138     /** A panel containing the two progress bars. */
    139141    private JPanel bar_area;
    140142    /** The panel on which buttons are rendered on higher detail modes. */
     
    232234    Dictionary.registerText(progress_build_label, "CreatePane.Build_Progress");
    233235
    234     build_monitor = new GBuildProgressMonitor(); //GBasicProgressMonitor();
     236    build_monitor = new GBuildProgressMonitor(import_monitor.getSharedProgress()); //GBasicProgressMonitor();
    235237    Gatherer.c_man.registerBuildMonitor(build_monitor);
    236238
     
    241243
    242244    // Buttons
     245    BuildButtonListener bbl = new BuildButtonListener();
     246    CancelButtonListener cbl = new CancelButtonListener();
     247    PreviewButtonListener pbl = new PreviewButtonListener();
     248
    243249    build_button = new GLIButton();
    244     build_button.addActionListener(new BuildButtonListener());
     250    build_button.addActionListener(bbl);
    245251    build_button.setMnemonic(KeyEvent.VK_B);
    246252    build_button.setPreferredSize(BUTTON_SIZE);
     
    248254
    249255    cancel_button = new GLIButton();
    250     cancel_button.addActionListener(new CancelButtonListener());
     256    cancel_button.addActionListener(cbl);
    251257    cancel_button.setEnabled(false);
    252258    cancel_button.setMnemonic(KeyEvent.VK_C);
     
    255261
    256262    preview_button = new GLIButton();
    257     preview_button.addActionListener(new PreviewButtonListener());
    258     preview_button.setEnabled(false);
     263    preview_button.addActionListener(pbl);
     264    if(Gatherer.c_man != null) {
     265        preview_button.setEnabled(Gatherer.c_man.built());
     266    }
     267    else {
     268        preview_button.setEnabled(false);
     269    }
    259270    preview_button.setMnemonic(KeyEvent.VK_P);
    260271    preview_button.setPreferredSize(BUTTON_SIZE);
    261272    Dictionary.registerBoth(preview_button, "CreatePane.Preview_Collection", "CreatePane.Preview_Collection_Tooltip");
     273
     274    simple_build_button = new GLIButton();
     275    simple_build_button.addActionListener(bbl);
     276    simple_build_button.setMnemonic(KeyEvent.VK_B);
     277    simple_build_button.setPreferredSize(BUTTON_SIZE);
     278    Dictionary.registerBoth(simple_build_button, "CreatePane.Build_Collection", "CreatePane.Build_Collection_Tooltip");
     279
     280    simple_cancel_button = new GLIButton();
     281    simple_cancel_button.addActionListener(cbl);
     282    simple_cancel_button.setEnabled(false);
     283    simple_cancel_button.setMnemonic(KeyEvent.VK_C);
     284    simple_cancel_button.setPreferredSize(BUTTON_SIZE);
     285    Dictionary.registerBoth(simple_cancel_button, "CreatePane.Cancel_Build", "CreatePane.Cancel_Build_Tooltip");
     286
     287    simple_preview_button = new GLIButton();
     288    simple_preview_button.addActionListener(pbl);
     289    if(Gatherer.c_man != null) {
     290        simple_preview_button.setEnabled(Gatherer.c_man.built());
     291    }
     292    else {
     293        simple_preview_button.setEnabled(false);
     294    }
     295    simple_preview_button.setMnemonic(KeyEvent.VK_P);
     296    simple_preview_button.setPreferredSize(BUTTON_SIZE);
     297    Dictionary.registerBoth(simple_preview_button, "CreatePane.Preview_Collection", "CreatePane.Preview_Collection_Tooltip");
     298
     299    bbl = null;
     300    cbl = null;
     301    pbl = null;
    262302    }
    263303
     
    295335    if (!Gatherer.c_man.built() || Gatherer.config.exec_address == null) {
    296336        preview_button.setEnabled(false);
     337        simple_preview_button.setEnabled(false);
    297338    } else {
    298339        preview_button.setEnabled(true);
     340        simple_preview_button.setEnabled(true);
    299341    }
    300342    }
     
    332374    button_pane = new JPanel();
    333375    button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
    334     button_pane.setLayout(new GridLayout(1,2));
    335     if(current_mode >= THRESHOLD) {
    336         button_pane.add(build_button);
    337         button_pane.add(cancel_button);
    338         button_pane.add(preview_button);
    339     }
     376    button_pane.setLayout(new GridLayout(1,3));
     377    button_pane.add(build_button);
     378    button_pane.add(cancel_button);
     379    button_pane.add(preview_button);
    340380
    341381    control_pane.setLayout(new BorderLayout());
     
    367407    progress_pane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    368408    progress_pane.setLayout(new BorderLayout());
     409    progress_pane.add(bar_area, BorderLayout.NORTH);
    369410    if(current_mode >= THRESHOLD) {
    370         progress_pane.add(bar_area, BorderLayout.NORTH);
    371411        progress_pane.add(log_scroll, BorderLayout.CENTER);
    372412    }
     
    375415    sbutton_panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
    376416    sbutton_panel.setLayout(new GridLayout(3,1));
    377     if(current_mode < THRESHOLD) {
    378         sbutton_panel.add(build_button);
    379         sbutton_panel.add(cancel_button);
    380         sbutton_panel.add(preview_button);
    381     }
     417    sbutton_panel.add(simple_build_button);
     418    sbutton_panel.add(simple_cancel_button);
     419    sbutton_panel.add(simple_preview_button);
     420
     421    JPanel simple_bar_area = new JPanel(new GridLayout(3,1));
     422    simple_bar_area.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
     423    simple_bar_area.add(import_monitor.getSharedProgress());
    382424
    383425    sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
    384426    sinner_panel.setLayout(new BorderLayout());
    385     if(current_mode < THRESHOLD) {
    386         sinner_panel.add(bar_area, BorderLayout.CENTER);
    387     }
    388     sinner_panel.add(sbutton_panel, BorderLayout.EAST);
     427    sinner_panel.add(sbutton_panel, BorderLayout.WEST);
     428    sinner_panel.add(simple_bar_area, BorderLayout.CENTER);
    389429   
    390430    if(options_pane != null) {
     
    435475    }
    436476    else if(!processing) {
     477        // Move the buttons to control
     478        control_pane.add(button_pane, BorderLayout.SOUTH);
    437479        card_layout.show(main_pane, CONTROL);
    438480    }
    439481    else {
     482        // Move the buttons to progress
     483        progress_pane.add(button_pane, BorderLayout.SOUTH);
    440484        card_layout.show(main_pane, PROGRESS);
    441485    }
     
    484528        souter_panel.add(sinner_panel);
    485529        // Remove the shared components from the expert panels
    486         button_pane.remove(build_button);
    487         button_pane.remove(cancel_button);
    488         button_pane.remove(preview_button);
    489         progress_pane.remove(bar_area);
    490530        progress_pane.remove(log_scroll);
    491531        // And add to simple one
    492         sbutton_panel.add(build_button);
    493         sbutton_panel.add(cancel_button);
    494         sbutton_panel.add(preview_button);
    495         sinner_panel.add(bar_area, BorderLayout.CENTER);
    496532        simple_panel.add(log_scroll, BorderLayout.CENTER);
    497533        // And bring the card to the front
     
    501537    else {
    502538        // Remove the shared components from the simple panel
    503         sbutton_panel.remove(build_button);
    504         sbutton_panel.remove(cancel_button);
    505         sbutton_panel.remove(preview_button);
    506         sinner_panel.remove(bar_area);
    507539        simple_panel.remove(log_scroll);
    508540        // And add then to the expert ones
    509         button_pane.add(build_button);
    510         button_pane.add(cancel_button);
    511         button_pane.add(preview_button);
    512         progress_pane.add(bar_area, BorderLayout.NORTH);
    513541        progress_pane.add(log_scroll, BorderLayout.CENTER);
    514542        // And bring the appropriate card to the front
    515543        if(!processing) {
     544        control_pane.add(button_pane, BorderLayout.SOUTH);
    516545        card_layout.show(main_pane, CONTROL);
    517546        }
    518547        else {
     548        progress_pane.add(button_pane, BorderLayout.SOUTH);
    519549        card_layout.show(main_pane, PROGRESS);
    520550        }
     
    536566        if(event.getType() == GShell.BUILD) {
    537567        processing = false;
     568        build_button.setEnabled(true);
    538569        cancel_button.setEnabled(false);
    539         build_button.setEnabled(true);
    540570        preview_button.setEnabled(true);
     571        simple_build_button.setEnabled(true);
     572        simple_cancel_button.setEnabled(false);
     573        simple_preview_button.setEnabled(true);
    541574        int status = event.getStatus();
    542575        document.setSpecialCharacter(OptionsPane.SUCCESSFUL);
     
    545578        import_monitor.reset();
    546579        if(Gatherer.config.getMode() >= THRESHOLD) {
     580            control_pane.add(button_pane, BorderLayout.SOUTH);
    547581            card_layout.show(main_pane, CONTROL);
    548582        }
     
    556590        // The build may have failed, but a previous index may still be in place
    557591        preview_button.setEnabled(Gatherer.c_man.built());
     592
     593        simple_build_button.setEnabled(true);
     594        simple_cancel_button.setEnabled(false);
     595        simple_preview_button.setEnabled(Gatherer.c_man.built());
    558596        if(event.getStatus() == GShell.CANCELLED) {
    559597        document.setSpecialCharacter(OptionsPane.CANCELLED);
     
    564602        options_pane.resetFileEntry();
    565603        if(Gatherer.config.getMode() >= THRESHOLD) {
     604        control_pane.add(button_pane, BorderLayout.SOUTH);
    566605        card_layout.show(main_pane, CONTROL);
    567606        }
     
    618657        cancel_button.setEnabled(true);
    619658        preview_button.setEnabled(false);
     659
     660        simple_build_button.setEnabled(false);
     661        simple_cancel_button.setEnabled(true);
     662        simple_preview_button.setEnabled(false);
     663
    620664        document = options_pane.createNewLogDocument();
    621665        log_textarea.setDocument(document);
     
    624668        processing = true;
    625669        if(Gatherer.config.getMode() >= THRESHOLD) {
     670        progress_pane.add(button_pane, BorderLayout.SOUTH);
    626671        card_layout.show(main_pane, PROGRESS);
    627672        }
     
    652697        cancel_button.setEnabled(false);
    653698        preview_button.setEnabled(false);
     699
     700        simple_build_button.setEnabled(true);
     701        simple_cancel_button.setEnabled(false);
     702        simple_preview_button.setEnabled(false);
     703
    654704        processing = false;
    655705        document.setSpecialCharacter(OptionsPane.CANCELLED);
    656706        if(Gatherer.config.getMode() >= THRESHOLD) {
     707        control_pane.add(button_pane, BorderLayout.SOUTH);
    657708        card_layout.show(main_pane, CONTROL);
    658709        }
    659710        // Set the stop flag in all the process monitor.
     711        import_monitor.setStop(true);
     712        import_monitor.reset();
    660713        build_monitor.setStop(true);
    661714        build_monitor.reset();
    662         copy_monitor.setStop(true);
    663         import_monitor.setStop(true);
    664         import_monitor.reset();
    665715        // Set removeold automatically.
    666716        Gatherer.c_man.getCollection().build_options.setImportValue("removeold", true, null);
  • trunk/gli/src/org/greenstone/gatherer/shell/GBasicProgressMonitor.java

    r6388 r6533  
    8282    return this;
    8383    }
     84
     85    public JProgressBar getSharedProgress() {
     86    return null;
     87    }
     88
    8489    /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
    8590     * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
  • trunk/gli/src/org/greenstone/gatherer/shell/GBuildProgressMonitor.java

    r6388 r6533  
    121121    /** The progress bar this monitor updates. */
    122122    private JProgressBar progress_bar;
     123    /** A progress bar that is shared between this this listener and the Import monitor. */
     124    private JProgressBar shared_progress_bar;
    123125
    124126    /** Construct a new GBuildProgressMonitor. */
    125     public GBuildProgressMonitor() {
     127    public GBuildProgressMonitor(JProgressBar shared_progress_bar) {
     128    this.shared_progress_bar = shared_progress_bar;
    126129    progress_bar = new JProgressBar();
    127130    progress_bar.setMaximum(MAX);
    128131    progress_bar.setMinimum(MIN);
    129     progress_bar.setValue(MIN);
     132    progress_bar.setString(null);
     133    progress_bar.setStringPainted(true);
     134    setValue(MIN);
    130135    }
    131136
     
    137142    progress_bar.setMaximum(MAX);
    138143    progress_bar.setMinimum(MIN);
    139     progress_bar.setValue(MIN);
     144    progress_bar.setStringPainted(false);
     145    progress_bar.setString(null);
     146    setValue(MIN);
    140147    }
    141148
     
    155162    return progress_bar;
    156163    }
     164
     165    public JProgressBar getSharedProgress() {
     166    return shared_progress_bar;
     167    }
     168
    157169    /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
    158170     * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
    159171     */
    160     public boolean hasSignalledStop() {
     172    public synchronized boolean hasSignalledStop() {
    161173    return stop;
    162174    }
     
    193205            state = BUILD;
    194206            // Produce a lower detail message if required
    195             if(Gatherer.config.getMode() <= threshold) {
     207            if(Gatherer.config.getMode() <= threshold && !stop) {
    196208            queue.add(new GShellEvent(event.getSource(), 0, event.getType(), Dictionary.get("GShell.Build.BuildBegun1"), event.getStatus()));
    197209            }
     
    254266        else if(name.equals(BUILD_ELEMENT) && element.isClosed()) {
    255267            progress_bar.setIndeterminate(false);
    256             progress_bar.setValue(MAX);
     268            setValue(MAX);
    257269            state = BASE;
    258270            if(Gatherer.config.getMode() <= threshold) {
     
    279291            // One third complete
    280292            progress_bar.setIndeterminate(false);
    281             progress_bar.setValue((int)(((double)current_stages + 0.3d) * MAX) / expected_stages);
     293            setValue((int)(((double)current_stages + 0.3d) * MAX) / expected_stages);
    282294            }
    283295            else if(value.equals(COMPRESSINGTEXT_VALUE)) {
    284296            // Two thirds complete
    285297            progress_bar.setIndeterminate(false);
    286             progress_bar.setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages);
     298                setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages);
    287299            }
    288300            else {
     
    302314            current_stages++;
    303315            progress_bar.setIndeterminate(false);
    304             progress_bar.setValue((current_stages * MAX) / expected_stages);
     316            setValue((current_stages * MAX) / expected_stages);
    305317            state = BUILD;
    306318        }
     
    323335            // One fifth complete
    324336            progress_bar.setIndeterminate(false);
    325             progress_bar.setValue((int)(((double)current_stages + 0.2d) * MAX) / expected_stages);
     337            setValue((int)(((double)current_stages + 0.2d) * MAX) / expected_stages);
    326338            }
    327339            else if(value.equals(CREATETHEWEIGHTS_VALUE)) {
    328340            // Two fifths complete
    329341            progress_bar.setIndeterminate(false);
    330             progress_bar.setValue((int)(((double)current_stages + 0.4d) * MAX) / expected_stages);
     342            setValue((int)(((double)current_stages + 0.4d) * MAX) / expected_stages);
    331343            }
    332344            else if(value.equals(CREATESTEMMEDDIC_VALUE)) {
    333345            // Three fifths complete
    334346            progress_bar.setIndeterminate(false);
    335             progress_bar.setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages);
     347            setValue((int)(((double)current_stages + 0.6d) * MAX) / expected_stages);
    336348            }
    337349            else if(value.equals(CREATINGSTEMINDX_VALUE)) {
    338350            // Four fifths complete
    339351            progress_bar.setIndeterminate(false);
    340             progress_bar.setValue((int)(((double)current_stages + 0.8d) * MAX) / expected_stages);
     352            setValue((int)(((double)current_stages + 0.8d) * MAX) / expected_stages);
    341353            }
    342354            else {
     
    359371            current_stages++;
    360372            progress_bar.setIndeterminate(false);
    361             progress_bar.setValue((current_stages * MAX) / expected_stages);
     373            setValue((current_stages * MAX) / expected_stages);
    362374            state = BUILD;
    363375        }
     
    379391            // One sixth complete
    380392            progress_bar.setIndeterminate(false);
    381             progress_bar.setValue((int)(((double)current_stages + 0.16d) * MAX) / expected_stages);
     393            setValue((int)(((double)current_stages + 0.16d) * MAX) / expected_stages);
    382394            }
    383395            else if(value.equals(SORTANDRENUMBER_VALUE)) {
    384396            // Two sixths complete
    385397            progress_bar.setIndeterminate(false);
    386             progress_bar.setValue((int)(((double)current_stages + 0.33d) * MAX) / expected_stages);
     398                setValue((int)(((double)current_stages + 0.33d) * MAX) / expected_stages);
    387399            }
    388400            else if(value.equals(PHRASEDATABASES_VALUE)) {
    389401            // Three sixths complete
    390402            progress_bar.setIndeterminate(false);
    391             progress_bar.setValue((int)(((double)current_stages + 0.5d) * MAX) / expected_stages);
     403                setValue((int)(((double)current_stages + 0.5d) * MAX) / expected_stages);
    392404            }
    393405            else if(value.equals(WORDLEVELINDEXES_VALUE)) {
    394406            // Four sixths complete
    395407            progress_bar.setIndeterminate(false);
    396             progress_bar.setValue((int)(((double)current_stages + 0.66d) * MAX) / expected_stages);
     408            setValue((int)(((double)current_stages + 0.66d) * MAX) / expected_stages);
    397409            }
    398410            else if(value.equals(DOCINFODATABASES_VALUE)) {
    399411            // Five sixths complete
    400412            progress_bar.setIndeterminate(false);
    401             progress_bar.setValue((int)(((double)current_stages + 0.83d) * MAX) / expected_stages);
     413            setValue((int)(((double)current_stages + 0.83d) * MAX) / expected_stages);
    402414            }
    403415            else {
     
    412424            current_stages++;
    413425            progress_bar.setIndeterminate(false);
    414             progress_bar.setValue((current_stages * MAX) / expected_stages);
     426            setValue((current_stages * MAX) / expected_stages);
    415427            state = BUILD;
    416428        }
     
    429441            current_stages++;
    430442            progress_bar.setIndeterminate(false);
    431             progress_bar.setValue((current_stages * MAX) / expected_stages);
     443            setValue((current_stages * MAX) / expected_stages);
    432444            state = BUILD;
    433445        }
     
    455467    expected_stages = 0;
    456468    progress_bar.setIndeterminate(false);
    457     progress_bar.setString(StaticStrings.SPACE_CHARACTER);
    458     progress_bar.setValue(MIN);
     469    progress_bar.setString(null);
     470    setValue(MIN);
    459471    state = BASE;
    460     stop = false;
    461472    progress_bar.updateUI();
    462473    }
    463474
    464475    public void saving() {
     476    }
     477
     478    public void setSharedProgressBar(JProgressBar shared_progress_bar) {
     479    this.shared_progress_bar = shared_progress_bar;
    465480    }
    466481
     
    468483     * @param state The desired state of the stop flag as a <strong>boolean</strong>.
    469484     */
    470     public void setStop(boolean state) {
    471     stop = state;
     485    public synchronized void setStop(boolean state) {
     486    this.stop = state;
    472487    progress_bar.setIndeterminate(false);
    473488    }
     
    476491     */
    477492    public void start() {
    478     progress_bar.setValue(MIN);
     493    stop = false;
     494    setValue(MIN);
    479495    expected_stages = 3; // Always compress text, create info database and auxiliary creation
    480496    // Retrieve cdm.
     
    507523    public void stop() {
    508524    progress_bar.setIndeterminate(false);
    509     progress_bar.setValue(MAX);
     525    setValue(MAX);
     526    }
     527
     528    private void setValue(int value) {
     529    progress_bar.setValue(value);
     530    // Incrementing the shared progress bar is a little more problematic as we may very well be trying to set it to MIN but instead set it to halfway if we're not careful.
     531    if(value > MIN) {
     532        shared_progress_bar.setValue(MAX + value);
     533    }
    510534    }
    511535}
  • trunk/gli/src/org/greenstone/gatherer/shell/GImportProgressMonitor.java

    r6388 r6533  
    7272    /** The progress bar this monitor updates. */
    7373    private JProgressBar progress_bar;
     74
     75    /** The progress bar that is shared with build monitor. */
     76    private JProgressBar shared_progress_bar;
     77
    7478    /** */
    7579    static final private String BLOCKED_ATTRIBUTE = "blocked";
     
    102106    progress_bar.setMaximum(CALCULATION + PROCESSED + EXTRACTED);
    103107    progress_bar.setMinimum(MIN);
    104     progress_bar.setString(StaticStrings.SPACE_CHARACTER);
     108    progress_bar.setString(null);
    105109    progress_bar.setStringPainted(true);
     110    next_progress_value = CALCULATION;
     111    shared_progress_bar = new JProgressBar();
     112    shared_progress_bar.setIndeterminate(false);
     113    shared_progress_bar.setMaximum((CALCULATION + PROCESSED + EXTRACTED) * 2);
     114    shared_progress_bar.setMinimum(MIN);
     115    shared_progress_bar.setString(null); // Default string
     116    shared_progress_bar.setStringPainted(true);
    106117    setValue(MIN);
    107     next_progress_value = CALCULATION;
    108118    }
    109119
     
    143153    }
    144154
     155    public JProgressBar getSharedProgress() {
     156    return shared_progress_bar;
     157    }
     158
    145159    /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
    146160     * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
    147161     */
    148     public boolean hasSignalledStop() {
     162    public synchronized boolean hasSignalledStop() {
    149163    return stop;
    150164    }
     
    168182    line = line.substring(line.indexOf(StaticStrings.GREATER_THAN_CHARACTER) + 1);
    169183    line = line.trim();
     184    ///ystem.err.println("Process: " + line);
    170185    if(line.startsWith(StaticStrings.LESS_THAN_CHARACTER) && line.endsWith(StaticStrings.GREATER_THAN_CHARACTER)) {
    171186        // No original event is passed on, even in the lower modes
     
    174189        GShellElement element = new GShellElement(line);
    175190        String name = element.getElementName();
     191        ///ystem.err.println("Gatherer tag: " + name);
    176192        // We may be reading a file. Remember we have to offset process as we recieve this message 'before' a document is processed. Hence the use of 'next_progress_value'
    177193        if(name.equals(IMPORT_ELEMENT)) {
     194        ///ystem.err.println("#Import");
    178195        // We're into parsing output, so we don't need the 'calculating file size' etc string.
    179196        if(showing_string) {
    180             progress_bar.setString("");
     197            progress_bar.setString(null);
    181198            showing_string = false;
    182199        }
     
    186203        }
    187204        else if(name.equals(FILE_ELEMENT)) {
     205        ///ystem.err.println("#File");
    188206        file_count++;
    189207        // Set the next progress
     
    197215        // Or we're being told what plugin is actually processing the file
    198216        else if(name.equals(FILEPROCESSING_ELEMENT)) {
     217        ///ystem.err.println("#FileProcessing");
    199218        // If we are at lower mode settings fire a new 'dumbed down' event
    200219        if(Gatherer.config.getMode() <= threshold) {
     
    243262            num_docs = 0;
    244263            }
     264
    245265            processed_str = null;
    246266            // The number of documents blocked
     
    278298            queue.add(new GShellEvent(event.getSource(), 0, event.getType(), Dictionary.get("GShell.Import.ImportComplete3"), event.getStatus()));
    279299        }
     300        else {
     301            // Try to set num docs
     302            String processed_str = element.getAttribute(PROCESSED_ATTRIBUTE);
     303            try {
     304            num_docs = Integer.parseInt(processed_str);
     305            }
     306            catch(Exception exception) {
     307            num_docs = 0;
     308            }
     309        }
    280310        }
    281311        else {
     
    291321    public void reset() {
    292322    setValue(MIN);
    293     progress_bar.setString(StaticStrings.SPACE_CHARACTER);
     323    progress_bar.setString(null);
    294324    progress_bar.updateUI();
    295325    }
     
    303333     * @param state The desired state of the stop flag as a <strong>boolean</strong>.
    304334     */
    305     public void setStop(boolean state) {
    306     stop = state;
     335    public synchronized void setStop(boolean state) {
     336    this.stop = state;
    307337    }
    308338
     
    310340     */
    311341    public void start() {
     342    stop = false;
    312343    setValue(MIN);
    313344    progress_bar.setString(Dictionary.get("FileActions.Calculating_Size"));
     
    329360    private void setValue(int value) {
    330361    progress_bar.setValue(value);
     362    shared_progress_bar.setValue(value);
    331363    if(value != 0 && value < previous_value) {
    332364        Gatherer.println("Progress is decreasing! " + previous_value + " -> " + value);
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r6388 r6533  
    4242import javax.swing.event.*;
    4343import javax.swing.tree.*;
     44import org.greenstone.gatherer.Configuration;
    4445import org.greenstone.gatherer.Dictionary;
    4546import org.greenstone.gatherer.Gatherer;
     
    228229        }
    229230        }
    230        
    231         // Of course, just because the process is finished doesn't mean the incoming streams are empty. Unfortunately I've got no chance of preserving order, so I'll process the error stream first, then the out stream
    232         while(eisr.ready()) {
    233         int c = eisr.read();
    234         ///atherer.println("eisr: '" + (char) c + "'");
    235         if(c == '\n' || c == '\r') {
    236             if(eline_buffer.length() > 0) {
    237             String eline = eline_buffer.toString();
    238             ///atherer.println("* " + eline + " *");
    239             fireMessage(type, typeAsString(type) + "> " + eline, status, bos);
    240             eline = null;
    241             eline_buffer = new StringBuffer();
    242             }
    243         }
    244         else {
    245             eline_buffer.append((char)c);
    246         }
    247         }
    248         while(stdisr.ready()) {
    249         int c = stdisr.read();
    250         ///atherer.println("eisr: '" + (char) c + "'");
    251         if(c == '\n' || c == '\r') {
    252             if(stdline_buffer.length() > 0) {
    253             String stdline = stdline_buffer.toString();
    254             ///atherer.println("+ " + stdline + " +");
    255             fireMessage(type, typeAsString(type) + "> " + stdline, status, null);
    256             stdline = null;
    257             stdline_buffer = new StringBuffer();
    258             }
    259         }
    260         else {
    261             stdline_buffer.append((char)c);
    262         }
    263         }
    264        
    265         // Ensure that any messages still remaining in the string buffers are fired off.
    266         if(eline_buffer.length() > 0) {
    267         String eline = eline_buffer.toString();
    268         ///atherer.println("Last bit of eline: " + eline);
    269         fireMessage(type, typeAsString(type) + "> " + eline, status, bos);
    270         eline = null;
    271         }
    272        
    273         if(stdline_buffer.length() > 0) {
    274         String stdline = stdline_buffer.toString();
    275         ///atherer.println("Last bit of stdline: " + stdline);
    276         fireMessage(type, typeAsString(type) + "> " + stdline, status, null);
    277         stdline = null;
     231        if(!hasSignalledStop()) {
     232        // Of course, just because the process is finished doesn't mean the incoming streams are empty. Unfortunately I've got no chance of preserving order, so I'll process the error stream first, then the out stream
     233        while(eisr.ready()) {
     234            int c = eisr.read();
     235            ///atherer.println("eisr: '" + (char) c + "'");
     236            if(c == '\n' || c == '\r') {
     237            if(eline_buffer.length() > 0) {
     238                String eline = eline_buffer.toString();
     239                ///atherer.println("* " + eline + " *");
     240                fireMessage(type, typeAsString(type) + "> " + eline, status, bos);
     241                eline = null;
     242                eline_buffer = new StringBuffer();
     243            }
     244            }
     245            else {
     246            eline_buffer.append((char)c);
     247            }
     248        }
     249        while(stdisr.ready()) {
     250            int c = stdisr.read();
     251            ///atherer.println("eisr: '" + (char) c + "'");
     252            if(c == '\n' || c == '\r') {
     253            if(stdline_buffer.length() > 0) {
     254                String stdline = stdline_buffer.toString();
     255                ///atherer.println("+ " + stdline + " +");
     256                fireMessage(type, typeAsString(type) + "> " + stdline, status, null);
     257                stdline = null;
     258                stdline_buffer = new StringBuffer();
     259            }
     260            }
     261            else {
     262            stdline_buffer.append((char)c);
     263            }
     264        }
     265       
     266        // Ensure that any messages still remaining in the string buffers are fired off.
     267        if(eline_buffer.length() > 0) {
     268            String eline = eline_buffer.toString();
     269            ///atherer.println("Last bit of eline: " + eline);
     270            fireMessage(type, typeAsString(type) + "> " + eline, status, bos);
     271            eline = null;
     272        }
     273       
     274        if(stdline_buffer.length() > 0) {
     275            String stdline = stdline_buffer.toString();
     276            ///atherer.println("Last bit of stdline: " + stdline);
     277            fireMessage(type, typeAsString(type) + "> " + stdline, status, null);
     278            stdline = null;
     279        }
     280        }
     281        else {
     282        System.err.println("We've been asked to stop.");
    278283        }
    279284       
     
    312317        fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Parsing_Metadata_Complete"), status, null);
    313318    }
     319    if(hasSignalledStop()) {
     320        status = CANCELLED;
     321    }
    314322    // We're done.
    315323    fireProcessComplete(type, status);
     
    388396     */
    389397    protected void fireProcessComplete(int type, int status) {
    390     // Tidy up by stopping the progress bar.
    391     if(progress != null) {
     398    // Tidy up by stopping the progress bar. If it was cancelled then the cancel command has arrived via the progress bars and they don't need to be told again (it actually causes problems).
     399    if(progress != null && status != CANCELLED) {
    392400        progress.stop();
     401    }
     402   
     403    // If we were cancelled, and we are lower details modes, fire off one last message.
     404    if(status == CANCELLED && Gatherer.config.getMode() <= Configuration.SYSTEMS_MODE) {
     405        GShellEvent current_event = new GShellEvent(this, 0, type, Dictionary.get("GShell.Build.BuildCancelled"), status);
     406        Object[] concerned = listeners.getListenerList();
     407        for(int i = 0; i < concerned.length ; i++) {
     408        if(concerned[i] == GShellListener.class) {
     409            ((GShellListener)concerned[i+1]).message(current_event);
     410        }
     411        }
     412        concerned = null;
    393413    }
    394414    // And firing off an event
     
    408428    boolean has_signalled_stop = false;
    409429    if(progress != null) {
    410         return progress.hasSignalledStop();
     430        has_signalled_stop = progress.hasSignalledStop();
    411431    }
    412432    return has_signalled_stop;
  • trunk/gli/src/org/greenstone/gatherer/shell/GShellProgressMonitor.java

    r6388 r6533  
    6666    public int exitValue();
    6767
     68    public JProgressBar getSharedProgress();
     69
    6870    /** Method to retrieve whatever control is being used as the progress indicator. Usually a <strong>JProgressBar</strong> but there may be others implemented later.
    6971     * @return A <strong>Component</strong> on which the progress of the process is being displayed.
Note: See TracChangeset for help on using the changeset viewer.