")
+ .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"))
{
- message.append("
...Checking latest version...");
+ // JBP removed this message for 2.11: May be reinstated in future version
+ // 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()
+ boolean red = false;
+ if (Cache.getProperty("VERSION").toLowerCase(Locale.ROOT)
.indexOf("automated build") == -1)
{
- red=true;
+ red = true;
// Displayed when code version and jnlp version do not match and code
// version is not a development build
message.append("
");
}
-
- message.append("
!! Jalview 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("AUTHORNAMES","Jim Procter, Andrew Waterhouse, Jan Engelhardt, Lauren Lui, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton")
- + "
Development managed by The Barton Group, University of Dundee, Scotland, UK.
"
- + "
For help, see the FAQ at www.jalview.org 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
*/
- public void documentationMenuItem_actionPerformed(ActionEvent e)
+ @Override
+ public void documentationMenuItem_actionPerformed()
{
try
{
- ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
- java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
- javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
-
- javax.help.HelpBroker hb = hs.createHelpBroker();
- hb.setCurrentID("home");
- hb.setDisplayed(true);
+ 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)
{
+ // TODO show a progress bar while closing?
JInternalFrame[] frames = desktop.getAllFrames();
for (int i = 0; i < frames.length; i++)
{
@@ -1153,19 +1512,28 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
}
}
+ 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)
+ {
+ ssm.resetAll();
}
}
+ @Override
public void raiseRelated_actionPerformed(ActionEvent e)
{
reorderAssociatedWindows(false, false);
}
+ @Override
public void minimizeAssociated_actionPerformed(ActionEvent e)
{
reorderAssociatedWindows(true, false);
@@ -1182,21 +1550,22 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @seejalview.jbgui.GDesktop#garbageCollect_actionPerformed(java.awt.event.
* ActionEvent)
*/
+ @Override
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)
{
desktop.showMemoryUsage(showMemusage.isSelected());
@@ -1209,6 +1578,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* jalview.jbgui.GDesktop#showConsole_actionPerformed(java.awt.event.ActionEvent
* )
*/
+ @Override
protected void showConsole_actionPerformed(ActionEvent e)
{
showConsole(showConsole.isSelected());
@@ -1223,11 +1593,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements
*/
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)
@@ -1238,7 +1611,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
return;
}
- AlignViewport source = null, target = null;
+ AlignmentViewport source = null, target = null;
if (frames[0] instanceof AlignFrame)
{
source = ((AlignFrame) frames[0]).getCurrentView();
@@ -1313,138 +1686,209 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @param e
* DOCUMENT ME!
*/
+ @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
*/
- public void saveState_actionPerformed(ActionEvent e)
+ @Override
+ public void saveState_actionPerformed()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jar" }, new String[]
- { "Jalview Project" }, "Jalview Project");
+ saveState_actionPerformed(false);
+ }
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("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();
- new Thread(new Runnable()
- {
- public void run()
- {
+ JalviewFileChooser chooser = new JalviewFileChooser("jvp",
+ "Jalview Project");
- setProgressBar("Saving jalview project " + choice.getName(),
- choice.hashCode());
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.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)
+ chooser.setFileView(new JalviewFileView());
+ chooser.setDialogTitle(MessageManager.getString("label.save_state"));
+
+ int value = chooser.showSaveDialog(this);
+
+ if (value == JalviewFileChooser.APPROVE_OPTION)
{
- Cache.log
- .error("Problems whilst trying to save to "
- + choice.getName(), ex);
- JOptionPane.showMessageDialog(me,
- "Error whilst saving current state to " + choice.getName(),
- "Couldn't save project", JOptionPane.WARNING_MESSAGE);
+ projectFile = chooser.getSelectedFile();
+ setProjectFile(projectFile);
+ approveSave = true;
}
- setProgressBar(null, choice.hashCode());
- }
- }).start();
}
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- public void loadState_actionPerformed(ActionEvent e)
- {
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jar" }, new String[]
- { "Jalview Project" }, "Jalview Project");
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Restore state");
-
- int value = chooser.showOpenDialog(this);
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ if (approveSave || autoSave)
{
- final String choice = chooser.getSelectedFile().getAbsolutePath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
- .getSelectedFile().getParent());
+ final Desktop me = this;
+ final java.io.File chosenFile = projectFile;
new Thread(new Runnable()
{
+ @Override
public void run()
{
- setProgressBar("loading jalview project " + choice,
- choice.hashCode());
+ // TODO: refactor to Jalview desktop session controller action.
+ 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().LoadJalviewAlign(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 loading project from " + choice, oom);
+ new OOMWarning("Whilst saving current state to "
+ + chosenFile.getName(), oom);
} catch (Exception ex)
{
- Cache.log.error("Problems whilst loading project from "
- + choice, ex);
- JOptionPane.showMessageDialog(Desktop.desktop,
- "Error whilst loading project from " + choice,
- "Couldn't load project", JOptionPane.WARNING_MESSAGE);
+ 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[]
+ { chosenFile.getName() }),
+ MessageManager.getString("label.couldnt_save_project"),
+ JvOptionPane.WARNING_MESSAGE);
}
- setProgressBar(null, choice.hashCode());
+ setProgressBar(null, chosenFile.hashCode());
}
}).start();
}
}
- public void inputSequence_actionPerformed(ActionEvent e)
+ @Override
+ public void saveAsState_actionPerformed(ActionEvent e)
{
- new SequenceFetcher(this);
+ saveState_actionPerformed(true);
}
- JPanel progressPanel;
- ArrayList