From: jprocter Date: Mon, 12 Sep 2011 15:55:50 +0000 (+0100) Subject: JAL-927 ensure api method calls that affect GUI state or spawn javascript callbacks... X-Git-Tag: Release_2_7~57 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3af74d4f33154e113234aab32ef8d8c9b04892c8;p=jalview.git JAL-927 ensure api method calls that affect GUI state or spawn javascript callbacks are executed on the AWT worker thread --- diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 25c907d..ba21b97 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -45,6 +45,7 @@ import java.applet.Applet; import java.awt.Button; import java.awt.Color; import java.awt.Component; +import java.awt.EventQueue; import java.awt.Font; import java.awt.Frame; import java.awt.Graphics; @@ -66,17 +67,21 @@ import netscape.javascript.JSObject; * @author $author$ * @version $Revision: 1.92 $ */ -public class JalviewLite extends Applet implements StructureSelectionManagerProvider, JalviewLiteJsApi +public class JalviewLite extends Applet implements + StructureSelectionManagerProvider, JalviewLiteJsApi { public StructureSelectionManager getStructureSelectionManager() { return StructureSelectionManager.getStructureSelectionManager(this); } + // ///////////////////////////////////////// // The following public methods maybe called // externally, eg via javascript in HTML page - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getSelectedSequences() */ public String getSelectedSequences() @@ -84,7 +89,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return getSelectedSequencesFrom(getDefaultTargetFrame()); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getSelectedSequences(java.lang.String) */ public String getSelectedSequences(String sep) @@ -92,16 +99,24 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return getSelectedSequencesFrom(getDefaultTargetFrame(), sep); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui.AlignFrame) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui + * .AlignFrame) */ public String getSelectedSequencesFrom(AlignFrame alf) { return getSelectedSequencesFrom(alf, separator); // ""+0x00AC); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui + * .AlignFrame, java.lang.String) */ public String getSelectedSequencesFrom(AlignFrame alf, String sep) { @@ -125,8 +140,11 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return result.toString(); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#highlight(java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#highlight(java.lang.String, + * java.lang.String, java.lang.String) */ public void highlight(String sequenceId, String position, String alignedPosition) @@ -135,19 +153,22 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv alignedPosition); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#highlightIn(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#highlightIn(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String, java.lang.String) */ - public void highlightIn(AlignFrame alf, String sequenceId, - String position, String alignedPosition) + public void highlightIn(final AlignFrame alf, final String sequenceId, + final String position, final String alignedPosition) { // TODO: could try to highlight in all alignments if alf==null jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher( alf.viewport.getAlignment().getSequencesArray()); - SequenceI sq = matcher.findIdMatch(sequenceId); + final SequenceI sq = matcher.findIdMatch(sequenceId); if (sq != null) { - int pos, apos = -1; + int apos = -1; try { apos = new Integer(position).intValue(); @@ -156,52 +177,79 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv { return; } + final StructureSelectionManagerProvider me = this; + final int pos = apos; // use vamsas listener to broadcast to all listeners in scope if (alignedPosition != null && (alignedPosition.trim().length() == 0 || alignedPosition .toLowerCase().indexOf("false") > -1)) { - StructureSelectionManager.getStructureSelectionManager(this) - .mouseOverVamsasSequence(sq, sq.findIndex(apos), null); + java.awt.EventQueue.invokeLater(new Runnable() + { + @Override + public void run() + { + StructureSelectionManager.getStructureSelectionManager(me) + .mouseOverVamsasSequence(sq, sq.findIndex(pos), null); + } + }); } else { - StructureSelectionManager.getStructureSelectionManager(this) - .mouseOverVamsasSequence(sq, apos, null); + java.awt.EventQueue.invokeLater(new Runnable() + { + @Override + public void run() + { + StructureSelectionManager.getStructureSelectionManager(me) + .mouseOverVamsasSequence(sq, pos, null); + } + }); } - } } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#select(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#select(java.lang.String, + * java.lang.String) */ public void select(String sequenceIds, String columns) { selectIn(getDefaultTargetFrame(), sequenceIds, columns, separator); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#select(java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#select(java.lang.String, + * java.lang.String, java.lang.String) */ public void select(String sequenceIds, String columns, String sep) { selectIn(getDefaultTargetFrame(), sequenceIds, columns, sep); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#selectIn(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#selectIn(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String) */ public void selectIn(AlignFrame alf, String sequenceIds, String columns) { selectIn(alf, sequenceIds, columns, separator); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#selectIn(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#selectIn(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String, java.lang.String) */ - public void selectIn(AlignFrame alf, String sequenceIds, String columns, - String sep) + public void selectIn(final AlignFrame alf, String sequenceIds, + String columns, String sep) { if (sep == null || sep.length() == 0) { @@ -218,8 +266,8 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv // deparse fields String[] ids = separatorListToArray(sequenceIds, sep); String[] cols = separatorListToArray(columns, sep); - SequenceGroup sel = new SequenceGroup(); - ColumnSelection csel = new ColumnSelection(); + final SequenceGroup sel = new SequenceGroup(); + final ColumnSelection csel = new ColumnSelection(); AlignmentI al = alf.viewport.getAlignment(); jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher( alf.viewport.getAlignment().getSequencesArray()); @@ -405,12 +453,23 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } sel.setStartRes(start); sel.setEndRes(end); - alf.select(sel, csel); + EventQueue.invokeLater(new Runnable() + { + @Override + public void run() + { + alf.select(sel, csel); + } + }); } } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getSelectedSequencesAsAlignment(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getSelectedSequencesAsAlignment(java.lang. + * String, java.lang.String) */ public String getSelectedSequencesAsAlignment(String format, String suffix) { @@ -418,8 +477,12 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv format, suffix); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getSelectedSequencesAsAlignmentFrom(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getSelectedSequencesAsAlignmentFrom(jalview + * .appletgui.AlignFrame, java.lang.String, java.lang.String) */ public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf, String format, String suffix) @@ -442,7 +505,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return ""; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getAlignmentOrder() */ public String getAlignmentOrder() @@ -450,16 +515,24 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return getAlignmentOrderFrom(getDefaultTargetFrame()); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getAlignmentOrderFrom(jalview.appletgui.AlignFrame) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getAlignmentOrderFrom(jalview.appletgui.AlignFrame + * ) */ public String getAlignmentOrderFrom(AlignFrame alf) { return getAlignmentOrderFrom(alf, separator); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getAlignmentOrderFrom(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getAlignmentOrderFrom(jalview.appletgui.AlignFrame + * , java.lang.String) */ public String getAlignmentOrderFrom(AlignFrame alf, String sep) { @@ -472,24 +545,34 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return arrayToSeparatorList(order); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#orderBy(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#orderBy(java.lang.String, + * java.lang.String) */ public String orderBy(String order, String undoName) { return orderBy(order, undoName, separator); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#orderBy(java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#orderBy(java.lang.String, + * java.lang.String, java.lang.String) */ public String orderBy(String order, String undoName, String sep) { return orderAlignmentBy(getDefaultTargetFrame(), order, undoName, sep); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#orderAlignmentBy(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#orderAlignmentBy(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String, java.lang.String) */ public String orderAlignmentBy(AlignFrame alf, String order, String undoName, String sep) @@ -530,17 +613,21 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return ""; } ; - AlignmentOrder aorder = new AlignmentOrder(sqs); + final AlignmentOrder aorder = new AlignmentOrder(sqs); if (undoName != null && undoName.trim().length() == 0) { undoName = null; } - - return alf.sortBy(aorder, undoName) ? "true" : ""; + final String _undoName = undoName; + // TODO: deal with synchronization here: cannot raise any events until after + // this has returned. + return alf.sortBy(aorder, _undoName) ? "true" : ""; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getAlignment(java.lang.String) */ public String getAlignment(String format) @@ -548,24 +635,35 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return getAlignmentFrom(getDefaultTargetFrame(), format, "true"); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getAlignmentFrom(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getAlignmentFrom(jalview.appletgui.AlignFrame, + * java.lang.String) */ public String getAlignmentFrom(AlignFrame alf, String format) { return getAlignmentFrom(alf, format, "true"); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getAlignment(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#getAlignment(java.lang.String, + * java.lang.String) */ public String getAlignment(String format, String suffix) { return getAlignmentFrom(getDefaultTargetFrame(), format, suffix); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getAlignmentFrom(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getAlignmentFrom(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String) */ public String getAlignmentFrom(AlignFrame alf, String format, String suffix) @@ -584,7 +682,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#loadAnnotation(java.lang.String) */ public void loadAnnotation(String annotation) @@ -592,8 +692,12 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv loadAnnotationFrom(getDefaultTargetFrame(), annotation); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame + * , java.lang.String) */ public void loadAnnotationFrom(AlignFrame alf, String annotation) { @@ -609,7 +713,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getFeatures(java.lang.String) */ public String getFeatures(String format) @@ -617,15 +723,21 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return getFeaturesFrom(getDefaultTargetFrame(), format); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getFeaturesFrom(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getFeaturesFrom(jalview.appletgui.AlignFrame, + * java.lang.String) */ public String getFeaturesFrom(AlignFrame alf, String format) { return alf.outputFeatures(false, format); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getAnnotation() */ public String getAnnotation() @@ -633,15 +745,21 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return getAnnotationFrom(getDefaultTargetFrame()); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getAnnotationFrom(jalview.appletgui.AlignFrame) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getAnnotationFrom(jalview.appletgui.AlignFrame + * ) */ public String getAnnotationFrom(AlignFrame alf) { return alf.outputAnnotations(false); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#newView() */ public AlignFrame newView() @@ -649,7 +767,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return newViewFrom(getDefaultTargetFrame()); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#newView(java.lang.String) */ public AlignFrame newView(String name) @@ -657,7 +777,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return newViewFrom(getDefaultTargetFrame(), name); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#newViewFrom(jalview.appletgui.AlignFrame) */ public AlignFrame newViewFrom(AlignFrame alf) @@ -665,16 +787,22 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return alf.newView(null); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#newViewFrom(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#newViewFrom(jalview.appletgui.AlignFrame, + * java.lang.String) */ public AlignFrame newViewFrom(AlignFrame alf, String name) { return alf.newView(name); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#loadAlignment(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#loadAlignment(java.lang.String, + * java.lang.String) */ public AlignFrame loadAlignment(String text, String title) { @@ -697,7 +825,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return null; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#setMouseoverListener(java.lang.String) */ public void setMouseoverListener(String listener) @@ -707,8 +837,12 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv private Vector javascriptListeners = new Vector(); - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#setMouseoverListener(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#setMouseoverListener(jalview.appletgui.AlignFrame + * , java.lang.String) */ public void setMouseoverListener(AlignFrame af, String listener) { @@ -737,7 +871,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#setSelectionListener(java.lang.String) */ public void setSelectionListener(String listener) @@ -745,8 +881,12 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv setSelectionListener(null, listener); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#setSelectionListener(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#setSelectionListener(jalview.appletgui.AlignFrame + * , java.lang.String) */ public void setSelectionListener(AlignFrame af, String listener) { @@ -775,8 +915,11 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#setStructureListener(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#setStructureListener(java.lang.String, + * java.lang.String) */ public void setStructureListener(String listener, String modelSet) { @@ -804,8 +947,12 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#removeJavascriptListener(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#removeJavascriptListener(jalview.appletgui + * .AlignFrame, java.lang.String) */ public void removeJavascriptListener(AlignFrame af, String listener) { @@ -858,30 +1005,33 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv public void stop() { - System.err.println("Applet "+getName()+" stop()."); + System.err.println("Applet " + getName() + " stop()."); tidyUp(); } + public void destroy() { - System.err.println("Applet "+getName()+" destroy()."); + System.err.println("Applet " + getName() + " destroy()."); tidyUp(); } + private void tidyUp() { removeAll(); - if (currentAlignFrame!=null && currentAlignFrame.viewport!=null - && currentAlignFrame.viewport.applet!=null) + if (currentAlignFrame != null && currentAlignFrame.viewport != null + && currentAlignFrame.viewport.applet != null) { AlignViewport av = currentAlignFrame.viewport; currentAlignFrame.closeMenuItem_actionPerformed(); - av.applet=null; - currentAlignFrame=null; + av.applet = null; + currentAlignFrame = null; } if (javascriptListeners != null) { while (javascriptListeners.size() > 0) { - jalview.javascript.JSFunctionExec mol = javascriptListeners.elementAt(0); + jalview.javascript.JSFunctionExec mol = javascriptListeners + .elementAt(0); javascriptListeners.removeElement(mol); if (mol instanceof SelectionListener) { @@ -893,87 +1043,151 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv StructureSelectionManager.getStructureSelectionManager(this) .removeStructureViewerListener(mol, null); } - mol.jvlite=null; + mol.jvlite = null; } } - if (jsFunctionExec!=null) { + if (jsFunctionExec != null) + { jsFunctionExec.stopQueue(); - jsFunctionExec.jvlite=null; + jsFunctionExec.jvlite = null; } - initialAlignFrame=null; + initialAlignFrame = null; jsFunctionExec = null; - javascriptListeners=null; + javascriptListeners = null; StructureSelectionManager.release(this); } + private jalview.javascript.JSFunctionExec jsFunctionExec; - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#mouseOverStructure(java.lang.String, java.lang.String, java.lang.String) + + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#mouseOverStructure(java.lang.String, + * java.lang.String, java.lang.String) */ - public void mouseOverStructure(String pdbResNum, String chain, - String pdbfile) + public void mouseOverStructure(final String pdbResNum, + final String chain, final String pdbfile) { - try + final StructureSelectionManagerProvider me = this; + java.awt.EventQueue.invokeLater(new Runnable() { - StructureSelectionManager.getStructureSelectionManager(this) - .mouseOverStructure(new Integer(pdbResNum).intValue(), chain, - pdbfile); - if (debug) + @Override + public void run() { - System.err.println("mouseOver for '" + pdbResNum + "' in chain '" - + chain + "' in structure '" + pdbfile + "'"); + try + { + StructureSelectionManager.getStructureSelectionManager(me) + .mouseOverStructure(new Integer(pdbResNum).intValue(), + chain, pdbfile); + if (debug) + { + System.err.println("mouseOver for '" + pdbResNum + + "' in chain '" + chain + "' in structure '" + pdbfile + + "'"); + } + } catch (NumberFormatException e) + { + System.err.println("Ignoring invalid residue number string '" + + pdbResNum + "'"); + } + } - } catch (NumberFormatException e) - { - System.err.println("Ignoring invalid residue number string '" - + pdbResNum + "'"); - } + }); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#scrollViewToIn(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String) + + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#scrollViewToIn(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String) */ - public void scrollViewToIn(AlignFrame alf, String topRow, String leftHandColumn) + public void scrollViewToIn(final AlignFrame alf, final String topRow, + final String leftHandColumn) { - try { - alf.scrollTo(new Integer(topRow).intValue(), new Integer(leftHandColumn).intValue()); - - } catch (Exception ex) + java.awt.EventQueue.invokeLater(new Runnable() { - System.err.println("Couldn't parse integer arguments (topRow='"+topRow+"' and leftHandColumn='"+leftHandColumn+"')"); - ex.printStackTrace(); - } + @Override + public void run() + { + try + { + alf.scrollTo(new Integer(topRow).intValue(), new Integer( + leftHandColumn).intValue()); + + } catch (Exception ex) + { + System.err.println("Couldn't parse integer arguments (topRow='" + + topRow + "' and leftHandColumn='" + leftHandColumn + + "')"); + ex.printStackTrace(); + } + } + }); } - /* (non-Javadoc) - * @see jalview.javascript.JalviewLiteJsApi#scrollViewToRowIn(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.javascript.JalviewLiteJsApi#scrollViewToRowIn(jalview.appletgui + * .AlignFrame, java.lang.String) */ @Override - public void scrollViewToRowIn(AlignFrame alf, String topRow) + public void scrollViewToRowIn(final AlignFrame alf, final String topRow) { - try { - alf.scrollToRow(new Integer(topRow).intValue()); - - } catch (Exception ex) + + java.awt.EventQueue.invokeLater(new Runnable() { - System.err.println("Couldn't parse integer arguments (topRow='"+topRow+"')"); - ex.printStackTrace(); - } + @Override + public void run() + { + try + { + alf.scrollToRow(new Integer(topRow).intValue()); + + } catch (Exception ex) + { + System.err.println("Couldn't parse integer arguments (topRow='" + + topRow + "')"); + ex.printStackTrace(); + } + + } + }); } - /* (non-Javadoc) - * @see jalview.javascript.JalviewLiteJsApi#scrollViewToColumnIn(jalview.appletgui.AlignFrame, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * jalview.javascript.JalviewLiteJsApi#scrollViewToColumnIn(jalview.appletgui + * .AlignFrame, java.lang.String) */ @Override - public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn) + public void scrollViewToColumnIn(final AlignFrame alf, + final String leftHandColumn) { - - try { - alf.scrollToColumn(new Integer(leftHandColumn).intValue()); - - } catch (Exception ex) + java.awt.EventQueue.invokeLater(new Runnable() { - System.err.println("Couldn't parse integer arguments (leftHandColumn='"+leftHandColumn+"')"); - ex.printStackTrace(); - } + + @Override + public void run() + { + try + { + alf.scrollToColumn(new Integer(leftHandColumn).intValue()); + + } catch (Exception ex) + { + System.err + .println("Couldn't parse integer arguments (leftHandColumn='" + + leftHandColumn + "')"); + ex.printStackTrace(); + } + } + }); + } // ////////////////////////////////////////////// @@ -1310,9 +1524,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv { vp.applet.currentAlignFrame = null; } - vp.applet=null; - vp=null; - + vp.applet = null; + vp = null; + } lastFrameX -= 40; lastFrameY -= 40; @@ -1902,7 +2116,8 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv { if (file.indexOf("://") == -1) { - String fl = applet.resolveUrlForLocalOrAbsolute(file, getDocumentBase()); + String fl = applet.resolveUrlForLocalOrAbsolute(file, + getDocumentBase()); try { if (new java.net.URL(fl).openStream() != null) @@ -1969,9 +2184,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv // IDS include pipes. /** - * set to enable the URL based javascript execution mechanism + * set to enable the URL based javascript execution mechanism */ - public boolean jsfallbackEnabled=false; + public boolean jsfallbackEnabled = false; /** * parse the string into a list @@ -2089,7 +2304,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return "" + separator; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getFeatureGroups() */ public String getFeatureGroups() @@ -2099,8 +2316,12 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return lst; } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getFeatureGroupsOn(jalview.appletgui.AlignFrame) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getFeatureGroupsOn(jalview.appletgui.AlignFrame + * ) */ public String getFeatureGroupsOn(AlignFrame alf) { @@ -2108,7 +2329,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return lst; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getFeatureGroupsOfState(boolean) */ public String getFeatureGroupsOfState(boolean visible) @@ -2117,34 +2340,53 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv .getFeatureGroupsOfState(visible)); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#getFeatureGroupsOfStateOn(jalview.appletgui.AlignFrame, boolean) + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#getFeatureGroupsOfStateOn(jalview.appletgui + * .AlignFrame, boolean) */ public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible) { return arrayToSeparatorList(alf.getFeatureGroupsOfState(visible)); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#setFeatureGroupStateOn(jalview.appletgui.AlignFrame, java.lang.String, boolean) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#setFeatureGroupStateOn(jalview.appletgui. + * AlignFrame, java.lang.String, boolean) */ - public void setFeatureGroupStateOn(AlignFrame alf, String groups, - boolean state) + public void setFeatureGroupStateOn(final AlignFrame alf, + final String groups, boolean state) { - boolean st = state;// !(state==null || state.equals("") || + final boolean st = state;// !(state==null || state.equals("") || // state.toLowerCase().equals("false")); - alf.setFeatureGroupState(separatorListToArray(groups), st); + java.awt.EventQueue.invokeLater(new Runnable() + { + @Override + public void run() + { + alf.setFeatureGroupState(separatorListToArray(groups), st); + } + }); } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#setFeatureGroupState(java.lang.String, boolean) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#setFeatureGroupState(java.lang.String, + * boolean) */ public void setFeatureGroupState(String groups, boolean state) { setFeatureGroupStateOn(getDefaultTargetFrame(), groups, state); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getSeparator() */ public String getSeparator() @@ -2152,7 +2394,9 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return separator; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#setSeparator(java.lang.String) */ public void setSeparator(String separator) @@ -2193,8 +2437,11 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv return false; } - /* (non-Javadoc) - * @see jalview.bin.JalviewLiteJsApi#addPdbFile(jalview.appletgui.AlignFrame, java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see jalview.bin.JalviewLiteJsApi#addPdbFile(jalview.appletgui.AlignFrame, + * java.lang.String, java.lang.String, java.lang.String) */ public boolean addPdbFile(AlignFrame alFrame, String sequenceId, String pdbEntryString, String pdbFile) @@ -2214,39 +2461,51 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv public void start() { -// callInitCallback(); + // callInitCallback(); } - private Hashtable jshashes=new Hashtable(); - private Hashtable> jsmessages=new Hashtable>(); + + private Hashtable jshashes = new Hashtable(); + + private Hashtable> jsmessages = new Hashtable>(); + public void setJsMessageSet(String messageclass, String viewId, String[] colcommands) { - Hashtable msgset = jsmessages.get(messageclass); - if (msgset==null) + Hashtable msgset = jsmessages.get(messageclass); + if (msgset == null) { - msgset=new Hashtable(); + msgset = new Hashtable(); jsmessages.put(messageclass, msgset); } msgset.put(viewId, colcommands); long[] l = new long[colcommands.length]; - for (int i=0;i msgset = jsmessages.get(messageclass); - if (msgset!=null) + Hashtable msgset = jsmessages.get(messageclass); + if (msgset != null) { String[] msgs = msgset.get(viewId); - if (msgs!=null) + if (msgs != null) { - for (int i=0;i