Changeset 34287

Show
Ignore:
Timestamp:
23.07.2020 21:08:07 (12 days ago)
Author:
ak19
Message:

Belongs with previous commit, had left out one more file that needed committing. Client-GLI was noticeably slow compared to GLI when swapping between format statements or when typing anything into a format statement. The cause was my own mistake from 9 years ago (commit revision 24424) when I didn't know that the CollectionManager?.built() operation was an expensive remote call in the case of IsGsdlRemote?. This function was being called to determine if the previewbutton should really be available (enabled or disabled) so that the user could not accidentally attempt to preview an unbuilt collection. However, I must not have realised back then that the previewbutton was being set this way at every character added into the Format statements editor, as well as when swapping between one format statement and another. As a result, all of such user action was being severely delayed when isGsdlRemote was true. Fixed this now by adding a function CollectionManager?.previewAvailable() that returns the last known result of the built() call. Client-GLI's format pane is now thankfully so much faster, rather than a pain to use.

Files:
1 modified

Legend:

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

    r31638 r34287  
    267267    preview_button = new PreviewButton(Dictionary.get("CreatePane.Preview_Collection"), Dictionary.get("CreatePane.Preview_Collection_Tooltip")); 
    268268    //preview_button.addActionListener(pbl); 
     269 
     270    // c_man.built() is an expensive operation for isGsdlRemote case, 
     271    // so calculate this once to set both preview and simple_preview buttons in one go 
     272    boolean been_built = Gatherer.c_man.built(); 
     273     
    269274    if(Gatherer.c_man != null) { 
    270         preview_button.setEnabled(Gatherer.c_man.built()); 
     275        preview_button.setEnabled(been_built); 
    271276    } 
    272277    else { 
     
    285290    //simple_preview_button.addActionListener(pbl); 
    286291    if(Gatherer.c_man != null) { 
    287         simple_preview_button.setEnabled(Gatherer.c_man.built()); 
     292        simple_preview_button.setEnabled(been_built); 
    288293    } 
    289294    else { 
     
    550555    public synchronized void processComplete(GShellEvent event) { 
    551556    DebugStream.println("In CreatePane::processComplete(" + event.getType() + ")..."); 
     557     
     558    // c_man.built() is an expensive operation in isGsdlRemote case, 
     559    // so calculate this once now to set both preview and simple_preview buttons in one go 
     560    boolean been_built = Gatherer.c_man.built(); 
     561     
    552562    if(event.getStatus() == GShell.OK) { 
    553563        if(event.getType() == GShell.SCHEDULE) { 
     
    558568        //preview_button.setEnabled(true); 
    559569        //only enable preview if the collection has been built.  
    560         preview_button.setEnabled(Gatherer.c_man.built()); 
     570        preview_button.setEnabled(been_built); 
    561571        simple_build_button.setEnabled(true); 
    562572        simple_cancel_button.setEnabled(false); 
    563         simple_preview_button.setEnabled(Gatherer.c_man.built());  
     573        simple_preview_button.setEnabled(been_built);  
    564574        int status = event.getStatus(); 
    565575        document.setSpecialCharacter(OptionsPane.SCHEDULED);  
     
    576586        build_button.setEnabled(true); 
    577587        cancel_button.setEnabled(false); 
    578         preview_button.setEnabled(Gatherer.c_man.built()); 
     588        preview_button.setEnabled(been_built); 
    579589        simple_build_button.setEnabled(true); 
    580590        simple_cancel_button.setEnabled(false); 
    581         simple_preview_button.setEnabled(Gatherer.c_man.built()); 
     591        simple_preview_button.setEnabled(been_built); 
    582592        int status = event.getStatus(); 
    583593        document.setSpecialCharacter(OptionsPane.SUCCESSFUL); 
     
    597607        build_button.setEnabled(true); 
    598608        // The build may have failed, but a previous index may still be in place 
    599         preview_button.setEnabled(Gatherer.c_man.built()); 
     609        // In which case, previewing should still be available       
     610        preview_button.setEnabled(been_built); 
    600611 
    601612        simple_build_button.setEnabled(true); 
    602613        simple_cancel_button.setEnabled(false); 
    603         simple_preview_button.setEnabled(Gatherer.c_man.built()); 
     614        simple_preview_button.setEnabled(been_built); 
    604615        if(event.getStatus() == GShell.CANCELLED) { 
    605616        document.setSpecialCharacter(OptionsPane.CANCELLED); 
     
    658669 
    659670    // Validate the preview button 
    660     if (Gatherer.c_man.built() && Configuration.library_url != null) { 
     671    // Calling the expensive built() operation here is justified probably, 
     672    // as long as refresh() is not called frivolously 
     673    boolean been_built = Gatherer.c_man.built(); 
     674    if (been_built && Configuration.library_url != null) { 
    661675        preview_button.setEnabled(true); 
    662676        simple_preview_button.setEnabled(true);