JAL-3048 code reordered for JalviewJS compliance
[jalview.git] / src / jalview / gui / Finder.java
index 457d871..fd8eb0c 100755 (executable)
@@ -101,14 +101,15 @@ public class Finder extends GFinder
     frame = new JInternalFrame();
     frame.setContentPane(this);
     frame.setLayer(JLayeredPane.PALETTE_LAYER);
-    frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
-    {
-      @Override
-      public void internalFrameClosing(InternalFrameEvent e)
-      {
-        closeAction();
-      }
-    });
+    frame.addInternalFrameListener(
+            new javax.swing.event.InternalFrameAdapter()
+            {
+              @Override
+              public void internalFrameClosing(InternalFrameEvent e)
+              {
+                closeAction();
+              }
+            });
     addEscapeHandler();
     Desktop.addInternalFrame(frame, MessageManager.getString("label.find"),
             MY_WIDTH, MY_HEIGHT);
@@ -121,8 +122,8 @@ public class Finder extends GFinder
    */
   private void addEscapeHandler()
   {
-    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
-            KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
+    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
+            .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
     getRootPane().getActionMap().put("Cancel", new AbstractAction()
     {
       @Override
@@ -133,7 +134,6 @@ public class Finder extends GFinder
     });
   }
 
-
   /**
    * Performs the 'Find Next' action.
    * 
@@ -223,21 +223,25 @@ public class Finder extends GFinder
     for (SearchResultMatchI match : searchResults.getResults())
     {
       seqs.add(match.getSequence().getDatasetSequence());
-      features.add(new SequenceFeature(searchString, desc, null, match
-              .getStart(), match.getEnd(), desc));
+      features.add(new SequenceFeature(searchString, desc, match.getStart(),
+              match.getEnd(), desc));
     }
 
-    if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
-            features, true, ap))
+    new FeatureEditor(ap).createFeatures(seqs, features, new Runnable()
     {
-      /*
-       * ensure feature display is turned on to show the new features,
-       * and remove them as highlighted regions
-       */
-      ap.alignFrame.showSeqFeatures.setSelected(true);
-      av.setShowSequenceFeatures(true);
-      ap.highlightSearchResults(null);
-    }
+      @Override
+              public void run()
+              {
+
+                /*
+                 * ensure feature display is turned on to show the new features,
+                 * and remove them as highlighted regions
+                 */
+                ap.alignFrame.showSeqFeatures.setSelected(true);
+                av.setShowSequenceFeatures(true);
+                ap.highlightSearchResults(null);
+              }
+            });
   }
 
   /**
@@ -297,6 +301,8 @@ public class Finder extends GFinder
       searchResults = null;
     }
 
+    searchBox.updateCache();
+
     // if allResults is null, this effectively switches displaySearch flag in
     // seqCanvas
     ap.highlightSearchResults(searchResults);
@@ -304,19 +310,19 @@ public class Finder extends GFinder
     // 'SelectRegion' selection
     if (!haveResults)
     {
+      resIndex = -1;
+      seqIndex = 0;
       JvOptionPane.showInternalMessageDialog(this,
               MessageManager.getString("label.finished_searching"), null,
               JvOptionPane.INFORMATION_MESSAGE);
-      resIndex = -1;
-      seqIndex = 0;
     }
     else
     {
       if (doFindAll)
       {
         // then we report the matches that were found
-        String message = (idMatch.size() > 0) ? "" + idMatch.size()
-                + " IDs" : "";
+        String message = (idMatch.size() > 0) ? "" + idMatch.size() + " IDs"
+                : "";
         if (searchResults != null)
         {
           if (idMatch.size() > 0 && searchResults.getSize() > 0)
@@ -326,13 +332,12 @@ public class Finder extends GFinder
           message += searchResults.getSize()
                   + " subsequence matches found.";
         }
-        JvOptionPane.showInternalMessageDialog(this, message, null,
-                JvOptionPane.INFORMATION_MESSAGE);
         resIndex = -1;
         seqIndex = 0;
+        JvOptionPane.showInternalMessageDialog(this, message, null,
+                JvOptionPane.INFORMATION_MESSAGE);
       }
     }
-    searchBox.updateCache();
   }
 
   /**