X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=7329a6f4f456eb49cbf5c087eb628d6c2ac87030;hb=8f21e24ce2efb4d0980d8a2af958668048fc72d6;hp=393476d387131208575cc85fc0036c30ba98af32;hpb=f533fb6976a511f5e76afdf176fce0f5c580064d;p=jalview.git diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 393476d..7329a6f 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -258,6 +258,7 @@ public class JalviewLite extends Applet public AlignFrame loadAlignment(String text, String title) { Alignment al = null; + String format = new IdentifyFile().Identify(text, AppletFormatAdapter.PASTE); try @@ -305,6 +306,7 @@ public class JalviewLite extends Applet boolean embedded = false; private boolean checkForJmol = true; + private boolean checkedForJmol = false; // ensure we don't check for jmol every time the app is re-inited public boolean jmolAvailable = false; @@ -327,7 +329,7 @@ public class JalviewLite extends Applet * if true disable the check for jmol */ String chkforJmol = getParameter("nojmol"); - if (chkforJmol!=null) + if (chkforJmol != null) { checkForJmol = !chkforJmol.equals("true"); } @@ -397,9 +399,6 @@ public class JalviewLite extends Applet } } - LoadJmolThread jmolAvailable = new LoadJmolThread(); - jmolAvailable.start(); - final JalviewLite applet = this; if (getParameter("embedded") != null && getParameter("embedded").equalsIgnoreCase("true")) @@ -540,8 +539,14 @@ public class JalviewLite extends Applet class LoadJmolThread extends Thread { + private boolean running=false; + public void run() { + if (running || checkedForJmol) { + return; + } + running=true; if (checkForJmol) { try @@ -559,13 +564,23 @@ public class JalviewLite extends Applet } catch (java.lang.ClassNotFoundException ex) { } - } else { - jmolAvailable=false; + } + else + { + jmolAvailable = false; if (debug) { - System.err.println("Skipping Jmol check. Will use MCView (probably)"); + System.err + .println("Skipping Jmol check. Will use MCView (probably)"); } } + checkedForJmol=true; + running=false; + } + + public boolean notFinished() + { + return running || !checkedForJmol; } } @@ -585,9 +600,8 @@ public class JalviewLite extends Applet * State variable: format of file source */ String format; - + String _file; JalviewLite applet; - private void dbgMsg(String msg) { if (applet.debug) @@ -622,24 +636,33 @@ public class JalviewLite extends Applet dbgMsg("Protocol identified as '" + protocol + "'"); return file; } - + public LoadingThread(String _file, JalviewLite _applet) { - dbgMsg("Loading thread started with:\n>>file\n" + _file + ">>endfile"); - file = setProtocolState(_file); - - format = new jalview.io.IdentifyFile().Identify(file, protocol); - dbgMsg("File identified as '" + format + "'"); + this._file=_file; applet = _applet; } public void run() { + LoadJmolThread jmolchecker = new LoadJmolThread(); + jmolchecker.start(); + while (jmolchecker.notFinished()) + { + // wait around until the Jmol check is complete. + try { Thread.sleep(2); } catch (Exception e) {}; + } startLoading(); } private void startLoading() { + AlignFrame newAlignFrame; + dbgMsg("Loading thread started with:\n>>file\n" + _file + ">>endfile"); + file = setProtocolState(_file); + + format = new jalview.io.IdentifyFile().Identify(file, protocol); + dbgMsg("File identified as '" + format + "'"); dbgMsg("Loading started."); Alignment al = null; try @@ -653,16 +676,20 @@ public class JalviewLite extends Applet if ((al != null) && (al.getHeight() > 0)) { dbgMsg("Successfully loaded file."); - initialAlignFrame = new AlignFrame(al, applet, file, embedded); + newAlignFrame = new AlignFrame(al, applet, file, embedded); + if (initialAlignFrame==null) + { + initialAlignFrame = newAlignFrame; + } // update the focus. - currentAlignFrame = initialAlignFrame; + currentAlignFrame = newAlignFrame; if (protocol == jalview.io.AppletFormatAdapter.PASTE) { - currentAlignFrame.setTitle("Sequences from " + getDocumentBase()); + newAlignFrame.setTitle("Sequences from " + getDocumentBase()); } - currentAlignFrame.statusBar.setText("Successfully loaded file " + newAlignFrame.statusBar.setText("Successfully loaded file " + file); String treeFile = applet.getParameter("tree"); @@ -688,7 +715,7 @@ public class JalviewLite extends Applet if (fin.getTree() != null) { - currentAlignFrame.loadTree(fin, treeFile); + newAlignFrame.loadTree(fin, treeFile); dbgMsg("Successfuly imported tree."); } else @@ -706,14 +733,14 @@ public class JalviewLite extends Applet { param = setProtocolState(param); - currentAlignFrame.parseFeaturesFile(param, protocol); + newAlignFrame.parseFeaturesFile(param, protocol); } param = getParameter("showFeatureSettings"); if (param != null && param.equalsIgnoreCase("true")) { - currentAlignFrame.viewport.showSequenceFeatures(true); - new FeatureSettings(currentAlignFrame.alignPanel); + newAlignFrame.viewport.showSequenceFeatures(true); + new FeatureSettings(newAlignFrame.alignPanel); } param = getParameter("annotations"); @@ -722,11 +749,11 @@ public class JalviewLite extends Applet param = setProtocolState(param); if (new AnnotationFile().readAnnotationFile( - currentAlignFrame.viewport.getAlignment(), param, + newAlignFrame.viewport.getAlignment(), param, protocol)) { - currentAlignFrame.alignPanel.fontChanged(); - currentAlignFrame.alignPanel.setScrollValues(0, 0); + newAlignFrame.alignPanel.fontChanged(); + newAlignFrame.alignPanel.setScrollValues(0, 0); } else { @@ -746,16 +773,16 @@ public class JalviewLite extends Applet jalview.io.JPredFile predictions = new jalview.io.JPredFile( param, protocol); JnetAnnotationMaker.add_annotation(predictions, - currentAlignFrame.viewport.getAlignment(), 0, false); // false==do - // not - // add - // sequence - // profile - // from - // concise - // output - currentAlignFrame.alignPanel.fontChanged(); - currentAlignFrame.alignPanel.setScrollValues(0, 0); + newAlignFrame.viewport.getAlignment(), 0, false); // false==do + // not + // add + // sequence + // profile + // from + // concise + // output + newAlignFrame.alignPanel.fontChanged(); + newAlignFrame.alignPanel.setScrollValues(0, 0); } catch (Exception ex) { ex.printStackTrace(); @@ -794,7 +821,7 @@ public class JalviewLite extends Applet String sequence = applet.getParameter("PDBSEQ"); if (sequence != null) seqs = new SequenceI[] - { (Sequence) currentAlignFrame.getAlignViewport() + { (Sequence) newAlignFrame.getAlignViewport() .getAlignment().findName(sequence) }; } @@ -814,7 +841,7 @@ public class JalviewLite extends Applet tmp2.addElement(st2.nextToken()); seqstring = st2.nextToken(); } - tmp.addElement((Sequence) currentAlignFrame + tmp.addElement((Sequence) newAlignFrame .getAlignViewport().getAlignment().findName( seqstring)); } @@ -829,14 +856,16 @@ public class JalviewLite extends Applet } param = setProtocolState(param); - if (!jmolAvailable - && protocol == AppletFormatAdapter.CLASSLOADER) + if (// !jmolAvailable + // && + protocol == AppletFormatAdapter.CLASSLOADER) { - // TODO: pass PDB file in classloader on to Jmol + // TODO: verify this Re: + // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605 // This exception preserves the current behaviour where, even if // the local pdb file was identified in the class loader protocol = AppletFormatAdapter.URL; // this is probably NOT - // CORRECT! + // CORRECT! param = addProtocol(param); // } @@ -866,13 +895,13 @@ public class JalviewLite extends Applet if (jmolAvailable) { new jalview.appletgui.AppletJmol(pdb, seqs, chains, - currentAlignFrame.alignPanel, protocol); + newAlignFrame.alignPanel, protocol); lastFrameX += 40; lastFrameY += 40; } else new MCview.AppletPDBViewer(pdb, seqs, chains, - currentAlignFrame.alignPanel, protocol); + newAlignFrame.alignPanel, protocol); } } @@ -886,13 +915,13 @@ public class JalviewLite extends Applet param = getParameter("hidefeaturegroups"); if (param != null) { - applet.setFeatureGroupState(param, false); + applet.setFeatureGroupStateOn(newAlignFrame,param, false); } // show specific groups param = getParameter("showfeaturegroups"); if (param != null) { - applet.setFeatureGroupState(param, true); + applet.setFeatureGroupStateOn(newAlignFrame,param, true); } } else @@ -971,7 +1000,8 @@ public class JalviewLite extends Applet * separator used for separatorList */ protected String separator = "|"; // this is a safe(ish) separator - tabs - // don't work for firefox + + // don't work for firefox /** * parse the string into a list @@ -1119,7 +1149,7 @@ public class JalviewLite extends Applet boolean state) { boolean st = state;// !(state==null || state.equals("") || - // state.toLowerCase().equals("false")); + // state.toLowerCase().equals("false")); alf.setFeatureGroupState(separatorListToArray(groups), st); }