Changeset 34286

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

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.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r34247 r34286  
    129129     * this will be the local bin/script folder. */ 
    130130    static private String scriptPath = ""; 
    131    
     131 
     132    private Boolean canPreview = null; 
     133     
    132134    /** Constructor. */ 
    133135    public CollectionManager() { 
     
    394396    } 
    395397 
     398    /** Calling c_man.built() is expensive in isGsdlRemote case. If you don't need built status recalculated 
     399     * call this method to get the last built() result, 
     400     * as the private canPreview variable stores the recalculated result after each call to built(). 
     401     * For example, this method should especially be used by the FormatPane for determining if the Preview 
     402     * button should be available as queried after every character has been input. The Preview Button should 
     403     * be available in such cases if the collection's last-known status indicated that an index folder from 
     404     * the most recent or prior build process was available. 
     405     * @return A boolean indicating the last known built status of the collection. 
     406     */ 
     407    public boolean previewAvailable() { 
     408    if(canPreview == null) { 
     409        built(); // this will set the variable canPreview, if not already set by CreatePane's calls to built() 
     410    } 
     411    return this.canPreview.booleanValue(); 
     412    } 
     413     
    396414    /** Used to determine whether the currently active collection has been built. 
    397415     * @return A boolean indicating the built status of the collection. 
    398416     */ 
    399417    public boolean built() { 
     418    boolean been_built = false; 
     419     
    400420    if(collection != null) { 
    401421        // Determine if the collection has been built by looking for the build.cfg (gs2)  
     
    420440 
    421441        if(Gatherer.isGsdlRemote) { 
    422         return Gatherer.remoteGreenstoneServer.exists(collection.getGroupQualifiedName(false), test_file); 
     442        been_built = Gatherer.remoteGreenstoneServer.exists(collection.getGroupQualifiedName(false), test_file); 
    423443        } else { 
    424         return test_file.exists(); 
    425         } 
    426     } 
    427     return false; 
     444        been_built = test_file.exists(); 
     445        } 
     446    } 
     447 
     448    // store recalculated result 
     449    this.canPreview = been_built ? Boolean.FALSE : Boolean.TRUE; 
     450 
     451    return been_built; //or: this.canPreview.booleanValue(); 
    428452    } 
    429453 
  • main/trunk/gli/src/org/greenstone/gatherer/gui/FormatPane.java

    r24424 r34286  
    123123    // unbuilt (as could happen when someone clicks on a format statement before  
    124124    // building the collection), then shouldn't enable previewing. 
    125     if(ready_to_preview && !Gatherer.c_man.built()) { 
     125    if(ready_to_preview && Gatherer.c_man.previewAvailable()) { 
    126126        ready_to_preview = false; 
    127127    }