X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileLoader.java;h=aa76da599eb073f84dc9bcd530b8351694145b5e;hb=b005d2429ec2b467aaf18318336842dc4c292b76;hp=067352298e3e33053092d610184f4a5b88cb4847;hpb=47168f025aefdaa044802bd5f8f510ffe43a4808;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 0673522..aa76da5 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.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. * @@ -21,15 +21,18 @@ package jalview.io; import jalview.datamodel.AlignmentI; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; import jalview.gui.Desktop; import jalview.gui.Jalview2XML; +import jalview.structure.StructureSelectionManager; +import jalview.util.MessageManager; import java.util.StringTokenizer; import java.util.Vector; -import jalview.util.MessageManager; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -148,6 +151,7 @@ public class FileLoader implements Runnable public AlignFrame LoadFileWaitTillLoaded(FileParse source, String format) { this.source = source; + file = source.getInFile(); protocol = source.type; this.format = format; @@ -272,7 +276,7 @@ public class FileLoader implements Runnable .println("IMPLEMENTATION ERROR: Cannot read consecutive Jalview XML projects from a stream."); // We read the data anyway - it might make sense. } - alignFrame = new Jalview2XML(raiseGUI).LoadJalviewAlign(file); + alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(file); } else { @@ -292,7 +296,7 @@ public class FileLoader implements Runnable // open a new source and read from it FormatAdapter fa = new FormatAdapter(); al = fa.readFile(file, protocol, format); - source = fa.afile; // keep reference for later if necessary. + source = fa.getAlignFile(); // keep reference for later if necessary. } } catch (java.io.IOException ex) { @@ -307,34 +311,57 @@ public class FileLoader implements Runnable error = format + "\n" + error; } } - + if ((al != null) && (al.getHeight() > 0)) { - if (viewport != null) + for (SequenceI sq : al.getSequences()) { - // TODO: create undo object for this JAL-1101 - for (int i = 0; i < al.getHeight(); i++) + while (sq.getDatasetSequence() != null) { - viewport.getAlignment().addSequence(al.getSequenceAt(i)); + sq = sq.getDatasetSequence(); + } + if (sq.getPDBId() != null) + { + for (PDBEntry pdbe : sq.getPDBId()) + { + StructureSelectionManager.getStructureSelectionManager( + Desktop.instance).registerPDBEntry(pdbe); + } } - viewport.firePropertyChange("alignment", null, viewport - .getAlignment().getSequences()); - + } + if (viewport != null) + { + viewport.addAlignment(al, title); } else { alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - alignFrame.statusBar.setText(MessageManager.formatMessage("label.successfully_loaded_file", new String[]{title})); + alignFrame.statusBar.setText(MessageManager.formatMessage( + "label.successfully_loaded_file", new String[] + { title })); if (!protocol.equals(AppletFormatAdapter.PASTE)) + { alignFrame.setFileName(file, format); + } + if (source instanceof HtmlFile) + { + ((HtmlFile) source).applySettingsToAlignFrame(alignFrame); + } + else if (source instanceof JSONFile) + { + ((JSONFile) source).applySettingsToAlignFrame(alignFrame); + } + if (raiseGUI) { // add the window to the GUI - // note - this actually should happen regardless of raiseGUI status in Jalview 3 - // TODO: define 'virtual desktop' for benefit of headless scripts that perform queries to find the 'current working alignment' + // note - this actually should happen regardless of raiseGUI + // status in Jalview 3 + // TODO: define 'virtual desktop' for benefit of headless scripts + // that perform queries to find the 'current working alignment' Desktop.addInternalFrame(alignFrame, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); } @@ -357,14 +384,17 @@ public class FileLoader implements Runnable final String errorMessage = "Couldn't load file " + title + "\n" + error; - if (raiseGUI) + // TODO: refactor FileLoader to be independent of Desktop / Applet GUI + // bits ? + if (raiseGUI && Desktop.desktop != null) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showInternalMessageDialog(Desktop.desktop, - errorMessage, MessageManager.getString("label.error_loading_file"), + errorMessage, MessageManager + .getString("label.error_loading_file"), JOptionPane.WARNING_MESSAGE); } }); @@ -389,8 +419,10 @@ public class FileLoader implements Runnable public void run() { javax.swing.JOptionPane.showInternalMessageDialog( - Desktop.desktop, MessageManager.formatMessage("label.problems_opening_file", new String[]{file}), - MessageManager.getString("label.file_open_error"), + Desktop.desktop, MessageManager.formatMessage( + "label.problems_opening_file", new String[] + { file }), MessageManager + .getString("label.file_open_error"), javax.swing.JOptionPane.WARNING_MESSAGE); } }); @@ -410,11 +442,8 @@ public class FileLoader implements Runnable javax.swing.JOptionPane .showInternalMessageDialog( Desktop.desktop, - "Out of memory loading file " - + file - + "!!" - + "\nSee help files for increasing Java Virtual Machine memory.", - "Out of memory", + MessageManager.formatMessage("warn.out_of_memory_loading_file", new String[]{file}), + MessageManager.getString("label.out_of_memory"), javax.swing.JOptionPane.WARNING_MESSAGE); } });