*/
package jalview.gui;
-import static jalview.util.UrlConstants.SEQUENCE_ID;
-
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.ListIterator;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
-import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
+ protected static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
+
+ public static HashMap<String, FileWriter> savingFiles = new HashMap<>();
+
private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
/**
doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ /*
+ if (!Platform.isAMac())
+ {
+ // this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ }
+ else
+ {
+ this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ }
+ */
+
+ try
+ {
+ APQHandlers.setAPQHandlers(this);
+ } catch (Exception e)
+ {
+ System.out.println("Cannot set APQHandlers");
+ // e.printStackTrace();
+ } catch (Throwable t)
+ {
+ System.out.println("Cannot set APQHandlers");
+ // t.printStackTrace();
+ }
+
+
+ addWindowListener(new WindowAdapter()
+ {
+
+ @Override
+ public void windowClosing(WindowEvent ev)
+ {
+ quit();
+ }
+ });
+
boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
false);
+
boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
false);
desktop = new MyDesktopPane(selmemusage);
showMemusage.setSelected(selmemusage);
desktop.setBackground(Color.white);
+
getContentPane().setLayout(new BorderLayout());
// alternate config - have scrollbars - see notes in JAL-153
// JScrollPane sp = new JScrollPane();
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
- desktop.setDesktopManager(
- new MyDesktopManager(
- (Platform.isWindows() ? new DefaultDesktopManager()
- : Platform.isAMac()
- ? new AquaInternalFrameManager(
- desktop.getDesktopManager())
- : desktop.getDesktopManager())));
+ desktop.setDesktopManager(new MyDesktopManager(
+ (Platform.isWindows() ? new DefaultDesktopManager()
+ : Platform.isAMac()
+ ? new AquaInternalFrameManager(
+ desktop.getDesktopManager())
+ : desktop.getDesktopManager())));
Rectangle dims = getLastKnownDimensions("");
if (dims != null)
}
jconsole = new Console(this, showjconsole);
// add essential build information
- jconsole.setHeader(
- "Jalview Version: " + jalview.bin.Cache.getProperty("VERSION")
- + "\n" + "Jalview Installation: "
- + jalview.bin.Cache.getDefault("INSTALLATION",
- "unknown")
- + "\n" + "Build Date: "
- + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")
- + "\n" + "Java version: "
- + System.getProperty("java.version") + "\n"
- + System.getProperty("os.arch") + " "
- + System.getProperty("os.name") + " "
- + System.getProperty("os.version"));
+ jconsole.setHeader(jalview.bin.Cache.getVersionDetailsForConsole());
showConsole(showjconsole);
KeyStroke ctrlWKey = KeyStroke.getKeyStroke(KeyEvent.VK_W,
InputEvent.CTRL_DOWN_MASK);
KeyStroke cmdWKey = KeyStroke.getKeyStroke(KeyEvent.VK_W,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx());
InputMap inputMap = frame
.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
{
String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
JalviewFileChooser chooser = JalviewFileChooser
- .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
+ .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat, BackupFiles.getEnabled());
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(
message.append("<h1><strong>Version: "
+ jalview.bin.Cache.getProperty("VERSION")
+ "</strong></h1>");
- message.append("<strong>Last Updated: <em>"
+ message.append("<strong>Built: <em>"
+ jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")
- + "</em></strong>");
+ + "</em> from " + jalview.bin.Cache.getBuildDetailsForSplash()
+ + "</strong>");
}
else
if (jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
.equals("Checking"))
{
- message.append("<br>...Checking latest version...</br>");
+ // JBP removed this message for 2.11: May be reinstated in future version
+ // message.append("<br>...Checking latest version...</br>");
}
else if (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
.equals(jalview.bin.Cache.getProperty("VERSION")))
{
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();
+ boolean autoSave = projectFile != null && !saveAs
+ && BackupFiles.getEnabled();
- //System.out.println("autoSave="+autoSave+", projectFile='"+projectFile+"', saveAs="+saveAs+", Backups "+(BackupFiles.getEnabled()?"enabled":"disabled"));
+ // System.out.println("autoSave="+autoSave+", projectFile='"+projectFile+"',
+ // saveAs="+saveAs+", Backups
+ // "+(BackupFiles.getEnabled()?"enabled":"disabled"));
boolean approveSave = false;
if (!autoSave)
}
}
- if (approveSave || autoSave) {
+ if (approveSave || autoSave)
+ {
final Desktop me = this;
final java.io.File chosenFile = projectFile;
new Thread(new Runnable()
backupfiles.rollBackupsAndRenameTempFile();
} catch (OutOfMemoryError oom)
{
- new OOMWarning(
- "Whilst saving current state to " + chosenFile.getName(),
- 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);
+ Cache.log.error("Problems whilst trying to save to "
+ + chosenFile.getName(), ex);
JvOptionPane.showMessageDialog(me,
MessageManager.formatMessage(
"label.error_whilst_saving_current_state_to",
final String[] desc = new String[] { "Jalview Project",
"Jalview Project (old)" };
JalviewFileChooser chooser = new JalviewFileChooser(
- Cache.getProperty("LAST_DIRECTORY"), suffix,
- desc,
- "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"));
while (li.hasNext())
{
String link = li.next();
- if (link.contains(SEQUENCE_ID)
+ if (link.contains(jalview.util.UrlConstants.SEQUENCE_ID)
&& !UrlConstants.isDefaultString(link))
{
check = true;
}
}
-
/**
* Accessor method to quickly get all the AlignmentFrames loaded.
*
{
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
+ jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()),
"Quit");
getRootPane().getActionMap().put("Quit", new AbstractAction()
{
progressBarHandlers = new Hashtable<>();
}
- if (progressBars.get(new Long(id)) != null)
+ if (progressBars.get(Long.valueOf(id)) != null)
{
- JPanel panel = progressBars.remove(new Long(id));
- if (progressBarHandlers.contains(new Long(id)))
+ JPanel panel = progressBars.remove(Long.valueOf(id));
+ if (progressBarHandlers.contains(Long.valueOf(id)))
{
- progressBarHandlers.remove(new Long(id));
+ progressBarHandlers.remove(Long.valueOf(id));
}
removeProgressPanel(panel);
}
else
{
- progressBars.put(new Long(id), addProgressPanel(message));
+ progressBars.put(Long.valueOf(id), addProgressPanel(message));
}
}
final IProgressIndicatorHandler handler)
{
if (progressBarHandlers == null
- || !progressBars.containsKey(new Long(id)))
+ || !progressBars.containsKey(Long.valueOf(id)))
{
throw new Error(MessageManager.getString(
"error.call_setprogressbar_before_registering_handler"));
}
- progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = progressBars.get(new Long(id));
+ progressBarHandlers.put(Long.valueOf(id), handler);
+ final JPanel progressPanel = progressBars.get(Long.valueOf(id));
if (handler.canCancel())
{
JButton cancel = new JButton(
try
{
- java.net.URL url = (URL) t.getTransferData(urlFlavour);
+ java.net.URL url = (URL) t.getTransferData(urlFlavour);
// nb: java 8 osx bug https://bugs.openjdk.java.net/browse/JDK-8156099
// means url may be null.
- if (url != null)
- {
- protocols.add(DataSourceType.URL);
- files.add(url.toString());
- Cache.log.debug("Drop handled as URL dataflavor "
- + files.get(files.size() - 1));
+ if (url != null)
+ {
+ protocols.add(DataSourceType.URL);
+ files.add(url.toString());
+ Cache.log.debug("Drop handled as URL dataflavor "
+ + files.get(files.size() - 1));
return;
}
else
"Please ignore plist error - occurs due to problem with java 8 on OSX");
}
;
- }
+ }
} catch (Throwable ex)
{
Cache.log.debug("URL drop handler failed.", ex);
&& (source.endsWith(".lnk") || source.endsWith(".url")
|| source.endsWith(".site")))
{
- try {
+ try
+ {
File lf = new File(files.get(f));
// process link file to get a URL
Cache.log.debug("Found potential link file: " + lf);
files.set(f, fullname);
Cache.log.debug("Parsed real filename " + fullname
+ " to extract protocol: " + protocols.get(f));
- }
- catch (Exception ex)
+ } catch (Exception ex)
{
- Cache.log.error("Couldn't parse "+files.get(f)+" as a link file.",ex);
+ Cache.log.error(
+ "Couldn't parse " + files.get(f) + " as a link file.",
+ ex);
}
}
}