")
+ .append("
Version: ")
+ .append(Cache.getProperty("VERSION")).append("
")
+ .append("
Built: ")
+ .append(Cache.getDefault("BUILD_DATE", "unknown"))
+ .append(" from ").append(Cache.getBuildDetailsForSplash())
+ .append("");
- }
- else
+ String latestVersion = Cache.getDefault("LATEST_VERSION", "Checking");
+ if (latestVersion.equals("Checking"))
{
-
- message.append("
Version "
- + jalview.bin.Cache.getProperty("VERSION")
- + "; last updated: "
- + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"));
+ // JBP removed this message for 2.11: May be reinstated in future version
+ // message.append("
...Checking latest version...");
}
-
- if (jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
- .equals("Checking"))
- {
- message.append("
...Checking latest version...");
- }
- else if (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
- .equals(jalview.bin.Cache.getProperty("VERSION")))
+ else if (!latestVersion.equals(Cache.getProperty("VERSION")))
{
boolean red = false;
- if (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
+ if (Cache.getProperty("VERSION").toLowerCase(Locale.ROOT)
.indexOf("automated build") == -1)
{
red = true;
@@ -1338,45 +1451,50 @@ public class Desktop extends jalview.jbgui.GDesktop
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")
- + " !!");
+ 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)
+ public void documentationMenuItem_actionPerformed()
{
try
{
- Help.showHelpWindow();
+ 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());
}
}
@@ -1396,10 +1514,6 @@ public class Desktop extends jalview.jbgui.GDesktop
}
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
@@ -1411,7 +1525,6 @@ public class Desktop extends jalview.jbgui.GDesktop
{
ssm.resetAll();
}
- System.gc();
}
@Override
@@ -1441,17 +1554,16 @@ public class Desktop extends jalview.jbgui.GDesktop
protected void garbageCollect_actionPerformed(ActionEvent e)
{
// We simply collect the garbage
- jalview.bin.Cache.log.debug("Collecting garbage...");
+ jalview.bin.Console.debug("Collecting garbage...");
System.gc();
- jalview.bin.Cache.log.debug("Finished garbage collection.");
+ jalview.bin.Console.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)
@@ -1481,11 +1593,14 @@ public class Desktop extends jalview.jbgui.GDesktop
*/
void showConsole(boolean selected)
{
- showConsole.setSelected(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)
@@ -1574,32 +1689,53 @@ public class Desktop extends jalview.jbgui.GDesktop
@Override
protected void preferences_actionPerformed(ActionEvent e)
{
- new Preferences();
+ 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)
+ public void saveState_actionPerformed()
{
- JalviewFileChooser chooser = new JalviewFileChooser("jvp",
- "Jalview Project");
+ 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)
+ boolean approveSave = false;
+ if (!autoSave)
{
- final Desktop me = this;
- final java.io.File choice = chooser.getSelectedFile();
- setProjectFile(choice);
+ JalviewFileChooser chooser = new JalviewFileChooser("jvp",
+ "Jalview Project");
+
+ 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
@@ -1608,38 +1744,52 @@ public class Desktop extends jalview.jbgui.GDesktop
// 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());
+ { 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);
+ 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 " + choice.getName(),
- oom);
+ new OOMWarning("Whilst saving current state to "
+ + chosenFile.getName(), oom);
} catch (Exception ex)
{
- Cache.log.error(
- "Problems whilst trying to save to " + choice.getName(),
- ex);
+ jalview.bin.Console.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() }),
+ { chosenFile.getName() }),
MessageManager.getString("label.couldnt_save_project"),
JvOptionPane.WARNING_MESSAGE);
}
- setProgressBar(null, choice.hashCode());
+ setProgressBar(null, chosenFile.hashCode());
}
}).start();
}
}
+ @Override
+ public void saveAsState_actionPerformed(ActionEvent e)
+ {
+ saveState_actionPerformed(true);
+ }
+
private void setProjectFile(File choice)
{
this.projectFile = choice;
@@ -1651,61 +1801,62 @@ public class Desktop extends jalview.jbgui.GDesktop
}
/**
- * 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)
+ 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"), new String[]
- { "jvp", "jar" },
- new String[]
- { "Jalview Project", "Jalview Project (old)" },
- "Jalview Project");
+ 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)
+ chooser.setResponseHandler(0, new Runnable()
{
- 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()
{
- @Override
- public void run()
+ File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ String choice = selectedFile.getAbsolutePath();
+ Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
+ new Thread(new Runnable()
{
- 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)
+ @Override
+ public void run()
{
- 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);
+ try
+ {
+ new Jalview2XML().loadJalviewAlign(selectedFile);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("Whilst loading project from " + choice, oom);
+ } catch (Exception ex)
+ {
+ jalview.bin.Console.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
@@ -1718,7 +1869,7 @@ public class Desktop extends jalview.jbgui.GDesktop
ArrayList