").append("
Version: ")
+ .append(Cache.getProperty("VERSION")).append("
").append("
Built: ")
+ .append(Cache.getDefault("BUILD_DATE", "unknown")).append(" from ")
+ .append(Cache.getBuildDetailsForSplash()).append("");
+
+ String latestVersion = Cache.getDefault("LATEST_VERSION", "Checking");
+ if (latestVersion.equals("Checking")) {
+ // JBP removed this message for 2.11: May be reinstated in future version
+ // message.append("
...Checking latest version...");
+ } else if (!latestVersion.equals(Cache.getProperty("VERSION"))) {
boolean red = false;
- if (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
- .indexOf("automated build") == -1)
- {
+ if (Cache.getProperty("VERSION").toLowerCase(Locale.ROOT).indexOf("automated build") == -1) {
red = true;
// Displayed when code version and jnlp version do not match and code
// version is not a development build
message.append("
");
}
- message.append("
!! Version "
- + jalview.bin.Cache.getDefault("LATEST_VERSION",
- "..Checking..")
- + " is available for download from "
- + jalview.bin.Cache.getDefault("www.jalview.org",
- "http://www.jalview.org")
- + " !!");
- if (red)
- {
+ message.append("
!! Version ").append(Cache.getDefault("LATEST_VERSION", "..Checking.."))
+ .append(" is available for download from ")
+ .append(Cache.getDefault("www.jalview.org", "https://www.jalview.org")).append(" !!");
+ if (red) {
message.append("
");
}
}
- message.append("
Authors: " + jalview.bin.Cache.getDefault(
- "AUTHORFNAMES",
- "The Jalview Authors (See AUTHORS file for current list)")
- + "
Development managed by The Barton Group, University of Dundee, Scotland, UK.
"
- + "
For help, see the FAQ at
www.jalview.org/faq and/or join the jalview-discuss@jalview.org mailing list"
- + "
If you use Jalview, please cite:"
- + "
Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
- + "
Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
- + "
Bioinformatics doi: 10.1093/bioinformatics/btp033"
- + "");
- return message;
+ message.append("
Authors: ");
+ message.append(Cache.getDefault("AUTHORFNAMES", DEFAULT_AUTHORS));
+ message.append(CITATION);
+
+ message.append("
");
+
+ return message.toString();
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on requesting Help documentation
*/
@Override
- public void documentationMenuItem_actionPerformed(ActionEvent e)
- {
- try
- {
- Help.showHelpWindow();
- } catch (Exception ex)
- {
+ public void documentationMenuItem_actionPerformed() {
+ try {
+ if (Platform.isJS()) {
+ BrowserLauncher.openURL("https://www.jalview.org/help.html");
+ } else
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ Help.showHelpWindow();
+ }
+ } catch (Exception ex) {
+ System.err.println("Error opening help: " + ex.getMessage());
}
}
@Override
- public void closeAll_actionPerformed(ActionEvent e)
- {
+ public void closeAll_actionPerformed(ActionEvent e) {
// TODO show a progress bar while closing?
JInternalFrame[] frames = desktop.getAllFrames();
- for (int i = 0; i < frames.length; i++)
- {
- try
- {
+ for (int i = 0; i < frames.length; i++) {
+ try {
frames[i].setClosed(true);
- } catch (java.beans.PropertyVetoException ex)
- {
+ } catch (java.beans.PropertyVetoException ex) {
}
}
Jalview.setCurrentAlignFrame(null);
System.out.println("ALL CLOSED");
- if (v_client != null)
- {
- // TODO clear binding to vamsas document objects on close_all
- }
/*
* reset state of singleton objects as appropriate (clear down session state
* when all windows are closed)
*/
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(this);
- if (ssm != null)
- {
+ StructureSelectionManager ssm = StructureSelectionManager.getStructureSelectionManager(this);
+ if (ssm != null) {
ssm.resetAll();
}
}
@Override
- public void raiseRelated_actionPerformed(ActionEvent e)
- {
+ public void raiseRelated_actionPerformed(ActionEvent e) {
reorderAssociatedWindows(false, false);
}
@Override
- public void minimizeAssociated_actionPerformed(ActionEvent e)
- {
+ public void minimizeAssociated_actionPerformed(ActionEvent e) {
reorderAssociatedWindows(true, false);
}
- void closeAssociatedWindows()
- {
+ void closeAssociatedWindows() {
reorderAssociatedWindows(false, true);
}
@@ -1459,24 +1272,21 @@ public class Desktop extends jalview.jbgui.GDesktop
* ActionEvent)
*/
@Override
- protected void garbageCollect_actionPerformed(ActionEvent e)
- {
+ protected void garbageCollect_actionPerformed(ActionEvent e) {
// We simply collect the garbage
- jalview.bin.Cache.log.debug("Collecting garbage...");
+ Cache.log.debug("Collecting garbage...");
System.gc();
- jalview.bin.Cache.log.debug("Finished garbage collection.");
+ Cache.log.debug("Finished garbage collection.");
}
/*
* (non-Javadoc)
*
- * @see
- * jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.ActionEvent
- * )
+ * @see jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.
+ * ActionEvent )
*/
@Override
- protected void showMemusage_actionPerformed(ActionEvent e)
- {
+ protected void showMemusage_actionPerformed(ActionEvent e) {
desktop.showMemoryUsage(showMemusage.isSelected());
}
@@ -1488,8 +1298,7 @@ public class Desktop extends jalview.jbgui.GDesktop
* )
*/
@Override
- protected void showConsole_actionPerformed(ActionEvent e)
- {
+ protected void showConsole_actionPerformed(ActionEvent e) {
showConsole(showConsole.isSelected());
}
@@ -1500,86 +1309,61 @@ public class Desktop extends jalview.jbgui.GDesktop
*
* @param selected
*/
- void showConsole(boolean selected)
- {
- showConsole.setSelected(selected);
+ void showConsole(boolean selected) {
// TODO: decide if we should update properties file
- Cache.setProperty("SHOW_JAVA_CONSOLE",
- Boolean.valueOf(selected).toString());
- jconsole.setVisible(selected);
+ if (jconsole != null) // BH 2018
+ {
+ showConsole.setSelected(selected);
+ Cache.setProperty("SHOW_JAVA_CONSOLE", Boolean.valueOf(selected).toString());
+ jconsole.setVisible(selected);
+ }
}
- void reorderAssociatedWindows(boolean minimize, boolean close)
- {
+ void reorderAssociatedWindows(boolean minimize, boolean close) {
JInternalFrame[] frames = desktop.getAllFrames();
- if (frames == null || frames.length < 1)
- {
+ if (frames == null || frames.length < 1) {
return;
}
AlignmentViewport source = null, target = null;
- if (frames[0] instanceof AlignFrame)
- {
+ if (frames[0] instanceof AlignFrame) {
source = ((AlignFrame) frames[0]).getCurrentView();
- }
- else if (frames[0] instanceof TreePanel)
- {
+ } else if (frames[0] instanceof TreePanel) {
source = ((TreePanel) frames[0]).getViewPort();
- }
- else if (frames[0] instanceof PCAPanel)
- {
+ } else if (frames[0] instanceof PCAPanel) {
source = ((PCAPanel) frames[0]).av;
- }
- else if (frames[0].getContentPane() instanceof PairwiseAlignPanel)
- {
+ } else if (frames[0].getContentPane() instanceof PairwiseAlignPanel) {
source = ((PairwiseAlignPanel) frames[0].getContentPane()).av;
}
- if (source != null)
- {
- for (int i = 0; i < frames.length; i++)
- {
+ if (source != null) {
+ for (int i = 0; i < frames.length; i++) {
target = null;
- if (frames[i] == null)
- {
+ if (frames[i] == null) {
continue;
}
- if (frames[i] instanceof AlignFrame)
- {
+ if (frames[i] instanceof AlignFrame) {
target = ((AlignFrame) frames[i]).getCurrentView();
- }
- else if (frames[i] instanceof TreePanel)
- {
+ } else if (frames[i] instanceof TreePanel) {
target = ((TreePanel) frames[i]).getViewPort();
- }
- else if (frames[i] instanceof PCAPanel)
- {
+ } else if (frames[i] instanceof PCAPanel) {
target = ((PCAPanel) frames[i]).av;
- }
- else if (frames[i].getContentPane() instanceof PairwiseAlignPanel)
- {
+ } else if (frames[i].getContentPane() instanceof PairwiseAlignPanel) {
target = ((PairwiseAlignPanel) frames[i].getContentPane()).av;
}
- if (source == target)
- {
- try
- {
- if (close)
- {
+ if (source == target) {
+ try {
+ if (close) {
frames[i].setClosed(true);
- }
- else
- {
+ } else {
frames[i].setIcon(minimize);
- if (!minimize)
- {
+ if (!minimize) {
frames[i].toFront();
}
}
- } catch (java.beans.PropertyVetoException ex)
- {
+ } catch (java.beans.PropertyVetoException ex) {
}
}
}
@@ -1589,149 +1373,143 @@ public class Desktop extends jalview.jbgui.GDesktop
/**
* DOCUMENT ME!
*
- * @param e
- * DOCUMENT ME!
+ * @param e DOCUMENT ME!
*/
@Override
- protected void preferences_actionPerformed(ActionEvent e)
- {
- new Preferences();
+ protected void preferences_actionPerformed(ActionEvent e) {
+ Preferences.openPreferences();
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Prompts the user to choose a file and then saves the Jalview state as a
+ * Jalview project file
*/
@Override
- public void saveState_actionPerformed(ActionEvent e)
- {
- JalviewFileChooser chooser = new JalviewFileChooser("jvp",
- "Jalview Project");
+ public void saveState_actionPerformed() {
+ saveState_actionPerformed(false);
+ }
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle(MessageManager.getString("label.save_state"));
+ public void saveState_actionPerformed(boolean saveAs) {
+ java.io.File projectFile = getProjectFile();
+ // autoSave indicates we already have a file and don't need to ask
+ boolean autoSave = projectFile != null && !saveAs && BackupFiles.getEnabled();
- int value = chooser.showSaveDialog(this);
+ // System.out.println("autoSave="+autoSave+", projectFile='"+projectFile+"',
+ // saveAs="+saveAs+", Backups
+ // "+(BackupFiles.getEnabled()?"enabled":"disabled"));
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- final Desktop me = this;
- final java.io.File choice = chooser.getSelectedFile();
- setProjectFile(choice);
+ boolean approveSave = false;
+ if (!autoSave) {
+ JalviewFileChooser chooser = new JalviewFileChooser("jvp", "Jalview Project");
- new Thread(new Runnable()
- {
+ chooser.setFileView(new JalviewFileView());
+ chooser.setDialogTitle(MessageManager.getString("label.save_state"));
+
+ int value = chooser.showSaveDialog(this);
+
+ if (value == JalviewFileChooser.APPROVE_OPTION) {
+ projectFile = chooser.getSelectedFile();
+ setProjectFile(projectFile);
+ approveSave = true;
+ }
+ }
+
+ if (approveSave || autoSave) {
+ final Desktop me = this;
+ final java.io.File chosenFile = projectFile;
+ new Thread(new Runnable() {
@Override
- public void run()
- {
+ public void run() {
// TODO: refactor to Jalview desktop session controller action.
- setProgressBar(MessageManager.formatMessage(
- "label.saving_jalview_project", new Object[]
- { choice.getName() }), choice.hashCode());
- jalview.bin.Cache.setProperty("LAST_DIRECTORY",
- choice.getParent());
+ setProgressBar(
+ MessageManager.formatMessage("label.saving_jalview_project", new Object[] { chosenFile.getName() }),
+ chosenFile.hashCode());
+ Cache.setProperty("LAST_DIRECTORY", chosenFile.getParent());
// TODO catch and handle errors for savestate
// TODO prevent user from messing with the Desktop whilst we're saving
- try
- {
- new Jalview2XML().saveState(choice);
- } catch (OutOfMemoryError oom)
- {
- new OOMWarning(
- "Whilst saving current state to " + choice.getName(),
- oom);
- } catch (Exception ex)
- {
- Cache.log.error(
- "Problems whilst trying to save to " + choice.getName(),
- ex);
+ try {
+ boolean doBackup = BackupFiles.getEnabled();
+ BackupFiles backupfiles = doBackup ? new BackupFiles(chosenFile) : null;
+
+ new Jalview2XML().saveState(doBackup ? backupfiles.getTempFile() : chosenFile);
+
+ if (doBackup) {
+ backupfiles.setWriteSuccess(true);
+ backupfiles.rollBackupsAndRenameTempFile();
+ }
+ } catch (OutOfMemoryError oom) {
+ new OOMWarning("Whilst saving current state to " + chosenFile.getName(), oom);
+ } catch (Exception ex) {
+ Cache.log.error("Problems whilst trying to save to " + chosenFile.getName(), ex);
JvOptionPane.showMessageDialog(me,
- MessageManager.formatMessage(
- "label.error_whilst_saving_current_state_to",
- new Object[]
- { choice.getName() }),
- MessageManager.getString("label.couldnt_save_project"),
- JvOptionPane.WARNING_MESSAGE);
+ MessageManager.formatMessage("label.error_whilst_saving_current_state_to",
+ new Object[] { chosenFile.getName() }),
+ MessageManager.getString("label.couldnt_save_project"), JvOptionPane.WARNING_MESSAGE);
}
- setProgressBar(null, choice.hashCode());
+ setProgressBar(null, chosenFile.hashCode());
}
}).start();
}
}
- private void setProjectFile(File choice)
- {
+ @Override
+ public void saveAsState_actionPerformed(ActionEvent e) {
+ saveState_actionPerformed(true);
+ }
+
+ private void setProjectFile(File choice) {
this.projectFile = choice;
}
- public File getProjectFile()
- {
+ public File getProjectFile() {
return this.projectFile;
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Shows a file chooser dialog and tries to read in the selected file as a
+ * Jalview project
*/
@Override
- public void loadState_actionPerformed(ActionEvent e)
- {
- JalviewFileChooser chooser = new JalviewFileChooser(
- Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jvp", "jar" },
- new String[]
- { "Jalview Project", "Jalview Project (old)" },
- "Jalview Project");
+ public void loadState_actionPerformed() {
+ final String[] suffix = new String[] { "jvp", "jar" };
+ final String[] desc = new String[] { "Jalview Project", "Jalview Project (old)" };
+ JalviewFileChooser chooser = new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"), suffix, desc,
+ "Jalview Project", true, BackupFiles.getEnabled()); // last two
+ // booleans:
+ // allFiles,
+ // allowBackupFiles
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
-
- int value = chooser.showOpenDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- final File selectedFile = chooser.getSelectedFile();
- setProjectFile(selectedFile);
- final String choice = selectedFile.getAbsolutePath();
- Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
- new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- setProgressBar(MessageManager.formatMessage(
- "label.loading_jalview_project", new Object[]
- { choice }), choice.hashCode());
- try
- {
- new Jalview2XML().loadJalviewAlign(choice);
- } catch (OutOfMemoryError oom)
- {
- new OOMWarning("Whilst loading project from " + choice, oom);
- } catch (Exception ex)
- {
- Cache.log.error(
- "Problems whilst loading project from " + choice, ex);
- JvOptionPane.showMessageDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.error_whilst_loading_project_from",
- new Object[]
- { choice }),
- MessageManager.getString("label.couldnt_load_project"),
- JvOptionPane.WARNING_MESSAGE);
+ chooser.setResponseHandler(0, new Runnable() {
+ @Override
+ public void run() {
+ File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ String choice = selectedFile.getAbsolutePath();
+ Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ new Jalview2XML().loadJalviewAlign(selectedFile);
+ } catch (OutOfMemoryError oom) {
+ new OOMWarning("Whilst loading project from " + choice, oom);
+ } catch (Exception ex) {
+ Cache.log.error("Problems whilst loading project from " + choice, ex);
+ JvOptionPane.showMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.error_whilst_loading_project_from", new Object[] { choice }),
+ MessageManager.getString("label.couldnt_load_project"), JvOptionPane.WARNING_MESSAGE);
+ }
}
- setProgressBar(null, choice.hashCode());
- }
- }).start();
- }
+ }, "Project Loader").start();
+ }
+ });
+
+ chooser.showOpenDialog(this);
}
@Override
- public void inputSequence_actionPerformed(ActionEvent e)
- {
+ public void inputSequence_actionPerformed(ActionEvent e) {
new SequenceFetcher(this);
}
@@ -1739,21 +1517,16 @@ public class Desktop extends jalview.jbgui.GDesktop
ArrayList