/* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.javascript; import jalview.api.JalviewApp; import jalview.appletgui.AlignFrame; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SequenceGroup; import jalview.structure.SelectionSource; public class JsSelectionSender extends JSFunctionExec implements jalview.structure.SelectionListener, JsCallBack { AlignFrame _af; String _listener; public JsSelectionSender(JalviewApp jvlite, AlignFrame af, String listener, boolean debug) { super(jvlite, debug); _af = af; _listener = listener; } @Override public void selection(SequenceGroup seqsel, ColumnSelection colsel, HiddenColumns hidden, SelectionSource source) { Object[] info = jvlite.getSelectionForListener(seqsel, colsel, hidden, source, _af); try { System.err.println("Relaying selection to jsfunction:" + _listener); executeJavascriptFunction(_listener, info); } catch (Exception ex) { System.err.println( "Jalview Javascript exec error: Couldn't send selection message using function '" + _listener + "'"); ex.printStackTrace(); if (ex instanceof netscape.javascript.JSException) { System.err.println("Javascript Exception: " + ((netscape.javascript.JSException) ex).getCause() .toString()); } } } @Override public AlignFrame getAlignFrame() { return _af; } @Override public String getListenerFunction() { return _listener; } }