Changeset 5581


Ignore:
Timestamp:
2003-10-06T13:32:25+13:00 (21 years ago)
Author:
mdewsnip
Message:

Many formatting, structural and code improvements.

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

Legend:

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

    r5564 r5581  
    1 package org.greenstone.gatherer;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer;
     38
    3839import java.awt.*;
    3940import java.io.*;
     
    4344import javax.swing.*;
    4445import javax.swing.plaf.*;
    45 import org.greenstone.gatherer.cdm.Language;
    46 import org.greenstone.gatherer.gui.Coloring;
    4746import org.greenstone.gatherer.msm.MSMUtils;
    48 import org.greenstone.gatherer.util.GURL;
    4947import org.greenstone.gatherer.util.Utility;
    5048import org.w3c.dom.*;
     49
    5150/** This class stores the various configurable settings inside the Gatherer, both during a session, and between sessions in the form of XML. However not all data members are retained during xml serialization. To further improve efficiency, the property-name -> DOM Element pairs are stored in a SoftReferenced Hashtable.
    5251 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    206205    HashMap properties = new HashMap();
    207206    try {
    208                 // Locate the appropriate element
     207        // Locate the appropriate element
    209208        Element document_element = null;
    210209        if(general) {
     
    306305    try {
    307306        String raw = getString(property, general);
    308                 // Dimension is a width by height pair, comma separated (also remove whitespace)
     307        // Dimension is a width by height pair, comma separated (also remove whitespace)
    309308        StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN1);
    310309        int width = Integer.parseInt(tokenizer.nextToken());
     
    656655    UIManager.put("ScrollBar.background", new ColorUIResource(getColor("coloring.scrollbar_background", false)));
    657656    UIManager.put("ScrollBar.thumb", new ColorUIResource(getColor("coloring.scrollbar_foreground", false)));
    658     if(Gatherer.g_man != null) {
     657    if (Gatherer.g_man != null) {
    659658        JPanel pane = (JPanel) Gatherer.g_man.getContentPane();
    660659        pane.updateUI();
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r5571 r5581  
    198198        dictionary = new Dictionary(config.getLocale("general.locale", true), config.getFont("general.font", true));
    199199
    200         if(gsdl_path == null) {
     200        if (gsdl_path == null) {
    201201        missingGSDL(dictionary);
    202202        }
    203203
    204204        // If we were given a server run it if neccessary.
    205         if(config.exec_file != null) {
     205        if (config.exec_file != null) {
    206206        startServerEXE();
    207207        }
    208208
    209209        // Having loaded the configuration (necessary to determine if certain warnings have been disabled) and dictionary, we now check if the necessary path variables have been provided.
    210         if(config.exec_file == null && config.exec_address == null) {
    211         if(config.exec_file == null) {
     210        if (config.exec_file == null && config.exec_address == null) {
     211        if (config.exec_file == null) {
    212212            Gatherer.println("config.exec_file is null");
    213213        }
    214         if(config.exec_address == null) {
     214        if (config.exec_address == null) {
    215215            Gatherer.println("config.exec_address is null");
    216216        }
    217217        missingEXEC(dictionary);
    218218        }
     219
    219220        // Perl path is a little different as it is perfectly ok to start the Gatherer without providing a perl path
    220221        boolean found_perl = false;
    221         if(config.perl_path != null) {
     222        if (config.perl_path != null) {
    222223        // See if the file pointed to actually exists
    223224        File perl_file = new File(config.perl_path);
     
    225226        perl_file = null;
    226227        }
    227         if(config.perl_path == null || !found_perl) {
     228        if (config.perl_path == null || !found_perl) {
    228229        // Run test to see if we can run perl as is.
    229230        PerlTest perl_test = new PerlTest();
    230         if(perl_test.found()) {
     231        if (perl_test.found()) {
    231232            // If so replace the perl path with the system default (or null for unix).
    232233            config.perl_path = perl_test.toString();
     
    234235        }
    235236        }
    236         if(!found_perl) {
     237        if (!found_perl) {
    237238        // Time for an error message.
    238239        missingPERL(dictionary);
     
    399400    return null;
    400401    }
     402
    401403    /** Used to 'spawn' a new child application when a file is double clicked.
    402404     * @param command The command to run in the child process to start the application, garnered from the registry of a default associations file, and presented as a <strong>String</strong>.
     
    946948    }
    947949}
    948 
    949 
    950 
    951 
    952 
  • trunk/gli/src/org/greenstone/gatherer/WGet.java

    r5317 r5581  
    1 package org.greenstone.gatherer;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer;
     38
    3839import java.awt.*;
    3940import java.io.*;
     
    4445import org.greenstone.gatherer.Gatherer;
    4546import org.greenstone.gatherer.collection.Job;
     47
    4648/** This class provides access to the functionality of the WGet program, either by calling it via a shell script or by the JNI. It maintains a queue of pending jobs, and the component for showing these tasks to the user.
    4749 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    8991
    9092    /** Called by the WGet native code to inform us of a new download starting within the given job.
    91     * @param url The url that is being downloaded, as a <strong>String</strong>.
    92     * @see org.greenstone.gatherer.collection.Job
    93     */
     93    * @param url The url that is being downloaded, as a <strong>String</strong>.
     94    * @see org.greenstone.gatherer.collection.Job
     95    */
    9496    public synchronized void addDownload(String url) {
    9597    job.addDownload(url);
     
    9799
    98100    /* Used to advise the Job of a newly parsed link. Its up to Job to decide if it already knows about this url, and if not to update its progress bar.
    99       * @param url The url in question as a <strong>String</strong>.
    100       * @param type <i>true</i> if this is an internal link, <i>false</i> for and external one.
    101       * @return A <i>boolean</i> with a value of <i>true</i> indicating if the url was added, <i>false</i> otherwise.
    102       * @see org.greenstone.gatherer.collection.Job
    103       */
     101     * @param url The url in question as a <strong>String</strong>.
     102     * @param type <i>true</i> if this is an internal link, <i>false</i> for and external one.
     103     * @return A <i>boolean</i> with a value of <i>true</i> indicating if the url was added, <i>false</i> otherwise.
     104     * @see org.greenstone.gatherer.collection.Job
     105     */
    104106    public synchronized boolean addLink(String url, int type) {
    105107    return job.addLink(url, type);
     
    107109
    108110    /* Whenever files are moved into or out of the collection we need to
    109       * run convertLinks on the files remaining. This ensures that we have
    110       * the most efficient balance between local and absolute links.
    111       * @param records A <strong>Vector</strong> containing information about the files in
    112       * the current collection. From these url and file information is
    113       * harvested.
    114       */
    115      // public void convertLinks(Vector records) {
     111     * run convertLinks on the files remaining. This ensures that we have
     112     * the most efficient balance between local and absolute links.
     113     * @param records A <strong>Vector</strong> containing information about the files in
     114     * the current collection. From these url and file information is
     115     * harvested.
     116     */
    116117    public void convertLinks() {
    117118    Vector args = new Vector();
     
    162163
    163164    /** This method is called to delete a certain job from the queue.
    164       * This job may be pending, complete or even in progress. However
    165       * if it is currently downloading then the delete method must
    166       * wait until the native job has cleanly exited before removing
    167       * the job.
    168       * @param delete_me The <strong>Job</strong> that is to be deleted.
    169       */
     165     * This job may be pending, complete or even in progress. However
     166     * if it is currently downloading then the delete method must
     167     * wait until the native job has cleanly exited before removing
     168     * the job.
     169     * @param delete_me The <strong>Job</strong> that is to be deleted.
     170     */
    170171    public void deleteJob(Job delete_me) {
    171     if(delete_me == job) {
    172                 // While this seems wasteful its only for the briefest moment.
     172    if (delete_me == job) {
     173        // While this seems wasteful its only for the briefest moment.
    173174        while(busy) {
    174175        }
    175176        job = null;
    176177    }
    177     if(delete_me.hasSignalledStop()) {
     178    if (delete_me.hasSignalledStop()) {
    178179        list_pane.remove(delete_me.getProgressBar());
    179180        job_queue.remove(delete_me);
     
    199200
    200201    /** Called by the WGet native code when the current download,
    201     * for the indicated job, is completed. In turn all download
    202     * listeners are informed.
    203     * @see org.greenstone.gatherer.collection.Job
    204     */
     202     * for the indicated job, is completed. In turn all download
     203     * listeners are informed.
     204     * @see org.greenstone.gatherer.collection.Job
     205     */
    205206    public synchronized void downloadComplete() {
    206207    job.downloadComplete();
     
    208209
    209210    /** Called by the WGet native code when the requested download returns
    210     * a status code other than 200-399 for the specified download job.
    211     * for.
    212     * @see org.greenstone.gatherer.collection.Job
    213     */
     211     * a status code other than 200-399 for the specified download job.
     212     * for.
     213     * @see org.greenstone.gatherer.collection.Job
     214     */
    214215    public synchronized void downloadFailed() {
    215216    // Add the failed download as a new job if the user so requests.
     
    218219
    219220    /** Called by the WGet native code when some non-fatal error has caused
    220     * a download to fail. An example of a warning would be if a file can't
    221     * be downloaded as doing so would clobber an existing file and the -nc
    222     * flag is set.
    223     * @see org.greenstone.gatherer.collection.Job
    224     */
     221     * a download to fail. An example of a warning would be if a file can't
     222     * be downloaded as doing so would clobber an existing file and the -nc
     223     * flag is set.
     224     * @see org.greenstone.gatherer.collection.Job
     225     */
    225226    public synchronized void downloadWarning() {
    226227    job.downloadWarning();
     
    228229
    229230    /** Used by other graphic functions to get a reference to the
    230       * scroll pane containing the current list of jobs.
    231       */
     231     * scroll pane containing the current list of jobs.
     232     */
    232233    public JScrollPane getJobList() {
    233234    return list_scroll;
     
    235236
    236237    /** Returns the current state of the stop flag for the job indicated.
    237     * @return A boolean representing whether the user has requested to
    238     * stop.
    239     * @see org.greenstone.gatherer.collection.Job
    240     */
     238     * @return A boolean representing whether the user has requested to
     239     * stop.
     240     * @see org.greenstone.gatherer.collection.Job
     241     */
    241242    public synchronized boolean hasSignalledStop() {
    242243    return job.hasSignalledStop();
     
    244245
    245246    /** Creates a new mirroring job on the queue given the target url and the destination (private, public). All other details are harvested from the config file, but these two must be  captured from the GUI's current state.
    246       * @param url a URL which points to the root url for the mirroring
    247       * @param model the GTreeModel that any new records should be added to
    248       * @param destination the destination file as a String
    249       * @see org.greenstone.gatherer.Configuration
    250       * @see org.greenstone.gatherer.Gatherer
    251     * @see org.greenstone.gatherer.collection.Job
    252       * @see org.greenstone.gatherer.gui.GProgressBar
    253       * @see org.greenstone.gatherer.util.GURL
    254       */
     247     * @param url a URL which points to the root url for the mirroring
     248     * @param model the GTreeModel that any new records should be added to
     249     * @param destination the destination file as a String
     250     * @see org.greenstone.gatherer.Configuration
     251     * @see org.greenstone.gatherer.Gatherer
     252     * @see org.greenstone.gatherer.collection.Job
     253     * @see org.greenstone.gatherer.gui.GProgressBar
     254     * @see org.greenstone.gatherer.util.GURL
     255     */
    255256    public void newJob(TreeModel model, boolean overwrite, boolean no_parents, boolean other_hosts, boolean page_requisites, URL url, int depth, String destination) {
    256257    // Create the job and fill in the details from gatherer.config.
     
    284285
    285286    /** Called by the WGet native code to signal the current progress of
    286     * downloading for the specified job.
    287     * @param current A long representing the number of bytes that have
    288     * been downloaded since the last update.
    289     * @param expected A long representing the total number of bytes
    290     * expected for this download.
    291     * @see org.greenstone.gatherer.collection.Job
    292     */
     287     * downloading for the specified job.
     288     * @param current A long representing the number of bytes that have
     289     * been downloaded since the last update.
     290     * @param expected A long representing the total number of bytes
     291     * expected for this download.
     292     * @see org.greenstone.gatherer.collection.Job
     293     */
    293294    public synchronized void updateProgress(long current, long expected) {
    294295    job.updateProgress(current, expected);
     
    296297
    297298    /* There may be times when the download thread is sleeping, but the
    298     * user has indicated that a previously paused job should now begin
    299     * again. The flag within the job will change, so we tell the thread
    300     * to start again.
    301     */
     299     * user has indicated that a previously paused job should now begin
     300     * again. The flag within the job will change, so we tell the thread
     301     * to start again.
     302     */
    302303    public void resumeThread() {
    303304    synchronized(this) {
     
    307308
    308309    /* This begins the WGet thread, which simply iterates through the waiting
    309     * jobs attempting each one. Successful downloads are removed from the
    310     * waiting list.
    311     * @see org.greenstone.gatherer.Gatherer
    312     * @see org.greenstone.gatherer.collection.Job
    313     */
     310     * jobs attempting each one. Successful downloads are removed from the
     311     * waiting list.
     312     * @see org.greenstone.gatherer.Gatherer
     313     * @see org.greenstone.gatherer.collection.Job
     314     */
    314315    public void run() {
    315316    while(true) {
     
    322323            if(job.getState() == Job.RUNNING) {
    323324            Gatherer.println("Job " + job.toString() + " Begun.");
    324                 // A lock to prevent us deleting this job while its being
    325                 // run, unless you want things to go really wrong.
     325            // A lock to prevent us deleting this job while its being
     326            // run, unless you want things to go really wrong.
    326327            busy = true;
    327328            if(simple) {
     
    358359   
    359360    /* Link to the call to the WGet Native method for downloading.
    360     * @param argc An int representing the number of elements in argv.
    361     * @param argv An array of objects passed as arguments to wget.
    362     * @param debug Whether the native code should show java-only debug
    363     * messages.
    364     */
     361     * @param argc An int representing the number of elements in argv.
     362     * @param argv An array of objects passed as arguments to wget.
     363     * @param debug Whether the native code should show java-only debug
     364     * messages.
     365     */
    365366    public native int wget(int argc, Object argv[], boolean debug);
    366367
    367368    /* Link to the call to the WGet Native method for converting url links.
    368     * @param argc An int representing the number of object elements in argv.
    369     * @param argv An array of objects passed as arguments to wget.
    370     * @param urlc An int representing the number of url string elements
    371     * in urlv.
    372     * @param urlv An array of strings representing urls.
    373     * @param filec An int representing the number of file string elements
    374     * in filev.
    375     * @param filev An array of strings representing files.
    376     */
     369     * @param argc An int representing the number of object elements in argv.
     370     * @param argv An array of objects passed as arguments to wget.
     371     * @param urlc An int representing the number of url string elements in urlv.
     372     * @param urlv An array of strings representing urls.
     373     * @param filec An int representing the number of file string elements in filev.
     374     * @param filev An array of strings representing files.
     375     */
    377376    public native void wren(int argc, Object argv[], int urlc, Object urlv[], int filec, Object filev[]);
    378377}
    379 
    380 
    381 
    382 
    383 
    384 
    385 
  • trunk/gli/src/org/greenstone/gatherer/checklist/CheckList.java

    r5159 r5581  
    3535 *########################################################################
    3636 */
    37 
    38  
    39 
    40 
    41 
    42 
    43 /* GPL_HEADER */
    4437package org.greenstone.gatherer.checklist;
     38
    4539/**************************************************************************************
    4640 * Title:        Gatherer
     
    5650import javax.swing.border.*;
    5751import org.greenstone.gatherer.checklist.Entry;
     52
    5853/** This class provides a visual component that has the form of a list, as provided by JList but uses JCheckBox for data selection. Thus several elements can be 'ticked' in the list, and this selection returned using the method getSelected().<BR>Parts of this code modified from Trevor Harmon's posting on www.dejanews.com.
    5954 * @author John Thompson
     
    156151
    157152    /** Retrieve the currently ticked entries from this list.
    158       * @return An <strong>ArrayList</strong> containing only those entries from the initial list that are checked.
    159       * @see org.greenstone.gatherer.checklist.CheckList.Entry
    160       */
     153     * @return An <strong>ArrayList</strong> containing only those entries from the initial list that are checked.
     154     * @see org.greenstone.gatherer.checklist.CheckList.Entry
     155     */
    161156    public ArrayList getSelected() {
    162157    ArrayList result = new ArrayList();
     
    230225
    231226    /** Checks the entries in the list whose name appear in the given array.
    232       * @param names The name of entries to be checked as a <strong>String[]</strong>.
    233       * @see org.greenstone.gatherer.checklist.CheckList.Entry
    234       */
     227     * @param names The name of entries to be checked as a <strong>String[]</strong>.
     228     * @see org.greenstone.gatherer.checklist.CheckList.Entry
     229     */
    235230    public void setSelected(String names[]) {
    236231    DefaultListModel model = (DefaultListModel) getModel();
     
    260255     * @param cell_has_focus <i>true</i> if and only if the specified cell has the focus.
    261256     * @return A <strong>Component</strong> whose paint() method will render the specified value.
    262             */
     257     */
    263258    public Component getListCellRendererComponent(JList list, Object value, int index, boolean is_selected, boolean cell_has_focus) {
    264259        JCheckBox checkbox = (JCheckBox) value;
     
    301296    }
    302297}
    303 
  • trunk/gli/src/org/greenstone/gatherer/collection/BuildOptions.java

    r5164 r5581  
    55import java.util.*;
    66import org.apache.xerces.parsers.DOMParser;
    7 import org.greenstone.gatherer.Configuration;
    87import org.greenstone.gatherer.Gatherer;
    98import org.greenstone.gatherer.cdm.Argument;
     
    1312import org.w3c.dom.*;
    1413import org.xml.sax.InputSource;
     14
    1515/** Build options uses the argument list found in config.xml and the current settings from the loaded collection configuration to represent the options the user wants to use during import and build. If there are no arguments stored in config.xml, or if the user indicates the argument are out of date, this class tries to parse new ones. */
    1616public class BuildOptions {
     
    371371        argument_element = null;
    372372        }
    373                 // If we haven't found an instance of this argument, but should have, then add it.
     373        // If we haven't found an instance of this argument, but should have, then add it.
    374374        if(!found && (enable || value != null)) {
    375375        Element argument_element = document.createElement(ARGUMENT);
     
    387387        arguments = null;
    388388        document = null;
    389                 // Make sure the collection knows to save.
     389        // Make sure the collection knows to save.
    390390        Gatherer.c_man.getCollection().setSaved(false);
    391391    }
  • trunk/gli/src/org/greenstone/gatherer/collection/Collection.java

    r5237 r5581  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.io.*;
    3940import java.util.*;
     
    5152import org.greenstone.gatherer.util.Utility;
    5253import org.w3c.dom.*;
     54
    5355/** Collection provides a common collection point for all the information about a certain collection build session. It keeps a record of several other managers that actually handle the content of the collection, such as metadata sets and metadata itself.
    5456 * @author John Thompson, Greenstone Digital Library, University of Waikato
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionConfiguration.java

    r5298 r5581  
    88import org.greenstone.gatherer.util.Utility;
    99import org.w3c.dom.*;
     10
    1011/** This class provides access to a collection configuration file. This version accepts either a valid xml document or a historical collect.cfg file. */
    1112public class CollectionConfiguration
     
    172173    }
    173174
    174     /** Retrieve the short name for this collection which, given this current file is in <col_name>/etc/collect.cfg, is the name of this file's parent file's parent.
    175     * @return the short name of this collection as a String
    176     */
    177     public String getShortName() {
    178         return file.getParentFile().getParentFile().getName();
    179     }
     175    /** Retrieve the short name for this collection which, given this current file is in <col_name>/etc/collect.cfg, is the name of this file's parent file's parent.
     176     * @return the short name of this collection as a String
     177     */
     178    public String getShortName() {
     179    return file.getParentFile().getParentFile().getName();
     180    }
    180181
    181182    public void setName(String name) {
     
    185186    /** Display the title for this collection. */
    186187    public String toString() {
    187         return getName();
    188     }
     188    return getName();
     189    }
    189190}
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r5571 r5581  
    105105
    106106    private int special_case = -1;
    107     /** Holds a reference to the thread responsible for closing the collection. If non-null then only calls from the given thread will see the collection is non-ready. All other threads will have to wait until closing thread, and all of it consequential calls, are completely finished. */
     107    /** Holds a reference to the thread responsible for closing the collection. If non-null then only calls from the given thread will see the collection is non-ready. All other threads will have to wait until closing thread, and all of it consequential calls, are completely finished. */
    108108    private Thread closing_thread = null;
    109109
     
    173173    shell.addGShellListener(Gatherer.g_man.create_pane);
    174174    shell.start();
    175     Gatherer.println("CollectionManager.buildCollection().return");
    176     }
     175    Gatherer.println("CollectionManager.buildCollection().return");
     176    }
     177
    177178    /** Used to determine whether the currently active collection has been built.
    178179     * @return A boolean indicating the built status of the collection.
     
    367368        // And if that fails then we must have been asked by Satan himself to build the very digital collections of hell, because they don't match any goodly greenstone collection I have ever seen, so you can't blame me if I can't import them.
    368369
    369 
    370370        // Now we update our collect.cfg
    371371        Gatherer.println("Copy and update collect.cfg from base collection.");
     
    381381        progress.setProgress(3);
    382382
    383                 // Has to be done after creating metadata set manager.
     383        // Has to be done after creating metadata set manager.
    384384        File gmeta_dir_temp = new File(getCollectionMetadata()+"temp.dat");
    385385        File gmeta_dir = gmeta_dir_temp.getParentFile();
     
    391391
    392392        progress.setProgress(6);
    393                 // Register ourselves as being interested in what the msm has to say.
     393        // Register ourselves as being interested in what the msm has to say.
    394394        collection.msm.addMSMListener(this);
    395                 // Create a lock file.
     395        // Create a lock file.
    396396        File lock_file = new File(a_dir, LOCK_FILE);
    397397        FileOutputStream out = new FileOutputStream(lock_file);
     
    465465    }
    466466    /** Constructs the absolute filename of the collection archive directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/archive/"
    467       * @return A <strong>String</strong> containing the filename.
    468       * @see org.greenstone.gatherer.Configuration
    469       * @see org.greenstone.gatherer.Gatherer
    470       * @see org.greenstone.gatherer.collection.Collection
    471       * @see org.greenstone.gatherer.util.Utility
    472       */
     467     * @return A <strong>String</strong> containing the filename.
     468     * @see org.greenstone.gatherer.Configuration
     469     * @see org.greenstone.gatherer.Gatherer
     470     * @see org.greenstone.gatherer.collection.Collection
     471     * @see org.greenstone.gatherer.util.Utility
     472     */
    473473    public String getCollectionArchive() {
    474474    return Utility.getArchiveDir(Gatherer.config.gsdl_path, collection.getName());
    475475    }
    476476    /** Constructs the absolute filename of the collection building directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/building/"
    477       * @return A <strong>String</strong> containing the filename.
    478       * @see org.greenstone.gatherer.Configuration
    479       * @see org.greenstone.gatherer.Gatherer
    480       * @see org.greenstone.gatherer.collection.Collection
    481       * @see org.greenstone.gatherer.util.Utility
    482       */
     477     * @return A <strong>String</strong> containing the filename.
     478     * @see org.greenstone.gatherer.Configuration
     479     * @see org.greenstone.gatherer.Gatherer
     480     * @see org.greenstone.gatherer.collection.Collection
     481     * @see org.greenstone.gatherer.util.Utility
     482     */
    483483    public String getCollectionBuild() {
    484484    return Utility.getBuildDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
    485485    }
    486486    /** Constructs the absolute filename of the collection cache directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/gcache/"
    487       * @return A <strong>String</strong> containing the filename.
    488       * @see org.greenstone.gatherer.Configuration
    489       * @see org.greenstone.gatherer.Gatherer
    490       * @see org.greenstone.gatherer.collection.Collection
    491       * @see org.greenstone.gatherer.util.Utility
    492       */
     487     * @return A <strong>String</strong> containing the filename.
     488     * @see org.greenstone.gatherer.Configuration
     489     * @see org.greenstone.gatherer.Gatherer
     490     * @see org.greenstone.gatherer.collection.Collection
     491     * @see org.greenstone.gatherer.util.Utility
     492     */
    493493    public String getCollectionCache() {
    494494    return Utility.getCacheDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
    495495    }
    496496    /** Constructs the absolute filename of the collection config file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/collect.cfg"
    497       * @return A <strong>String</strong> containing the filename.
    498       * @see org.greenstone.gatherer.Configuration
    499       * @see org.greenstone.gatherer.Gatherer
    500       * @see org.greenstone.gatherer.collection.Collection
    501       * @see org.greenstone.gatherer.util.Utility
    502       */
     497     * @return A <strong>String</strong> containing the filename.
     498     * @see org.greenstone.gatherer.Configuration
     499     * @see org.greenstone.gatherer.Gatherer
     500     * @see org.greenstone.gatherer.collection.Collection
     501     * @see org.greenstone.gatherer.util.Utility
     502     */
    503503    public String getCollectionConfig() {
    504504    return Utility.getConfigDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     
    506506
    507507    /** Constructs the absolute filename of the collection directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;"
    508       * @return A <strong>String</strong> containing the directory name.
    509       * @see org.greenstone.gatherer.Configuration
    510       * @see org.greenstone.gatherer.Gatherer
    511       * @see org.greenstone.gatherer.collection.Collection
    512       * @see org.greenstone.gatherer.util.Utility
    513       */
     508     * @return A <strong>String</strong> containing the directory name.
     509     * @see org.greenstone.gatherer.Configuration
     510     * @see org.greenstone.gatherer.Gatherer
     511     * @see org.greenstone.gatherer.collection.Collection
     512     * @see org.greenstone.gatherer.util.Utility
     513     */
    514514    public String getCollectionDirectory() {
    515515    return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator;
     
    517517
    518518    /** Constructs the absolute filename of the collection etc directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/etc/"
    519       * @return A <strong>String</strong> containing the filename.
    520       * @see org.greenstone.gatherer.Configuration
    521       * @see org.greenstone.gatherer.Gatherer
    522       * @see org.greenstone.gatherer.collection.Collection
    523       * @see org.greenstone.gatherer.util.Utility
    524       */
     519     * @return A <strong>String</strong> containing the filename.
     520     * @see org.greenstone.gatherer.Configuration
     521     * @see org.greenstone.gatherer.Gatherer
     522     * @see org.greenstone.gatherer.collection.Collection
     523     * @see org.greenstone.gatherer.util.Utility
     524     */
    525525    public String getCollectionEtc() {
    526526    return Utility.getEtcDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
    527527    }
    528528    /** Constructs the absolute filename of the collection file, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/&lt;col_name&gt;.col"
    529       * @return A <strong>String</strong> containing the filename.
    530       * @see org.greenstone.gatherer.Configuration
    531       * @see org.greenstone.gatherer.Gatherer
    532       * @see org.greenstone.gatherer.collection.Collection
    533       * @see org.greenstone.gatherer.util.Utility
    534       */
     529     * @return A <strong>String</strong> containing the filename.
     530     * @see org.greenstone.gatherer.Configuration
     531     * @see org.greenstone.gatherer.Gatherer
     532     * @see org.greenstone.gatherer.collection.Collection
     533     * @see org.greenstone.gatherer.util.Utility
     534     */
    535535    public String getCollectionFilename() {
    536536    return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + collection.getName() + ".col";
    537537    }
    538538    /** Constructs the absolute filename of the collection import directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/import/"
    539       * @return A <strong>String</strong> containing the filename.
    540       * @see org.greenstone.gatherer.Configuration
    541       * @see org.greenstone.gatherer.Gatherer
    542       * @see org.greenstone.gatherer.collection.Collection
    543       * @see org.greenstone.gatherer.util.Utility
    544       */
     539     * @return A <strong>String</strong> containing the filename.
     540     * @see org.greenstone.gatherer.Configuration
     541     * @see org.greenstone.gatherer.Gatherer
     542     * @see org.greenstone.gatherer.collection.Collection
     543     * @see org.greenstone.gatherer.util.Utility
     544     */
    545545    public String getCollectionImport() {
    546546    return Utility.getImportDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
    547547    }
    548548    /** Constructs the absolute filename of the collection index directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/index/"
    549       * @return A <strong>String</strong> containing the filename.
    550       * @see org.greenstone.gatherer.Configuration
    551       * @see org.greenstone.gatherer.Gatherer
    552       * @see org.greenstone.gatherer.collection.Collection
    553       * @see org.greenstone.gatherer.util.Utility
    554       */
     549     * @return A <strong>String</strong> containing the filename.
     550     * @see org.greenstone.gatherer.Configuration
     551     * @see org.greenstone.gatherer.Gatherer
     552     * @see org.greenstone.gatherer.collection.Collection
     553     * @see org.greenstone.gatherer.util.Utility
     554     */
    555555    public String getCollectionIndex() {
    556556    return Utility.getIndexDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
    557557    }
    558558    /** Constructs the absolute filename of the collection log directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/log/"
    559       * @return A <strong>String</strong> containing the filename.
    560       * @see org.greenstone.gatherer.Configuration
    561       * @see org.greenstone.gatherer.Gatherer
    562       * @see org.greenstone.gatherer.collection.Collection
    563       * @see org.greenstone.gatherer.util.Utility
    564       */
     559     * @return A <strong>String</strong> containing the filename.
     560     * @see org.greenstone.gatherer.Configuration
     561     * @see org.greenstone.gatherer.Gatherer
     562     * @see org.greenstone.gatherer.collection.Collection
     563     * @see org.greenstone.gatherer.util.Utility
     564     */
    565565    public String getCollectionLog() {
    566566    return Utility.getLogDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
    567567    }
    568568    /** Constructs the absolute filename of the collection metadata directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/metadata/"
    569       * @return A <strong>String</strong> containing the filename.
    570       * @see org.greenstone.gatherer.Configuration
    571       * @see org.greenstone.gatherer.Gatherer
    572       * @see org.greenstone.gatherer.collection.Collection
    573       * @see org.greenstone.gatherer.util.Utility
    574       */
     569     * @return A <strong>String</strong> containing the filename.
     570     * @see org.greenstone.gatherer.Configuration
     571     * @see org.greenstone.gatherer.Gatherer
     572     * @see org.greenstone.gatherer.collection.Collection
     573     * @see org.greenstone.gatherer.util.Utility
     574     */
    575575    public String getCollectionMetadata() {
    576576    return Utility.getMetadataDir(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator);
     
    578578
    579579    /** This method either returns the title of the current collection, or a placeholder string of 'No Collection'.
    580       * @return A <strong>String</strong> which represents what we wish to display for a collection title.
    581       * @see org.greenstone.gatherer.collection.Collection
    582       */
     580     * @return A <strong>String</strong> which represents what we wish to display for a collection title.
     581     * @see org.greenstone.gatherer.collection.Collection
     582     */
    583583    public String getCollectionTitle() {
    584584    if(collection != null) {
     
    683683    }
    684684    /** This method when called, creates a new GShell in order to run the import.pl script.
    685       * @see org.greenstone.gatherer.Configuration
    686       * @see org.greenstone.gatherer.Gatherer
    687       * @see org.greenstone.gatherer.Message
    688       * @see org.greenstone.gatherer.gui.BuildOptions
    689       * @see org.greenstone.gatherer.shell.GShell
    690       * @see org.greenstone.gatherer.shell.GShellListener
    691       * @see org.greenstone.gatherer.shell.GShellProgressMonitor
    692       * @see org.greenstone.gatherer.util.Utility
    693       */
     685     * @see org.greenstone.gatherer.Configuration
     686     * @see org.greenstone.gatherer.Gatherer
     687     * @see org.greenstone.gatherer.Message
     688     * @see org.greenstone.gatherer.gui.BuildOptions
     689     * @see org.greenstone.gatherer.shell.GShell
     690     * @see org.greenstone.gatherer.shell.GShellListener
     691     * @see org.greenstone.gatherer.shell.GShellProgressMonitor
     692     * @see org.greenstone.gatherer.util.Utility
     693     */
    694694    public void importCollection() {
    695695    Gatherer.println("CollectionManager.importCollection()");
     
    739739    }
    740740    /** Attempts to load the given collection. Currently uses simple serialization of the collection class.
    741       * @param location The path to the collection as a <strong>String</strong>.
    742       * @see org.greenstone.gatherer.Configuration
    743       * @see org.greenstone.gatherer.Gatherer
    744       * @see org.greenstone.gatherer.Message
    745       * @see org.greenstone.gatherer.collection.Collection
    746       * @see org.greenstone.gatherer.msm.MetadataSetManager
    747       * @see org.greenstone.gatherer.msm.MSMListener
    748       * @see org.greenstone.gatherer.util.Utility
    749       */
     741     * @param location The path to the collection as a <strong>String</strong>.
     742     * @see org.greenstone.gatherer.Configuration
     743     * @see org.greenstone.gatherer.Gatherer
     744     * @see org.greenstone.gatherer.Message
     745     * @see org.greenstone.gatherer.collection.Collection
     746     * @see org.greenstone.gatherer.msm.MetadataSetManager
     747     * @see org.greenstone.gatherer.msm.MSMListener
     748     * @see org.greenstone.gatherer.util.Utility
     749     */
    750750    public boolean loadCollection(String location) {
    751751    Gatherer.println("Load Collection '" + location + "'");
     
    908908    }
    909909    /** This call is fired whenever a process within a GShell created by this class ends.
    910       * @param event A <strong>GShellEvent</strong> containing information about the GShell process.
    911       * @see org.greenstone.gatherer.Gatherer
    912       * @see org.greenstone.gatherer.gui.GUIManager
    913       * @see org.greenstone.gatherer.shell.GShell
    914       */
     910     * @param event A <strong>GShellEvent</strong> containing information about the GShell process.
     911     * @see org.greenstone.gatherer.Gatherer
     912     * @see org.greenstone.gatherer.gui.GUIManager
     913     * @see org.greenstone.gatherer.shell.GShell
     914     */
    915915    public synchronized void processComplete(GShellEvent event) {
    916916    Gatherer.println("CollectionManager.processComplete(" + event.getType() + ")");
     
    950950     * @return A <i>boolean</i> which is <i>true</i> to indicate a collection has been loaded and thus the collection is ready for editing, <i>false</i> otherwise.
    951951     */
    952    
    953952    public synchronized boolean ready() {
    954953    if(collection != null) {
     
    959958    }
    960959    }
    961    
     960
    962961    public synchronized boolean reallyReady() {
    963962    // If the closing thread is non-null we should only allow that thread to see the collection as closed.
     
    10121011    }
    10131012    /** This method associates the collection build monitor with the build monitor created in CreatePane.
    1014       * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the build monitor.
    1015       */
     1013     * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the build monitor.
     1014     */
    10161015    public void registerBuildMonitor(GShellProgressMonitor monitor) {
    10171016    build_monitor = monitor;
    10181017    }
    10191018    /** This method associates the collection copy monitor with the copy monitor created in CreatePane.
    1020       * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the copy monitor.
    1021       */
     1019     * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the copy monitor.
     1020     */
    10221021    public void registerCopyMonitor(GShellProgressMonitor monitor) {
    10231022    copy_monitor = monitor;
    10241023    }
    10251024    /** This method associates the collection import monitor with the import monitor created in CreatePane.
    1026       * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the import monitor.
    1027       */
     1025     * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the import monitor.
     1026     */
    10281027    public void registerImportMonitor(GShellProgressMonitor monitor) {
    10291028    import_monitor = monitor;
    10301029    }
    10311030    /** Remove a previously assigned special directory mapping.
    1032       * @param name The symbolic name of the special directory mapping to remove as a <strong>String</strong>.
    1033       * @return The <strong>File</strong> of the mapping removed.
    1034       */
     1031     * @param name The symbolic name of the special directory mapping to remove as a <strong>String</strong>.
     1032     * @return The <strong>File</strong> of the mapping removed.
     1033     */
    10351034    public File removeDirectoryMapping(FileNode target) {
    10361035    File file = null;
    10371036    if(ready()) {
    1038                 // Remove from collection, remembering file
     1037        // Remove from collection, remembering file
    10391038        file = collection.removeDirectoryMapping(target.toString());
    1040                 // Update tree.
     1039        // Update tree.
    10411040        FileSystemModel model = (FileSystemModel) Gatherer.g_man.collection_pane.getWorkspaceTree().getModel();
    10421041        SynchronizedTreeModelTools.removeNodeFromParent(model, target);
     
    10451044    }
    10461045    /** Used to check whether all open collections have a 'saved' state.
    1047       * @return A <i>boolean</i> which is <i>true</i> if the collection has been saved.
    1048       * @see org.greenstone.gatherer.collection.Collection
    1049       */
     1046     * @return A <i>boolean</i> which is <i>true</i> if the collection has been saved.
     1047     * @see org.greenstone.gatherer.collection.Collection
     1048     */
    10501049    public boolean saved() {
    10511050    boolean result = true;
     
    10561055    }
    10571056    /** Saves a collection by serializing it to file.
    1058       * @param close_after <i>true</i> to cause the Gatherer to close the collection once save is complete, <i>false</i> otherwise.
    1059       * @param exit_after <i>true</i> to cause the Gatherer to exit once save is complete, <i>false</i> otherwise.
    1060       * @see org.greenstone.gatherer.Gatherer
    1061       * @see org.greenstone.gatherer.Message
    1062       * @see org.greenstone.gatherer.gui.GUIManager
    1063       * @see org.greenstone.gatherer.gui.GConfigPane
    1064       * @see org.greenstone.gatherer.collection.Collection
    1065       */
     1057     * @param close_after <i>true</i> to cause the Gatherer to close the collection once save is complete, <i>false</i> otherwise.
     1058     * @param exit_after <i>true</i> to cause the Gatherer to exit once save is complete, <i>false</i> otherwise.
     1059     * @see org.greenstone.gatherer.Gatherer
     1060     * @see org.greenstone.gatherer.Message
     1061     * @see org.greenstone.gatherer.gui.GUIManager
     1062     * @see org.greenstone.gatherer.gui.GConfigPane
     1063     * @see org.greenstone.gatherer.collection.Collection
     1064     */
    10661065    public void saveCollection(boolean close_after, boolean exit_after) {
    1067         Gatherer.println("Save collection: " + collection.getName());
     1066    Gatherer.println("Save collection: " + collection.getName());
    10681067    try {
    10691068        SaveCollectionTask save_task = new SaveCollectionTask(collection, close_after, exit_after);
     
    10771076    }
    10781077    /** Saves the current collection to a new filename, then restores the original collection. Finally opens the collection copy.
    1079       * @param name The name collection name.
    1080       */
     1078     * @param name The name collection name.
     1079     */
    10811080    public void saveCollectionAs(String name) {
    10821081    // We need to do this in a separate thread so create a SaveCollectionAsTask
     
    10911090
    10921091    /** Method that is called whenever the metadata set collection changes in some way, such as the addition of a new set or the merging of two sets. We want to mark the collection so that it needs saving again.
    1093       * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
    1094       * @see org.greenstone.gatherer.collection.Collection
    1095       */
     1092     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     1093     * @see org.greenstone.gatherer.collection.Collection
     1094     */
    10961095    public void setChanged(MSMEvent event) {
    10971096    // Invalidate saved
     
    11131112    }
    11141113    /** Called whenever the value tree of an metadata element changes in some way, such as the addition of a new value. We want to mark the collection so that it needs saving again.
    1115       * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
    1116       * @see org.greenstone.gatherer.collection.Collection
    1117       */
     1114     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     1115     * @see org.greenstone.gatherer.collection.Collection
     1116     */
    11181117    public void valueChanged(MSMEvent event) {
    11191118    collection.setSaved(false);
  • trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java

    r5536 r5581  
    9494    super(Gatherer.g_man);
    9595    close_button = new JButton();
    96     Dictionary.setText(close_button, "General.Close");
     96    close_button.setMnemonic(KeyEvent.VK_C);
     97    Dictionary.setBoth(close_button, "General.Close", "General.Close_Tooltip");
    9798    confirmation = new JCheckBox();
    9899    Dictionary.setText(confirmation, "DeleteCollectionPrompt.Confirm_Delete");
    99100    details = new JTextArea();
     101    details.setEditable(false);
    100102    details.setFont(Gatherer.config.getFont("general.tooltip_font", false));
    101103    Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection");
     
    107109    list_model = new DefaultListModel();
    108110    ok_button = new JButton();
    109     Dictionary.setText(ok_button, "General.OK");
     111    ok_button.setMnemonic(KeyEvent.VK_D);
     112    Dictionary.setBoth(ok_button, "DeleteCollectionPrompt.Delete", "DeleteCollectionPrompt.Delete_Tooltip");
    110113    prompt = this;
    111114    setModal(true);
    112115    setSize(SIZE);
    113     // setTitle();
    114116    Dictionary.setText(this, "DeleteCollectionPrompt.Title");
    115117
     
    203205    }
    204206    }
    205 
    206207
    207208    /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections.
     
    364365    }
    365366}
    366 
    367 
  • trunk/gli/src/org/greenstone/gatherer/collection/Job.java

    r5564 r5581  
    196196
    197197    if(depth < 0) {
    198                 // Infinite recursion
     198        // Infinite recursion
    199199        command = command + "-r ";
    200200    }
    201201    else if (depth == 0) {
    202                 // Just this page.
     202        // Just this page.
    203203    }
    204204    else if (depth > 0) {
    205                 // Recursion to the specified depth.
     205        // Recursion to the specified depth.
    206206        command = command + "-r -l" + depth + " ";
    207207    }
     
    260260        Runtime rt = Runtime.getRuntime();
    261261        Process prcs = rt.exec(command);
    262         InputStreamReader isr =
    263         new InputStreamReader( prcs.getErrorStream() );
    264         BufferedReader br = new BufferedReader( isr );
    265                 // Capture the standard error stream and seach for two particular
    266                 // occurances.
     262        InputStreamReader isr = new InputStreamReader(prcs.getErrorStream());
     263        BufferedReader br = new BufferedReader(isr);
     264        // Capture the standard error stream and seach for two particular occurances.
    267265        String line;
    268266        boolean ignore_for_robots = false;
     
    311309            Gatherer.println("Already there.");
    312310            String new_url =
    313             line.substring(line.indexOf("`") + 1,
    314                        line.lastIndexOf("'"));
     311            line.substring(line.indexOf("`") + 1, line.lastIndexOf("'"));
    315312            // For some strange reason this won't compile
    316313            //   src/org/greenstone/gatherer/collection/Job.java:311: cannot resolve symbol
     
    340337        }
    341338        }
    342                 // Now display final message based on exit value
     339        // Now display final message based on exit value
    343340        prcs.waitFor();
    344     } catch (Exception ioe) {
    345                 //message(Utility.ERROR, ioe.toString());
     341    }
     342    catch (Exception ioe) {
     343        //message(Utility.ERROR, ioe.toString());
    346344        Gatherer.printStackTrace(ioe);
    347345    }
     
    396394
    397395    if(depth < 0) {
    398                 // Infinite recursion
     396        // Infinite recursion
    399397        args.add("-r");
    400398    }
    401399    else if (depth == 0) {
    402                 // Just this page.
     400        // Just this page.
    403401    }
    404402    else if (depth > 0) {
    405                 // Recursion to the specified depth.
     403        // Recursion to the specified depth.
    406404        args.add("-r");
    407405        args.add("-l");
     
    461459    current_url = null;
    462460    }
    463      
     461
    464462    /** Called by the WGet native code when the requested download returns
    465463     * a status code other than 200.
     
    537535    }
    538536}
    539 
    540 
    541 
    542 
  • trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionBox.java

    r5564 r5581  
    7070    // Dialog setup
    7171    this.setModal(true);
    72     this.setTitle(Dictionary.newget("SaveCollectionBox.Title"));
    7372    this.setSize(360,100);
     73    Dictionary.setText(this, "SaveCollectionBox.Title");
    7474    }
     75
    7576    /** 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 see what button the users clicked, set the appropriate result then dispose of the dialog. */
    7677    public void actionPerformed(ActionEvent event) {
     
    8687    }
    8788    }
     89
    8890    /** Destructor. */
    8991    public void destroy() {
     
    9698    rootPane = null;
    9799    }
     100
    98101    /** Displays the prompt by first building the controls, then waits for a user selection.
    99102     * @param name The name of the current collection as a <strong>String</strong>.
     
    131134    Dictionary.setBoth(cancel, "General.Cancel", "General.Cancel_Tooltip");
    132135    button_pane.add(cancel);
     136
    133137    // Center on screen.
    134138    Dimension dlgSize = getSize();
     
    137141    setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    138142    show();
     143
    139144    // Deallocate things we allocated here.
    140145    yes.removeKeyListener(key_listener);
  • trunk/gli/src/org/greenstone/gatherer/file/FileAssociation.java

    r4675 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.file;
    3738
    38  
    39 
    40 
    41 
    42 
    43 /* GPL_HEADER */
    44 package org.greenstone.gatherer.file;
    4539/**************************************************************************************
    4640 * Title:        Gatherer
  • trunk/gli/src/org/greenstone/gatherer/file/FileJob.java

    r4675 r5581  
    1 package org.greenstone.gatherer.file;
    21/**
    32 *#########################################################################
     
    2625 *########################################################################
    2726 */
     27package org.greenstone.gatherer.file;
     28
    2829import javax.swing.tree.*;
    2930import org.greenstone.gatherer.file.FileNode;
    3031import org.greenstone.gatherer.file.FileSystemModel;
    3132import org.greenstone.gatherer.util.DragComponent;
     33
    3234/** This object encapsulates all the information about a certain file movement job. This job be to create a copy of a file from one place to another, or to simply delete a file.
    3335 * @author John Thompson
     
    6163    /** An element of the job type enumeration indicating a move action. */
    6264    static final public byte MOVE   = 3;
     65
    6366    /** Constructor.
    6467     * @param id A unique identifier for this job (and others created with a single gesture) as a long.
     
    8285    if(dest != null) {
    8386        this.destination_path = new TreePath(dest.getPath());
    84                 ///ystem.err.println("Destination Path: " + destination_path);
     87        ///ystem.err.println("Destination Path: " + destination_path);
    8588    }
    8689    if(orig != null) {
    8790        this.origin_path = new TreePath(orig.getPath());
    88                 ///ystem.err.println("Origin Path: " + origin_path);
     91        ///ystem.err.println("Origin Path: " + origin_path);
    8992    }
    9093    }
     94
    9195    /** Retrieve the destination node. Watch out for stale versions by always attempting to load the node at destination_path first. */
    9296    public FileNode getDestination() {
     
    97101        destination = model.getNode(destination_path);
    98102        }
    99                 // If the above fails, a stale copy may be better than nothing.
     103        // If the above fails, a stale copy may be better than nothing.
    100104        else {
    101105        destination = (FileNode) destination_path.getLastPathComponent();
     
    104108    return destination;
    105109    }
     110
    106111    /** Retrieve the origin node. Watch out for stale versions by always attempting to load the node at origin_path first. */
    107112    public FileNode getOrigin() {
     
    112117        origin = model.getNode(origin_path);
    113118        }
    114                 // If the above fails, a stale copy may be better than nothing.
     119        // If the above fails, a stale copy may be better than nothing.
    115120        else {
    116121        origin = (FileNode) origin_path.getLastPathComponent();
     
    119124    return origin;
    120125    }
     126
    121127    /** Retrieve the id for this job. */
    122128    public long ID() {
     
    150156    if(destination != null) {
    151157        text.append(destination.getFile().getAbsolutePath());
    152     }    
     158    } 
    153159    else {
    154160        text.append("Recycle Bin");
  • trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r5564 r5581  
    7373    // If source and target are different
    7474    else {
    75         // If target is the UndoManager, we're deleting
     75        // If target is the UndoManager, we're deleting
    7676        if(target instanceof UndoManager) {
    7777        // If the source is the workspace then display an error message. Workspace is read only.
     
    8585        }
    8686        }
    87                 // Otherwise we are copying
     87        // Otherwise we are copying
    8888        else {
    8989        type = FileJob.COPY;
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r5564 r5581  
    392392    }
    393393    else {
    394                 ///ystem.err.println("No file for " + this + " - can't unmap.");
     394        ///ystem.err.println("No file for " + this + " - can't unmap.");
    395395    }
    396396    }
  • trunk/gli/src/org/greenstone/gatherer/file/FileOpenActionListener.java

    r4675 r5581  
    1 package org.greenstone.gatherer.file;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.file;
     38
    3839import java.awt.event.*;
    3940import java.io.*;
     
    4344import org.greenstone.gatherer.Gatherer;
    4445import org.greenstone.gatherer.file.FileNode;
     46
    4547/** This class listens for mouse clicks and responds to double-clicks (spawn a new application to view the selected file) and right mouse button clicks (popup menu).
    4648 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    5658    }
    5759    /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to start an external application if someone double clicks on an appropriate file record.
    58       * @param event A <strong>MouseEvent</strong> containing further information about the mouse click performed.
    59       * @see org.greenstone.gatherer.Gatherer
    60       * @see org.greenstone.gatherer.collection.FileRecord
    61       * @see org.greenstone.gatherer.tree.GTree
    62       */
     60     * @param event A <strong>MouseEvent</strong> containing further information about the mouse click performed.
     61     * @see org.greenstone.gatherer.Gatherer
     62     * @see org.greenstone.gatherer.collection.FileRecord
     63     * @see org.greenstone.gatherer.tree.GTree
     64     */
    6365    public void mouseClicked(MouseEvent event) {
    6466    ///ystem.err.println("Mouse clicked");
     
    8082    }
    8183    else {
    82                 ///ystem.err.println("Caused by tree expansion / collapse. Ignoring.");
     84        ///ystem.err.println("Caused by tree expansion / collapse. Ignoring.");
    8385        ignore = false;
    8486    }
    8587    }
    8688    /** Any implementation of TreeExpansionListener must include this method so that we can be informed when a tree node has been collapsed, thus indicating that any mouse click events about to be recieved are most likely related to this event.
    87       * @param event A <strong>TreeExpansionEvent</strong> containing information about the node collapsed.
    88       */
     89     * @param event A <strong>TreeExpansionEvent</strong> containing information about the node collapsed.
     90     */
    8991    public void treeCollapsed(TreeExpansionEvent event) {
    9092    ///ystem.err.println("Tree Collapsed");
     
    9294    }
    9395    /** Any implementation of TreeExpansionListener must include this method so that we can be informed when a tree node has been expanded, thus indicating that any mouse click events about to be recieved are most likely related to this event.
    94       * @param event A <strong>TreeExpansionEvent</strong> containing information about the node expanded.
    95       */
     96     * @param event A <strong>TreeExpansionEvent</strong> containing information about the node expanded.
     97     */
    9698    public void treeExpanded(TreeExpansionEvent event) {
    9799    ///ystem.err.println("Tree Expanded");
  • trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r5564 r5581  
    9696
    9797    /** Requeue an existing job into the queue.
    98       * @param job A previously created FileJob.
    99       */
     98     * @param job A previously created FileJob.
     99     */
    100100    synchronized public void addJob(FileJob job, int position) {
    101101    job.done = true; // Ensure that the requeued job is marked as done.
     
    647647        }
    648648        selection = null;
    649         String args[] = new String[2];
    650         args[0] = "" + file_count + "";
    651         args[1] = "" + dir_count + "";
    652         //job_status.setText(get("Selected", args));
    653         args = null;
     649        // String args[] = new String[2];
     650        // args[0] = "" + file_count + "";
     651        // args[1] = "" + dir_count + "";
     652        // job_status.setText(get("Selected", args));
     653        // args = null;
    654654    }
    655655    tree = null;
     
    661661
    662662    /** Copy a file from the source location to the destination location.
    663       * @param source The source File.
    664       * @param destination The destination File.
    665       * @see org.greenstone.gatherer.Gatherer
    666       */
     663     * @param source The source File.
     664     * @param destination The destination File.
     665     * @see org.greenstone.gatherer.Gatherer
     666     */
    667667    public void copyFile(File source, File destination, LongProgressBar progress)
    668668    throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException, WriteNotPermittedException {
     
    671671    }
    672672    else {
    673                 // Check if the origin file exists.
     673        // Check if the origin file exists.
    674674        if(!source.exists()) {
    675675        System.err.println("Couldn't find the source file.");
    676676        throw(new FileNotFoundException());
    677677        }
    678                 // Check if the destination file does not exist.
     678        // Check if the destination file does not exist.
    679679        if(destination.exists()) {
    680680        throw(new FileAlreadyExistsException());
     
    682682        File dirs = destination.getParentFile();
    683683        dirs.mkdirs();
    684                 // Copy the file.
     684        // Copy the file.
    685685        FileInputStream f_in = new FileInputStream(source);
    686686        FileOutputStream f_out = null;
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r5571 r5581  
    5353import org.greenstone.gatherer.collection.Collection;
    5454import org.greenstone.gatherer.collection.DeleteCollectionPrompt;
    55 import org.greenstone.gatherer.collection.LoadCollectionBox;
    5655import org.greenstone.gatherer.collection.SaveCollectionBox;
    5756import org.greenstone.gatherer.file.FileNode;
     
    618617        // Wait until it is closed.
    619618        try {
    620             synchronized(this) {
     619            synchronized(this) {
    621620                while(Gatherer.c_man.reallyReady()) {
    622                 wait(10);
     621                wait(10);
    623622                }
    624             }
     623            }
    625624        }
    626625        catch(Exception error) {
  • trunk/gli/src/org/greenstone/gatherer/help/HelpFrame.java

    r5525 r5581  
    3535 *########################################################################
    3636 */
    37 
    3837package org.greenstone.gatherer.help;
    3938
    40 /**
    41  * @author Michael Dewsnip, NZDL Project
    42  */
    4339import calpa.html.*;
    44 import java.awt.BorderLayout;
    45 import java.awt.Dimension;
    46 import java.awt.Toolkit;
    47 import java.io.File;
    48 import java.net.URL;
    49 import java.util.Enumeration;
    50 import javax.swing.JFrame;
    51 import javax.swing.JPanel;
    52 import javax.swing.JScrollPane;
    53 import javax.swing.JSplitPane;
    54 import javax.swing.JTree;
    55 import javax.swing.event.TreeSelectionEvent;
    56 import javax.swing.event.TreeSelectionListener;
    57 import javax.swing.tree.DefaultTreeModel;
    58 import javax.swing.tree.DefaultMutableTreeNode;
    59 import javax.swing.tree.MutableTreeNode;
    60 import javax.swing.tree.TreePath;
     40import java.awt.*;
     41import java.io.*;
     42import java.net.*;
     43import java.util.*;
     44import javax.swing.*;
     45import javax.swing.event.*;
     46import javax.swing.tree.*;
    6147import org.apache.xerces.parsers.DOMParser;
     48import org.greenstone.gatherer.Dictionary;
    6249import org.greenstone.gatherer.util.Utility;
    6350import org.w3c.dom.*;
    64 
    6551
    6652/**
    6753 * This class provides a nice help facility. It is a separate frame that can be positioned
    6854 * as the user wishes, and provides a contents page and the help information.
     55 * @author Michael Dewsnip, NZDL Project
    6956 */
    7057public class HelpFrame
     
    9178    view = new CalHTMLPane(new CalHTMLPreferences(), new Observer(), "Help Pages");
    9279
    93     HelpItem rootNode = new HelpItem("Contents", "<null>");
     80    HelpItem rootNode = new HelpItem(Dictionary.newget("Help.Contents"), "<null>");
    9481    model = new ContentsModel(rootNode);
    9582    contents = new JTree((DefaultTreeModel) model);
  • trunk/gli/src/org/greenstone/gatherer/msm/Declarations.java

    r4674 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.msm;
    3738
    38  
    39 
    40 
    41 
    42 
    43 /* GPL_HEADER */
    44 package org.greenstone.gatherer.msm;
    4539/**************************************************************************************
    4640 * Title:        Gatherer
  • trunk/gli/src/org/greenstone/gatherer/msm/ElementWrapper.java

    r5154 r5581  
    3636 */
    3737package org.greenstone.gatherer.msm;
     38
    3839/**************************************************************************************
    3940 * Title:        Gatherer
     
    4748import org.greenstone.gatherer.util.StaticStrings;
    4849import org.greenstone.gatherer.util.Utility;
    49 import org.w3c.dom.Element;
    50 import org.w3c.dom.Node;
     50import org.w3c.dom.*;
     51
    5152/** This class provides a convience wrapper around a DOM model Element to allow Components such as the MetadataTable to display this information properly.
    5253 * @author John Thompson
     
    6162    /** Constructor for elements with no namespace necessary.
    6263     * @param element The DOM <strong>Element</strong> this is to be based on.
    63       */
     64     */
    6465    public ElementWrapper(Element element) {
    6566    this.element = element;
     
    7071   
    7172    }
    72     /** Constructor.
    73       * @param element The DOM <strong>Element</strong> this is to be based on.
    74 
    75       * @param namespace_required <i>true</i> if this element wrapper should always attempt to show a namespace prefix (retrieving it from the DOM if necessary).
    76       * @deprecated
    77       */
    78     //  public ElementWrapper(Element element, boolean namespace_required) {
    79     //this(element);
    80     //  }
    8173
    8274    public void addAttribute(String name, String value) {
     
    8981
    9082    /** Create a copy of this element wrapper.
    91       * @return A new <strong>ElementWrapper</strong> based on the same element as this one.
    92       */
     83     * @return A new <strong>ElementWrapper</strong> based on the same element as this one.
     84     */
    9385    public ElementWrapper copy() {
    9486    Element element_copy = (Element) element.cloneNode(true);
     
    9688    }
    9789    /** Compare two element wrappers for ordering.
    98       * @param object An <strong>Object</strong> which is most likely another element wrapper to be compared with.
    99       * @return An <i>int</i> indicating order, -1, 0, 1 if this element wrapper is less than, equal to or greater than the given object.
    100       */
     90     * @param object An <strong>Object</strong> which is most likely another element wrapper to be compared with.
     91     * @return An <i>int</i> indicating order, -1, 0, 1 if this element wrapper is less than, equal to or greater than the given object.
     92     */
    10193    public int compareTo(Object object) {
    10294    return toString().compareTo(object.toString());
    10395    }
    10496    /** Decrement the number of occurances of this metadata element.
    105       * @see org.greenstone.gatherer.msm.MSMUtils
    106       */
     97     * @see org.greenstone.gatherer.msm.MSMUtils
     98     */
    10799    public void dec() {
    108100    MSMUtils.setOccurance(element, -1);
    109101    }
    110102    /** Test if two ElementWrappers are equal.
    111       * @param object The <strong>Object</strong> to test against.
    112       */
     103     * @param object The <strong>Object</strong> to test against.
     104     */
    113105    public boolean equals(Object object) {
    114106    if(object instanceof ElementWrapper) {
     
    120112    }
    121113    /** Retrieve the attributes associated with the element this element wrapper is built around.
    122       * @return A <strong>TreeSet</strong> of the attributes.
    123       * @see org.greenstone.gatherer.msm.MSMUtils
    124       */
     114     * @return A <strong>TreeSet</strong> of the attributes.
     115     * @see org.greenstone.gatherer.msm.MSMUtils
     116     */
    125117    public TreeSet getAttributes() {
    126118    return MSMUtils.getAttributes(element);
    127119    }
    128120    /** Retrieve the element this is wrapped around.
    129       * @return A DOM <strong>Element</strong> which represents a metadata element.
    130       */
     121     * @return A DOM <strong>Element</strong> which represents a metadata element.
     122     */
    131123    public Element getElement() {
    132124    return element;
    133125    }
    134126    /** Retrieve the identity of this element (not necessary the same as this elements name). Identity is language and locale dependant.
    135       * @return The identity as a <strong>String</strong>.
    136       * @see org.greenstone.gatherer.msm.MSMUtils
    137       */
     127     * @return The identity as a <strong>String</strong>.
     128     * @see org.greenstone.gatherer.msm.MSMUtils
     129     */
    138130    public String getIdentity() {
    139131    return MSMUtils.getIdentifier(element);
    140132    }
    141133    /** Retrieve the name of this element. Name is unique.
    142       * @return The name as a <strong>String</strong>.
    143       * @see org.greenstone.gatherer.msm.MSMUtils
    144       */
     134     * @return The name as a <strong>String</strong>.
     135     * @see org.greenstone.gatherer.msm.MSMUtils
     136     */
    145137    public String getName() {
    146138    return MSMUtils.getFullName(element, namespace);
    147139    }
    148140    /** Retrieve the namespace prefix for this element wrapper.
    149       * @return A <strong>String</strong> containing the namespace or "" if there is no namespace for this element.
    150       * @see org.greenstone.gatherer.msm.MSMUtils
    151       */
     141     * @return A <strong>String</strong> containing the namespace or "" if there is no namespace for this element.
     142     * @see org.greenstone.gatherer.msm.MSMUtils
     143     */
    152144    public String getNamespace() {
    153145    if (!namespace.equals("")) {
     
    164156    }
    165157    /** Look for the occurances 'field' of the element and return it if found.
    166       * @return An <i>int</i> which matches the number in the occurances attribute of the element, or 0 if no such attribute.
    167       * @see org.greenstone.gatherer.msm.MSMUtils
    168       */
     158     * @return An <i>int</i> which matches the number in the occurances attribute of the element, or 0 if no such attribute.
     159     * @see org.greenstone.gatherer.msm.MSMUtils
     160     */
    169161    public int getOccurances() {
    170162    return MSMUtils.getOccurances(element);
    171163    }
    172164    /** This method is essentially the same as getDescription() in that it does indeed return this metaelements description. However this method uses the Utility function formatHTMLWidth() to ensure the String can be displayed in a tool-tip window using html markup.
    173       * @return A String containing the HTML formatted versions of definition and content (comment).
    174       * @see org.greenstone.gatherer.msm.MSMUtils
    175       * @see org.greenstone.gatherer.util.Utility
    176       */
     165     * @return A String containing the HTML formatted versions of definition and content (comment).
     166     * @see org.greenstone.gatherer.msm.MSMUtils
     167     * @see org.greenstone.gatherer.util.Utility
     168     */
    177169    public String getToolTip() {
    178170    // Add HTML formatting
     
    194186    return element.getAttribute(StaticStrings.HIERARCHY_ATTRIBUTE).equalsIgnoreCase(StaticStrings.TRUE_STR);
    195187    }
    196 
    197188
    198189    /** Removes an Attribute node from the element. */
     
    217208    }
    218209
    219 
    220     /** Set the value of the namespace required flag.
    221       * @param namespace_required The new value as a <i>boolean</i>.
    222       * @see org.greenstone.gatherer.msm.MSMUtils
    223       * @deprecated
    224       */
    225     public void setNamespaceRequired(boolean namespace_required) {
    226     }
    227210    public String toString() {
    228211    return MSMUtils.getFullIdentifier(element, namespace);
  • trunk/gli/src/org/greenstone/gatherer/msm/ExistingMetadataLoader.java

    r4674 r5581  
    1 package org.greenstone.gatherer.msm;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.msm;
     38
    3839import java.io.*;
    3940import java.util.*;
  • trunk/gli/src/org/greenstone/gatherer/msm/ExportMDSPrompt.java

    r5564 r5581  
    101101    if(export) {
    102102        setSize(EXPORT_SIZE);
     103        setJMenuBar(new SimpleMenuBar("selectingmetadatasets"));
    103104        Dictionary.setText(this, "MSMPrompt.Export_Title");
     105    }
     106    else {
     107        setSize(IMPORT_SIZE);
    104108        setJMenuBar(new SimpleMenuBar("selectingmetadatasets"));
    105     }
    106     else {
    107         setSize(IMPORT_SIZE);
    108109        Dictionary.setText(this, "MSMPrompt.Import_Title");
    109         setJMenuBar(new SimpleMenuBar("selectingmetadatasets"));
    110110    }
    111111    JPanel content_pane = (JPanel) getContentPane();
  • trunk/gli/src/org/greenstone/gatherer/msm/GDMManager.java

    r5164 r5581  
    4949import org.greenstone.gatherer.util.HashMap3D;
    5050import org.greenstone.gatherer.util.Utility;
    51 import org.greenstone.gatherer.valuetree.GValueModel;
    52 import org.greenstone.gatherer.valuetree.GValueNode;
     51// import org.greenstone.gatherer.valuetree.GValueNode;
    5352import org.w3c.dom.*;
    5453/** This object manages the metadata attached to file records. By storing all of the metadata in one place you garner several advantages. Firstly only one copy of each metadata object is retained, all actual entries are converted to references. Next you can immediately determine what metadata is assigned to an entire directory, thus the metadata.xml files can be built more effeciently (whereas the current 'optimal' method uses recursion through the tree contents). Finally, and perhaps most importantly, it allows for dynamic 'on demand' lookup of metadata. This is especially necessary with large collections, where the raw, unconnected metadata files could range into the tens of megabytes of memory and require hundreds of megabytes to read by in using serialization. Dynamic loading allows you to connect the metadata objects on load, reducing value node paths (possibly of hundreds of characters) down to a single reference pointer! At the very worst this object uses far less memory than the current method, and given that the current method is completely incapable of handling large collections, is necessary. The trade off of course is in time needed to load metadata.xml on demand, the worst possible case being the user selecting the root node of the collection tree of a large collection immediately after opening the collection. The subsequent attempt to build the metadata table will result in the metadata being loaded for every single file. But since this process is sequential and a small cache of metadata.xml files is implemented, and given that the table will actually be build on a separate thread, the wait should not be too arduous.<BR>
  • trunk/gli/src/org/greenstone/gatherer/msm/MetadataSet.java

    r5564 r5581  
    185185    public ElementWrapper addElement(String name) {
    186186    Text text = document.createTextNode(name);
    187     Element identifier = document.createElementNS("","Attribute");
    188     identifier.setAttribute("name","identifier");
    189     identifier.appendChild(text);
    190     Element element = document.createElementNS("","Element");
    191     element.setAttribute("name",name);
    192     element.appendChild(identifier);
    193     root.appendChild(element);
    194     ElementWrapper wrapper = new ElementWrapper(element);
    195     ///ystem.err.println("Added a new element " + wrapper);
    196     return wrapper;
     187    Element identifier = document.createElementNS("","Attribute");
     188    identifier.setAttribute("name","identifier");
     189    identifier.appendChild(text);
     190    Element element = document.createElementNS("","Element");
     191    element.setAttribute("name",name);
     192    element.appendChild(identifier);
     193    root.appendChild(element);
     194    ElementWrapper wrapper = new ElementWrapper(element);
     195    ///ystem.err.println("Added a new element " + wrapper);
     196    return wrapper;
    197197    }
    198198
  • trunk/gli/src/org/greenstone/gatherer/msm/parsers/GreenstoneMetadataParser.java

    r5153 r5581  
    4646import org.greenstone.gatherer.msm.MetadataParser;
    4747import org.greenstone.gatherer.msm.MSMUtils;
    48 import org.greenstone.gatherer.util.DecodeHTMLReader;
    4948import org.greenstone.gatherer.util.StaticStrings;
    5049import org.greenstone.gatherer.util.Utility;
     
    827826            try {
    828827            FileReader in_filereader = new FileReader((File)target);
    829             //DecodeHTMLReader in_decodehtmlreader = new DecodeHTMLReader(in_filereader);
    830828            BufferedReader in = new BufferedReader(in_filereader);
    831829            String line = null;
     
    851849            in.close();
    852850            in = null;
    853             //in_decodehtmlreader = null;
    854851            in_filereader = null;
    855852            hfiles.put(element, result);
  • trunk/gli/src/org/greenstone/gatherer/shell/GBasicProgressMonitor.java

    r5034 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.shell;
    3738
    38  
    39 
    40 
    41 
    42 
    43 package org.greenstone.gatherer.shell;
    4439/** Title:        The Gatherer<br>
    4540 *  Description:  The Gatherer: a tool for gathering and enriching digital collections.<br>
     
    5146 *  @author John Thompson, Greenstone Digital Libraries
    5247 *  @version 2.1 */
     48
    5349import java.awt.Component;
    54 import javax.swing.ImageIcon;
    55 import javax.swing.JLabel;
    5650import javax.swing.JProgressBar;
    5751import org.greenstone.gatherer.shell.GShellProgressMonitor;
    58 import org.greenstone.gatherer.util.Utility;
     52
    5953/** This is the most basic implementation of <i>GShellProgressMonitor</i> in that it doesn't even attempt to parse the process messages. Instead it has one graphic which is displayed once the start() method is called, and another which appears after the stop().
    6054 */
     
    6761    public GBasicProgressMonitor() {
    6862    super();
    69     //this.setIcon(ready);
    7063    }
    7164    /** Don't do anything if we are given a progress bar, we have our own.
    72       * @param progress_bar A JProgressBar
    73       */
     65     * @param progress_bar A JProgressBar
     66     */
    7467    public void addProgressBar(JProgressBar progress_bar) {
    7568    }
    7669    /** Determine the script exit value according to the progress monitor. This gets around a problem where several script failures actually result with a successful exit value.
    77       * @return A <i>int</i> with a value of zero if and only if the script was successful.
    78       */
     70     * @return A <i>int</i> with a value of zero if and only if the script was successful.
     71     */
    7972    public int exitValue() {
    8073    // Always return true as we don't know any better.
     
    8275    }
    8376    /** As we are probably accessing this via an interface we need to gain
    84       * access to the component itself.
    85       */
     77     * access to the component itself.
     78     */
    8679    public Component getProgress() {
    8780    return this;
    8881    }
    8982    /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
    90       * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
    91       */
     83     * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
     84     */
    9285    public boolean hasSignalledStop() {
    9386    return stop;
     
    9891    }
    9992    /** The parse method is how more complex progress bars figure out how far they have progressed. However we don't.
    100       * @param line A String representing the latest line of output from
    101       * the external process we are monitoring.
    102       */
     93     * @param line A String representing the latest line of output from
     94     * the external process we are monitoring.
     95     */
    10396    public void parse(String line) {
    10497    }
     
    108101
    109102    /** Since the creator of this process monitor is actually in the GUI, this class provides the simpliest way to send a cancel process message between the two.
    110       * @param state The desired state of the stop flag as a <strong>boolean</strong>.
    111       */
     103     * @param state The desired state of the stop flag as a <strong>boolean</strong>.
     104     */
    112105    public void setStop(boolean state) {
    113106    stop = state;
    114107    }
    115108    /** This method tells this class that the job it is showing the progress
    116       * for has begun.
    117       */
     109     * for has begun.
     110     */
    118111    public void start() {
    119     //this.setIcon(busy);
    120112    setIndeterminate(true);
    121113    }
    122114    /** This method tells this class that the job it is showing the progress
    123       * for has come to an end.
    124       */
     115     * for has come to an end.
     116     */
    125117    public void stop() {
    126     //this.setIcon(ready);
    127118    setIndeterminate(false);
    128119    }
  • trunk/gli/src/org/greenstone/gatherer/shell/GBuildProgressMonitor.java

    r5034 r5581  
    1 package org.greenstone.gatherer.shell;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.shell;
     38
    3839import java.awt.Component;
    3940import javax.swing.JProgressBar;
     
    5859    private int state = 0;
    5960
    60     /** The progress bar this monitor updates. */
     61    /** The progress bar this monitor updates. */
    6162    private JProgressBar progress_bar;
    6263
     
    106107
    107108    /** Method to register a new progress bar with this monitor.
    108       * @param progress_bar The new <strong>JProgressBar</strong>.
    109       */     
     109     * @param progress_bar The new <strong>JProgressBar</strong>.
     110     */ 
    110111    public void addProgressBar(JProgressBar progress_bar) {
    111112    this.progress_bar = progress_bar;
     
    114115    progress_bar.setValue(MIN);
    115116    }
     117
    116118    /** Determine the script exit value according to the progress monitor. This gets around a problem where several script failures actually result with a successful exit value.
    117       * @return A <i>int</i> with a value of zero if and only if the script was successful.
    118       */
     119     * @return A <i>int</i> with a value of zero if and only if the script was successful.
     120     */
    119121    public int exitValue() {
    120122    if(state == BASE) {
     
    124126    }
    125127    /** Method to retrieve whatever control is being used as the progress indicator. Usually a <strong>JProgressBar</strong> but there may be others implemented later.
    126       * @return A <strong>Component</strong> on which the progress of the process is being displayed.
    127       */
     128     * @return A <strong>Component</strong> on which the progress of the process is being displayed.
     129     */
    128130    public Component getProgress() {
    129131    return progress_bar;
    130132    }
    131133    /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
    132       * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
    133       */
     134     * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
     135     */
    134136    public boolean hasSignalledStop() {
    135137    return stop;
     
    141143
    142144    /** This method is used to 'feed in' a line of text captured from the process.
    143       * @param line A <strong>String</strong> of text captured from either standard out or standard error.
    144       */
     145     * @param line A <strong>String</strong> of text captured from either standard out or standard error.
     146     */
    145147    public void parse(String raw_line) {
    146148    String line = raw_line.toLowerCase();
     
    289291    }
    290292    else {
    291                 ///ystem.err.println("Number of documents = " + num_docs);
    292                 ///ystem.err.println("Number of indexes = " + num_indexes);
     293        ///ystem.err.println("Number of documents = " + num_docs);
     294        ///ystem.err.println("Number of indexes = " + num_indexes);
    293295        progress_bar.setIndeterminate(true);
    294296    }
     
    308310
    309311    /** Since the creator of this process monitor is actually in the GUI, this class provides the simpliest way to send a cancel process message between the two.
    310       * @param state The desired state of the stop flag as a <strong>boolean</strong>.
    311       */
     312     * @param state The desired state of the stop flag as a <strong>boolean</strong>.
     313     */
    312314    public void setStop(boolean state) {
    313315    stop = state;
     
    315317    }
    316318    /** This method resets this monitor to the start, reseting the process parsing and progress bar.
    317       * TODO Everthing.
    318       */
     319     * TODO Everthing.
     320     */
    319321    public void start() {
    320322    progress_bar.setValue(MIN);
     
    323325    }
    324326    /** This method indicates the process is complete.
    325       * TODO Everthing.
    326       */
     327     * TODO Everthing.
     328     */
    327329    public void stop() {
    328330    progress_bar.setIndeterminate(false);
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r5564 r5581  
    4646import org.greenstone.gatherer.shell.GShellListener;
    4747import org.greenstone.gatherer.shell.GShellProgressMonitor;
    48 import org.greenstone.gatherer.util.StaticStrings;
     48
    4949/** The <strong>GShell</strong> is reponsible for running a separately threaded process in the command shell. This is necessary for executing the Perl Scripts and also for other system related funcitonality.
    5050 */
     
    179179        if(stdinline != null) {
    180180            fireMessage(type, typeAsString(type) + "> " + stdinline, status);
    181            
    182181        }
    183182        }
     
    190189            status = OK;
    191190            fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Success"), status);
    192            
    193         } else {
     191        }
     192        else {
    194193            status = ERROR;
    195194            fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Failure"), status);
    196            
    197195        }
    198196        }
  • trunk/gli/src/org/greenstone/gatherer/shell/GShellEvent.java

    r4364 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.shell;
    3738
    38  
    39 
    40 
    41 
    42 
    43 package org.greenstone.gatherer.shell;
    4439/** Title:        The Gatherer<br>
    4540 * Description:  The Gatherer: a tool for gathering and enriching digital collections.<br>
     
    5247 * @version 2.1 */
    5348import java.awt.AWTEvent;
     49
    5450/** This class encapsulates all the information created by an event within a <strong>GShell</strong> process. */
    5551public class GShellEvent
     
    6157    /** Any message associated with this event. */
    6258    private String message = null;
     59
    6360    /* Constructor.
    6461     * @param source The <strong>GShell</strong> that fired this message.
     
    6764     * @param message A <strong>String</strong> representing any message attatched with this event.
    6865     * @param status The status of the process post event, as an <strong>int</strong>.
    69       */
    70     public GShellEvent(Object source, int id, int type, String message,
    71                int status) {
     66     */
     67    public GShellEvent(Object source, int id, int type, String message, int status) {
    7268    super(source, id);
    7369    this.message = message;
     
    7571    this.type = type;
    7672    }
     73
    7774    /** Gets the message associated with this event.
    78       * @return The message as a <strong>String</strong> or <i>null</i>.
    79       */
     75     * @return The message as a <strong>String</strong> or <i>null</i>.
     76     */
    8077    public String getMessage() {
    8178    return message;
    8279    }
     80
    8381    /** Gets the status associated with this event. This status can then be matched back to the constants in <strong>GShell</strong>.
    84       * @return An <strong>int</strong> signifying the process status.
    85       */
     82     * @return An <strong>int</strong> signifying the process status.
     83     */
    8684    public int getStatus() {
    8785    return status;
    8886    }
     87
    8988    /** Gets the type associated with this event. This type can then be matched back to the constants in <strong>GShell</strong>.
    90       * @return An <strong>int</strong> signifying the process type.
    91       */
     89     * @return An <strong>int</strong> signifying the process type.
     90     */
    9291    public int getType() {
    9392    return type;
  • trunk/gli/src/org/greenstone/gatherer/shell/GShellListener.java

    r5571 r5581  
    4949 */
    5050import java.util.EventListener;
     51
    5152/** This interface details the methods required of a class that wishes to listen to a <strong>GShell</strong>.
    5253 */
     
    5556    /** All implementation of <i>GShellListener</i> must include this method so the listener can be informed of messages from the <strong>GShell</strong>.
    5657     * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
    57       */
     58     */
    5859    public void message(GShellEvent event);
     60
    5961    /** All implementation of <i>GShellListener</i> must include this method so the listener can be informed when a <strong>GShell</strong> begins its task.
    60       * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
    61       */
     62     * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
     63     */
    6264    public void processBegun(GShellEvent event);
     65
    6366    /** All implementation of <i>GShellListener</i> must include this method so the listener can be informed when a <strong>GShell</strong> completes its task.
    64       * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
    65       */
     67     * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
     68     */
    6669    public void processComplete(GShellEvent event);
    6770}
  • trunk/gli/src/org/greenstone/gatherer/shell/GShellProgressMonitor.java

    r5034 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.shell;
    3738
    38  
    39 
    40 
    41 
    42 
    43 package org.greenstone.gatherer.shell;
    4439/**
    4540 * Title:        The Gatherer<br>
     
    5550import java.awt.Component;
    5651import javax.swing.JProgressBar;
     52
    5753/** When implemented, this interface allows another class to monitor the progress of a <strong>GShell</strong> process. Specifically implementing classes should be designed to take the textual output from the process and then translate that message into some quanitive measure of progress which can then be shown on the progress bar.
    5854 */
     
    6258     */
    6359    public void addProgressBar(JProgressBar progress_bar);
     60
    6461    /** Determine the script exit value according to the progress monitor. This gets around a problem where several script failures actually result with a successful exit value.
    6562     * @return A <i>int</i> with a value of zero if and only if the script was successful.
    6663     */
    6764    public int exitValue();
     65
    6866    /** Method to retrieve whatever control is being used as the progress indicator. Usually a <strong>JProgressBar</strong> but there may be others implemented later.
    6967     * @return A <strong>Component</strong> on which the progress of the process is being displayed.
    7068     */
    7169    public Component getProgress();
     70
    7271    /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
    7372     * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
     
    7776    /** Inform the progress bar that it should programatically increment progress by one step. */
    7877    public void increment();
     78
    7979    /** This method is used to 'feed in' a line of text captured from the process.
    8080     * @param line A <strong>String</strong> of text captured from either standard out or standard error.
     
    8888     */
    8989    public void setStop(boolean state);
     90
    9091    /** This method resets this monitor to the start, reseting the process parsing and progress bar.
    9192     */
    9293    public void start();
     94
    9395    /** This method indicates the process is complete.
    9496     */
  • trunk/gli/src/org/greenstone/gatherer/undo/UndoManager.java

    r4686 r5581  
    1 package org.greenstone.gatherer.undo;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.undo;
     38
    3839import java.awt.*;
    3940import java.awt.datatransfer.Transferable;
     
    119120        UndoJob undo_job = undo.pop();
    120121        undo_job.action(true, file_queue);
    121                 // Now retrieve all other undo jobs with the same job-number and action them
     122        // Now retrieve all other undo jobs with the same job-number and action them
    122123        while((undo_job = undo.getJob(undo_job.ID())) != null) {
    123124        undo_job.action(true, file_queue);
     
    128129        UndoJob redo_job = redo.pop();
    129130        redo_job.action(false, file_queue);
    130                 // Now retrieve all other redo jobs with the same job-number and action them
     131        // Now retrieve all other redo jobs with the same job-number and action them
    131132        while((redo_job = redo.getJob(redo_job.ID())) != null) {
    132133        redo_job.action(false, file_queue);
     
    138139    for(int i = 0; metadatum != null && i < metadatum.size(); i++) {
    139140        Metadata metadata = (Metadata) metadatum.get(i);
    140                 ///ystem.err.println("UndoMetadata: " + file.getAbsolutePath() + " => " + metadata);
     141        ///ystem.err.println("UndoMetadata: " + file.getAbsolutePath() + " => " + metadata);
    141142        String file_path = file.getAbsolutePath().replace('\\', '/');
    142143        obsolete_metadata.addMetadata(file_path, metadata);
     
    203204    pt_last = pt;
    204205    if(!DragSource.isDragImageSupported()) {
    205                 // Erase the last ghost image and or cue line
     206        // Erase the last ghost image and or cue line
    206207        paintImmediately(ra_ghost.getBounds());
    207                 // Remember where you are about to draw the new ghost image
     208        // Remember where you are about to draw the new ghost image
    208209        ra_ghost.setRect(pt.x - group.mouse_offset.x, pt.y - group.mouse_offset.y, group.image_ghost.getWidth(), group.image_ghost.getHeight());
    209                 // Draw the ghost image
     210        // Draw the ghost image
    210211        g2.drawImage(group.image_ghost, AffineTransform.getTranslateInstance(ra_ghost.getX(), ra_ghost.getY()), null);
    211212    }
     
    226227        source_nodes[i] = (FileNode) selection[i].getLastPathComponent();
    227228        }
    228                 ///ystem.err.println("Dropped files vector contains " + new_files.size() + " files.");
     229        ///ystem.err.println("Dropped files vector contains " + new_files.size() + " files.");
    229230        event.acceptDrop(drag_action);
    230                 // Action delete
     231        // Action delete
    231232        Gatherer.f_man.action(source, source_nodes, this, null);
    232233        group.setSource(null);
     
    251252    UndoJob job = new UndoJob(id, null, null, target_model, record, FILE_COPY);
    252253    if(undo_event) {
    253                 ///ystem.err.println("Add undo job");
     254        ///ystem.err.println("Add undo job");
    254255        undo.push(job);
    255256    }
    256257    else {
    257                 ///ystem.err.println("Add redo job");
     258        ///ystem.err.println("Add redo job");
    258259        redo.push(job);
    259260    }
     
    263264    UndoJob job = new UndoJob(id, source_model, source_parent, this, record, FILE_DELETE);
    264265    if(undo_event) {
    265                 ///ystem.err.println("Add undo job");
     266        ///ystem.err.println("Add undo job");
    266267        undo.push(job);
    267268    }
    268269    else {
    269                 ///ystem.err.println("Add redo job");
     270        ///ystem.err.println("Add redo job");
    270271        redo.push(job);
    271272    }
     
    276277    UndoJob job = new UndoJob(id, source_model, source_parent, target_model, record, FILE_MOVE);
    277278    if(undo_event) {
    278                 ///ystem.err.println("Add undo job");
     279        ///ystem.err.println("Add undo job");
    279280        undo.push(job);
    280281    }
    281282    else {
    282                 ///ystem.err.println("Add redo job");
     283        ///ystem.err.println("Add redo job");
    283284        redo.push(job);
    284285    }
     
    330331    while((undo_job = undo.pop()) != null) {
    331332        undo_job.action(true, immediate_queue);
    332                 // Now retrieve all other undo jobs with the same job-number and action them
     333        // Now retrieve all other undo jobs with the same job-number and action them
    333334        while((undo_job = undo.getJob(undo_job.ID())) != null) {
    334335        undo_job.action(true, immediate_queue);
     
    394395
    395396    public void action(boolean is_undo, FileQueue file_queue) {
    396                 // Retrieve the lastest version of each file record
     397        // Retrieve the lastest version of each file record
    397398        FileNode latest_record = null;
    398399        FileNode latest_source_parent = null;
     
    405406        latest_source_parent = ((FileSystemModel)source_model.getTreeModel()).getNode(source_parent_path);
    406407        }
    407                 // Of course if there are no newer versions, stick to the ones we've already got.
     408        // Of course if there are no newer versions, stick to the ones we've already got.
    408409        if(latest_record == null) {
    409410        ///ystem.err.println("Using original record.");
  • trunk/gli/src/org/greenstone/gatherer/util/ApplyXSLT.java

    r5564 r5581  
    2020package org.greenstone.gatherer.util;
    2121
    22 // General Java classes
    23 import java.io.StringReader;
    24 import java.io.StringWriter;
    25 import java.io.File;
    26 
    27 // XML classes
     22import java.io.*;
    2823import javax.xml.transform.Transformer;
    2924import javax.xml.transform.TransformerFactory;
     
    7267    }
    7368}
    74 
    75  
  • trunk/gli/src/org/greenstone/gatherer/util/ArrayTools.java

    r4388 r5581  
    11/* GPL_HEADER */
    22package org.greenstone.gatherer.util;
     3
    34/**************************************************************************************
    45 * Title:        Gatherer
     
    1516import org.greenstone.gatherer.msm.Metadata;
    1617import org.w3c.dom.*;
     18
    1719/** This utility class contains a series of static methods for common array type manipulations including appending, casting and changing between containers.
    1820 * @author John Thompson
  • trunk/gli/src/org/greenstone/gatherer/util/DefaultSynchronizedTreeNode.java

    r4674 r5581  
    66
    77public class DefaultSynchronizedTreeNode
    8     extends DefaultMutableTreeNode
    9     implements SynchronizedTreeNode {
     8    extends DefaultMutableTreeNode
     9    implements SynchronizedTreeNode {
    1010
    11     private String text = null;
     11    private String text = null;
    1212
    13     DefaultSynchronizedTreeNode(Object userObject) {
    14         super(userObject);
     13    DefaultSynchronizedTreeNode(Object userObject) {
     14    super(userObject);
     15    }
     16
     17    public SynchronizedTreeNode cloneNode() {
     18    // Create new node with same userObject
     19    SynchronizedTreeNode new_node = new DefaultSynchronizedTreeNode(userObject);
     20    // Clone and add children.
     21    for(int i = 0; i < getChildCount(); i++) {
     22        SynchronizedTreeNode child = (SynchronizedTreeNode) getChildAt(i);
     23        new_node.insert(child.cloneNode(), i);
    1524    }
     25    return new_node;
     26    }
    1627
    17     public SynchronizedTreeNode cloneNode() {
    18         // Create new node with same userObject
    19         SynchronizedTreeNode new_node = new DefaultSynchronizedTreeNode(userObject);
    20         // Clone and add children.
    21         for(int i = 0; i < getChildCount(); i++) {
    22             SynchronizedTreeNode child = (SynchronizedTreeNode) getChildAt(i);
    23             new_node.insert(child.cloneNode(), i);
    24         }
    25         return new_node;
     28    public int compareTo(Object other) {
     29    if(text == null) {
     30        text = userObject.toString();
    2631    }
     32    return text.compareTo(other.toString());
     33    }
    2734
    28     public int compareTo(Object other) {
    29         if(text == null) {
    30             text = userObject.toString();
    31         }
    32         return text.compareTo(other.toString());
     35    public boolean equals(Object other) {
     36    if(text == null) {
     37        text = userObject.toString();
    3338    }
     39    return text.equals(other.toString());
     40    }
    3441
    35     public boolean equals(Object other) {
    36         if(text == null) {
    37             text = userObject.toString();
    38         }
    39         return text.equals(other.toString());
     42    public String toString() {
     43    if(text == null) {
     44        text = userObject.toString();
    4045    }
    41 
    42     public String toString() {
    43         if(text == null) {
    44             text = userObject.toString();
    45         }
    46         return text;
    47     }
     46    return text;
     47    }
    4848}
  • trunk/gli/src/org/greenstone/gatherer/util/DragGroup.java

    r4686 r5581  
    7979
    8080    /** Register a DragComponent as begin part of this group.
    81       * @param component The DragComponent to add.
    82       */
     81     * @param component The DragComponent to add.
     82     */
    8383    public void add(DragComponent component) {
    8484    if(!registered.contains(component)) {
     
    9999    }         
    100100    /** Determines the current 'active' component, ie that component with focus.
    101       * @return The DragComponent which is currently responsible for drawing the ghost, and thus is active.
    102       */
     101     * @return The DragComponent which is currently responsible for drawing the ghost, and thus is active.
     102     */
    103103    public DragComponent getActive() {
    104104    return ghost_owner;
    105105    }
    106106    /** Retrieve the nodes selected at the beginning of this drag operation.
    107       * @return A TreePath[].
    108       */
     107     * @return A TreePath[].
     108     */
    109109    public TreePath[] getSelection() {
    110110    return selection;
    111111    }
    112112    /** Retrieve the component which served as the source of this drag action.
    113       * @return The DragComponent in question.
    114       */
     113     * @return The DragComponent in question.
     114     */
    115115    public DragTree getSource() {
    116116    return drag_source;
    117117    }
    118118    /** When called this method asserts that one of the registered GComponents just became the proud owner of focus, and is henceforth responsible for drawing the ghost, and acting like a component thats in focus.
    119       * @param new_owner The DragComponent that has gained focus during a drag action.
    120       */
     119     * @param new_owner The DragComponent that has gained focus during a drag action.
     120     */
    121121    public void grabFocus(DragComponent new_owner) {
    122122    // Tell the previous owner of ghost to clear itself.
     
    138138    }
    139139    /** Sets the value of selected_nodes.
    140       * @param selection The new value for selected_nodes as a TreePath[].
    141       */
     140     * @param selection The new value for selected_nodes as a TreePath[].
     141     */
    142142    public void setSelection(TreePath[] selection) {
    143143    this.selection = selection;
    144144    }
    145145    /** Sets the value of drag_source.
    146       * @param drag_source The new value for drag_source as a DragTree.
    147       */
     146     * @param drag_source The new value for drag_source as a DragTree.
     147     */
    148148    public void setSource(DragTree drag_source) {
    149149    this.drag_source = drag_source;
  • trunk/gli/src/org/greenstone/gatherer/util/ExclusiveListSelectionListener.java

    r4674 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.util;
    3738
    38  
    39 
    40 
    41 
    42 
    43 /* GPL_HEADER */
    44 package org.greenstone.gatherer.util;
    4539/**************************************************************************************
    4640 * Title:        Gatherer
     
    6559    /** Method to register a new JList with this listener.
    6660     * @param list The new <strong>JList</strong> to register.
    67       */
     61     */
    6862    public void add(JList list) {
    6963    list.addListSelectionListener(this);
     
    8074    }
    8175    /** Any implementation of ListSelectionListener must include this method so we can be informed when the selection changes. In this case we want to clear the selections of all other registered JLists other than the caller.
    82       * @param event A <strong>ListSelectionEvent</strong> containing informaiton about the event.
    83       */
     76     * @param event A <strong>ListSelectionEvent</strong> containing informaiton about the event.
     77     */
    8478    public void valueChanged(ListSelectionEvent event) {
    8579    if(!ignore) {
  • trunk/gli/src/org/greenstone/gatherer/util/GURL.java

    r5326 r5581  
    3535 *########################################################################
    3636 */
    37 
    38  
    39 
    40 
    41 
    42 
    4337package org.greenstone.gatherer.util;
    4438
    45 import java.io.File;
    46 import java.io.Serializable;
    47 
    48 import java.lang.Cloneable;
    49 
    50 import java.net.MalformedURLException;
    51 import java.net.URL;
    52 
    53 import java.util.Vector;
    54 
    55 import javax.swing.JProgressBar;
     39import java.io.*;
     40import java.lang.*;
     41import java.net.*;
     42import java.util.*;
    5643
    5744/**
     
    11097    }
    11198    catch (MalformedURLException e) {
    112                 // Fix it
     99        // Fix it
    113100    }
    114101    }
     
    176163    private String parseFile(String raw) {
    177164    if(raw != null && !raw.equals("")) {
    178                 // Remove everything upto and including the last '/'
     165        // Remove everything upto and including the last '/'
    179166        if(raw.indexOf("/") != -1) {
    180167        return raw.substring(raw.lastIndexOf("/") + 1);
     
    186173    private String parsePath(String raw) {
    187174    if(raw != null && !raw.equals("")) {
    188                 // Remove everything after the last "/"
     175        // Remove everything after the last "/"
    189176        if(raw.indexOf("/") != -1) {
    190177        return raw.substring(0, raw.lastIndexOf("/"));
  • trunk/gli/src/org/greenstone/gatherer/util/HTMLStringTokenizer.java

    r4674 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.util;
    3738
    38  
    39 
    40 
    41 
    42 
    43 package org.greenstone.gatherer.util;
    4439/**
    4540 * Title:        The Gatherer<br>
     
    5045 * @version 2.1
    5146 */
    52 import java.util.Stack;
    5347import org.greenstone.gatherer.util.Utility;
     48
    5449/** This class functions much like a <strong>StringTokenizer</strong> in that it tokenizes a long string into tokens, however this tokenizer cleverly notices HTML formatting tags. */
    5550public class HTMLStringTokenizer {
     
    6459    /** Constructor.
    6560     * @param source The source <strong>String</strong> to be tokenized.
    66       */
     61     */
    6762    public HTMLStringTokenizer(String source) {
    6863    this.source = source;
     
    7166    }
    7267    /** Determines if there are still tokens remaining unparsed in the source.
    73       * @return A <strong>boolean</strong> which is <i>true</i> if there are more tokens.
    74       */
     68     * @return A <strong>boolean</strong> which is <i>true</i> if there are more tokens.
     69     */
    7570    public boolean hasMoreTokens() {
    7671    if(current != null && current.length() > 0) {
     
    8075    }
    8176    /** Determines if the tag currently being returned by sameToken is a tag.
    82       * @return A <strong>boolean</strong> indicating if the token is a tag.
    83       */
     77     * @return A <strong>boolean</strong> indicating if the token is a tag.
     78     */
    8479    public boolean isTag() {
    8580    if(previous.startsWith("<") && previous.endsWith(">")) {
     
    8984    }
    9085    /** Retrieves the next token.
    91       * @return A <strong>String</strong> representing the token.
    92       */
     86     * @return A <strong>String</strong> representing the token.
     87     */
    9388    public String nextToken() {
    9489    previous = current;
     
    9994    }
    10095    /** Repeats the result of the last <i>nextToken()</i>.
    101       * @return A <strong>String</strong> representing the token.
    102       */
     96     * @return A <strong>String</strong> representing the token.
     97     */
    10398    public String sameToken() {
    10499    return previous;
    105100    }
    106101    /** Parses the next token and stores it in current.
    107       */
     102     */
    108103    private void parseToken() {
    109104    boolean found = false;
     
    149144    }
    150145    /** Method to ignore whitespace in the source.
    151       */
     146     */
    152147    private void dumpWhiteSpace() {
    153148    while(pos < source.length() && source.charAt(pos) == ' ') {
  • trunk/gli/src/org/greenstone/gatherer/util/HashMap3D.java

    r5369 r5581  
    2626 */
    2727package org.greenstone.gatherer.util;
     28
    2829/**************************************************************************************
    2930 * Written:      20/08/02
     
    3334import java.util.Iterator;
    3435import org.greenstone.gatherer.msm.Metadata;
     36
    3537/** Provides a HashMap implementation that indexes by two keys. Perfect for the storage of metadata references based on their metadata element and assigned value.
    3638 * @author John Thompson, Greenstone Digital Library, University of Waikato
  • trunk/gli/src/org/greenstone/gatherer/util/MetadataXML.java

    r5564 r5581  
    3030import java.util.*;
    3131import javax.swing.tree.*;
    32 import org.greenstone.gatherer.Gatherer;
    3332import org.greenstone.gatherer.msm.ElementWrapper;
    3433import org.greenstone.gatherer.msm.MetadataSetManager;
  • trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModel.java

    r4674 r5581  
    11package org.greenstone.gatherer.util;
     2
    23import javax.swing.*;
    34import javax.swing.tree.*;
    4 
    55import org.greenstone.gatherer.util.DefaultSynchronizedTreeNode;
    66import org.greenstone.gatherer.util.TreeModelTest;
     
    2020*/
    2121public class SynchronizedTreeModel
    22     extends DefaultTreeModel
    23     implements Runnable {
     22    extends DefaultTreeModel
     23    implements Runnable {
    2424
    25     private boolean changed = false;
    26     private DefaultTreeModel offscreen;
    27     private TreeModelTest test = null;
     25    private boolean changed = false;
     26    private DefaultTreeModel offscreen;
     27    private TreeModelTest test = null;
    2828
    29     SynchronizedTreeModel(SynchronizedTreeNode root) {
    30         super(root);
    31         offscreen = new DefaultTreeModel(root.cloneNode());
     29    SynchronizedTreeModel(SynchronizedTreeNode root) {
     30    super(root);
     31    offscreen = new DefaultTreeModel(root.cloneNode());
     32    }
     33
     34    SynchronizedTreeModel(SynchronizedTreeNode root, TreeModelTest test) {
     35    super(root);
     36    offscreen = new DefaultTreeModel(root.cloneNode());
     37    this.test = test;
     38    }
     39
     40    /** Returns the child of parent at index index in the parent's child array. */
     41    public Object getChild(Object parent, int index) {
     42    if(isEventThread()) {
     43        return super.getChild(parent, index);
    3244    }
     45    else {
     46        return offscreen.getChild(parent, index);
     47    }
     48    }
    3349
    34     SynchronizedTreeModel(SynchronizedTreeNode root, TreeModelTest test) {
    35         super(root);
    36         offscreen = new DefaultTreeModel(root.cloneNode());
    37         this.test = test;
     50    /** Returns the number of children of parent. */
     51    public int getChildCount(Object parent) {
     52    if(isEventThread()) {
     53        return super.getChildCount(parent);
    3854    }
     55    else {
     56        return offscreen.getChildCount(parent);
     57    }
     58    }
    3959
    40     /** Returns the child of parent at index index in the parent's child array. */
    41     public Object getChild(Object parent, int index) {
    42         if(isEventThread()) {
    43             return super.getChild(parent, index);
    44         }
    45         else {
    46             return offscreen.getChild(parent, index);
    47         }
     60    /** Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. This is probably the most 'expensive' method we make synchronized, but it isn't called often so thats ok. */
     61    public TreeNode[] getPathToRoot(TreeNode aNode) {
     62    if(isEventThread()) {
     63        return super.getPathToRoot(aNode);
    4864    }
     65    else {
     66        return offscreen.getPathToRoot(aNode);
     67    }
     68    }
    4969
    50     /** Returns the number of children of parent. */
    51     public int getChildCount(Object parent) {
    52         if(isEventThread()) {
    53             return super.getChildCount(parent);
    54         }
    55         else {
    56             return offscreen.getChildCount(parent);
    57         }
     70    public Object getRoot() {
     71    if(isEventThread()) {
     72        return super.getRoot();
    5873    }
     74    else {
     75        return offscreen.getRoot();
     76    }
     77    }
    5978
    60     /** Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. This is probably the most 'expensive' method we make synchronized, but it isn't called often so thats ok. */
    61     public TreeNode[] getPathToRoot(TreeNode aNode) {
    62         if(isEventThread()) {
    63             return super.getPathToRoot(aNode);
    64         }
    65         else {
    66             return offscreen.getPathToRoot(aNode);
    67         }
     79    /** Invoked this to insert newChild at location index in parents children. */
     80    public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index) {
     81    if(isEventThread()) {
     82        if(test != null) test.debug("insertNodeInto(" + newChild + ", " + parent + ", " + index + ")");
     83        super.insertNodeInto(newChild, parent, index);
    6884    }
     85    else {
     86        if(test != null) test.debug("offscreen.insertNodeInto(" + newChild + ", " + parent + ", " + index + ")");
     87        offscreen.insertNodeInto(newChild, parent, index);
     88        queueUpdate();
     89    }
     90    }
    6991
    70     public Object getRoot() {
    71         if(isEventThread()) {
    72             return super.getRoot();
    73         }
    74         else {
    75             return offscreen.getRoot();
    76         }
     92    /** Message this to remove node from its parent. */
     93    public void removeNodeFromParent(MutableTreeNode node) {
     94    if(isEventThread()) {
     95        if(test != null) test.debug("removeNodeFromParent(" + node + ")");
     96        super.removeNodeFromParent(node);
    7797    }
     98    else {
     99        if(test != null) test.debug("offscreen.removeNodeFromParent(" + node + ")");
     100        offscreen.removeNodeFromParent(node);
     101        queueUpdate();
     102    }
     103    }
    78104
     105    public void run() {
     106    synchronized(this) {
     107        if(changed) {
     108        setRoot(((SynchronizedTreeNode)(offscreen.getRoot())).  cloneNode());
     109        nodeChanged(root);
     110        changed = false;
     111        if(test != null) test.debug("Painted model refreshed.");
     112        }
     113        else {
     114        if(test != null) test.debug("Painted model is current.");
     115        }
     116    }
     117    }
    79118
    80     /** Invoked this to insert newChild at location index in parents children. */
    81     public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index) {
    82         if(isEventThread()) {
    83             if(test != null) test.debug("insertNodeInto(" + newChild + ", " + parent + ", " + index + ")");
    84             super.insertNodeInto(newChild, parent, index);
    85         }
    86         else {
    87             if(test != null) test.debug("offscreen.insertNodeInto(" + newChild + ", " + parent + ", " + index + ")");
    88             offscreen.insertNodeInto(newChild, parent, index);
    89             queueUpdate();
    90         }
    91     }
     119    /** Determine if this call is happening on the AWTEvent Dispatch Thread. */
     120    private boolean isEventThread() {
     121    return SwingUtilities.isEventDispatchThread();
     122    }
    92123
    93     /** Message this to remove node from its parent. */
    94     public void removeNodeFromParent(MutableTreeNode node) {
    95         if(isEventThread()) {
    96             if(test != null) test.debug("removeNodeFromParent(" + node + ")");
    97             super.removeNodeFromParent(node);
    98         }
    99         else {
    100             if(test != null) test.debug("offscreen.removeNodeFromParent(" + node + ")");
    101             offscreen.removeNodeFromParent(node);
    102             queueUpdate();
    103         }
    104     }
    105 
    106     public void run() {
    107         synchronized(this) {
    108             if(changed) {
    109                 setRoot(((SynchronizedTreeNode)(offscreen.getRoot())).  cloneNode());
    110                 nodeChanged(root);
    111                 changed = false;
    112                 if(test != null) test.debug("Painted model refreshed.");
    113             }
    114             else {
    115                 if(test != null) test.debug("Painted model is current.");
    116             }
    117         }
    118     }
    119 
    120     /** Determine if this call is happening on the AWTEvent Dispatch Thread. */
    121     private boolean isEventThread() {
    122         return SwingUtilities.isEventDispatchThread();
    123     }
    124 
    125     private synchronized void queueUpdate() {
    126         changed = true;
    127         SwingUtilities.invokeLater(this);
    128         if(test != null) test.debug("Painted model is obsolete.");
    129     }
     124    private synchronized void queueUpdate() {
     125    changed = true;
     126    SwingUtilities.invokeLater(this);
     127    if(test != null) test.debug("Painted model is obsolete.");
     128    }
    130129}
  • trunk/gli/src/org/greenstone/gatherer/util/SynchronizedTreeModelTools.java

    r4674 r5581  
    1 package org.greenstone.gatherer.util;
    21/**
    32 *#########################################################################
     
    2625 *########################################################################
    2726 */
     27package org.greenstone.gatherer.util;
     28
    2829import java.lang.Runnable;
    2930import java.lang.Thread;
  • trunk/gli/src/org/greenstone/gatherer/util/TreeModelTest.java

    r4686 r5581  
    11package org.greenstone.gatherer.util;
     2
    23import java.awt.*;
    34import java.awt.event.*;
     
    1112
    1213public class TreeModelTest
    13     extends JFrame {
    14 
    15     /** Testing - test frame size. */
    16     static final private Dimension SIZE = new Dimension(400,400);
    17 
    18     /** Testing - should a debug file be written. */
    19     static private boolean debug = false;
    20 
    21     /** Testing - debug output stream. */
    22     static private FileOutputStream output = null;
    23 
    24     /** Testing - write a message to the debug file. */
    25     static void debug(String message) {
    26         if(debug) {
    27             try {
    28                 if(output == null) {
    29                     output = new FileOutputStream(new File("debug.txt"));
    30                 }
    31                 output.write(message.getBytes());
    32                 output.flush();
    33 
     14    extends JFrame {
     15
     16    /** Testing - test frame size. */
     17    static final private Dimension SIZE = new Dimension(400,400);
     18
     19    /** Testing - should a debug file be written. */
     20    static private boolean debug = false;
     21
     22    /** Testing - debug output stream. */
     23    static private FileOutputStream output = null;
     24
     25    /** Testing - write a message to the debug file. */
     26    static void debug(String message) {
     27    if(debug) {
     28        try {
     29        if(output == null) {
     30            output = new FileOutputStream(new File("debug.txt"));
     31        }
     32        output.write(message.getBytes());
     33        output.flush();
     34        }
     35        catch (Exception error) {
     36        error.printStackTrace();
     37        }
     38    }
     39    }
     40
     41    /** Testing - usage message. */
     42    static void printUsage() {
     43    System.out.println("Usage: java Test3 [-safe] [-debug]");
     44    System.out.println(" safe  - use SynchronizedTreeModel");
     45    System.out.println(" debug - write debug messages to debug.txt file\n");
     46    System.out.println("Actions:");
     47    System.out.println(" 'Add Node' - Adds a new node to the selected node. Since this happens on the AWTEvent Thread it should always be safe.");
     48    System.out.println(" 'Remove Node' - Removes the selected node. Since this happens on the AWTEvent Thread it should always be safe.");
     49    System.out.println(" 'Preset Structure' - Generates a small preset structure on a seperate (dangerous) thread.");
     50    System.out.println(" 'Dangerous' - The ultimate test. Hammers the model with incessant random mutations from a separate thread.");
     51    System.exit(0);
     52    }
     53    /** Testing - creates a frame containing a JTree backed by either a normal DefaultTreeModel or a SynchronizedTreeModel depending on arguments. There are also several actions you can perform by clicking on buttons. */
     54    static public void main(String[] args) {
     55    boolean safe = false;
     56    if(args.length <= 2) {
     57        for(int i = 0; i < args.length; i++) {
     58        String arg = args[i];
     59        if(arg.equalsIgnoreCase("-safe")) {
     60            safe = true;
     61        }
     62        else if(arg.equalsIgnoreCase("-debug")) {
     63            debug = true;
     64        }
     65        else {
     66            printUsage();
     67        }
     68        }
     69    }
     70    else {
     71        printUsage();
     72    }
     73    new TreeModelTest(safe);
     74    }
     75
     76    /** Testing - a dangerous thread which hammers the mutable tree model. */
     77    private DangerousTask task;
     78
     79    /** Testing - a dangerous thread which builds a preset structure. */
     80    private DangerousTask preset_task;
     81
     82    /** Testing - the tree model, which may be a SynchronizedTreeModel. */
     83    private DefaultTreeModel model;
     84
     85    /** Testing - a button for toggling the dangerous thread on and off. */
     86    private JToggleButton dangerous_button;
     87
     88    /** Testing - the tree used during testing. */
     89    private JTree tree;
     90
     91    TreeModelTest(boolean safe) {
     92    super("Testing");
     93    setDefaultCloseOperation(EXIT_ON_CLOSE);
     94    setSize(SIZE);
     95    JPanel content_panel = (JPanel) getContentPane();
     96
     97    // Creation
     98    task = new DangerousTask(false);
     99    preset_task = new DangerousTask(true);
     100
     101    if(safe) {
     102        model = new SynchronizedTreeModel(new DefaultSynchronizedTreeNode("Root"));
     103    }
     104    else {
     105        model = new DefaultTreeModel(new DefaultMutableTreeNode("Root"));
     106    }
     107   
     108    tree = new JTree(model);
     109
     110    JPanel button_panel = new JPanel();
     111    JButton add_button = new JButton("Add Node");
     112    dangerous_button = new JToggleButton("Dangerous!");
     113    dangerous_button.setSelected(false);
     114    JButton remove_button = new JButton("Remove Node");
     115    JButton preset_button = new JButton("Preset Structure");
     116
     117    // Connection
     118    add_button.addActionListener(new AddListener());
     119    dangerous_button.addActionListener(new ActionListener() {
     120        public void actionPerformed(ActionEvent event) {
     121            if(dangerous_button.isSelected()) {
     122            task.start();
     123            }
     124            else {
     125            task.exit = true;
     126            }
     127        }
     128        });
     129    remove_button.addActionListener(new ActionListener() {
     130        public void actionPerformed(ActionEvent event) {
     131            ///ystem.err.println("*** Start Remove ***");
     132            // Get the selected node
     133            TreePath selected_path = tree.getSelectionPath();
     134            if(selected_path != null) {
     135            DefaultMutableTreeNode old_child = (DefaultMutableTreeNode)     selected_path.getLastPathComponent();
     136            if(!old_child.isRoot()) {
     137                // Remove node.
     138                model.removeNodeFromParent(old_child);
    34139            }
    35             catch (Exception error) {
    36                 error.printStackTrace();
     140            }
     141            ///ystem.err.println("*** End Remove ***\n");
     142        }
     143        });
     144    preset_button.addActionListener(new ActionListener() {
     145        public void actionPerformed(ActionEvent event) {
     146            preset_task.start();
     147        }
     148        });
     149   
     150    // Layout
     151    button_panel.setLayout(new GridLayout(2,2));
     152    button_panel.add(add_button);
     153    button_panel.add(remove_button);
     154    button_panel.add(preset_button);
     155    button_panel.add(dangerous_button);
     156   
     157    content_panel.setLayout(new BorderLayout());
     158    content_panel.add(new JScrollPane(tree), BorderLayout.CENTER);
     159    content_panel.add(button_panel, BorderLayout.SOUTH);
     160
     161    // Display
     162    Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
     163    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
     164    show();
     165    }
     166
     167    private class AddListener
     168    implements ActionListener {
     169    public void actionPerformed(ActionEvent event) {
     170        ///ystem.err.println("*** Start Add ***");
     171        // Get the selected node
     172        TreePath selected_path = tree.getSelectionPath();
     173        if(selected_path != null) {
     174        DefaultMutableTreeNode parent = (DefaultMutableTreeNode)    selected_path.getLastPathComponent();
     175        // Create a new node
     176        MutableTreeNode new_child = new DefaultSynchronizedTreeNode(    String.valueOf(System.currentTimeMillis()));
     177        // Insert node.
     178        model.insertNodeInto(new_child, parent, parent.getChildCount());
     179        }
     180        ///ystem.err.println("*** End Add ***\n");
     181    }
     182    }
     183
     184    private class DangerousTask
     185    extends Thread {
     186
     187    private boolean exit = false;
     188    private boolean preset = false;
     189
     190    DangerousTask(boolean preset) {
     191        this.preset = preset;
     192    }
     193
     194    public void run() {
     195        if(preset) {
     196        DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
     197        MutableTreeNode alpha = new DefaultSynchronizedTreeNode("Alpha");
     198        MutableTreeNode beta = new DefaultSynchronizedTreeNode("Beta");
     199        MutableTreeNode delta = new DefaultSynchronizedTreeNode("Delta");
     200        MutableTreeNode gamma = new DefaultSynchronizedTreeNode("Gamma");
     201        MutableTreeNode epsilon = new DefaultSynchronizedTreeNode("Epsilon");
     202        MutableTreeNode rho = new DefaultSynchronizedTreeNode("Rho");
     203        MutableTreeNode pi = new DefaultSynchronizedTreeNode("Pi");
     204        MutableTreeNode xhi = new DefaultSynchronizedTreeNode("Xhi");
     205        MutableTreeNode kappa = new DefaultSynchronizedTreeNode("Kappa");
     206        MutableTreeNode lambda = new DefaultSynchronizedTreeNode("Lambda");
     207        MutableTreeNode omega = new DefaultSynchronizedTreeNode("Omega");MutableTreeNode tau = new DefaultSynchronizedTreeNode("Tau");
     208       
     209        model.insertNodeInto(alpha, root, 0);
     210        model.insertNodeInto(omega, root, 1);
     211        model.insertNodeInto(pi, root, 1);
     212
     213        model.insertNodeInto(beta, alpha, 0);
     214        model.insertNodeInto(delta, beta, 0);
     215        model.insertNodeInto(epsilon, delta, 0);
     216        model.insertNodeInto(gamma, delta, 0);
     217        model.insertNodeInto(rho, pi, 0);
     218        model.insertNodeInto(xhi, alpha, 0);
     219        model.insertNodeInto(kappa, root, 1);
     220
     221        debug("Root has: " + model.getChildCount(model.getRoot()));
     222        }
     223        else {
     224        exit = false;
     225        while(!exit) {
     226            // Find a random node
     227            DefaultMutableTreeNode current = (DefaultMutableTreeNode) model.getRoot();
     228            while(Math.random() > 0.3 && model.getChildCount(current) > 0) {
     229            int index = (int)(Math.random() * (model.getChildCount(current) - 1));
     230            current = (DefaultMutableTreeNode) model.getChild(current, index);
     231            }
     232            // Either add or remove a random node.
     233            if(Math.random() > 0.9) {
     234            ///ystem.err.println("<< Expand >>");
     235            TreePath path = new TreePath(model.getPathToRoot(current));
     236            tree.expandPath(path);
     237            }
     238            else if(Math.random() > 0.4 || current.isRoot()) {
     239            if(model.getChildCount(current) < 25) {
     240                ///ystem.err.println("<<< Add >>>");
     241                // Add a new node
     242                MutableTreeNode new_child = new DefaultSynchronizedTreeNode(String.valueOf(System.currentTimeMillis()));
     243                // Insert node.
     244                model.insertNodeInto(new_child, current, model. getChildCount(current));
     245                ///ystem.err.println("<<<     >>>\n");
    37246            }
    38         }
    39     }
    40 
    41     /** Testing - usage message. */
    42     static void printUsage() {
    43         System.out.println("Usage: java Test3 [-safe] [-debug]");
    44         System.out.println(" safe  - use SynchronizedTreeModel");
    45         System.out.println(" debug - write debug messages to debug.txt file\n");
    46         System.out.println("Actions:");
    47         System.out.println(" 'Add Node' - Adds a new node to the selected node. Since this happens on the AWTEvent Thread it should always be safe.");
    48         System.out.println(" 'Remove Node' - Removes the selected node. Since this happens on the AWTEvent Thread it should always be safe.");
    49         System.out.println(" 'Preset Structure' - Generates a small preset structure on a seperate (dangerous) thread.");
    50         System.out.println(" 'Dangerous' - The ultimate test. Hammers the model with incessant random mutations from a separate thread.");
    51         System.exit(0);
    52     }
    53     /** Testing - creates a frame containing a JTree backed by either a normal DefaultTreeModel or a SynchronizedTreeModel depending on arguments. There are also several actions you can perform by clicking on buttons. */
    54     static public void main(String[] args) {
    55         boolean safe = false;
    56         if(args.length <= 2) {
    57             for(int i = 0; i < args.length; i++) {
    58                 String arg = args[i];
    59                 if(arg.equalsIgnoreCase("-safe")) {
    60                     safe = true;
    61                 }
    62                 else if(arg.equalsIgnoreCase("-debug")) {
    63                     debug = true;
    64                 }
    65                 else {
    66                     printUsage();
    67                 }
     247            }
     248            else {
     249            ///ystem.err.println("<<< Remove >>>");
     250            // Remove node.
     251            model.removeNodeFromParent(current);
     252            ///ystem.err.println("<<<        >>>\n");
     253            }
     254
     255            // Wait some random minute amount of time
     256            try {
     257            synchronized(this) {
     258                wait((int)(5 * Math.random()) + 1);
    68259            }
    69         }
    70         else {
    71             printUsage();
    72         }
    73         new TreeModelTest(safe);
    74     }
    75 
    76     /** Testing - a dangerous thread which hammers the mutable tree model. */
    77     private DangerousTask task;
    78 
    79     /** Testing - a dangerous thread which builds a preset structure. */
    80     private DangerousTask preset_task;
    81 
    82     /** Testing - the tree model, which may be a SynchronizedTreeModel. */
    83     private DefaultTreeModel model;
    84 
    85     /** Testing - a button for toggling the dangerous thread on and off. */
    86     private JToggleButton dangerous_button;
    87 
    88     /** Testing - the tree used during testing. */
    89     private JTree tree;
    90 
    91     TreeModelTest(boolean safe) {
    92         super("Testing");
    93         setDefaultCloseOperation(EXIT_ON_CLOSE);
    94         setSize(SIZE);
    95         JPanel content_panel = (JPanel) getContentPane();
    96         // Creation
    97 
    98         task = new DangerousTask(false);
    99         preset_task = new DangerousTask(true);
    100 
    101         if(safe) {
    102             model = new SynchronizedTreeModel(new DefaultSynchronizedTreeNode("Root"));
    103         }
    104         else {
    105             model = new DefaultTreeModel(new DefaultMutableTreeNode("Root"));
    106         }
    107 
    108         tree = new JTree(model);
    109 
    110         JPanel button_panel = new JPanel();
    111         JButton add_button = new JButton("Add Node");
    112         dangerous_button = new JToggleButton("Dangerous!");
    113         dangerous_button.setSelected(false);
    114         JButton remove_button = new JButton("Remove Node");
    115         JButton preset_button = new JButton("Preset Structure");
    116 
    117         // Connection
    118         add_button.addActionListener(new AddListener());
    119         dangerous_button.addActionListener(new ActionListener() {
    120             public void actionPerformed(ActionEvent event) {
    121                 if(dangerous_button.isSelected()) {
    122                     task.start();
    123                 }
    124                 else {
    125                     task.exit = true;
    126                 }
    127             }
    128         });
    129         remove_button.addActionListener(new ActionListener() {
    130             public void actionPerformed(ActionEvent event) {
    131                 ///ystem.err.println("*** Start Remove ***");
    132                 // Get the selected node
    133                 TreePath selected_path = tree.getSelectionPath();
    134                 if(selected_path != null) {
    135                     DefaultMutableTreeNode old_child = (DefaultMutableTreeNode)     selected_path.getLastPathComponent();
    136                     if(!old_child.isRoot()) {
    137                         // Remove node.
    138                         model.removeNodeFromParent(old_child);
    139                     }
    140                 }
    141                 ///ystem.err.println("*** End Remove ***\n");
    142             }
    143         });
    144         preset_button.addActionListener(new ActionListener() {
    145             public void actionPerformed(ActionEvent event) {
    146                 preset_task.start();
    147             }
    148         });
    149 
    150         // Layout
    151         button_panel.setLayout(new GridLayout(2,2));
    152         button_panel.add(add_button);
    153         button_panel.add(remove_button);
    154         button_panel.add(preset_button);
    155         button_panel.add(dangerous_button);
    156 
    157         content_panel.setLayout(new BorderLayout());
    158         content_panel.add(new JScrollPane(tree), BorderLayout.CENTER);
    159         content_panel.add(button_panel, BorderLayout.SOUTH);
    160 
    161         // Display
    162         Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
    163         setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
    164         show();
    165     }
    166 
    167     private class AddListener
    168         implements ActionListener {
    169         public void actionPerformed(ActionEvent event) {
    170             ///ystem.err.println("*** Start Add ***");
    171             // Get the selected node
    172             TreePath selected_path = tree.getSelectionPath();
    173             if(selected_path != null) {
    174                 DefaultMutableTreeNode parent = (DefaultMutableTreeNode)    selected_path.getLastPathComponent();
    175                 // Create a new node
    176                 MutableTreeNode new_child = new DefaultSynchronizedTreeNode(    String.valueOf(System.currentTimeMillis()));
    177                 // Insert node.
    178                 model.insertNodeInto(new_child, parent, parent.getChildCount());
    179             }
    180             ///ystem.err.println("*** End Add ***\n");
    181         }
    182     }
    183 
    184     private class DangerousTask
    185         extends Thread {
    186 
    187         private boolean exit = false;
    188         private boolean preset = false;
    189 
    190         DangerousTask(boolean preset) {
    191             this.preset = preset;
    192         }
    193 
    194         public void run() {
    195             if(preset) {
    196                 DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    197                 MutableTreeNode alpha = new DefaultSynchronizedTreeNode("Alpha");
    198                 MutableTreeNode beta = new DefaultSynchronizedTreeNode("Beta");
    199                 MutableTreeNode delta = new DefaultSynchronizedTreeNode("Delta");
    200                 MutableTreeNode gamma = new DefaultSynchronizedTreeNode("Gamma");
    201                 MutableTreeNode epsilon = new DefaultSynchronizedTreeNode("Epsilon");
    202                 MutableTreeNode rho = new DefaultSynchronizedTreeNode("Rho");
    203                 MutableTreeNode pi = new DefaultSynchronizedTreeNode("Pi");
    204                 MutableTreeNode xhi = new DefaultSynchronizedTreeNode("Xhi");
    205                 MutableTreeNode kappa = new DefaultSynchronizedTreeNode("Kappa");
    206                 MutableTreeNode lambda = new DefaultSynchronizedTreeNode("Lambda");
    207                 MutableTreeNode omega = new DefaultSynchronizedTreeNode("Omega");MutableTreeNode tau = new DefaultSynchronizedTreeNode("Tau");
    208 
    209                 model.insertNodeInto(alpha, root, 0);
    210                 model.insertNodeInto(omega, root, 1);
    211                 model.insertNodeInto(pi, root, 1);
    212 
    213                 model.insertNodeInto(beta, alpha, 0);
    214                 model.insertNodeInto(delta, beta, 0);
    215                 model.insertNodeInto(epsilon, delta, 0);
    216                 model.insertNodeInto(gamma, delta, 0);
    217                 model.insertNodeInto(rho, pi, 0);
    218                 model.insertNodeInto(xhi, alpha, 0);
    219                 model.insertNodeInto(kappa, root, 1);
    220 
    221 
    222                 debug("Root has: " + model.getChildCount(model.getRoot()));
    223             }
    224             else {
    225                 exit = false;
    226                 while(!exit) {
    227                     // Find a random node
    228                     DefaultMutableTreeNode current = (DefaultMutableTreeNode) model.getRoot();
    229                     while(Math.random() > 0.3 && model.getChildCount(current) > 0) {
    230                         int index = (int)(Math.random() * (model.getChildCount(current) - 1));
    231                         current = (DefaultMutableTreeNode) model.getChild(current, index);
    232                     }
    233                     // Either add or remove a random node.
    234                     if(Math.random() > 0.9) {
    235                         ///ystem.err.println("<< Expand >>");
    236                         TreePath path = new TreePath(model.getPathToRoot(current));
    237                         tree.expandPath(path);
    238                     }
    239                     else if(Math.random() > 0.4 || current.isRoot()) {
    240                         if(model.getChildCount(current) < 25) {
    241                             ///ystem.err.println("<<< Add >>>");
    242                             // Add a new node
    243                             MutableTreeNode new_child = new DefaultSynchronizedTreeNode(String.valueOf(System.currentTimeMillis()));
    244                             // Insert node.
    245                             model.insertNodeInto(new_child, current, model. getChildCount(current));
    246                             ///ystem.err.println("<<<     >>>\n");
    247                         }
    248                     }
    249                     else {
    250                         ///ystem.err.println("<<< Remove >>>");
    251                         // Remove node.
    252                         model.removeNodeFromParent(current);
    253                         ///ystem.err.println("<<<        >>>\n");
    254 
    255                     }
    256                     // Wait some random minute amount of time
    257                     try {
    258                         synchronized(this) {
    259                             wait((int)(5 * Math.random()) + 1);
    260                         }
    261                     } catch (Exception exception) {
    262                         exception.printStackTrace();
    263                     }
    264                 }
    265             }
    266         }
    267     }
     260            } catch (Exception exception) {
     261            exception.printStackTrace();
     262            }
     263        }
     264        }
     265    }
     266    }
    268267}
  • trunk/gli/src/org/greenstone/gatherer/util/TreeSynchronizer.java

    r4674 r5581  
    1 package org.greenstone.gatherer.util;
    21/**
    32 *#########################################################################
     
    2625 *########################################################################
    2726 */
     27package org.greenstone.gatherer.util;
     28
    2829import java.util.Vector;
    2930import javax.swing.JTree;
     
    4849    /** Add a new tree to the synchronization list of trees to be synchronized.
    4950     * @param tree The lastest victim, a <strong>JTree</strong>.
    50       */
     51     */
    5152    public void add(JTree tree) {
    5253    super.add(tree);
     
    6364
    6465    /** Called whenever an item in the tree has been collapsed.
    65       * @param event A <strong>TreeExpansionEvent</strong> containing information about the event.
    66       */
     66     * @param event A <strong>TreeExpansionEvent</strong> containing information about the event.
     67     */
    6768    public void treeCollapsed(TreeExpansionEvent event) {
    6869    if(!ignore) {
    6970        ignore = true;
    70                 // Collapse that path in all registered trees.
     71        // Collapse that path in all registered trees.
    7172        JTree tree = (JTree)event.getSource();
    7273        TreePath path = event.getPath();
     
    8182    }
    8283    /** Called whenever an item in the tree has been expanded.
    83       * @param event A <strong>TreeExpansionEvent</strong> containing information about the event.
    84       */
     84     * @param event A <strong>TreeExpansionEvent</strong> containing information about the event.
     85     */
    8586    public void treeExpanded(TreeExpansionEvent event) {
    8687    if(!ignore) {
     
    99100    }
    100101    /** Called whenever the one of the trees selection changes.
    101       * @param event A <strong>TreeSelectionEvent</strong> containing information about the event.
    102       */
     102     * @param event A <strong>TreeSelectionEvent</strong> containing information about the event.
     103     */
    103104    public void valueChanged(TreeSelectionEvent event) {
    104105    if(!ignore) {
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r5564 r5581  
    259259    return result;
    260260    }
    261     /** Generate a depth first enumeration of a tree. */
    262     static public EnumeratedVector depthFirstEnumeration(TreeNode node, EnumeratedVector result) {
    263     result.add(node);
    264     for(int i = 0; i < node.getChildCount(); i++) {
    265         depthFirstEnumeration(node.getChildAt(i), result);
    266     }
    267     return result;
    268     }
    269261
    270262    static public String encodeGreenstone(String raw) {
     
    375367    }
    376368    if(pos < number_char.length) {
    377                 // Print the '.' and at most two characters after it
     369        // Print the '.' and at most two characters after it
    378370        result.append(number_char[pos]);
    379371        pos++;
     
    381373        result.append(number_char[pos]);
    382374        }
    383                 // Search through the remaining string for 'E'
     375        // Search through the remaining string for 'E'
    384376        while(pos < number_char.length && number_char[pos] != 'E') {
    385377        pos++;
    386378        }
    387                 // If we still have string then we found an E. Copy the remaining string.
     379        // If we still have string then we found an E. Copy the remaining string.
    388380        while(pos < number_char.length) {
    389381        result.append(number_char[pos]);
     
    579571    int year = current.get(Calendar.YEAR);
    580572
    581     return day_name + " " + month_name + " " + day + " " + year + " " + Utility.pad(String.valueOf(hour), 2, '0', true) + ":" + Utility.pad(String.valueOf(minute), 2, '0', true) + ":" + Utility.pad(String.valueOf(second), 2, '0', true);
     573    return Dictionary.newget("Dates." + day_name) + " " + Dictionary.newget("Dates." + month_name) + " " + day + " " + year + " " + Utility.pad(String.valueOf(hour), 2, '0', true) + ":" + Utility.pad(String.valueOf(minute), 2, '0', true) + ":" + Utility.pad(String.valueOf(second), 2, '0', true);
    582574    }
    583575
  • trunk/gli/src/org/greenstone/gatherer/util/WinRegistry.java

    r4674 r5581  
    3535 *########################################################################
    3636 */
     37package org.greenstone.gatherer.util;
    3738
    38  
    39 
    40 
    41 
    42 
    43 package org.greenstone.gatherer.util;
    4439/**
    4540 * Title:        The Gatherer
  • trunk/gli/src/org/greenstone/gatherer/valuetree/GValueModel.java

    r5294 r5581  
    1 package org.greenstone.gatherer.valuetree;
    21/**
    32 *#########################################################################
     
    2625 *########################################################################
    2726 */
     27package org.greenstone.gatherer.valuetree;
     28
    2829import java.util.*;
    2930import javax.swing.tree.*;
    3031import org.greenstone.gatherer.Gatherer;
    3132import org.greenstone.gatherer.msm.ElementWrapper;
    32 import org.greenstone.gatherer.msm.MetadataSetManager;
    3333import org.greenstone.gatherer.msm.MSMUtils;
    34 import org.greenstone.gatherer.util.Codec;
    3534import org.greenstone.gatherer.util.PatternTokenizer;
    36 import org.greenstone.gatherer.util.StaticStrings;
    37 import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
    3835import org.greenstone.gatherer.util.Utility;
    3936import org.w3c.dom.*;
  • trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java

    r5294 r5581  
    3636 */
    3737package org.greenstone.gatherer.valuetree;
     38
    3839/**
    3940 * Title:        The Gatherer<br>
     
    4647 * @version 2.1
    4748 */
    48 import java.util.Collections;
    49 import java.util.Enumeration;
    50 import java.util.HashMap;
    51 import java.util.Hashtable;
    52 import java.util.Vector;
     49
     50import java.util.*;
    5351import javax.swing.tree.*;
    5452import org.greenstone.gatherer.Gatherer;
    55 import org.greenstone.gatherer.msm.ElementWrapper;
    5653import org.greenstone.gatherer.msm.MSMUtils;
    5754import org.greenstone.gatherer.util.Codec;
    5855import org.greenstone.gatherer.util.StaticStrings;
    5956import org.greenstone.gatherer.util.Utility;
    60 import org.w3c.dom.Document;
    61 import org.w3c.dom.Element;
    62 import org.w3c.dom.Node;
    63 import org.w3c.dom.NodeList;
     57import org.w3c.dom.*;
     58
    6459/** This class is instantiated using a metadata element. From this parent element, which refers to a specific Element in the mds DOM model, the AssignedValues child is used as the root of a tree data-structure encompassing all of the nodes within the AssignedValues tree. This class also provide methods for adding, updating and removing nodes within this tree, as well as implementing all of the methods necessary for this node to be used as the basis of a tree model.
    6560 */
     
    8075    this.default_value = default_value;
    8176    }
     77
    8278    /** Compares two GValueNodes for ordering by using the String.compareTo method.
    8379     * @param sibling The <strong>Object</strong> representing the GValueNode we are comparing ourselves to.
     
    8783    return toString().compareTo(sibling.toString());
    8884    }
     85
    8986    /** Determine if this tree node contains a child with a matching value.
    9087     * @param value The value we are attempting to match, as a <strong>String</strong>.
     
    9794    return getValue(value) != null;
    9895    }
     96
    9997    /** Returns an enumeration of the child nodes.
    10098     * @return An <strong>Enumeration</strong> containing the child nodes.
     
    125123    Element element = (Element) userObject;
    126124    for(Node pos_node = element.getFirstChild(); pos_node != null; pos_node = pos_node.getNextSibling()) {
    127                 // And if we find such a node
     125        // And if we find such a node
    128126        if(pos_node.getNodeName().equals("Alias")) {
    129127        // Retrieve its text node
     
    158156    return (GValueNode) children.get(index);
    159157    }
     158
    160159    /** Returns the number of children <I>TreeNode</I>s the reciever contains. */
    161160    public int getChildCount() {
     
    384383    Element element = (Element) userObject;
    385384    for(Node pos_node = element.getFirstChild(); pos_node != null; pos_node = pos_node.getNextSibling()) {
    386                 // And if we find such a node
     385        // And if we find such a node
    387386        if(pos_node.getNodeName().equals(name)) {
    388387        // And the new value is non-null, retrieve its text node and change it.
Note: See TracChangeset for help on using the changeset viewer.