Changeset 6622


Ignore:
Timestamp:
2004-01-27T16:35:34+13:00 (20 years ago)
Author:
jmt12
Message:

More modifications to mirroring including testing for a valid version of Wget (and complaining if its missing or it is old) and rearranging buttons on the GProgressBar

Location:
trunk/gli
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/classes/xml/config.xml

    r6534 r6622  
    116116    <Argument name="warning.MissingMDS">true</Argument>
    117117    <Argument name="warning.NoMetadataSetsSelected">true</Argument>
     118    <Argument name="warning.OldWGet">true</Argument>
    118119    <Argument name="warning.TitleClashes">true</Argument>
    119120    <!-- Workflow -->
  • trunk/gli/gli.sh

    r6467 r6622  
    1919
    2020##  ---- Determine GSDLHOME ----
    21 gsdlpath=
     21gsdlpath=/research/jmt12/gsdl
    2222
    2323# Some users may set the above line manually
     
    119119fi
    120120
     121## ---- Check WGet exists ----
     122wgetpath=/home/jmt12/local/bin/wget
     123
     124wok="NoWGet"
     125# Some users may set the above line manually
     126if [ "$wgetpath" == "" ]; then
     127    # Check if WGet is on the search path
     128    wgetpath=`which wget 2> /dev/null`
     129fi
     130
     131# Check that a WGet executable has been found
     132echo "Checking WGet: $wgetpath"
     133if [ ! -x "$wgetpath" ]; then
     134    echo
     135    echo "Failed to locate an appropriate version of WGet. Web mirroring will"
     136    echo "be disabled. Greenstone Librarian Interface requires WGet installed"
     137    echo "in order to fully access this feature."
     138else
     139    ## -- Check the version of WGet is new enough (1.9 or higher) to run properly --
     140    wgetversion=`$wgetpath --version 2>&1 | sed -n 's/^GNU Wget \(.*\)/\1/p'`   
     141    wvmajor=`echo $wgetversion | sed -n 's/^\([0-9]*\).*$/\1/p'`
     142    wvminor=`echo $wgetversion | sed -n 's/^[0-9]*\.\(.*\)$/\1/p'`
     143
     144    wok="WGet1.9"
     145    if [ $wvmajor -lt 1 ] ; then
     146    wok="<WGet1.9"
     147    fi
     148    if [ $wvmajor -eq 1 ] && [ $wvminor -lt 9 ] ; then
     149    wok="<WGet1.9"
     150    fi
     151    if [ $wok == "<WGet1.9" ] ; then
     152    echo
     153    echo "The version of the WGet you have installed has a known bug when"
     154    echo "mirroring files which contain encoded characters such as space and"
     155    echo "tilde in their URL. While this shouldn't be a problem, we recommend"
     156        echo "installing WGet 1.9 or higher."
     157    fi
     158fi
    121159
    122160## ---- Check that the GLI has been compiled ----
     
    147185# -Xloggc:<file>   Write garbage collection log
    148186
    149 java -classpath classes/:GLI.jar:lib/apache.jar:lib/calpa.jar:lib/jp.jar:lib/polloxml.jar:lib/qfslib.jar:lib/skinlf.jar org.greenstone.gatherer.Gatherer -gsdl $GSDLHOME $*
     187java -classpath classes/:GLI.jar:lib/apache.jar:lib/calpa.jar:lib/jp.jar:lib/polloxml.jar:lib/qfslib.jar:lib/skinlf.jar org.greenstone.gatherer.Gatherer -gsdl $GSDLHOME -wget $wok$wgetpath $*
    150188
    151189echo "Done!"
  • trunk/gli/src/org/greenstone/gatherer/Configuration.java

    r6593 r6622  
    102102    /** The screen size of the desktop the Gatherer will be displayed on. */
    103103    public Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
     104
     105    /** If true, overrides the mirroring enabled setting in the config.xml file. */
     106    private boolean mirroring_enabled = false;
    104107    /** Collection level configuration (which in some cases overrides general configuration. */
    105108    private Document collection_config;
     
    112115    private int cache_hit = 0;
    113116    private int cache_miss = 0;
     117
     118    private String wget_path = null;
     119    private String wget_version_str = StaticStrings.NO_WGET_STR;
     120
    114121    public URL exec_address = null;
    115122
     
    119126     * @param perl_path The path to the PERL executable, as a <strong>String</strong>.
    120127     */
    121     public Configuration(String gsdl_path, String exec_path, String perl_path) {
     128    public Configuration(String gsdl_path, String exec_path, String perl_path, boolean mirroring_enabled, String wget_version_str, String wget_path) {
    122129    super();
    123130    this.gsdl_path = gsdl_path;
    124131    this.exec_path = exec_path;
     132    this.mirroring_enabled = mirroring_enabled;
     133    this.wget_version_str = wget_version_str;
     134    this.wget_path = wget_path;
     135
    125136    // The exec_path may contain an url address, in which case we blindly use that and leave it up to the user to worry about settings and resetting.
    126137    Gatherer.println("EXEC_PATH = " + exec_path);
     
    256267    /** The default get action retrieves the named property from the desired configuration, and returns a true or false. */
    257268    public boolean get(String property, boolean general) {
     269    if(general && mirroring_enabled && property.equals(StaticStrings.WORKFLOW_MIRROR)) {
     270        return mirroring_enabled;
     271    }
    258272    String raw = getString(property, general);
    259273    return (raw != null && raw.equalsIgnoreCase("true"));
     
    574588
    575589    public String getWGetPath() {
    576     return "/usr/bin/wget";
     590    return wget_path;
     591    }
     592
     593    public String getWGetVersion() {
     594    return wget_version_str;
    577595    }
    578596
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r6549 r6622  
    165165    }
    166166
    167     public void run(Dimension size, String gsdl_path, String exec_path, boolean debug_enabled, String perl_path, boolean no_load, Splash splash, String open_collection) {
     167    public void run(Dimension size, String gsdl_path, String exec_path, boolean debug_enabled, String perl_path, boolean no_load, Splash splash, String open_collection, boolean mirroring_enabled, String wget_version_str, String wget_path) {
    168168
    169169    // This will hopefully catch ctrl-c and terminate, and exit gracefully. However it is platform specific, and may not be supported by some JVMs.
     
    199199    try {
    200200        // Load Config
    201         loadConfig(gsdl_path, exec_path, perl_path);
     201        loadConfig(gsdl_path, exec_path, perl_path, mirroring_enabled, wget_version_str, wget_path);
    202202
    203203        // MDSTesting
     
    499499
    500500    boolean debug = false;
     501    boolean mirroring_enabled = false;
    501502    boolean no_load = false;
    502503    Dictionary dictionary = new Dictionary(null, null); // Default dictionary. Only used for starting error messages.
     
    507508    String gsdl_path = null;
    508509    String perl_path = null;
     510    String wget_path = null;
     511    String wget_version_str = StaticStrings.NO_WGET_STR;
    509512    // Parse arguments
    510513    int argument_index = 0;
    511514    String next_token = null;
    512515    while(argument_index < args.length || next_token != null) {
    513         // 1. We start by attempting to parse an argument name. An argument must start with a '-', and should not contain spaces. If anything else is encountered it is ignored.
    514         String argument_name = null;
    515         if(next_token == null) {
    516             next_token = args[argument_index];
    517             argument_index++;
    518         }
    519         if(next_token.startsWith(StaticStrings.MINUS_CHARACTER)) {
    520             // Trim second '-' just to be kind to Unixy-type people
    521             if(next_token.startsWith(StaticStrings.MINUS_CHARACTER + StaticStrings.MINUS_CHARACTER)) {
    522                 argument_name = next_token.substring(1);
     516        // 1. We start by attempting to parse an argument name. An argument must start with a '-', and should not contain spaces. If anything else is encountered it is ignored.
     517        String argument_name = null;
     518        if(next_token == null) {
     519        next_token = args[argument_index];
     520        argument_index++;
     521        }
     522        if(next_token.startsWith(StaticStrings.MINUS_CHARACTER)) {
     523        // Trim second '-' just to be kind to Unixy-type people
     524        if(next_token.startsWith(StaticStrings.MINUS_CHARACTER + StaticStrings.MINUS_CHARACTER)) {
     525            argument_name = next_token.substring(1);
     526        }
     527        else {
     528            argument_name = next_token;
     529        }
     530        }
     531        next_token = null;
     532        // 2. If we now have an argument name we continue by attempting to parse a value. A value is taken to be the sequence of space seperated Strings between the last argument name and up to but not including the next argument name. Of course an argument needn't have any value (ie -debug, -help), in which case value will be null.
     533        if(argument_name != null) {
     534        String argument_value = null;
     535        StringBuffer argument_value_buffer = new StringBuffer("");
     536        while(argument_index < args.length && next_token == null) {
     537            next_token = args[argument_index];
     538            argument_index++;
     539            // If we just parsed an arbitary String then append it to value, followed by a single space
     540            if(!next_token.startsWith(StaticStrings.MINUS_CHARACTER)) {
     541            argument_value_buffer.append(next_token);
     542            argument_value_buffer.append(StaticStrings.SPACE_CHARACTER);
     543            next_token = null;
     544            }
     545            // If the argument token retrieved is an argument name, then leave it in next_token, which will cause the argument parsing process to move onto the next step.
     546        }
     547        // If a value now exists in argument buffer, retrieve it. Remove the last character as it will be an erroneous space.
     548        if(argument_value_buffer.length() > 0) {
     549            argument_value = argument_value_buffer.substring(0, argument_value_buffer.length() - 1);
     550        }
     551       
     552        // 3. We now have the argument name, and any associated value. We are ready to store the data in the appropriate variables.
     553        Gatherer.println("Parsed Argument: name=" + argument_name + (argument_value != null ? (", value=" + argument_value) : ", no value"));
     554        // 3a. First those arguments that have no associated value
     555        if(argument_value == null) {
     556            if(argument_name.equals(StaticStrings.HELP_ARGUMENT)) {
     557            printUsage(dictionary);
     558            System.exit(0);
     559            }
     560            // Run GLI in debug mode. Produces debug log plus extra messages.
     561            else if(argument_name.equals(StaticStrings.DEBUG_ARGUMENT)) {
     562            debug = true;
     563            }
     564            // Forces no loading on previous collection.
     565            else if(argument_name.equals(StaticStrings.NO_LOAD_ARGUMENT)) {
     566            no_load = true;
     567            filename = null;
     568            }
     569            // Run the GLI with mirroring enabled
     570            else if(argument_name.equals(StaticStrings.MIRROR_ARGUMENT)) {
     571            mirroring_enabled = true;
     572            }
     573            /* I've got a sneak suspicion Aqua look and feel is not free domain
     574               // Specify the use of Greenstone LAF.
     575               else if(argument_name.equals(StaticStrings.SKIN_ARGUMENT)) {
     576               // SkinLF
     577               try {
     578               SkinLookAndFeel.setSkin(SkinLookAndFeel.loadThemePackDefinition(SkinUtils.toURL(new File(SKIN_DEFINITION_FILE))));
     579               SkinLookAndFeel.enable();
     580               }
     581               catch (Exception error) {
     582               ///ystem.err.println("Error: " + error);
     583               error.printStackTrace();
     584               }
     585               }
     586            */
     587        }
     588        // 3b. Now for those that do
     589        else {
     590            // Parse the path to the GSDL. Required argument.
     591            if(argument_name.equals(StaticStrings.GSDL_ARGUMENT)) {
     592            if(argument_value.endsWith(File.separator)) {
     593                gsdl_path = argument_value;
    523594            }
    524595            else {
    525                 argument_name = next_token;
    526             }
    527         }
    528         next_token = null;
    529         // 2. If we now have an argument name we continue by attempting to parse a value. A value is taken to be the sequence of space seperated Strings between the last argument name and up to but not including the next argument name. Of course an argument needn't have any value (ie -debug, -help), in which case value will be null.
    530         if(argument_name != null) {
    531             String argument_value = null;
    532             StringBuffer argument_value_buffer = new StringBuffer("");
    533             while(argument_index < args.length && next_token == null) {
    534             next_token = args[argument_index];
    535             argument_index++;
    536                 // If we just parsed an arbitary String then append it to value, followed by a single space
    537             if(!next_token.startsWith(StaticStrings.MINUS_CHARACTER)) {
    538                 argument_value_buffer.append(next_token);
    539                 argument_value_buffer.append(StaticStrings.SPACE_CHARACTER);
    540                 next_token = null;
    541             }
    542                 // If the argument token retrieved is an argument name, then leave it in next_token, which will cause the argument parsing process to move onto the next step.
    543             }
    544             // If a value now exists in argument buffer, retrieve it. Remove the last character as it will be an erroneous space.
    545             if(argument_value_buffer.length() > 0) {
    546             argument_value = argument_value_buffer.substring(0, argument_value_buffer.length() - 1);
    547             }
    548            
    549             // 3. We now have the argument name, and any associated value. We are ready to store the data in the appropriate variables.
    550             Gatherer.println("Parsed Argument: name=" + argument_name + (argument_value != null ? (", value=" + argument_value) : ", no value"));
    551             // 3a. First those arguments that have no associated value
    552             if(argument_value == null) {
    553             if(argument_name.equals(StaticStrings.HELP_ARGUMENT)) {
    554                 printUsage(dictionary);
    555                 System.exit(0);
    556                 }
    557                 // Run GLI in debug mode. Produces debug log plus extra messages.
    558                 else if(argument_name.equals(StaticStrings.DEBUG_ARGUMENT)) {
    559                 debug = true;
    560                 }
    561             // Forces no loading on previous collection.
    562             else if(argument_name.equals(StaticStrings.NO_LOAD_ARGUMENT)) {
    563                 no_load = true;
    564                 filename = null;
    565             }
    566             /* I've got a sneak suspicion Aqua look and feel is not free domain
    567             // Specify the use of Greenstone LAF.
    568             else if(argument_name.equals(StaticStrings.SKIN_ARGUMENT)) {
    569                 // SkinLF
    570                 try {
    571                 SkinLookAndFeel.setSkin(SkinLookAndFeel.loadThemePackDefinition(SkinUtils.toURL(new File(SKIN_DEFINITION_FILE))));
    572                 SkinLookAndFeel.enable();
    573                 }
    574                 catch (Exception error) {
    575                 ///ystem.err.println("Error: " + error);
    576                 error.printStackTrace();
    577                 }
    578                 }
    579             */
    580             }
    581             // 3b. Now for those that do
    582             else {
    583             // Parse the path to the GSDL. Required argument.
    584                 if(argument_name.equals(StaticStrings.GSDL_ARGUMENT)) {
    585                 if(argument_value.endsWith(File.separator)) {
    586                 gsdl_path = argument_value;
     596                gsdl_path = argument_value + File.separator;
     597            }
     598            }
     599            // Specify a collection to load initially. Could be used for file associations.
     600            else if(argument_name.equals(StaticStrings.LOAD_ARGUMENT)) {
     601            filename = argument_value;
     602            no_load = false;
     603            }
     604            // Parse the url to a running web server, or a file path to the local library server.
     605            else if(argument_name.equals(StaticStrings.LIBRARY_ARGUMENT)) {
     606            exec_path = argument_value;
     607            // If there is no colon in first five characters of the exec_path (which would either be an existing protocol, or a windows file path to say a local library), we can append the protocol http://.
     608            if(argument_value.lastIndexOf(StaticStrings.COLON_CHARACTER, 5) == -1) {
     609                exec_path = StaticStrings.HTTP_PROTOCOL_STR + argument_value;
     610            }
     611            else {
     612                exec_path = argument_value;
     613            }
     614            // If the user has given us an address, but it ends with a '/' we assume we're using the greenstone library.cgi
     615            if(exec_path.startsWith(StaticStrings.HTTP_PROTOCOL_STR) && exec_path.endsWith(StaticStrings.URL_SEPARATOR_CHARACTER)) {
     616                exec_path = exec_path + StaticStrings.LIBRARY_STR;
     617            }
     618            }
     619            // Parse the path to PERL. If not provided its assumes perl should be availble on the PATH.
     620            else if(argument_name.equals(StaticStrings.PERL_ARGUMENT)) {
     621            perl_path = argument_value;
     622            // Test whether this points to the Perl bin directory or the Perl executable itself.
     623            File perl_file = new File(perl_path);
     624            if(perl_file.isDirectory()) {
     625                // If this is windows we create a child file perl.exe, otherwise we create perl
     626                if(Utility.isWindows()) {
     627                perl_file = new File(perl_file, Utility.PERL_EXECUTABLE_WINDOWS);
    587628                }
    588629                else {
    589                 gsdl_path = argument_value + File.separator;
     630                perl_file = new File(perl_file, Utility.PERL_EXECUTABLE_UNIX);
    590631                }
    591                 }
    592             // Specify a collection to load initially. Could be used for file associations.
    593                 else if(argument_name.equals(StaticStrings.LOAD_ARGUMENT)) {
    594                 filename = argument_value;
    595                 no_load = false;
    596                 }
    597             // Parse the url to a running web server, or a file path to the local library server.
    598                 else if(argument_name.equals(StaticStrings.LIBRARY_ARGUMENT)) {
    599                     exec_path = argument_value;
    600                     // If there is no colon in first five characters of the exec_path (which would either be an existing protocol, or a windows file path to say a local library), we can append the protocol http://.
    601                     if(argument_value.lastIndexOf(StaticStrings.COLON_CHARACTER, 5) == -1) {
    602                         exec_path = StaticStrings.HTTP_PROTOCOL_STR + argument_value;
    603                     }
    604                     else {
    605                         exec_path = argument_value;
    606                     }
    607                     // If the user has given us an address, but it ends with a '/' we assume we're using the greenstone library.cgi
    608                     if(exec_path.startsWith(StaticStrings.HTTP_PROTOCOL_STR) && exec_path.endsWith(StaticStrings.URL_SEPARATOR_CHARACTER)) {
    609                         exec_path = exec_path + StaticStrings.LIBRARY_STR;
    610                     }
    611                 }
    612                 // Parse the path to PERL. If not provided its assumes perl should be availble on the PATH.
    613                 else if(argument_name.equals(StaticStrings.PERL_ARGUMENT)) {
    614                     perl_path = argument_value;
    615                     // Test whether this points to the Perl bin directory or the Perl executable itself.
    616                     File perl_file = new File(perl_path);
    617                     if(perl_file.isDirectory()) {
    618                         // If this is windows we create a child file perl.exe, otherwise we create perl
    619                         if(Utility.isWindows()) {
    620                         perl_file = new File(perl_file, Utility.PERL_EXECUTABLE_WINDOWS);
    621                         }
    622                         else {
    623                         perl_file = new File(perl_file, Utility.PERL_EXECUTABLE_UNIX);
    624                         }
    625                         // And store this new path.
    626                         perl_path = perl_file.getAbsolutePath();
    627                         perl_file = null;
    628                     }
    629                     // Otherwise its fine as it is
    630                 }
    631             }
    632         }
    633         // Argument name was null, nothing to be done.
     632                // And store this new path.
     633                perl_path = perl_file.getAbsolutePath();
     634                perl_file = null;
     635            }
     636            // Otherwise its fine as it is
     637            }
     638            // Test for the presence of a WGet version. This is only useful if the user has enabled mirroring. Note that mirroring can be enabled by running the GLI with -mirror, editing the config.xml for GLI, or through a new option on the connections page of the preferences.
     639            else if(argument_name.equals(StaticStrings.WGET_ARGUMENT)) {
     640            if(argument_value.startsWith(StaticStrings.WGET_STR)) {
     641                wget_version_str = StaticStrings.WGET_STR;
     642                wget_path = argument_value.substring(StaticStrings.WGET_STR.length());
     643            }
     644            else if(argument_value.startsWith(StaticStrings.WGET_OLD_STR)) {
     645                wget_version_str = StaticStrings.WGET_OLD_STR;
     646                wget_path = argument_value.substring(StaticStrings.WGET_OLD_STR.length());
     647            }
     648            }
     649        }
     650        }
     651        // Argument name was null, nothing to be done.
    634652    }
    635653    next_token = null;
     
    639657    Splash splash = new Splash();
    640658    dictionary.destroy();
    641     gatherer.run(size, gsdl_path, exec_path, debug, perl_path, no_load, splash, filename);
     659    gatherer.run(size, gsdl_path, exec_path, debug, perl_path, no_load, splash, filename, mirroring_enabled, wget_version_str, wget_path);
    642660    }
    643661
     
    766784     * @see org.greenstone.gatherer.Configuration
    767785     */
    768     private void loadConfig(String gsdl_path, String exec_path, String perl_path) {
     786    private void loadConfig(String gsdl_path, String exec_path, String perl_path, boolean mirroring_enabled, String wget_version_str, String wget_path) {
    769787    try {
    770         config = new Configuration(gsdl_path, exec_path, perl_path);
     788        config = new Configuration(gsdl_path, exec_path, perl_path, mirroring_enabled, wget_version_str, wget_path);
    771789    }
    772790    catch (Exception error) {
     
    10291047            if (exitCode != 0) { // if Netscape or mozilla was not open
    10301048            Gatherer.println("couldn't do remote, trying original command");
    1031             printArray(commands);
     1049            if(debug != null) {
     1050                printArray(commands);
     1051            }
    10321052            process = rt.exec(commands); // try the original command
    10331053            }
     
    10601080    public void printArray(String [] array) {
    10611081        for(int i = 0; i < array.length; i++) {
     1082        debug.print(array[i]+" ");
    10621083        System.err.println(array[i]+" ");
    10631084        }
  • trunk/gli/src/org/greenstone/gatherer/WGet.java

    r6590 r6622  
    258258    Gatherer.println("About to create a new job");
    259259    // If it was decided not to download page requisites, then create the destination by basing it on the given destination, but appending the url host and paths. If page requisites is used then WGet will do this for us
    260     if(!page_requisites) {
    261         System.err.println("Initially destination: " + destination);
     260    if(!page_requisites && depth == 0) {
     261        Gatherer.println("Initially destination: " + destination);
    262262        String almost_the_entire_path = url.getPath();
    263263        int index = -1;
     
    265265        almost_the_entire_path = almost_the_entire_path.substring(0, index);
    266266        }
    267         destination = destination + url.getHost() + almost_the_entire_path + "/";
    268         System.err.println("Finale destination:    " + destination);
     267        destination = destination + url.getHost() + almost_the_entire_path;
     268        Gatherer.println("Final destination:    " + destination);
    269269    }
    270270    Job new_job = new Job(Gatherer.config.get("mirroring.debug", false), no_parents, other_hosts, page_requisites, Gatherer.config.get("mirroring.quiet", false), url, depth, destination, Gatherer.config.proxy_pass, Gatherer.config.proxy_user, this, simple);
     271    // Tell it to run as soon as possible
     272    new_job.setState(Job.RUNNING);
     273
    271274    // Add to job_queue job list.
    272275    job_queue.add(new_job);
  • trunk/gli/src/org/greenstone/gatherer/collection/Job.java

    r6590 r6622  
    221221        if(user_pass.indexOf("@") != -1) {
    222222        // Write the use proxy command
    223         command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=" + user_pass.substring(0, user_pass.indexOf("@")) + " --proxy-passwd=" + user_pass.substring(user_pass.indexOf("@") + 1) + " -Y on ";
     223        command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=\"" + user_pass.substring(0, user_pass.indexOf("@")) + "\" --proxy-passwd=*** -Y on ";
    224224
    225225        }
     
    235235    // or not. In which case we ensure links are rewritten.
    236236    else {
     237        command = command + "-k ";
    237238    }
    238239
     
    289290            String current_file_downloading = line.substring(line.indexOf("`") + 1, line.lastIndexOf("'"));
    290291            if(!ignore_for_robots) {
    291             System.err.println("Not ignore for robots");
     292            Gatherer.println("Not ignore for robots");
    292293            // Download complete
    293294            downloadComplete(current_file_downloading);
    294295            }
    295296            else {
    296             System.err.println("Ignore for robots");
     297            Gatherer.println("Ignore for robots");
    297298            ignore_for_robots = false;
    298299            }
     
    382383    // Parse arguments into array.
    383384    args.add(Utility.BASE_DIR + "wget");
    384     //args.add("-k");
    385385    args.add("-d");
    386386    args.add("-o");
     
    458458    public void downloadComplete(String current_file_downloading) {
    459459    progress.downloadComplete();
    460     ///ystem.err.println("Current File: " + current_file_downloading);
     460    Gatherer.println("Current File: " + current_file_downloading);
    461461    //WorkspaceTreeModel.refreshWebCacheMappings();
    462462    if(Gatherer.g_man.collection_pane.workspace_tree != null) {
     
    473473        // Add download cache name
    474474        /** @todo - add to dictionary */
    475         raw_path.add(0, "Mirror Cache");
     475        raw_path.add(0, "Mirroring.Mirror_Cache");
    476476        // And the root node
    477477        raw_path.add(0, tree_model.getRoot());
     
    481481        FileNode destination_node = (FileNode) tree_model.getNode(destination_path);
    482482        // destination_path = null;
    483         FileNode new_file_node = new FileNode(new_file);
    484         SynchronizedTreeModelTools.insertNodeInto(tree_model, destination_node, new_file_node);
    485         System.err.println("Ready to insert new FileNode.");
    486         System.err.println("Model:            " + tree_model);
    487         System.err.println("Destination path: " + destination_path);
    488         System.err.println("Destination node: " + destination_node);
    489         System.err.println("New node:         " + new_file_node);
    490 
    491         new_file_node = null;
     483        //FileNode new_file_node = new FileNode(new_file);
     484
     485        // It suddenly occurs to me that by retrieving the destination path, we are causing the potential destination node to map its children which includes the file which I am about to add. Hence I was ending up with two copies.
     486        ///atherer.println("Ready to insert new FileNode.");
     487        Gatherer.println("Model:            " + tree_model);
     488        Gatherer.println("Destination path: " + destination_path);
     489        destination_node.unmap();
     490        ///atherer.println("Destination node: " + destination_node);
     491        ///atherer.println("New node:         " + new_file_node);
     492        //SynchronizedTreeModelTools.insertNodeInto(tree_model, destination_node, new_file_node);
     493
     494        //new_file_node = null;
    492495        destination_node = null;
    493496        tree_model = null;
     
    554557    }
    555558
     559    public void setState(int state) {
     560    previous_state = this.state;
     561    this.state = state;
     562    }
     563
    556564    /** A convinence call.
    557565     * @return A String representing the url of the initial url (root node of the mirrored tree).
  • trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java

    r6539 r6622  
    105105
    106106    public String getBrowserCommand(String url) {
    107     System.err.println("Get browser command: " + url);
     107    Gatherer.println("Get browser command: " + url);
    108108    // First off we try to retrieve one from the configuration
    109109    String command = Gatherer.config.getPreviewCommand();
     
    111111    if(command != null && command.length() > 0) {
    112112        command = command.replaceAll("%1", url);
    113         System.err.println("Result = " + command);
     113        Gatherer.println("Result = " + command);
    114114        return command;
    115115    }
     
    164164    // if we haven't got a command by now, we'll never get one
    165165    if (command == null) {
    166         System.err.println("Result = " + command);
     166        Gatherer.println("Result = " + command);
    167167        return null;
    168168    }
    169169    // Replace %1 with the url in quotes
    170170    command = command.replaceAll(FILENAME_ARG, url);
    171     System.err.println("Result = " + command);
     171    Gatherer.println("Result = " + command);
    172172    return command;
    173173    }
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r6255 r6622  
    218218    /** Adds child to the receiver at index. */
    219219    public void insert(MutableTreeNode child, int index) {
    220     ///ystem.err.println("Insert " + child + " in " + this + " at index " + index + " [Model: " + model + "]");
     220    Gatherer.println("Insert " + child + " in " + this + " at index " + index + " [Model: " + model + "]");
    221221    //map();
    222222    try {
  • trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java

    r6590 r6622  
    6767            stale_node = (FileNode) stale_object;
    6868        }
    69         Gatherer.print("Searching for '" + stale_node + "': ");
     69        Gatherer.print("Searching for '" + stale_object + "': ");
    7070        // Locate the fresh node by searching current's children. Remember to ensure that current is mapped.
    7171        current.map();
  • trunk/gli/src/org/greenstone/gatherer/gui/GProgressBar.java

    r6590 r6622  
    5050    extends JPanel
    5151    implements ActionListener {
     52
     53    static final private Dimension MINIMUM_BUTTON_SIZE = new Dimension(100, 25);
    5254
    5355    private boolean simple = false;
     
    100102
    101103    inner_pane = new JPanel(new BorderLayout());
    102     inner_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
    103 
    104     action = new GLIButton(Utility.getImage("vcrplay.gif"));
    105     action.addActionListener(this);
    106     action.addActionListener(owner);
    107     action.setMnemonic(KeyEvent.VK_ENTER);
    108     Dictionary.setTooltip(action, "Mirroring.Job.Start_Tooltip");
     104    inner_pane.setBorder(BorderFactory.createEmptyBorder(2,(MINIMUM_BUTTON_SIZE.width + 2),2,2));
    109105
    110106    center_pane = new JPanel(new GridLayout(3,1));
     
    128124    center_pane.add(results_status);
    129125
    130     cancel = new GLIButton(Utility.getImage("vcrstop.gif"));
     126    JPanel button_pane = new JPanel();
     127
     128    /** @todo - add to dictionary, and rewrite existing tooltip */
     129    action = new GLIButton("Mirroring.Job.Retry");
     130    action.addActionListener(this);
     131    action.addActionListener(owner);
     132    action.setMinimumSize(MINIMUM_BUTTON_SIZE);
     133    action.setMnemonic(KeyEvent.VK_A);
     134    Dictionary.setTooltip(action, "Mirroring.Job.Start_Tooltip");
     135
     136    /** @todo - add to dictionary, and rewrite existing tooltip */
     137    cancel = new GLIButton("Mirroring.Job.Cancel");
    131138    cancel.addActionListener(owner);
    132139    cancel.addActionListener(this);
    133     cancel.setMnemonic(KeyEvent.VK_BACK_SPACE);
     140    cancel.setMinimumSize(MINIMUM_BUTTON_SIZE);
     141    cancel.setMnemonic(KeyEvent.VK_C);
    134142    Dictionary.setTooltip(cancel, "Mirroring.Job.Stop_Tooltip");
    135143
     144    // Layout - or at least some of it
     145
    136146    inner_pane.add(center_pane, BorderLayout.NORTH);
    137147
    138     this.add(action, BorderLayout.WEST);
     148    button_pane.setLayout(new GridLayout(2,1));
     149    button_pane.add(action);
     150    button_pane.add(cancel);
     151
    139152    this.add(inner_pane, BorderLayout.CENTER);
    140     this.add(cancel, BorderLayout.EAST);
     153    this.add(button_pane, BorderLayout.EAST);
    141154
    142155    // Make the labels, etc update.
     
    148161        if (current_action == Job.RUNNING) {
    149162        current_action = Job.STOPPED;
    150         action.setIcon(Utility.getImage("vcrplay.gif"));
    151         Dictionary.setTooltip(action, "Mirroring.Job.Start_Tooltip");
    152         cancel.setEnabled(true);
     163        action.setEnabled(true);
    153164        }
    154165        else {
    155166        current_action = Job.RUNNING;
    156         action.setIcon(Utility.getImage("vcrpause.gif"));
    157         Dictionary.setTooltip(action, "Mirroring.Job.Pause_Tooltip");
    158         cancel.setEnabled(false);
     167        action.setEnabled(false);
    159168        }
    160169    }
     
    232241    }
    233242    current_action = Job.RUNNING;
    234     action.setIcon(Utility.getImage("vcrpause.gif"));
    235     Dictionary.setTooltip(cancel, "Mirroring.Job.Pause_Tooltip");
    236     // If this is a simple download, then pause is not available (nor is prematurely stopping!)
    237     action.setEnabled(!simple);
    238     cancel.setEnabled(false);
     243    action.setEnabled(false);
    239244    if(simple) {
    240245        progress.setIndeterminate(true);
     
    258263    //Dictionary.setText(progress, "Mirroring.Job.Mirror_Complete");
    259264
    260     action.setIcon(Utility.getImage("vcrfastforward.gif"));
    261     Dictionary.setTooltip(action, "Mirroring.Job.Restart_Tooltip");
    262     action.setEnabled(true);
     265    action.setEnabled(false);
    263266    cancel.setEnabled(true);
    264267    this.updateUI();
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6582 r6622  
    5858import org.greenstone.gatherer.file.FileOpenActionListener;
    5959import org.greenstone.gatherer.gui.AboutDialog;
    60 import org.greenstone.gatherer.gui.BrowsingPane;
     60//import org.greenstone.gatherer.gui.BrowsingPane;
    6161import org.greenstone.gatherer.gui.CollectionPane;
    6262import org.greenstone.gatherer.gui.CreatePane;
     
    8787    implements ActionListener, ChangeListener {
    8888    /** The browsing pane behaves much like an internet browser, or at least will some day. */
    89     public BrowsingPane browser_pane = null;
     89    //public BrowsingPane browser_pane = null;
    9090    /** The collection pane is more like a file manager where you drag files from one tree to another. */
    9191    public CollectionPane collection_pane = null;
     
    146146    this.meta_audit = new MetaAuditFrame(collection_tree_sync, null);
    147147    this.workspace_tree_sync = new TreeSynchronizer();
     148   
     149    // Add a focus listener to ourselves. Thus if we gain focus when a Modal Dialog should instead have it, we can try to bring the modal dialog to the fore.
     150    this.addFocusListener(new GLIGUIFocusListener());
     151
    148152    // Make the Tool tip hang around for a rediculous amount of time.
    149153    ToolTipManager.sharedInstance().setDismissDelay(10000);
     
    156160    UIManager.put("FileChooser.fileNameLabelText", Dictionary.get("SaveCollectionBox.File_Name"));
    157161    }
     162
     163    private class GLIGUIFocusListener
     164    extends FocusAdapter {
     165    public void focusGained(FocusEvent e) {
     166        if(Gatherer.current_modal != null) {
     167        Gatherer.current_modal.makeVisible();
     168        Gatherer.current_modal.toFront();
     169        }
     170    }
     171    }
     172
    158173    /** Any implementation of <i>ActionListener</i> must include this method so that we can be informed when an action has occured. In this case we are listening to actions from the menu-bar, and should react appropriately.
    159174      * @param event An <strong>ActionEvent</strong> containing information about the action that has occured.
     
    304319        new AboutDialog(this);
    305320    }
    306     else if(esrc == menu_bar.help_browse) {
    307         help.setView("huntingforfiles");
    308     }
     321//      else if(esrc == menu_bar.help_browse) {
     322//          help.setView("huntingforfiles");
     323//      }
    309324    else if(esrc == menu_bar.help_build) {
    310325        help.setView("producingthecollection");
     
    347362     */
    348363    public void afterDisplay() {
    349     if(Gatherer.config.get("workflow.browse", true)) {
    350         browser_pane.afterDisplay();
    351     }
     364//      if(Gatherer.config.get("workflow.browse", true)) {
     365//          browser_pane.afterDisplay();
     366//      }
     367    mirror_pane.afterDisplay();
    352368    metaedit_pane.afterDisplay();
    353369    }
     
    425441        // Pretty corner icon
    426442        this.setIconImage(Utility.getImage("gatherer_small.gif").getImage());
    427         // BorderLayout for the main screen. I'll try my best to avoid t
    428         // hese in subcomponents as they're space greedy.
     443        // BorderLayout for the main screen. I'll try my best to avoid these in subcomponents as they're space greedy.
    429444        content_pane.setLayout(new BorderLayout());
    430445        // Create the menu-bar and stick it up the top.
     
    437452        tab_pane.setFont(Gatherer.config.getFont("general.font", false));
    438453
    439         // May have to play with the order in which tabs are added.
    440         if(Gatherer.config.get("workflow.browse", true)) {
    441         browser_pane = new BrowsingPane();
    442         tab_pane.addTab("GUI.Hunt", Utility.getImage("browsing.gif"), browser_pane);
    443         tab_pane.setEnabledAt(tab_pane.indexOfComponent(browser_pane), Gatherer.config.get("workflow.browse", false));
    444         }
    445 
    446         if(Gatherer.config.get("workflow.mirror", true)) {
     454//          // May have to play with the order in which tabs are added.
     455//          if(Gatherer.config.get("workflow.browse", true)) {
     456//          browser_pane = new BrowsingPane();
     457//          tab_pane.addTab("GUI.Hunt", Utility.getImage("browsing.gif"), browser_pane);
     458//          tab_pane.setEnabledAt(tab_pane.indexOfComponent(browser_pane), Gatherer.config.get("workflow.browse", false));
     459//          }
     460
     461        if(Gatherer.config.get(StaticStrings.WORKFLOW_MIRROR, true)) {
    447462        mirror_pane = new MirrorPane();
    448463        tab_pane.addTab("GUI.Mirror", Utility.getImage("mirroring.gif"), mirror_pane);
    449         tab_pane.setEnabledAt(tab_pane.indexOfComponent(mirror_pane), Gatherer.config.get("workflow.mirror", false));
     464        tab_pane.setEnabledAt(tab_pane.indexOfComponent(mirror_pane), Gatherer.config.get(StaticStrings.WORKFLOW_MIRROR, false));
    450465        }
    451466
     
    490505        //}
    491506
    492         // Find the first tab that is enabled and select that.
    493         boolean found = false;
    494         for(int i = 0; !found && i < tab_pane.getTabCount(); i++) {
    495         if(tab_pane.isEnabledAt(i)) {
    496             tab_pane.setSelectedIndex(i);
    497             found = true;
     507        // Select the collect pane if it is available
     508        if(Gatherer.config.get("workflow.gather", false)) {
     509        tab_pane.setSelectedComponent(collection_pane);
     510        }
     511        // Otherwise find the first tab that is enabled and select that.
     512        else {
     513        boolean found = false;
     514        for(int i = 0; !found && i < tab_pane.getTabCount(); i++) {
     515            if(tab_pane.isEnabledAt(i)) {
     516            tab_pane.setSelectedIndex(i);
     517            found = true;
     518            }
    498519        }
    499520        }
     
    515536    public void exit() {
    516537    // First of all an exit can only happen if no modal dialog is currently being displayed. Something is creating a modal dialog but not disposing of it.
    517     //if(Gatherer.current_modal != null) {
    518     //    return;
    519     //}
     538    if(Gatherer.current_modal != null) {
     539        System.err.println("There is a modal dialog open.");
     540        Gatherer.current_modal.makeVisible();
     541        Gatherer.current_modal.toFront();
     542        return;
     543    }
    520544
    521545    boolean cont = true;
     
    871895
    872896    menu_bar.tabSelected(tab_pane.getSelectedIndex());
    873     if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(collection_pane)) {
     897    int selected_index = tab_pane.getSelectedIndex();
     898    if( selected_index == tab_pane.indexOfComponent(collection_pane)) {
    874899        collection_pane.gainFocus();
    875900        // "View assigned metadata" menu item is enabled for the "Gather" pane
    876901        menu_bar.metadata_view.setCanEnable(true);
    877902    }
    878     else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(metaedit_pane)) {
     903    else if(selected_index == tab_pane.indexOfComponent(metaedit_pane)) {
    879904        metaedit_pane.gainFocus();
    880905        // "View assigned metadata" menu item is enabled for the "Enrich" pane
    881906        menu_bar.metadata_view.setCanEnable(true);
    882907    }
    883     else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(config_pane)) {
     908    else if(selected_index == tab_pane.indexOfComponent(config_pane)) {
    884909        config_pane.gainFocus();
    885910    }
    886     else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(create_pane)) {
     911    else if(selected_index == tab_pane.indexOfComponent(create_pane)) {
    887912        create_pane.gainFocus();
     913    }
     914    else if(selected_index == tab_pane.indexOfComponent(mirror_pane)) {
     915        mirror_pane.gainFocus();
    888916    }
    889917    //else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(preview_pane)) {
     
    9731001    implements Runnable {
    9741002    private boolean ready = false;
    975     private int browse_pos = -1;
     1003    //private int browse_pos = -1;
    9761004    private int mirror_pos = -1;
    9771005    private int config_pos = -1;
     
    9841012        this.ready = ready;
    9851013        this.tab_pane = tab_pane;
    986         browse_pos = tab_pane.indexOfComponent(browser_pane);
     1014        //browse_pos = tab_pane.indexOfComponent(browser_pane);
    9871015        mirror_pos = tab_pane.indexOfComponent(mirror_pane);
    9881016        metaedit_pos = tab_pane.indexOfComponent(metaedit_pane);
     
    9921020        //preview_pos = tab_pane.indexOfComponent(preview_pane);
    9931021    }
     1022
    9941023    public void run() {
    995         if(browse_pos != -1) {
    996         if(ready) {
    997             tab_pane.setEnabledAt(browse_pos, Gatherer.config.get("workflow.browse", false));
    998         }
    999         else {
    1000             tab_pane.setEnabledAt(browse_pos, Gatherer.config.get("workflow.browse", true));
    1001         }
    1002         }
     1024//          if(browse_pos != -1) {
     1025//          if(ready) {
     1026//              tab_pane.setEnabledAt(browse_pos, Gatherer.config.get("workflow.browse", false));
     1027//          }
     1028//          else {
     1029//              tab_pane.setEnabledAt(browse_pos, Gatherer.config.get("workflow.browse", true));
     1030//          }
     1031//          }
    10031032        if(mirror_pos != -1) {
    10041033        if(ready) {
  • trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java

    r6590 r6622  
    5151import org.greenstone.gatherer.file.FileNode;
    5252import org.greenstone.gatherer.gui.GLIButton;
     53import org.greenstone.gatherer.gui.URLField;
     54import org.greenstone.gatherer.util.StaticStrings;
    5355import org.greenstone.gatherer.util.Utility;
    5456
     
    6062    extends JPanel {
    6163
     64    private boolean download_button_enabled = false;
     65    private boolean ready = false;
    6266    private JButton download_button;
    6367    private JCheckBox higher_checkbox;
     
    6670    private JScrollPane list_scroll;
    6771    private JComboBox depth_combobox;
    68     private JTextField url_textfield;
     72    private URLField url_field;
    6973    private Vector depth_model;
    7074    private WGet getter;
     
    8690    url_label.setPreferredSize(Utility.LABEL_SIZE);
    8791    Dictionary.registerText(url_label, "Mirroring.Source_URL");
    88     url_textfield = new JTextField();
    89     Dictionary.registerTooltip(url_textfield, "Mirroring.Source_URL_Tooltip");
     92    url_field = new URLField(Gatherer.config.getColor("coloring.editable_foreground", false), Gatherer.config.getColor("coloring.editable_background", false), Gatherer.config.getColor("coloring.error_foreground", false), Gatherer.config.getColor("coloring.error_background", false));
     93    Dictionary.registerTooltip(url_field, "Mirroring.Source_URL_Tooltip");
    9094
    9195    depth_model = new Vector();
    9296    /* @todo - add to dictionary */
    93     depth_model.add(new DepthEntry(0, "0 (this page only)"));
    94     /* @todo - add to dictionary */
    95     depth_model.add(new DepthEntry(1, "1"));
    96     /* @todo - add to dictionary */
    97     depth_model.add(new DepthEntry(2, "2"));
    98     /* @todo - add to dictionary */
    99     depth_model.add(new DepthEntry(3, "3"));
    100     /* @todo - add to dictionary */
    101     depth_model.add(new DepthEntry(4, "4"));
    102     /* @todo - add to dictionary */
    103     depth_model.add(new DepthEntry(5, "5"));
    104     /* @todo - add to dictionary */
    105     depth_model.add(new DepthEntry(-1, "Unlimited"));
     97    depth_model.add(new DepthEntry(0, "Mirroring.Download_Depth.Zero"));
     98    /* @todo - add to dictionary */
     99    depth_model.add(new DepthEntry(1, String.valueOf(1)));
     100    /* @todo - add to dictionary */
     101    depth_model.add(new DepthEntry(2, String.valueOf(3)));
     102    /* @todo - add to dictionary */
     103    depth_model.add(new DepthEntry(3, String.valueOf(3)));
     104    /* @todo - add to dictionary */
     105    depth_model.add(new DepthEntry(4, String.valueOf(4)));
     106    /* @todo - add to dictionary */
     107    depth_model.add(new DepthEntry(5, String.valueOf(5)));
     108    /* @todo - add to dictionary */
     109    depth_model.add(new DepthEntry(-1, "Mirroring.Download_Depth.Unlimited"));
    106110    JPanel depth_pane = new JPanel();
    107111    JLabel depth_label = new JLabel();
     
    121125   
    122126    /* @todo - add to dictionary */
    123     JLabel further_label = new JLabel("For further options see File->Preferences->Connection");
     127    JLabel further_label = new JLabel("Mirroring.Further_Options");
    124128
    125129    JPanel button_pane = new JPanel();
     
    130134    // Connect
    131135    download_button.addActionListener(new DownloadButtonListener());
     136    url_field.getDocument().addDocumentListener(new DownloadButtonEnabler());
    132137
    133138    // Layout
    134139    url_pane.setLayout(new BorderLayout());
    135140    url_pane.add(url_label, BorderLayout.WEST);
    136     url_pane.add(url_textfield, BorderLayout.CENTER);
     141    url_pane.add(url_field, BorderLayout.CENTER);
    137142
    138143    depth_pane.setLayout(new GridLayout(1,3));
     
    165170    }
    166171
     172    public void afterDisplay() {
     173    ready = true;
     174    }
     175
    167176    public void collectionChanged(boolean ready) {
    168177    }
    169178
     179    /** This method is called whenever the Mirror pane is brought into focus and is a good time to display a warning message if WGet is not available or of an older, problematic, version.
     180     */
     181    public void gainFocus() {
     182    if(!ready) {
     183        return;
     184    }
     185    // Lets see what warning message we should display, if any.
     186    String wget_version_str = Gatherer.config.getWGetVersion();
     187    if(wget_version_str.equals(StaticStrings.NO_WGET_STR)) {
     188        // If there was no WGet available then downloading is disabled entirely
     189        download_button_enabled = false;
     190        // And we tell the user why.
     191        /** @todo - add to dictionary */
     192        JOptionPane.showMessageDialog(Gatherer.g_man, "Mirroring.No_WGet", "Mirroring.No_WGet_Title", JOptionPane.ERROR_MESSAGE);
     193    }
     194    else if(wget_version_str.equals(StaticStrings.WGET_OLD_STR)) {
     195        // Downloading is enabled
     196        download_button_enabled = true;
     197        // But we display a preventable warning message about the path problems.
     198        WarningDialog dialog = new WarningDialog("warning.OldWGet", false);
     199        dialog.display();
     200        dialog.dispose();
     201        dialog = null;
     202    }
     203    // Otherwise version must be ok
     204    else {
     205        download_button_enabled = true;
     206    }
     207    // It is also a good time to determine if the download should be enabled - ie if its allowed to be enabled and a valid URL is present in the field.
     208    download_button.setEnabled(download_button_enabled && !url_field.isEmpty() && url_field.validateURL());
     209    }
     210
    170211    public void setURL(String url) {
    171     url_textfield.setText(url);
     212    url_field.setText(url);
    172213    }
    173214
     
    175216    static public FileNode getWebCacheMapping()
    176217    {
    177     if (Gatherer.config.get("workflow.mirror", false) && Gatherer.c_man.ready()) {
     218    if (Gatherer.config.get("workflow.mirror", true) || Gatherer.config.get("workflow.mirror", false)) {
    178219        /* @todo - add to dictionary */
    179         return new FileNode(Utility.getCacheDir(), "Mirror Cache");
     220        return new FileNode(Utility.getCacheDir(), "Mirroring.Mirror_Cache");
    180221    }
    181222    return null;
     
    235276    }
    236277
     278    private class DownloadButtonEnabler
     279    implements DocumentListener {
     280    /** Gives notification that an attribute or set of attributes changed. */
     281    public void changedUpdate(DocumentEvent e) {
     282        validateDownloadButton();
     283    }
     284        /** Gives notification that there was an insert into the document. */
     285    public void insertUpdate(DocumentEvent e) {
     286        validateDownloadButton();
     287    }
     288        /** Gives notification that a portion of the document has been removed. */
     289    public void removeUpdate(DocumentEvent e) {
     290        validateDownloadButton();
     291    }
     292    private void validateDownloadButton() {
     293        download_button.setEnabled(download_button_enabled && !url_field.isEmpty() && url_field.validateURL());
     294    }
     295    }
     296
    237297    private class DownloadButtonListener
    238298    implements ActionListener {
     
    240300    public void actionPerformed(ActionEvent event) {
    241301        // Retrieve the current url and confirm it is valid
    242         String url_str = url_textfield.getText();
     302        String url_str = url_field.getText();
    243303        URL url = null;
    244304        try {
     
    273333        catch(Exception exception) {
    274334            /* @todo - add to dictionary */
    275             JOptionPane.showMessageDialog(Gatherer.g_man, "The depth value you have entered is not valid.\nPlease choose an item from the list, or type in\na number.", "Invalid Depth", JOptionPane.ERROR_MESSAGE);
     335            JOptionPane.showMessageDialog(Gatherer.g_man, "Mirroring.Mirror_Depth.Invalid_Depth", "Mirroring.Mirror_Depth.Invalid_Depth_Title", JOptionPane.ERROR_MESSAGE);
    276336            return;
    277337        }
  • trunk/gli/src/org/greenstone/gatherer/gui/ModalDialog.java

    r6539 r6622  
    4949    public ModalDialog() {
    5050    super((Frame)null, "", false);
    51     Gatherer.current_modal = this;
    5251    }
    5352
     
    5756    public ModalDialog(Dialog parent) {
    5857    super(parent, "", false);
    59     Gatherer.current_modal = this;
    6058    }
    6159
     
    6765    super(parent, "", false);
    6866    this.modal = modal;
    69     Gatherer.current_modal = this;
    7067    }
    7168   
     
    7774    super (parent, title, false);
    7875    this.modal = false;
    79     Gatherer.current_modal = this;
    8076    }
    8177
     
    8884    super (parent, title, false);
    8985    this.modal = modal;
    90     Gatherer.current_modal = this;
    9186    }
    9287
     
    9691    public ModalDialog(Frame parent) {
    9792    super(parent, "", false);
    98     Gatherer.current_modal = this;
    9993    }
    10094
     
    106100    super(parent, "", false);
    107101    this.modal = modal;
    108     Gatherer.current_modal = this;
    109102    }
    110103   
     
    115108    public ModalDialog(Frame parent, String title) {
    116109    super (parent, title, false);
    117     Gatherer.current_modal = this;
    118110    }
    119111
     
    126118    super (parent, title, false);
    127119    this.modal = modal;
    128     Gatherer.current_modal = this;
    129120    }
    130121
    131122    public void dispose() {
    132     Gatherer.current_modal = null;
    133123    super.dispose();
     124    }
     125
     126    /** Ensures the current dialog is visible. */
     127    public void makeVisible() {
     128    super.setVisible(true);
    134129    }
    135130
     
    142137    super.setVisible (visible);
    143138    if (modal && visible) {
     139        Gatherer.current_modal = this;
    144140        try {
    145141        if (SwingUtilities.isEventDispatchThread ()) {
     
    180176    }
    181177    else if(modal && !visible && waiting) {
     178        Gatherer.current_modal = null;
    182179        ///ystem.err.println("Hiding dialog. Tree lock is: " + getTreeLock());
    183180        synchronized(getTreeLock()) {
     
    187184    }
    188185    else if(modal && !waiting) {
     186        Gatherer.current_modal = null;
    189187        ///ystem.err.println("Modal Dialog is not currently waiting.");
    190188    }
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r6582 r6622  
    4848    static public boolean titleClashes(String title, File current_config_file) {
    4949    // An empty collection title never clashes with anything. I may look ugly in the final collection but there is nothing wrong with having no title for a particular language.
    50     if(title == null || title.length() == 0) {
    51         return false;
    52     }
     50    //if(title == null || title.length() == 0) {
     51    //    return false;
     52    //}
    5353    File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
    5454    File children[] = collection_directory.listFiles();
  • trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r6389 r6622  
    118118     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValue
    119119     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValueEnabled
    120      * @see org.greenstone.gatherer.gui.OptionsPane#ArgumentControl
     120     * @see org.greenstone.gatherer.gui.OptionsPane.ArgumentControl
    121121     */
    122122    public JPanel buildBuild(JPanel pane) {
     
    178178     * @see org.greenstone.gatherer.collection.BuildOptions#getImportValue
    179179     * @see org.greenstone.gatherer.collection.BuildOptions#getImportValueEnabled
    180      * @see org.greenstone.gatherer.gui.OptionsPane#ArgumentControl
     180     * @see org.greenstone.gatherer.gui.OptionsPane.ArgumentControl
    181181     */
    182182    public JPanel buildImport(JPanel pane) {
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r6567 r6622  
    5656    private JButton apply_button;
    5757    private JButton cancel_button;
     58    private JButton clear_cache_button;
    5859    private JButton ok_button;
    5960    private JCheckBox show_file_size_checkbox;
     
    208209    Dictionary.registerTooltip(proxy_port_field, "Preferences.Connection.Proxy_Port_Tooltip");
    209210
     211    /** @todo - add to dictionary. Bet you're getting sick of these by now! */
     212    clear_cache_button = new GLIButton("Preferences.Connection.Clear_Cache");
     213
    210214    // Connection
    211215    use_proxy_checkbox.addActionListener(new UseProxyListener());
     216    clear_cache_button.addActionListener(new ClearCacheListener());
    212217
    213218    // Layout
     
    235240    connection_pane.add(proxy_host_pane);
    236241    connection_pane.add(proxy_port_pane);
     242    if(Gatherer.config.get(StaticStrings.WORKFLOW_MIRROR, true)) {
     243        connection_pane.add(clear_cache_button);
     244    }
    237245
    238246    return connection_pane;
     
    717725    }
    718726
     727    private class ClearCacheListener
     728    implements ActionListener {
     729    public void actionPerformed(ActionEvent event) {
     730        // Retrieve the cache folder and delete it.
     731        Utility.delete(Utility.getCacheDir());
     732    }
     733    }
     734
    719735    private class DictionaryEntry
    720736    implements Comparable {
  • trunk/gli/src/org/greenstone/gatherer/gui/URLField.java

    r6397 r6622  
    1111    implements DocumentListener {
    1212
    13     static final public Pattern URL_PATTERN = Pattern.compile("h|ht|htt|http|http:|http:/|http://|http://(([a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*(\\.[a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*)|(([0-9])+\\.([0-9])+\\.([0-9])+\\.([0-9])+))(:([0-9])+)?(/([a-zA-Z]|[0-9]|[\\$\\-_\\.\\&\\+]|[!\\*\"\'\\(\\),]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*");
     13    //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?(([a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*(\\.[a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*)|(([0-9])+\\.([0-9])+\\.([0-9])+\\.([0-9])+))(:([0-9])+)?(/([a-zA-Z]|[0-9]|[\\$\\-_\\.\\&\\+]|[!\\*\"\'\\(\\),]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*");
     14
     15    // Crap RegEx that matches everything dammit
     16    //static final public Pattern URL_PATTERN = Pattern.compile("((.*?)://)?(([^:]*):([^@]*)@)?(([^/:]*)(:[^/]*))?([^\\?#]*/?)?(\\?([^?#]*))?(#(.*))?");
     17
     18    //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[a-zA-Z0-9-]*(\.[a-zA-Z0-9-])*");
     19
     20    static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[\\w]+(\\.[\\w]+)([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?");
    1421
    1522    private Color background;
     
    5259    validateURL();
    5360    }
     61
     62    public boolean isEmpty() {
     63    return (this.getText().length() == 0);
     64    }
    5465         
    5566    /** Gives notification that a portion of the document has been removed.
  • trunk/gli/src/org/greenstone/gatherer/msm/MSMUtils.java

    r6568 r6622  
    327327     * @param element the Element whose attributes we wish to catalog
    328328     * @return a TreeSet of the attributes sorted by their natural ordering
    329      * @see org.greenstone.gatherer.msm.MSMUtils#getValue(Element)
     329     * @see org.greenstone.gatherer.msm.MSMUtils#getValue(Node)
    330330     * @see org.greenstone.gatherer.util.StaticStrings#ATTRIBUTE_ELEMENT
    331331     * @see org.greenstone.gatherer.util.StaticStrings#CODE_ATTRIBUTE
     
    817817     * @return true if the desired attribute was successfully found and removed, false otherwise
    818818     * @see org.greenstone.gatherer.msm.MSMUtils#isAttributeLanguageDependant
    819      * @see org.greenstone.gatherer.msm.MSMUtils#getValue(Element)
     819     * @see org.greenstone.gatherer.msm.MSMUtils#getValue(Node)
    820820     * @see org.greenstone.gatherer.util.StaticStrings#ATTRIBUTE_ELEMENT
    821821     * @see org.greenstone.gatherer.util.StaticStrings#CODE_ATTRIBUTE
  • trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java

    r6539 r6622  
    895895    }
    896896
    897     /** Listens for actions on the read button, and if detected creates a new ReadTask to test the document. */
     897    /** Listens for actions on the read button, and if detected creates a new ReadTask to test the document.
     898     * @author John Thompson, Greenstone Project, New Zealand Digital Library, University of Waikato
     899     * @version 2.41 final
     900     */
    898901    static private class ReadButtonListener
    899902    implements ActionListener {
     
    918921    }
    919922
    920     /** This threaded task opens a large document, aptly named 'big.txt', and then bombards the document object we are testing with lines from the file. This file should be several megs (such as Alice or TREC) to fully test functionality, thread conditions etc. */
     923    /** This threaded task opens a large document, aptly named 'big.txt', and then bombards the document object we are testing with lines from the file. This file should be several megs (such as Alice or TREC) to fully test functionality, thread conditions etc.
     924     * @author John Thompson, Greenstone Project, New Zealand Digital Library, University of Waikato
     925     * @version 2.41 final
     926     */
    921927    static private class ReadTask
    922928    extends Thread {
  • trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r6582 r6622  
    140140    static final public String LANGUAGE_DEFAULT_STR                       = "defaultlanguage";
    141141    static final public String LANGUAGE_STR                               = "language";
    142     static final public String LANGUAGEDEPENDANT_ATTRIBUTE                = "language_dependant";
     142    static final public String LANGUAGEDEPENDANT_ATTRIBUTE                = "language_dependent";
    143143    static final public String LANGUAGES_ELEMENT                          = "Languages";
    144144    static final public String LANGUAGES_STR                              = "languages";
     
    167167    static final public String MGPP_ATTRIBUTE                             = "mgpp_enabled";
    168168    static final public String MINUS_CHARACTER                            = "-";
     169    static final public String MIRROR_ARGUMENT                            = "-mirror";
    169170    static final public String MODE_STR                                   = "Mode: ";
    170171    static final public String MODEGLI_ELEMENT                            = "ModeGLI";
     
    175176    static final public String NEWLINE_ELEMENT                            = "NewLine";
    176177    static final public String NO_LOAD_ARGUMENT                           = "-no_load";
     178    static final public String NO_WGET_STR                                = "NoWGet";
    177179    static final public String ONE_CHARACTER                              = "1";
    178180    static final public String OPEN_PARENTHESIS_CHARACTER                 = "(";
     
    232234    static final public String VALUE_ATTRIBUTE                            = "value";
    233235    static final public String VALUE_TREE_ATTRIBUTE                       = "remember_values";
    234     static final public String WIN_9X_OPEN_COMMAND = "command.com /c start \"%1\"";
    235     static final public String WIN_OPEN_COMMAND = "cmd.exe /c start \"\" \"%1\"";
     236    static final public String WGET_ARGUMENT                              = "-wget";
     237    static final public String WGET_OLD_STR                               = "<WGet1.9";
     238    static final public String WGET_STR                                   = "WGet1.9";
     239    static final public String WIN_9X_OPEN_COMMAND                        = "command.com /c start \"%1\"";
     240    static final public String WIN_OPEN_COMMAND                           = "cmd.exe /c start \"\" \"%1\"";
     241    static final public String WORKFLOW_MIRROR                            = "workflow.mirror";
    236242    static final public String YES_STR                                    = "yes";
    237243    static final public String ZERO_CHARACTER                             = "0";
  • trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModelTools.java

    r6212 r6622  
    4242    }
    4343
    44     static final public Runnable insertNodeInto(final DefaultTreeModel model, final MutableTreeNode parent, final MutableTreeNode target_node, boolean wait_allowed) {
     44    static final public Runnable insertNodeInto(final DefaultTreeModel model, final MutableTreeNode parent, final MutableTreeNode target_node, final boolean wait_allowed) {
    4545    final Runnable doInsertNodeInto = new Runnable() {
    4646        public void run() {
    4747            ///ystem.err.print("Running task... ");
     48            Gatherer.println("insertNodeInto(" + model + ", " + parent + ", " + target_node + ", " + wait_allowed);
    4849            int index = -1;
    4950            int pos = 0;
Note: See TracChangeset for help on using the changeset viewer.