JAL-3253 temporary branch SwingJS upgrade with testNG fixes Java 8
[jalview.git] / src / jalview / project / Jalview2XML.java
index b0315e8..2c93ee5 100644 (file)
@@ -35,6 +35,7 @@ import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
 import jalview.api.structures.JalviewStructureDisplayI;
 import jalview.bin.Cache;
+import jalview.bin.Jalview;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
@@ -189,7 +190,6 @@ import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 
 import javax.swing.JInternalFrame;
-import javax.swing.SwingUtilities;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.Marshaller;
@@ -2784,8 +2784,9 @@ public class Jalview2XML
     {
       try
       {
+
          // BH 2019 -- can't wait
-        SwingUtilities.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
@@ -3354,16 +3355,16 @@ public class Jalview2XML
    *          data source provider
    * @return alignment frame created from view stored in DOM
    */
-  AlignFrame loadFromObject(JalviewModel jalviewModel, String file,
+  private AlignFrame loadFromObject(JalviewModel jalviewModel, String file,
           boolean loadTreesAndStructures, jarInputStreamProvider jprovider)
   {
 
-//    Platform.timeCheck("Jalview2XML.loadFromObject0", Platform.TIME_MARK);
+    // Platform.timeCheck("Jalview2XML.loadFromObject0", Platform.TIME_MARK);
 
-    SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet().get(0);
+    SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet()
+            .get(0);
     List<Sequence> vamsasSeqs = vamsasSet.getSequence();
 
-
     // JalviewModelSequence jms = object.getJalviewModelSequence();
 
     // Viewport view = (jms.getViewportCount() > 0) ? jms.getViewport(0)
@@ -3394,7 +3395,7 @@ public class Jalview2XML
               : view.getId() + uniqueSetSuffix);
     }
 
-//    Platform.timeCheck("Jalview2XML.loadFromObject1", Platform.TIME_MARK);
+    // Platform.timeCheck("Jalview2XML.loadFromObject1", Platform.TIME_MARK);
     // ////////////////////////////////
     // LOAD SEQUENCES
 
@@ -3480,8 +3481,8 @@ public class Jalview2XML
       }
     }
 
-//    Platform.timeCheck("Jalview2XML.loadFromObject-seq",
-//            Platform.TIME_MARK);
+    // Platform.timeCheck("Jalview2XML.loadFromObject-seq",
+    // Platform.TIME_MARK);
     // /
     // Create the alignment object from the sequence set
     // ///////////////////////////////
@@ -3522,8 +3523,8 @@ public class Jalview2XML
       recoverDatasetFor(vamsasSet, al, isdsal, uniqueSeqSetId);
     }
 
-//    Platform.timeCheck("Jalview2XML.loadFromObject-align",
-//            Platform.TIME_MARK);
+    // Platform.timeCheck("Jalview2XML.loadFromObject-align",
+    // Platform.TIME_MARK);
     if (referenceseqForView != null)
     {
       al.setSeqrep(referenceseqForView);
@@ -3536,8 +3537,8 @@ public class Jalview2XML
       al.setProperty(ssp.getKey(), ssp.getValue());
     }
 
-//    Platform.timeCheck("Jalview2XML.loadFromObject-setseqprop",
-//            Platform.TIME_MARK);
+    // Platform.timeCheck("Jalview2XML.loadFromObject-setseqprop",
+    // Platform.TIME_MARK);
     // ///////////////////////////////
 
     Hashtable pdbloaded = new Hashtable(); // TODO nothing writes to this??
@@ -3551,7 +3552,7 @@ public class Jalview2XML
       // now, for 2.10 projects, this is also done if the xml doc includes
       // dataset sequences not actually present in any particular view.
       //
-//      Platform.timeCheck("J2XML features0", Platform.TIME_RESET);
+      // Platform.timeCheck("J2XML features0", Platform.TIME_RESET);
       for (int i = 0; i < vamsasSeqs.size(); i++)
       {
         JSeq jseq = jseqs.get(i);
@@ -3606,9 +3607,9 @@ public class Jalview2XML
             }
 
             // adds feature to datasequence's feature set (since Jalview 2.10)
-//            Platform.timeCheck(null, Platform.TIME_SET);
+            // Platform.timeCheck(null, Platform.TIME_SET);
             al.getSequenceAt(i).addSequenceFeature(sf);
-//            Platform.timeCheck(null, Platform.TIME_MARK);
+            // Platform.timeCheck(null, Platform.TIME_MARK);
           }
         }
         if (vamsasSeqs.get(i).getDBRef().size() > 0)
@@ -3668,8 +3669,7 @@ public class Jalview2XML
             {
               entry.setProperty(prop.getName(), prop.getValue());
             }
-            Desktop.getStructureSelectionManager()
-                    .registerPDBEntry(entry);
+            Desktop.getStructureSelectionManager().registerPDBEntry(entry);
             // adds PDBEntry to datasequence's set (since Jalview 2.10)
             if (al.getSequenceAt(i).getDatasetSequence() != null)
             {
@@ -3684,9 +3684,9 @@ public class Jalview2XML
 
       }
 
-//      Platform.timeCheck("features done", Platform.TIME_GET);
-//      Platform.timeCheck("Jalview2XML.loadFromObject-endmultiview",
-//              Platform.TIME_MARK);
+      // Platform.timeCheck("features done", Platform.TIME_GET);
+      // Platform.timeCheck("Jalview2XML.loadFromObject-endmultiview",
+      // Platform.TIME_MARK);
     } // end !multipleview
 
     // ///////////////////////////////
@@ -3720,16 +3720,16 @@ public class Jalview2XML
               else
               {
                 // defer to later
-                frefedSequence.add(
-                        newAlcodMapRef(map.getDnasq(), cf, mapping));
+                frefedSequence
+                        .add(newAlcodMapRef(map.getDnasq(), cf, mapping));
               }
             }
           }
           al.addCodonFrame(cf);
         }
       }
-//      Platform.timeCheck("Jalview2XML.loadFromObject-seqmap",
-//              Platform.TIME_MARK);
+      // Platform.timeCheck("Jalview2XML.loadFromObject-seqmap",
+      // Platform.TIME_MARK);
     }
 
     // ////////////////////////////////
@@ -3790,8 +3790,8 @@ public class Jalview2XML
         }
         // Construct new annotation from model.
         List<AnnotationElement> ae = annotation.getAnnotationElement();
-//        System.err.println(
-//                "Jalview2XML processing " + ae.size() + " annotations");
+        // System.err.println(
+        // "Jalview2XML processing " + ae.size() + " annotations");
 
         jalview.datamodel.Annotation[] anot = null;
         java.awt.Color firstColour = null;
@@ -3936,8 +3936,7 @@ public class Jalview2XML
         jaa.setCalcId(annotation.getCalcId());
         if (annotation.getProperty().size() > 0)
         {
-          for (Annotation.Property prop : annotation
-                  .getProperty())
+          for (Annotation.Property prop : annotation.getProperty())
           {
             jaa.setProperty(prop.getName(), prop.getValue());
           }
@@ -3954,8 +3953,8 @@ public class Jalview2XML
           al.addAnnotation(jaa);
         }
       }
-//      Platform.timeCheck("Jalview2XML.loadFromObject-annot",
-//              Platform.TIME_MARK);
+      // Platform.timeCheck("Jalview2XML.loadFromObject-annot",
+      // Platform.TIME_MARK);
     }
     // ///////////////////////
     // LOAD GROUPS
@@ -4020,9 +4019,9 @@ public class Jalview2XML
         sg.setShowNonconserved(safeBoolean(jGroup.isShowUnconserved()));
         sg.thresholdTextColour = safeInt(jGroup.getTextColThreshold());
         // attributes with a default in the schema are never null
-          sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram());
-          sg.setshowSequenceLogo(jGroup.isShowSequenceLogo());
-          sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo());
+        sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram());
+        sg.setshowSequenceLogo(jGroup.isShowSequenceLogo());
+        sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo());
         sg.setIgnoreGapsConsensus(jGroup.isIgnoreGapsinConsensus());
         if (jGroup.getConsThreshold() != null
                 && jGroup.getConsThreshold().intValue() != 0)
@@ -4066,12 +4065,13 @@ public class Jalview2XML
         if (addAnnotSchemeGroup)
         {
           // reconstruct the annotation colourscheme
-          sg.setColourScheme(constructAnnotationColour(
-                  jGroup.getAnnotationColours(), null, al, jalviewModel, false));
+          sg.setColourScheme(
+                  constructAnnotationColour(jGroup.getAnnotationColours(),
+                          null, al, jalviewModel, false));
         }
       }
-//      Platform.timeCheck("Jalview2XML.loadFromObject-groups",
-//              Platform.TIME_MARK);
+      // Platform.timeCheck("Jalview2XML.loadFromObject-groups",
+      // Platform.TIME_MARK);
     }
     if (view == null)
     {
@@ -4111,8 +4111,8 @@ public class Jalview2XML
         }
 
       }
-//      Platform.timeCheck("Jalview2XML.loadFromObject-viewport",
-//              Platform.TIME_MARK);
+      // Platform.timeCheck("Jalview2XML.loadFromObject-viewport",
+      // Platform.TIME_MARK);
     }
     /**
      * indicate that annotation colours are applied across all groups (pre
@@ -4165,47 +4165,47 @@ public class Jalview2XML
     final AlignFrame af0 = af;
     final AlignViewport av0 = av;
     final AlignmentPanel ap0 = ap;
-//    Platform.timeCheck("Jalview2XML.loadFromObject-beforetree",
-//            Platform.TIME_MARK);
+    // Platform.timeCheck("Jalview2XML.loadFromObject-beforetree",
+    // Platform.TIME_MARK);
     if (loadTreesAndStructures)
     {
       if (!jalviewModel.getTree().isEmpty())
       {
-        SwingUtilities.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
           {
-//            Platform.timeCheck(null, Platform.TIME_MARK);
+            // Platform.timeCheck(null, Platform.TIME_MARK);
             loadTrees(jalviewModel, view, af0, av0, ap0);
-//            Platform.timeCheck("Jalview2XML.loadTrees", Platform.TIME_MARK);
+            // Platform.timeCheck("Jalview2XML.loadTrees", Platform.TIME_MARK);
           }
         });
       }
       if (!jalviewModel.getPcaViewer().isEmpty())
       {
-        SwingUtilities.invokeLater(new Runnable()
+        Jalview.execRunnable(new Runnable()
         {
           @Override
           public void run()
           {
-//            Platform.timeCheck(null, Platform.TIME_MARK);
+            // Platform.timeCheck(null, Platform.TIME_MARK);
             loadPCAViewers(jalviewModel, ap0);
-//            Platform.timeCheck("Jalview2XML.loadPCA", Platform.TIME_MARK);
+            // Platform.timeCheck("Jalview2XML.loadPCA", Platform.TIME_MARK);
           }
         });
       }
-      SwingUtilities.invokeLater(new Runnable()
+      Jalview.execRunnable(new Runnable()
       {
         @Override
         public void run()
         {
-//          Platform.timeCheck(null, Platform.TIME_MARK);
+          // Platform.timeCheck(null, Platform.TIME_MARK);
           loadPDBStructures(jprovider, jseqs, af0, ap0);
-//          Platform.timeCheck("Jalview2XML.loadPDB", Platform.TIME_MARK);
+          // Platform.timeCheck("Jalview2XML.loadPDB", Platform.TIME_MARK);
         }
       });
-      SwingUtilities.invokeLater(new Runnable()
+      Jalview.execRunnable(new Runnable()
       {
         @Override
         public void run()
@@ -4213,6 +4213,7 @@ public class Jalview2XML
           loadRnaViewers(jprovider, jseqs, ap0);
         }
       });
+
     }
     // and finally return.
     // but do not set holdRepaint true just yet, because this could be the
@@ -4773,7 +4774,7 @@ public class Jalview2XML
             svattrib.getWidth(), svattrib.getHeight());
     // try
     // {
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
+    Jalview.execRunnable(new Runnable()
       {
         @Override
         public void run()
@@ -4799,7 +4800,8 @@ public class Jalview2XML
             }
           }
         }
-      });
+    });
+    // javax.swing.SwingUtilities.invokeLater(r);
     // } catch (InvocationTargetException ex)
     // {
     // warn("Unexpected error when opening Jmol view.", ex);