Changeset 32923


Ignore:
Timestamp:
2019-03-25T18:13:17+13:00 (3 years ago)
Author:
ak19
Message:

Changes to reinstate SwingUtilities.invokeLater() calls added for GUI testing so that it will still work with the remote GS server. Note however that new Gatherer() calls Gatherer.init() does a lot of GUI stuff too depending on circumstances (such as requestGLIServerURL(), missingGSDL(), missingExec(), popupFedoraInfo(), initCollectDirectoryPath() which calls nonStandardCollectHomeMessage()). But Gatherer.init() is not yet wrapped in an invokeLater(), so this will conflict with GLI GUI testing.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
4 edited

Legend:

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

    r32695 r32923  
    672672        }
    673673
     674    }
     675
     676   
     677    /** Returns the correct version of the (local or remote) Greenstone server if init() has already been called. */
     678    public static int serverVersionNumber() {
     679        return GS3 ? 3 : 2;
     680    }
     681
     682    /** Returns "Server: version number" if init() has already been called. */
     683    public static String getServerVersionAsString() {
     684        return "Server: v" + serverVersionNumber();
     685    }
     686
     687    public void openGUI()
     688    {
     689
     690        // openGUI() is called on the EDT (graphical/swing thread)
     691        // remoteGS.downloadCollectionConfigurations() moved here as it calls remoteGS3.authenticateUser()
     692        // which displays a dialog to get user input and therefore belongs on the EDT.
    674693        // If using a remote Greenstone we need to download the collection configurations now
    675694        if (Gatherer.isGsdlRemote) {
     
    682701            }
    683702        }
    684     }
    685 
    686    
    687     /** Returns the correct version of the (local or remote) Greenstone server if init() has already been called. */
    688     public static int serverVersionNumber() {
    689         return GS3 ? 3 : 2;
    690     }
    691 
    692     /** Returns "Server: version number" if init() has already been called. */
    693     public static String getServerVersionAsString() {
    694         return "Server: v" + serverVersionNumber();
    695     }
    696 
    697     public void openGUI()
    698     {
     703       
    699704        // Size and place the frame on the screen
    700705        Rectangle bounds = Configuration.getBounds("general.bounds", true);
  • main/trunk/gli/src/org/greenstone/gatherer/GathererProg.java

    r32920 r32923  
    7676    // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI
    7777    Gatherer gatherer = new Gatherer(args);
    78    
    79     // Display the GUI immediately
    80     gatherer.openGUI();
    81    
    82     /* 
     78       
    8379    // TESTING circumventing the old GUI event dispatch thread exceptions in GLI. Follows
    8480    // https://docs.oracle.com/javase/6/docs/api/javax/swing/package-summary.html#threading
     
    9086    SwingUtilities.invokeLater(new Runnable() {
    9187            public void run() {
    92         // These lines used to be done immediate after setGLIDirectoryPath() call above
    93         // but are now inside an invokeLater().
    94        
    95         // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI
    96         Gatherer gatherer = new Gatherer(args);
    97        
     88        // This line used to be done immediately after setGLIDirectoryPath()
     89        // and new Gatherer() above, but is now inside an invokeLater() to do graphical stuff here.
     90
    9891        // Display the GUI immediately
    9992        gatherer.openGUI();
    10093            }
    10194        });
    102     */
     95   
    10396    }
    10497}
  • main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r32920 r32923  
    183183    }
    184184    else if (esrc == menu_bar.file_delete) {
    185         new DeleteCollectionTask().start();
    186         //SwingUtilities.invokeLater(new DeleteCollectionTask());
     185        //new DeleteCollectionTask().start();
     186        SwingUtilities.invokeLater(new DeleteCollectionTask());
    187187    }
    188188    else if (esrc == menu_bar.file_cdimage) {
     
    203203    }
    204204        else if (esrc == menu_bar.file_new) {
    205         new NewCollectionTask().start();
    206         //SwingUtilities.invokeLater(new NewCollectionTask());
     205        //new NewCollectionTask().start();
     206        SwingUtilities.invokeLater(new NewCollectionTask());
    207207    }
    208208    else if (esrc == menu_bar.file_open) {
    209         new OpenCollectionTask().start(); // will cause an EDT access violation exception
     209        //new OpenCollectionTask().start(); // will cause an EDT access violation exception
    210210        // since the GUI stuff of opening a collection is not done in a Swing thread
    211         //SwingUtilities.invokeLater(new OpenCollectionTask());
     211        SwingUtilities.invokeLater(new OpenCollectionTask());
    212212    }
    213213    else if (esrc == menu_bar.file_options) {
     
    940940
    941941    private class OpenCollectionTask
    942     extends Thread
    943     //implements Runnable //extends Thread -> If this extends Thread, it will cause an EDT access
     942    implements Runnable //extends Thread -> If this extends Thread, it will cause an EDT access
    944943           // violation since the GUI stuff in run() is not done in the Swing Event Dispatch Thread/EDT.
    945944    {
     
    989988
    990989    private class NewCollectionTask
    991     extends Thread
    992     //implements Runnable //extends Thread
     990    implements Runnable //extends Thread
    993991    {
    994992    public void run()
     
    10221020
    10231021    private class DeleteCollectionTask
    1024     extends Thread
    1025     //implements Runnable //extends Thread
     1022    implements Runnable //extends Thread
    10261023    {
    10271024    public void run()
     
    10921089    public void updateUI()
    10931090    {
    1094     //SwingUtilities.invokeLater(new Runnable() {
    1095     //  public void run() {
     1091    SwingUtilities.invokeLater(new Runnable() {
     1092        public void run() {
    10961093            JPanel pane = (JPanel) getContentPane();
    10971094            pane.updateUI();
     
    11031100            workflowUpdate("Create", Configuration.get("workflow.create", false));
    11041101            workflowUpdate("Format", Configuration.get("workflow.format", false));
    1105         //  }
    1106         //      });
     1102            }
     1103        });
    11071104    }
    11081105
  • main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java

    r31777 r32923  
    265265    String threadName = Thread.currentThread().getName();
    266266
     267    /*
    267268    // If we're running in the GUI thread we must return immediately
    268269    // We cannot wait for the action to complete because this will block any GUI updates
     
    273274        return null;
    274275    }
     276    */
    275277
    276278    // Otherwise wait until the action is processed
Note: See TracChangeset for help on using the changeset viewer.