X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=2371be313e5ee2a4797232f93871e108bfcdfca9;hb=6463d6e0b78c66ca70ebe73c9f0f115185d1e681;hp=0c252620bcb3cd1e1b0a6e7f04cee6857ee3f50f;hpb=9cd3ff27d8a47b2e8b1f3be9ff07d47ea9bc6fd1;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0c25262..2371be3 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -194,9 +194,9 @@ public class AlignFrame extends GAlignFrame /** * Current filename for this alignment */ - String fileName = null; + private String fileName = null; - File fileObject; + private File fileObject; /** * Creates a new AlignFrame object with specific width and height. @@ -1053,86 +1053,86 @@ public class AlignFrame extends GAlignFrame @Override public void reload_actionPerformed(ActionEvent e) { - System.out.println("AlignFrame.reload " + fileName); - if (fileName != null) + if (fileName == null) { - // TODO: JAL-1108 - ensure all associated frames are closed regardless of - // originating file's format - // TODO: work out how to recover feature settings for correct view(s) when - // file is reloaded. - if (FileFormat.Jalview.equals(currentFileFormat)) + return; + } + // TODO: JAL-1108 - ensure all associated frames are closed regardless of + // originating file's format + // TODO: work out how to recover feature settings for correct view(s) when + // file is reloaded. + if (FileFormat.Jalview.equals(currentFileFormat)) + { + JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames(); + for (int i = 0; i < frames.length; i++) { - JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames(); - for (int i = 0; i < frames.length; i++) + if (frames[i] instanceof AlignFrame && frames[i] != this + && ((AlignFrame) frames[i]).fileName != null + && ((AlignFrame) frames[i]).fileName.equals(fileName)) { - if (frames[i] instanceof AlignFrame && frames[i] != this - && ((AlignFrame) frames[i]).fileName != null - && ((AlignFrame) frames[i]).fileName.equals(fileName)) + try + { + frames[i].setSelected(true); + Desktop.getInstance().closeAssociatedWindows(); + } catch (java.beans.PropertyVetoException ex) { - try - { - frames[i].setSelected(true); - Desktop.getInstance().closeAssociatedWindows(); - } catch (java.beans.PropertyVetoException ex) - { - } } - } - Desktop.getInstance().closeAssociatedWindows(); - FileLoader loader = new FileLoader(); - DataSourceType protocol = fileName.startsWith("http:") - ? DataSourceType.URL - : DataSourceType.FILE; - loader.loadFile(viewport, - (fileObject == null ? fileName : fileObject), protocol, - currentFileFormat); } - else - { - Rectangle bounds = this.getBounds(); + Desktop.getInstance().closeAssociatedWindows(); - FileLoader loader = new FileLoader(); + FileLoader loader = new FileLoader(); + DataSourceType protocol = fileName.startsWith("http:") + ? DataSourceType.URL + : DataSourceType.FILE; + loader.loadFile(viewport, + (fileObject == null ? fileName : fileObject), protocol, + currentFileFormat); + } + else + { + Rectangle bounds = this.getBounds(); - AlignFrame newframe = null; + FileLoader loader = new FileLoader(); - if (fileObject == null) - { + AlignFrame newframe = null; - DataSourceType protocol = (fileName.startsWith("http:") - ? DataSourceType.URL - : DataSourceType.FILE); - newframe = loader.loadFileWaitTillLoaded(fileName, protocol, - currentFileFormat); - } - else - { - newframe = loader.loadFileWaitTillLoaded(fileObject, - DataSourceType.FILE, currentFileFormat); - } + if (fileObject == null) + { + + DataSourceType protocol = (fileName.startsWith("http:") + ? DataSourceType.URL + : DataSourceType.FILE); + newframe = loader.loadFileWaitTillLoaded(fileName, protocol, + currentFileFormat); + } + else + { + newframe = loader.loadFileWaitTillLoaded(fileObject, + DataSourceType.FILE, currentFileFormat); + } - newframe.setBounds(bounds); - if (featureSettings != null && featureSettings.isShowing()) + newframe.setBounds(bounds); + if (featureSettings != null && featureSettings.isShowing()) + { + final Rectangle fspos = featureSettings.frame.getBounds(); + // TODO: need a 'show feature settings' function that takes bounds - + // need to refactor Desktop.addFrame + newframe.featureSettings_actionPerformed(null); + final FeatureSettings nfs = newframe.featureSettings; + SwingUtilities.invokeLater(new Runnable() { - final Rectangle fspos = featureSettings.frame.getBounds(); - // TODO: need a 'show feature settings' function that takes bounds - - // need to refactor Desktop.addFrame - newframe.featureSettings_actionPerformed(null); - final FeatureSettings nfs = newframe.featureSettings; - SwingUtilities.invokeLater(new Runnable() + @Override + public void run() { - @Override - public void run() - { - nfs.frame.setBounds(fspos); - } - }); - this.featureSettings.close(); - this.featureSettings = null; - } - this.closeMenuItem_actionPerformed(true); + nfs.frame.setBounds(fspos); + } + }); + this.featureSettings.close(); + this.featureSettings = null; } + this.closeMenuItem_actionPerformed(true); } }