JAL-3563 for merging to JAL-3253-applet
authorBobHanson <hansonr@stolaf.edu>
Sun, 22 Mar 2020 23:07:37 +0000 (18:07 -0500)
committerBobHanson <hansonr@stolaf.edu>
Sun, 22 Mar 2020 23:07:37 +0000 (18:07 -0500)
More Jalview.isSynchronized(), Jalview.execRunnable(), and
Jalview.execThread()

src/jalview/bin/Jalview.java
src/jalview/bin/JalviewAppLoader.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/Desktop.java

index 13ac248..5d82015 100755 (executable)
@@ -2207,9 +2207,7 @@ public class Jalview implements ApplicationSingletonI, JalviewJSApi
    */
   public static void setSynchronous(boolean b)
   {
-
     isSynchronous = b;
-
   }
 
   /**
index 51a0330..8fe2cdc 100644 (file)
@@ -31,7 +31,6 @@ import jalview.structure.StructureSelectionManager;
 import jalview.util.HttpUtils;
 import jalview.util.MessageManager;
 
-import java.awt.EventQueue;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -787,7 +786,7 @@ public class JalviewAppLoader
   public void setFeatureGroupStateOn(final AlignFrameI alf,
           final String groups, boolean state)
   {
-    java.awt.EventQueue.invokeLater(new Runnable()
+    Jalview.execRunnable(new Runnable()
     {
       @Override
       public void run()
@@ -807,7 +806,7 @@ public class JalviewAppLoader
   public void scrollViewToIn(final AlignFrameI alf, final String topRow,
           final String leftHandColumn)
   {
-    java.awt.EventQueue.invokeLater(new Runnable()
+    Jalview.execRunnable(new Runnable()
     {
       @Override
       public void run()
@@ -831,7 +830,7 @@ public class JalviewAppLoader
   public void scrollViewToRowIn(final AlignFrameI alf, final String topRow)
   {
 
-    java.awt.EventQueue.invokeLater(new Runnable()
+    Jalview.execRunnable(new Runnable()
     {
       @Override
       public void run()
@@ -854,7 +853,7 @@ public class JalviewAppLoader
   public void scrollViewToColumnIn(final AlignFrameI alf,
           final String leftHandColumn)
   {
-    java.awt.EventQueue.invokeLater(new Runnable()
+    Jalview.execRunnable(new Runnable()
     {
 
       @Override
@@ -982,7 +981,7 @@ public class JalviewAppLoader
       if (alignedPosition != null && (alignedPosition.trim().length() == 0
               || alignedPosition.toLowerCase().indexOf("false") > -1))
       {
-        java.awt.EventQueue.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
@@ -995,7 +994,7 @@ public class JalviewAppLoader
       }
       else
       {
-        java.awt.EventQueue.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
@@ -1211,7 +1210,7 @@ public class JalviewAppLoader
       }
       sel.setStartRes(start);
       sel.setEndRes(end);
-      EventQueue.invokeLater(new Runnable()
+      Jalview.execRunnable(new Runnable()
       {
         @Override
         public void run()
@@ -1305,7 +1304,6 @@ public class JalviewAppLoader
     {
       return "";
     }
-    ;
     final AlignmentOrder aorder = new AlignmentOrder(sqs);
 
     if (undoName != null && undoName.trim().length() == 0)
index 8d7a600..e44ccdc 100644 (file)
@@ -1121,7 +1121,7 @@ public class AlignFrame extends GAlignFrame
         // need to refactor Desktop.addFrame
         newframe.featureSettings_actionPerformed(null);
         final FeatureSettings nfs = newframe.featureSettings;
-        SwingUtilities.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
@@ -5160,12 +5160,12 @@ public class AlignFrame extends GAlignFrame
 
     });
     rfetch.add(fetchr);
-    new Thread(new Runnable()
+    Jalview.execThread(new Thread(new Runnable()
     {
       @Override
       public void run()
       {
-        javax.swing.SwingUtilities.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
@@ -5384,7 +5384,7 @@ public class AlignFrame extends GAlignFrame
           }
         });
       }
-    }).start();
+    }));
 
   }
 
index d8035bb..1c2e91c 100644 (file)
@@ -67,8 +67,6 @@ import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.List;
 
-import javax.swing.SwingUtilities;
-
 /**
  * The main panel of an AlignFrame, containing holders for the IdPanel,
  * SeqPanel, AnnotationLabels (a JPanel), and AnnotationPanel.
@@ -802,7 +800,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       // This is only called if file loaded is a jar file that
       // was wrapped when saved and user has wrap alignment true
       // as preference setting
-      SwingUtilities.invokeLater(new Runnable()
+      Jalview.execRunnable(new Runnable()
       {
         @Override
         public void run()
index 1e58d1b..e13a63e 100644 (file)
@@ -516,39 +516,42 @@ public class Desktop extends GDesktop
 
       }
 
-      this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
-
-      this.addWindowListener(new WindowAdapter()
+      if (!Jalview.isSynchronous())
       {
-        @Override
-        public void windowClosing(WindowEvent evt)
-        {
-          quit();
-        }
-      });
+        this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
 
-      MouseAdapter ma;
-      this.addMouseListener(ma = new MouseAdapter()
-      {
-        @Override
-        public void mousePressed(MouseEvent evt)
+        this.addWindowListener(new WindowAdapter()
         {
-          if (evt.isPopupTrigger()) // Mac
+          @Override
+          public void windowClosing(WindowEvent evt)
           {
-            showPasteMenu(evt.getX(), evt.getY());
+            quit();
           }
-        }
+        });
 
-        @Override
-        public void mouseReleased(MouseEvent evt)
+        MouseAdapter ma;
+        this.addMouseListener(ma = new MouseAdapter()
         {
-          if (evt.isPopupTrigger()) // Windows
+          @Override
+          public void mousePressed(MouseEvent evt)
           {
-            showPasteMenu(evt.getX(), evt.getY());
+            if (evt.isPopupTrigger()) // Mac
+            {
+              showPasteMenu(evt.getX(), evt.getY());
+            }
           }
-        }
-      });
-      desktopPane.addMouseListener(ma);
+
+          @Override
+          public void mouseReleased(MouseEvent evt)
+          {
+            if (evt.isPopupTrigger()) // Windows
+            {
+              showPasteMenu(evt.getX(), evt.getY());
+            }
+          }
+        });
+        desktopPane.addMouseListener(ma);
+      }
     } catch (Throwable t)
     {
       t.printStackTrace();