X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAssociatePdbFileWithSeq.java;fp=src%2Fjalview%2Fgui%2FAssociatePdbFileWithSeq.java;h=5b5bd18f7e60ddb2cc7bac027450349f7ea1e4f3;hb=586ade46bdcd05ff028a1cff82c3c527326d28ec;hp=20e8dfef7077f9b340a115dd82de6bfa2c28f27c;hpb=adcef27f5747b4e70e89a56c3735bc3afb8ce9bf;p=jalview.git diff --git a/src/jalview/gui/AssociatePdbFileWithSeq.java b/src/jalview/gui/AssociatePdbFileWithSeq.java index 20e8dfe..5b5bd18 100644 --- a/src/jalview/gui/AssociatePdbFileWithSeq.java +++ b/src/jalview/gui/AssociatePdbFileWithSeq.java @@ -20,16 +20,15 @@ */ 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; /** - * GUI related routines for associating PDB files with sequences + * GUI related routines for associating PDB files with sequences. A single + * static method. * * @author JimP * @@ -37,58 +36,56 @@ import jalview.util.MessageManager; public class AssociatePdbFileWithSeq { + private AssociatePdbFileWithSeq() + { + // inaccessible + } + /** - * assocate the given PDB file with + * Associate the given PDB file name or URL with a sequence. Do not map + * mouse-over events. * - * @param choice + * @param fileName + * or URL + * @param type + * will be DataType.FILE or DataType.URL * @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 PDBEntry associatePdbWithSeq(String choice, DataSourceType file, - SequenceI sequence, boolean prompt, - StructureSelectionManagerProvider ssmp) + public static PDBEntry associatePdbWithSeq(String fileName, + DataSourceType type, SequenceI sequence, boolean prompt) { PDBEntry entry = new PDBEntry(); StructureFile pdbfile = null; - pdbfile = StructureSelectionManager.getStructureSelectionManager(ssmp) + pdbfile = Desktop.getStructureSelectionManager() .setMapping(false, new SequenceI[] - { sequence }, null, choice, file); + { sequence }, null, fileName, type); if (pdbfile == null) { // stacktrace already thrown so just return return null; } - if (pdbfile.getId() == 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) { - 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()); + return null; } + entry.setId(id); entry.setType(PDBEntry.Type.FILE); - - if (pdbfile != null) - { - entry.setFile(choice); - sequence.getDatasetSequence().addPDBId(entry); - StructureSelectionManager.getStructureSelectionManager(ssmp) - .registerPDBEntry(entry); - } + entry.setFile(fileName); + sequence.getDatasetSequence().addPDBId(entry); + Desktop.getStructureSelectionManager() + .registerPDBEntry(entry); return entry; } }