FileFormat enum wip changes
[jalview.git] / src / jalview / gui / SequenceFetcher.java
index d5a04a9..3a77c6c 100755 (executable)
@@ -28,9 +28,11 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.fts.service.pdb.PDBFTSPanel;
 import jalview.fts.service.uniprot.UniprotFTSPanel;
+import jalview.io.FileFormatI;
 import jalview.io.gff.SequenceOntologyI;
 import jalview.util.DBRefUtils;
 import jalview.util.MessageManager;
+import jalview.util.Platform;
 import jalview.ws.dbsources.das.api.DasSourceRegistryI;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
@@ -274,13 +276,13 @@ public class SequenceFetcher extends JPanel implements Runnable
 
     frame = new JInternalFrame();
     frame.setContentPane(this);
-    if (new jalview.util.Platform().isAMac())
+    if (Platform.isAMac())
     {
-      Desktop.addInternalFrame(frame, getFrameTitle(), 400, 240);
+      Desktop.addInternalFrame(frame, getFrameTitle(), false, 400, 240);
     }
     else
     {
-      Desktop.addInternalFrame(frame, getFrameTitle(), 400, 180);
+      Desktop.addInternalFrame(frame, getFrameTitle(), false, 400, 180);
     }
   }
 
@@ -365,7 +367,19 @@ public class SequenceFetcher extends JPanel implements Runnable
     jPanel1.add(close);
     jPanel3.add(jPanel2, java.awt.BorderLayout.CENTER);
     jPanel2.setLayout(borderLayout3);
-    databaseButt = database.getDatabaseSelectorButton();
+    databaseButt = /*database.getDatabaseSelectorButton();
+                   final JButton viewdbs =*/new JButton(
+            MessageManager.getString("action.select_ddbb"));
+    databaseButt.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent arg0)
+      {
+        hidePanel();
+        database.showDialog();
+      }
+    });
     databaseButt.setFont(JvSwingUtils.getLabelFont());
     database.addActionListener(new ActionListener()
     {
@@ -374,6 +388,12 @@ public class SequenceFetcher extends JPanel implements Runnable
       {
         debounceTrap++;
         String currentSelection = database.getSelectedItem();
+        if (currentSelection == null)
+        {
+          close_actionPerformed(null);
+        }
+
+        showPanel();
 
         if (currentSelection.equalsIgnoreCase("pdb")
                 && (database.action == KeyEvent.VK_ENTER || ((debounceTrap % 2) == 0)))
@@ -407,6 +427,10 @@ public class SequenceFetcher extends JPanel implements Runnable
     this.add(jPanel2, java.awt.BorderLayout.NORTH);
     jScrollPane1.getViewport().add(textArea);
 
+    /*
+     * open the database tree
+     */
+    database.waitForInput();
   }
 
   private void pdbSourceAction()
@@ -873,7 +897,7 @@ public class SequenceFetcher extends JPanel implements Runnable
   }
 
   AlignmentI parseResult(AlignmentI al, String title,
-          String currentFileFormat,
+          FileFormatI currentFileFormat,
           FeatureSettingsModelI preferredFeatureColours)
   {
 
@@ -919,7 +943,7 @@ public class SequenceFetcher extends JPanel implements Runnable
         }
         if (Cache.getDefault("HIDE_INTRONS", true))
         {
-          hideIntronsIfPresent(af);
+          af.hideFeatureColumns(SequenceOntologyI.EXON, false);
         }
 
         Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
@@ -944,25 +968,6 @@ public class SequenceFetcher extends JPanel implements Runnable
     return al;
   }
 
-  /**
-   * Hide columns not containing 'exon' features, provided there are exon
-   * features on the alignment
-   * 
-   * @param af
-   */
-  public void hideIntronsIfPresent(AlignFrame af)
-  {
-    boolean hasExons = af.avc.markColumnsContainingFeatures(false, false,
-            false,
-            SequenceOntologyI.EXON);
-    if (hasExons)
-    {
-      af.avc.markColumnsContainingFeatures(true, false, true,
-              SequenceOntologyI.EXON);
-      af.getViewport().hideSelectedColumns();
-    }
-  }
-
   void showErrorMessage(final String error)
   {
     resetDialog();
@@ -987,4 +992,22 @@ public class SequenceFetcher extends JPanel implements Runnable
   {
     this.progressIndicator = progressIndicator;
   }
+
+  /**
+   * Make this panel visible (after a selection has been made in the database
+   * chooser)
+   */
+  void showPanel()
+  {
+    frame.setVisible(true);
+  }
+
+  /**
+   * Hide this panel (on clicking the database button to open the database
+   * chooser)
+   */
+  void hidePanel()
+  {
+    frame.setVisible(false);
+  }
 }