* @param guiIndic
* @param selectedDb
* @param queryString
+ * @param interactive
*/
public SequenceFetcher(IProgressIndicator guiIndic,
final String selectedDb, final String queryString)
{
+ this(guiIndic, selectedDb, queryString, true);
+ }
+
+ public SequenceFetcher(IProgressIndicator guiIndic,
+ final String selectedDb, final String queryString,
+ boolean interactive)
+ {
this.progressIndicator = guiIndic;
getSequenceFetcherSingleton();
this.guiWindow = progressIndicator;
alignFrame = (AlignFrame) progressIndicator;
}
- jbInit(selectedDb);
+ jbInit(selectedDb, interactive);
textArea.setText(queryString);
frame = new JInternalFrame();
.getString("label.additional_sequence_fetcher"));
}
- private void jbInit(String selectedDb)
+ private void jbInit(String selectedDb, boolean interactive)
{
this.setLayout(new BorderLayout());
jScrollPane1.getViewport().add(textArea);
idsPanel.add(jScrollPane1, BorderLayout.CENTER);
+ // En/disable or show/hide interactive elements
+ database.setEnabled(interactive);
+ exampleAccession.setVisible(interactive);
+ replacePunctuation.setVisible(interactive);
+ okBtn.setVisible(interactive);
+ exampleBtn.setVisible(interactive);
+ closeBtn.setVisible(interactive);
+ backBtn.setVisible(interactive);
+ jLabel1.setVisible(interactive);
+ clear.setVisible(interactive);
+ textArea.setEnabled(interactive);
+
this.add(actionPanel, BorderLayout.SOUTH);
this.add(idsPanel, BorderLayout.CENTER);
this.add(databasePanel, BorderLayout.NORTH);
+
}
/**
*/
public void ok_actionPerformed()
{
- ok_actionPerformed(false);
+ ok_actionPerformed(false, null);
}
- public CompletableFuture ok_actionPerformed(boolean returnFuture)
+ public CompletableFuture<Void> ok_actionPerformed(boolean returnFuture,
+ String id)
{
/*
* tidy inputs and check there is something to search for
backBtn.setEnabled(false);
CompletableFuture<Void> worker = CompletableFuture
- .runAsync(new Thread(this));
+ .runAsync(() -> runAndCacheAlignFrame(returnFuture, id));
return returnFuture ? worker : null;
}
+ private void runAndCacheAlignFrame(boolean cacheAlignFrame, String id)
+ {
+ AlignFrame af = this.run(cacheAlignFrame);
+ if (cacheAlignFrame && id != null && af != null)
+ af.cacheAlignFrameFromRestId(id);
+ }
+
private void resetDialog()
{
exampleBtn.setEnabled(true);
@Override
public void run()
{
+ run(false);
+ }
+
+ public AlignFrame run(boolean returnAlignFrame)
+ {
boolean addToLast = false;
List<String> aresultq = new ArrayList<>();
List<String> presultTitle = new ArrayList<>();
: MessageManager.getString("status.processing"),
Thread.currentThread().hashCode());
// process results
+ AlignFrame af = null;
while (presult.size() > 0)
{
- parseResult(presult.remove(0), presultTitle.remove(0), null,
+ af = parseResult(presult.remove(0), presultTitle.remove(0), null,
preferredFeatureColours);
}
// only remove visual delay after we finished parsing.
showErrorMessage(sb.toString());
}
resetDialog();
+ return returnAlignFrame ? af : null;
}
/**
return "Retrieved from " + database.getSelectedItem();
}
- AlignmentI parseResult(AlignmentI al, String title,
+ AlignFrame parseResult(AlignmentI al, String title,
FileFormatI currentFileFormat,
FeatureSettingsModelI preferredFeatureColours)
{
+ AlignFrame af = alignFrame;
if (al != null && al.getHeight() > 0)
{
if (title == null)
{
title = getDefaultRetrievalTitle();
}
- if (alignFrame == null)
+ if (af == null)
{
- AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
if (currentFileFormat != null)
{
}
else
{
- alignFrame.viewport.addAlignment(al, title);
+ af.viewport.addAlignment(al, title);
}
}
- return al;
+ return af;
}
void showErrorMessage(final String error)