")
.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 (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 ")
.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: ");
message.append(Cache.getDefault("AUTHORFNAMES", DEFAULT_AUTHORS));
message.append(CITATION);
message.append("
");
return message.toString();
}
/**
* Action on requesting Help documentation
*/
@Override
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)
{
jalview.bin.Console
.errPrintln("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++)
{
try
{
frames[i].setClosed(true);
} catch (java.beans.PropertyVetoException ex)
{
}
}
Jalview.getInstance().setCurrentAlignFrame(null);
jalview.bin.Console.info("ALL CLOSED");
/*
* 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();
}
}
public int structureViewersStillRunningCount()
{
int count = 0;
JInternalFrame[] frames = desktop.getAllFrames();
for (int i = 0; i < frames.length; i++)
{
if (frames[i] != null
&& frames[i] instanceof JalviewStructureDisplayI)
{
if (((JalviewStructureDisplayI) frames[i]).stillRunning())
count++;
}
}
return count;
}
@Override
public void raiseRelated_actionPerformed(ActionEvent e)
{
reorderAssociatedWindows(false, false);
}
@Override
public void minimizeAssociated_actionPerformed(ActionEvent e)
{
reorderAssociatedWindows(true, false);
}
void closeAssociatedWindows()
{
reorderAssociatedWindows(false, true);
}
/*
* (non-Javadoc)
*
* @seejalview.jbgui.GDesktop#garbageCollect_actionPerformed(java.awt.event.
* ActionEvent)
*/
@Override
protected void garbageCollect_actionPerformed(ActionEvent e)
{
// We simply collect the garbage
jalview.bin.Console.debug("Collecting garbage...");
System.gc();
jalview.bin.Console.debug("Finished garbage collection.");
}
/*
* (non-Javadoc)
*
* @see jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.
* ActionEvent )
*/
@Override
protected void showMemusage_actionPerformed(ActionEvent e)
{
desktop.showMemoryUsage(showMemusage.isSelected());
}
/*
* (non-Javadoc)
*
* @see
* jalview.jbgui.GDesktop#showConsole_actionPerformed(java.awt.event.ActionEvent
* )
*/
@Override
protected void showConsole_actionPerformed(ActionEvent e)
{
showConsole(showConsole.isSelected());
}
Console jconsole = null;
/**
* control whether the java console is visible or not
*
* @param selected
*/
void showConsole(boolean selected)
{
// TODO: decide if we should update properties file
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)
{
JInternalFrame[] frames = desktop.getAllFrames();
if (frames == null || frames.length < 1)
{
return;
}
AlignmentViewport source = null, target = null;
if (frames[0] instanceof AlignFrame)
{
source = ((AlignFrame) frames[0]).getCurrentView();
}
else if (frames[0] instanceof TreePanel)
{
source = ((TreePanel) frames[0]).getViewPort();
}
else if (frames[0] instanceof PCAPanel)
{
source = ((PCAPanel) frames[0]).av;
}
else if (frames[0].getContentPane() instanceof PairwiseAlignPanel)
{
source = ((PairwiseAlignPanel) frames[0].getContentPane()).av;
}
if (source != null)
{
for (int i = 0; i < frames.length; i++)
{
target = null;
if (frames[i] == null)
{
continue;
}
if (frames[i] instanceof AlignFrame)
{
target = ((AlignFrame) frames[i]).getCurrentView();
}
else if (frames[i] instanceof TreePanel)
{
target = ((TreePanel) frames[i]).getViewPort();
}
else if (frames[i] instanceof PCAPanel)
{
target = ((PCAPanel) frames[i]).av;
}
else if (frames[i].getContentPane() instanceof PairwiseAlignPanel)
{
target = ((PairwiseAlignPanel) frames[i].getContentPane()).av;
}
if (source == target)
{
try
{
if (close)
{
frames[i].setClosed(true);
}
else
{
frames[i].setIcon(minimize);
if (!minimize)
{
frames[i].toFront();
}
}
} catch (java.beans.PropertyVetoException ex)
{
}
}
}
}
}
/**
* DOCUMENT ME!
*
* @param e
* DOCUMENT ME!
*/
@Override
protected void preferences_actionPerformed(ActionEvent e)
{
Preferences.openPreferences();
}
/**
* Prompts the user to choose a file and then saves the Jalview state as a
* Jalview project file
*/
@Override
public void saveState_actionPerformed()
{
saveState_actionPerformed(false);
}
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();
// jalview.bin.Console.outPrintln("autoSave="+autoSave+",
// projectFile='"+projectFile+"',
// saveAs="+saveAs+", Backups
// "+(BackupFiles.getEnabled()?"enabled":"disabled"));
boolean approveSave = false;
if (!autoSave)
{
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
public void run()
{
// 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
{
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)
{
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, chosenFile.hashCode());
}
}).start();
}
}
@Override
public void saveAsState_actionPerformed(ActionEvent e)
{
saveState_actionPerformed(true);
}
protected void setProjectFile(File choice)
{
this.projectFile = choice;
}
public File getProjectFile()
{
return this.projectFile;
}
/**
* Shows a file chooser dialog and tries to read in the selected file as a
* Jalview project
*/
@Override
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"));
chooser.setResponseHandler(0, () -> {
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)
{
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);
}
}
}, "Project Loader").start();
});
chooser.showOpenDialog(this);
}
@Override
public void inputSequence_actionPerformed(ActionEvent e)
{
new SequenceFetcher(this);
}
JPanel progressPanel;
ArrayList