X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAssociatePdbFileWithSeq.java;fp=src%2Fjalview%2Fgui%2FAssociatePdbFileWithSeq.java;h=fe0aedfc79c99440d6f6d8f5e42c3093d3b859f7;hb=4f77328104498504339216829abf5ea87e2791ec;hp=b81c344197456608c24f594a9927e2e5336dd54d;hpb=2b8c0785318a3528e1876e8e2dd48b7d831eae69;p=jalview.git diff --git a/src/jalview/gui/AssociatePdbFileWithSeq.java b/src/jalview/gui/AssociatePdbFileWithSeq.java index b81c344..fe0aedf 100644 --- a/src/jalview/gui/AssociatePdbFileWithSeq.java +++ b/src/jalview/gui/AssociatePdbFileWithSeq.java @@ -20,15 +20,18 @@ */ package jalview.gui; +import jalview.api.StructureSelectionManagerProvider; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.io.DataSourceType; import jalview.io.StructureFile; +import jalview.structure.StructureSelectionManager; import jalview.util.MessageManager; +import javax.swing.JOptionPane; + /** - * GUI related routines for associating PDB files with sequences. A single - * static method. + * GUI related routines for associating PDB files with sequences * * @author JimP * @@ -36,56 +39,58 @@ import jalview.util.MessageManager; public class AssociatePdbFileWithSeq { - private AssociatePdbFileWithSeq() - { - // inaccessible - } - /** - * Associate the given PDB file name or URL with a sequence. Do not map - * mouse-over events. + * assocate the given PDB file with * - * @param fileName - * or URL - * @param type - * will be DataType.FILE or DataType.URL + * @param choice * @param sequence - * to associate - * @param prompt - * true if the user should be asked what to do if the specified file - * does not seem to contain PDB information (StructureChooser only) - * @return null if file is not found */ - public static PDBEntry associatePdbWithSeq(String fileName, - DataSourceType type, SequenceI sequence, boolean prompt) + public PDBEntry associatePdbWithSeq(String choice, DataSourceType file, + SequenceI sequence, boolean prompt, + StructureSelectionManagerProvider ssmp) { PDBEntry entry = new PDBEntry(); StructureFile pdbfile = null; - pdbfile = Desktop.getInstance().getStructureSelectionManager() + pdbfile = StructureSelectionManager.getStructureSelectionManager(ssmp) .setMapping(false, new SequenceI[] - { sequence }, null, fileName, type); + { sequence }, null, choice, file); if (pdbfile == null) { // stacktrace already thrown so just return return null; } - String id = pdbfile.getId(); - if (id == null && (id = (prompt - ? JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(), - MessageManager - .getString("label.couldnt_find_pdb_id_in_file"), - MessageManager.getString("label.no_pdb_id_in_file"), - JvOptionPane.QUESTION_MESSAGE) - : null)) == null) + if (pdbfile.getId() == null) { - return null; + String reply = null; + + if (prompt) + { + reply = JvOptionPane.showInternalInputDialog(Desktop.desktop, + MessageManager + .getString("label.couldnt_find_pdb_id_in_file"), + MessageManager.getString("label.no_pdb_id_in_file"), + JvOptionPane.QUESTION_MESSAGE); + } + if (reply == null) + { + return null; + } + + entry.setId(reply); + } + else + { + entry.setId(pdbfile.getId()); } - entry.setId(id); entry.setType(PDBEntry.Type.FILE); - entry.setFile(fileName); - sequence.getDatasetSequence().addPDBId(entry); - Desktop.getInstance().getStructureSelectionManager() - .registerPDBEntry(entry); + + if (pdbfile != null) + { + entry.setFile(choice); + sequence.getDatasetSequence().addPDBId(entry); + StructureSelectionManager.getStructureSelectionManager(ssmp) + .registerPDBEntry(entry); + } return entry; } }