import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.UrlConstants;
-import jalview.util.dialogrunner.RunResponse;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.ParamManager;
import jalview.ws.utils.UrlDownloadClient;
import java.util.Hashtable;
import java.util.List;
import java.util.ListIterator;
-import java.util.StringTokenizer;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
*/
public Desktop()
{
+ 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.
*/
instance = this;
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
doVamsasClientCheck();
}
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");
+ }
+
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(
- (Platform.isWindows() ? new DefaultDesktopManager()
- : Platform.isAMac()
+ (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager()
+ : Platform.isAMacAndNotJS()
? new AquaInternalFrameManager(
desktop.getDesktopManager())
: desktop.getDesktopManager())));
setBounds(xPos, yPos, 900, 650);
}
- boolean doFullLoad = /** @j2sNative ! */true;
+ boolean doFullLoad = !Platform.isJS();
if (doFullLoad) {
frame.setResizable(resizable);
frame.setMaximizable(resizable);
frame.setIconifiable(resizable);
- frame.setOpaque(/** @j2sNative true || */
- false);
+ frame.setOpaque(Platform.isJS()); // BH this should not be necessary
if (frame.getX() < 1 && frame.getY() < 1)
{
MessageManager.getString("label.open_local_file"));
chooser.setToolTipText(MessageManager.getString("action.open"));
- chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
+ chooser.setResponseHandler(0, new Runnable()
{
-
@Override
public void run()
{
new FileLoader().LoadFile(viewport, selectedFile,
DataSourceType.FILE, format);
}
- }).openDialog(this);
+ });
+ chooser.showOpenDialog(this);
}
/**
*/
JComponent history;
String urlBase = "http://www.";
- if (Jalview.isJS())
+ if (Platform.isJS())
{
history = new JTextField(urlBase, 35);
}
Object[] options = new Object[] { MessageManager.getString("action.ok"),
MessageManager.getString("action.cancel") };
- RunResponse action = new RunResponse(JvOptionPane.OK_OPTION) {
+ Runnable action = new Runnable() {
@Override
public void run()
{
- String url = Jalview.isJS() ? ((JTextField) history).getText()
+ String url = Platform.isJS() ? ((JTextField) history).getText()
: ((JComboBox<String>) history).getSelectedItem()
.toString();
}};
String dialogOption = MessageManager
.getString("label.input_alignment_from_url");
- JvOptionPane.newOptionDialog(desktop).response(action)
+ JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action)
.showInternalDialog(panel, dialogOption,
JvOptionPane.YES_NO_CANCEL_OPTION,
JvOptionPane.PLAIN_MESSAGE, null, options,
{
try
{
- if (Jalview.isJS())
+ if (Platform.isJS())
{
BrowserLauncher.openURL("http://www.jalview.org/help.html");
}
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.save_state"));
- // TODO: JAL-3048 Dialog runner refactoring here
- int value = chooser.showSaveDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ int option = chooser.showSaveDialog(this);
+ if (option == JalviewFileChooser.APPROVE_OPTION)
{
- final Desktop me = this;
- final java.io.File choice = chooser.getSelectedFile();
+ File choice = chooser.getSelectedFile();
setProjectFile(choice);
new Thread(new Runnable()
Cache.log.error(
"Problems whilst trying to save to " + choice.getName(),
ex);
- JvOptionPane.showMessageDialog(me,
+ JvOptionPane.showMessageDialog(Desktop.this,
MessageManager.formatMessage(
"label.error_whilst_saving_current_state_to",
new Object[]
setProgressBar(null, choice.hashCode());
}
}).start();
- }
+ }
}
- private void setProjectFile(File choice)
+ void setProjectFile(File choice)
{
this.projectFile = choice;
}
"Jalview Project");
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
+ @Override
+ public void run()
{
- if (asCastor)
- {
- new Jalview2XML().loadJalviewAlign(choice);
- }
- else
+ try {
+ if (asCastor)
+ {
+ new Jalview2XML().loadJalviewAlign(choice);
+ }
+ else
+ {
+ new jalview.project.Jalview2XML().loadJalviewAlign(selectedFile);
+ }
+ } catch (OutOfMemoryError oom)
{
- new jalview.project.Jalview2XML().loadJalviewAlign(choice);
- }
- } catch (OutOfMemoryError oom)
- {
new OOMWarning("Whilst loading project from " + choice, oom);
- } catch (Exception ex)
- {
+ } catch (Exception ex)
+ {
Cache.log.error(
"Problems whilst loading project from " + choice, ex);
JvOptionPane.showMessageDialog(Desktop.desktop,
{ choice }),
MessageManager.getString("label.couldnt_load_project"),
JvOptionPane.WARNING_MESSAGE);
+ }
}
- setProgressBar(null, choice.hashCode());
- }
- }).start();
- }
+ }).start();
+ }
+ });
+
+ chooser.showOpenDialog(this);
}
@Override
/**
* import file into a new vamsas session (uses jalview.gui.VamsasApplication)
*
- * @param file
+ * @param fileName
* @return true if import was a success and a session was started.
*/
public boolean vamsasImport(URL url)
}
else
{
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
System.err.println(
"Please ignore plist error - occurs due to problem with java 8 on OSX");
}
}
}
- if (Platform.isWindows())
-
+ if (Platform.isWindowsAndNotJS())
{
Cache.log.debug("Scanning dropped content for Windows Link Files");