X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceFetcher.java;h=6a0d0102b6b92cc1c9bfe8d1863f908659c7f15c;hb=31a33833640b743a506f7801388b17f96e915ef3;hp=fb94c05c8fe299eb2950b22e9722ad2038259329;hpb=e4da162f3c4eb461c40f7b97794cd77d3b1e2407;p=jalview.git diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index fb94c05..6a0d010 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,7 +20,6 @@ */ package jalview.gui; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; @@ -115,7 +114,7 @@ public class SequenceFetcher extends JPanel implements Runnable private static Thread initingThread = null; - int x = 0; + int debounceTrap = 0; /** * Blocking method that initialises and returns the shared instance of the * SequenceFetcher client @@ -178,8 +177,7 @@ public class SequenceFetcher extends JPanel implements Runnable jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher(); if (guiWindow != null) { - guiWindow.setProgressBar(MessageManager.getString("status.init_sequence_database_fetchers"), - Thread.currentThread().hashCode()); + guiWindow.setProgressBar(null, Thread.currentThread().hashCode()); } lastDasSourceRegistry = (dasRegistry.getDasRegistryURL() + dasRegistry .getLocalSourceString()).hashCode(); @@ -190,9 +188,10 @@ public class SequenceFetcher extends JPanel implements Runnable return sfetch; } + private IProgressIndicator progressIndicator; public SequenceFetcher(IProgressIndicator guiIndic) { - final IProgressIndicator guiWindow = guiIndic; + this.progressIndicator = guiIndic; final SequenceFetcher us = this; // launch initialiser thread Thread sf = new Thread(new Runnable() @@ -201,9 +200,9 @@ public class SequenceFetcher extends JPanel implements Runnable @Override public void run() { - if (getSequenceFetcherSingleton(guiWindow) != null) + if (getSequenceFetcherSingleton(progressIndicator) != null) { - us.initGui(guiWindow); + us.initGui(progressIndicator); } else { @@ -357,21 +356,21 @@ public class SequenceFetcher extends JPanel implements Runnable @Override public void actionPerformed(ActionEvent e) { - x++; + debounceTrap++; String currentSelection = database.getSelectedItem(); - if (!currentSelection.equalsIgnoreCase("pdb")) { otherSourceAction(); } - if (currentSelection.equalsIgnoreCase("pdb") && ((x % 2) == 0)) + if (currentSelection.equalsIgnoreCase("pdb") + && (database.action == KeyEvent.VK_ENTER || ((debounceTrap % 2) == 0))) { - frame.dispose(); - new EBIFetchPanel(); + pdbSourceAction(); } - + database.action = -1; } }); + dbeg.setText(""); jPanel2.add(databaseButt, java.awt.BorderLayout.NORTH); jPanel2.add(dbeg, java.awt.BorderLayout.CENTER); @@ -388,10 +387,13 @@ public class SequenceFetcher extends JPanel implements Runnable } - private void hideX() + private void pdbSourceAction() { - this.setVisible(false); + databaseButt.setText(database.getSelectedItem()); + new PDBSearchPanel(this); + frame.dispose(); } + private void otherSourceAction() { try @@ -772,7 +774,7 @@ public class SequenceFetcher extends JPanel implements Runnable AlignmentI parseResult(String result, String title) { String format = new IdentifyFile().Identify(result, "Paste"); - Alignment sequences = null; + AlignmentI sequences = null; if (FormatAdapter.isValidFormat(format)) { sequences = null; @@ -814,6 +816,10 @@ public class SequenceFetcher extends JPanel implements Runnable if (al != null && al.getHeight() > 0) { + if (title == null) + { + title = getDefaultRetrievalTitle(); + } if (alignFrame == null) { AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, @@ -826,10 +832,6 @@ public class SequenceFetcher extends JPanel implements Runnable // Alignments? } - if (title == null) - { - title = getDefaultRetrievalTitle(); - } SequenceFeature[] sfs = null; List alsqs; synchronized (alsqs = al.getSequences()) @@ -863,21 +865,7 @@ public class SequenceFetcher extends JPanel implements Runnable } else { - for (int i = 0; i < al.getHeight(); i++) - { - alignFrame.viewport.getAlignment().addSequence( - al.getSequenceAt(i)); // this - // also - // creates - // dataset - // sequence - // entries - } - alignFrame.viewport.setEndSeq(alignFrame.viewport.getAlignment() - .getHeight()); - alignFrame.viewport.getAlignment().getWidth(); - alignFrame.viewport.firePropertyChange("alignment", null, - alignFrame.viewport.getAlignment().getSequences()); + alignFrame.viewport.addAlignment(al, title); } } return al; @@ -897,4 +885,16 @@ public class SequenceFetcher extends JPanel implements Runnable } }); } + + public IProgressIndicator getProgressIndicator() + { + return progressIndicator; + } + + + + public void setProgressIndicator(IProgressIndicator progressIndicator) + { + this.progressIndicator = progressIndicator; + } }