Merge branch 'develop' into features/JAL-1780_export-settings_flatfile
[jalview.git] / src / jalview / io / FileLoader.java
index e27c666..0cd2987 100755 (executable)
  */
 package jalview.io;
 
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
 import jalview.api.ComplexAlignFile;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
@@ -39,6 +33,12 @@ import jalview.schemes.ColourSchemeI;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
 
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
 public class FileLoader implements Runnable
 {
   String file;
@@ -317,6 +317,7 @@ public class FileLoader implements Runnable
 
         if ((al != null) && (al.getHeight() > 0))
         {
+          // construct and register dataset sequences
           for (SequenceI sq : al.getSequences())
           {
             while (sq.getDatasetSequence() != null)
@@ -327,21 +328,23 @@ public class FileLoader implements Runnable
             {
               for (PDBEntry pdbe : sq.getPDBId())
               {
+                // register PDB entries with desktop's structure selection
+                // manager
                 StructureSelectionManager.getStructureSelectionManager(
                         Desktop.instance).registerPDBEntry(pdbe);
               }
             }
           }
+
           if (viewport != null)
           {
+            // append to existing alignment
             viewport.addAlignment(al, title);
           }
           else
           {
-            if (!protocol.equals(AppletFormatAdapter.PASTE))
-            {
-              alignFrame.setFileName(file, format);
-            }
+            // otherwise construct the alignFrame
+
             if (source instanceof ComplexAlignFile)
             {
               ColumnSelection colSel = ((ComplexAlignFile) source)
@@ -353,8 +356,7 @@ public class FileLoader implements Runnable
               ColourSchemeI cs = ((ComplexAlignFile) source)
                       .getColourScheme();
               alignFrame = new AlignFrame(al, hiddenSeqs, colSel,
-                      AlignFrame.DEFAULT_WIDTH,
-                      AlignFrame.DEFAULT_HEIGHT);
+                      AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
 
               alignFrame.getViewport().setShowSequenceFeatures(
                       showSeqFeatures);
@@ -365,29 +367,34 @@ public class FileLoader implements Runnable
               alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
                       AlignFrame.DEFAULT_HEIGHT);
             }
+          }
+          // add metadata and update ui
+          if (!protocol.equals(AppletFormatAdapter.PASTE))
+          {
+            alignFrame.setFileName(file, format);
+          }
 
-            alignFrame.statusBar.setText(MessageManager.formatMessage(
-                    "label.successfully_loaded_file", new String[]
-                    { title }));
+          alignFrame.statusBar.setText(MessageManager.formatMessage(
+                  "label.successfully_loaded_file", new String[]
+                  { title }));
 
-            if (raiseGUI)
-            {
-              // add the window to the GUI
-              // note - this actually should happen regardless of raiseGUI
-              // status in Jalview 3
-              // TODO: define 'virtual desktop' for benefit of headless scripts
-              // that perform queries to find the 'current working alignment'
-              Desktop.addInternalFrame(alignFrame, title,
-                      AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
-            }
+          if (raiseGUI)
+          {
+            // add the window to the GUI
+            // note - this actually should happen regardless of raiseGUI
+            // status in Jalview 3
+            // TODO: define 'virtual desktop' for benefit of headless scripts
+            // that perform queries to find the 'current working alignment'
+            Desktop.addInternalFrame(alignFrame, title,
+                    AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+          }
 
-            try
-            {
-              alignFrame.setMaximum(jalview.bin.Cache.getDefault(
-                      "SHOW_FULLSCREEN", false));
-            } catch (java.beans.PropertyVetoException ex)
-            {
-            }
+          try
+          {
+            alignFrame.setMaximum(jalview.bin.Cache.getDefault(
+                    "SHOW_FULLSCREEN", false));
+          } catch (java.beans.PropertyVetoException ex)
+          {
           }
         }
         else