import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import jalview.structure.StructureMapping;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
import jalview.ws.seqfetcher.DbSourceProxy;
List<SequenceI> seqsWithoutSourceDBRef = null;
+ private boolean showChooserGUI = true;
+
private static StructureViewer lastTargetedView = null;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
{
+ this(selectedSeqs, selectedSeq, ap, true);
+ }
+
+ public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
+ AlignmentPanel ap, boolean showGUI)
+ {
// which FTS engine to use
data = StructureChooserQuerySource.getQuerySourceFor(selectedSeqs);
initDialog();
this.selectedSequence = selectedSeq;
this.selectedSequences = selectedSeqs;
this.progressIndicator = (ap == null) ? null : ap.alignFrame;
+ this.showChooserGUI = showGUI;
init();
}
populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists);
discoverStructureViews();
updateProgressIndicator(null, startTime);
- mainFrame.setVisible(true);
+ mainFrame.setVisible(showChooserGUI);
updateCurrentView();
}
@Override
public void setProgressBar(String message, long id)
{
- progressBar.setProgressBar(message, id);
+ if (!Platform.isHeadless())
+ progressBar.setProgressBar(message, id);
}
@Override
{
return notQueriedTDBYet;
}
+
+ /**
+ * Open a single structure file for a given sequence
+ */
+ public static void openStructureFileForSequence(AlignmentPanel ap,
+ SequenceI seq, File sFile)
+ {
+ //Open the chooser headlessly. Not sure this is actually needed ?
+ StructureChooser sc = new StructureChooser(new SequenceI[] { seq }, seq,
+ ap, false);
+ StructureSelectionManager ssm = ap.getStructureSelectionManager();
+ PDBEntry fileEntry = null;
+ try
+ {
+ fileEntry = new AssociatePdbFileWithSeq().associatePdbWithSeq(
+ sFile.getAbsolutePath(), DataSourceType.FILE, seq, true,
+ Desktop.instance);
+ } catch (Exception e)
+ {
+ Console.error("Could not open structure file '"
+ + sFile.getAbsolutePath() + "'");
+ return;
+ }
+
+ StructureViewer sViewer = sc.launchStructureViewer(ssm,
+ new PDBEntry[]
+ { fileEntry }, ap, new SequenceI[] { seq });
+
+ sc.mainFrame.dispose();
+ }
}