Changeset 10555


Ignore:
Timestamp:
2005-08-24T15:11:34+12:00 (19 years ago)
Author:
mdewsnip
Message:

Opening files in an external program is now done in a separate thread, so the progress bar works when using a remote Greenstone server.

File:
1 edited

Legend:

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

    r10517 r10555  
    143143
    144144
    145     public void openFileInExternalApplication(File file)
    146     {
    147     // If we're using a remote Greenstone server, we need to download the file before viewing it...
    148     if (Gatherer.isGsdlRemote) {
    149         // ... but only if it is inside the collection and we haven't already downloaded it
    150         if (file.getAbsolutePath().startsWith(Gatherer.getCollectDirectoryPath()) && file.length() == 0) {
    151         RemoteGreenstoneServer.downloadCollectionFile(Gatherer.c_man.getCollection().getName(), file);
    152         }
    153     }
    154 
    155     Gatherer.spawnApplication(file);
    156     }
    157 
    158 
    159145    private class FileTask
    160146    extends Thread
     
    197183        progress_bar.setIndeterminate(false);
    198184        progress_bar.clear();
     185    }
     186    }
     187
     188
     189    public void openFileInExternalApplication(File file)
     190    {
     191    // This must go in a separate thread because we need the progress bar to work (remote Greenstone server)
     192    new OpenFileInExternalApplicationTask(file).start();
     193    }
     194
     195
     196    private class OpenFileInExternalApplicationTask
     197    extends Thread
     198    {
     199    private File file = null;
     200
     201    public OpenFileInExternalApplicationTask(File file)
     202    {
     203        this.file = file;
     204    }
     205
     206    public void run()
     207    {
     208        // If we're using a remote Greenstone server, we need to download the file before viewing it...
     209        if (Gatherer.isGsdlRemote) {
     210        // ... but only if it is inside the collection and we haven't already downloaded it
     211        if (file.getAbsolutePath().startsWith(Gatherer.getCollectDirectoryPath()) && file.length() == 0) {
     212            RemoteGreenstoneServer.downloadCollectionFile(Gatherer.c_man.getCollection().getName(), file);
     213        }
     214        }
     215
     216        // View the file in an external application
     217        Gatherer.spawnApplication(file);
    199218    }
    200219    }
Note: See TracChangeset for help on using the changeset viewer.