ensure source is rarely null
authorjprocter <Jim Procter>
Fri, 21 Jan 2011 17:03:40 +0000 (17:03 +0000)
committerjprocter <Jim Procter>
Fri, 21 Jan 2011 17:03:40 +0000 (17:03 +0000)
src/jalview/javascript/JsSelectionSender.java

index d948363..e55c658 100644 (file)
@@ -35,34 +35,16 @@ public class JsSelectionSender extends JSFunctionExec implements
       String setid = "";
       String viewid = "";
       AlignFrame src = _af;
-      // filter events if necessary
-      if (source instanceof AlignViewport)
+      if (source != null)
       {
-        if (_af != null
-                && !_af.alignPanel.av.getSequenceSetId().equals(
-                        ((AlignViewport) source).getSequenceSetId()))
+        if (source instanceof jalview.appletgui.AlignViewport
+                && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
         {
-          return;
-        }
-        jalview.appletgui.AlignmentPanel[] aps = jalview.appletgui.PaintRefresher
-                .getAssociatedPanels(setid = ((AlignViewport) source)
-                        .getSequenceSetId());
-        for (int a = 0; a < aps.length; a++)
-        {
-          System.out.println("Selection: testing source alignPanel : "
-                  + aps[a].getName());
-          if (aps[a].av == source)
-          {
-            src = aps[a].alignFrame;
-          }
+          // should be valid if it just generated an event!
+          src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
+
         }
       }
-      else
-      {
-        // unhandled!
-        System.err.println("Unhandled selection source !");
-        return;
-      }
       String[] seqs = new String[]
       {};
       String[] cols = new String[]