Merge branch 'Jalview-BH/JAL-3026-JAL-3063-JAXB' of
[jalview.git] / src / jalview / gui / SequenceFetcher.java
index 8037fed..646a7f1 100755 (executable)
@@ -145,8 +145,8 @@ public class SequenceFetcher extends JPanel implements Runnable
 
     frame = new JInternalFrame();
     frame.setContentPane(this);
-    int height = Platform.isAMac() ? 240 : 180;
-    Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, height);
+    Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, 
+               Platform.isAMacAndNotJS() ? 240 : 180);
   }
 
   private String getFrameTitle()
@@ -187,13 +187,13 @@ public class SequenceFetcher extends JPanel implements Runnable
 
         if ("pdb".equalsIgnoreCase(currentSelection))
         {
-          new PDBFTSPanel(SequenceFetcher.this);
           frame.dispose();
+          new PDBFTSPanel(SequenceFetcher.this);
         }
         else if ("uniprot".equalsIgnoreCase(currentSelection))
         {
-          new UniprotFTSPanel(SequenceFetcher.this);
           frame.dispose();
+          new UniprotFTSPanel(SequenceFetcher.this);
         }
         else
         {
@@ -207,11 +207,11 @@ public class SequenceFetcher extends JPanel implements Runnable
     JLabel jLabel1 = new JLabel(MessageManager
             .getString("label.separate_multiple_accession_ids"));
     jLabel1.setFont(new Font("Verdana", Font.ITALIC, 11));
-    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
+    jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
 
     replacePunctuation = new JCheckBox(
             MessageManager.getString("label.replace_commas_semicolons"));
-    replacePunctuation.setHorizontalAlignment(SwingConstants.CENTER);
+    replacePunctuation.setHorizontalAlignment(SwingConstants.LEFT);
     replacePunctuation.setFont(new Font("Verdana", Font.ITALIC, 11));
     okBtn = new JButton(MessageManager.getString("action.ok"));
     okBtn.addActionListener(new ActionListener()
@@ -331,7 +331,7 @@ public class SequenceFetcher extends JPanel implements Runnable
   }
 
   /**
-   * Action on selected a database other than Uniprot or PDB is to enable or
+   * Action on selecting a database other than Uniprot or PDB is to enable or
    * disable 'Replace commas', and await input in the query field
    */
   protected void otherSourceAction()
@@ -340,8 +340,7 @@ public class SequenceFetcher extends JPanel implements Runnable
     {
       String eq = exampleAccession.getText();
       // TODO this should be a property of the SequenceFetcher whether commas
-      // are and
-      // colons are allowed in the IDs...
+      // are allowed in the IDs...
 
       boolean enablePunct = !(eq != null && eq.indexOf(",") > -1);
       replacePunctuation.setEnabled(enablePunct);
@@ -418,13 +417,17 @@ public class SequenceFetcher extends JPanel implements Runnable
     /*
      * tidy inputs and check there is something to search for
      */
-    String text = textArea.getText();
+    String t0 = textArea.getText();
+    String text = t0.trim();
     if (replacePunctuation.isEnabled() && replacePunctuation.isSelected())
     {
       text = text.replace(",", ";");
     }
-    text = text.replaceAll("(\\s|[,; ])+", ";");
-    textArea.setText(text);
+    text = text.replaceAll("(\\s|[; ])+", ";");
+    if (!t0.equals(text)) 
+    {
+         textArea.setText(text);
+    }
     if (text.isEmpty())
     {
       // todo i18n
@@ -463,9 +466,8 @@ public class SequenceFetcher extends JPanel implements Runnable
     List<DbSourceProxy> sources = sfetch
             .getSourceProxy((String) database.getSelectedItem());
     Iterator<DbSourceProxy> proxies = sources.iterator();
-    String[] qries;
-    List<String> nextFetch = Arrays
-            .asList(qries = textArea.getText().split(";"));
+    String[] qries = textArea.getText().trim().split(";");
+    List<String> nextFetch = Arrays.asList(qries);
     Iterator<String> en = Arrays.asList(new String[0]).iterator();
     int nqueries = qries.length;
 
@@ -751,13 +753,14 @@ public class SequenceFetcher extends JPanel implements Runnable
 
     for (String q : queries)
     {
-      DBRefEntry dbr = new DBRefEntry();
-      dbr.setSource(proxy.getDbSource());
-      dbr.setVersion(null);
+       // BH 2019.01.25 dbr is never used.
+//      DBRefEntry dbr = new DBRefEntry();
+//      dbr.setSource(proxy.getDbSource());
+//      dbr.setVersion(null);
       String accId = proxy.getAccessionIdFromQuery(q);
-      dbr.setAccessionId(accId);
+//      dbr.setAccessionId(accId);
       boolean rfound = false;
-      for (int r = 0; r < rs.length; r++)
+      for (int r = 0, nr = rs.length; r < nr; r++)
       {
         if (rs[r] != null)
         {