*/
public Desktop()
{
- super();
+ super();
/**
- * A note to implementors. It is ESSENTIAL that any activities that might block
- * are spawned off as threads rather than waited for during this constructor.
+ * A note to implementors. It is ESSENTIAL that any activities that might
+ * block are spawned off as threads rather than waited for during this
+ * constructor.
*/
instance = this;
if (!Platform.isJS())
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());
// JScrollPane sp = new JScrollPane();
// sp.getViewport().setView(desktop);
// getContentPane().add(sp, BorderLayout.CENTER);
-
- // BH 2018 - just an experiment to try unclipped JInternalFrames.
- if (Platform.isJS())
- {
- getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
- }
-
+
+ // BH 2018 - just an experiment to try unclipped JInternalFrames.
+ if (Platform.isJS())
+ {
+ getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
+ }
+
getContentPane().add(desktop, BorderLayout.CENTER);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
-
+
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
desktop.setDesktopManager(new MyDesktopManager(
int yPos = Math.max(5, (screenSize.height - 650) / 2);
setBounds(xPos, yPos, 900, 650);
}
-
- boolean doFullLoad = /** @j2sNative ! */true;
-
- if (doFullLoad) {
-
+
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+
jconsole = new Console(this, showjconsole);
// add essential build information
jconsole.setHeader("Jalview Version: "
}
});
- // Thread off a new instance of the file chooser - this reduces the time it
+ // Thread off a new instance of the file chooser - this reduces the time
+ // it
// takes to open it later on.
new Thread(new Runnable()
{
});
- }
+ }
this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
frame.setResizable(resizable);
frame.setMaximizable(resizable);
frame.setIconifiable(resizable);
- frame.setOpaque(/** @j2sNative true || */
- false);
+ frame.setOpaque(Platform.isJS());
if (frame.getX() < 1 && frame.getY() < 1)
{
{
format = new IdentifyFile().identify(file, protocol);
}
-
+ if (file instanceof File)
+ {
+ Platform.cacheFileData((File) file);
+ }
new FileLoader().LoadFile(null, file, protocol, format);
}
JPanel panel = new JPanel(new GridLayout(2, 1));
panel.add(label);
-
+
/*
* the URL to fetch is
* Java: an editable combobox with history
history = new JTextField(urlBase, 35);
}
else
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
JComboBox<String> asCombo = new JComboBox<>();
asCombo.setPreferredSize(new Dimension(400, 20));
Object[] options = new Object[] { MessageManager.getString("action.ok"),
MessageManager.getString("action.cancel") };
- Runnable action = new Runnable() {
+ Runnable action = new Runnable()
+ {
@Override
public void run()
{
- String url = Platform.isJS() ? ((JTextField) history).getText()
+ @SuppressWarnings("unchecked")
+ String url = (history instanceof JTextField
+ ? ((JTextField) history).getText()
: ((JComboBox<String>) history).getSelectedItem()
- .toString();
+ .toString());
if (url.toLowerCase().endsWith(".jar"))
{
if (format == null)
{
- String msg = MessageManager.formatMessage("label.couldnt_locate", url);
+ String msg = MessageManager
+ .formatMessage("label.couldnt_locate", url);
JvOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
MessageManager.getString("label.url_not_found"),
JvOptionPane.WARNING_MESSAGE);
new FileLoader().LoadFile(url, DataSourceType.URL, format);
}
}
- }};
+ }
+ };
String dialogOption = MessageManager
.getString("label.input_alignment_from_url");
JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action)
BrowserLauncher.openURL("http://www.jalview.org/help.html");
}
else
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
Help.showHelpWindow();
}
// TODO prevent user from messing with the Desktop whilst we're saving
try
{
- BackupFiles backupfiles = new BackupFiles(chosenFile);
+ boolean doBackup = BackupFiles.getEnabled();
+ BackupFiles backupfiles = doBackup ? new BackupFiles(chosenFile) : null;
- new Jalview2XML().saveState(backupfiles.getTempFile());
+ new Jalview2XML().saveState(doBackup ? backupfiles.getTempFile() : chosenFile);
- backupfiles.setWriteSuccess(true);
- backupfiles.rollBackupsAndRenameTempFile();
+ if (doBackup)
+ {
+ backupfiles.setWriteSuccess(true);
+ backupfiles.rollBackupsAndRenameTempFile();
+ }
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst saving current state to "