import jalview.gui.JvOptionPane;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.util.dialogrunner.DialogRunner;
import jalview.util.dialogrunner.DialogRunnerI;
import jalview.util.dialogrunner.Response;
import jalview.util.dialogrunner.RunResponse;
public class JalviewFileChooser extends JFileChooser
implements PropertyChangeListener, DialogRunnerI
{
- jalview.util.dialogrunner.DialogRunner<JalviewFileChooser> runner = new jalview.util.dialogrunner.DialogRunner<>(
- this);
+ DialogRunner<JalviewFileChooser> runner = new DialogRunner<>(this);
+
/**
* Factory method to return a file chooser that offers readable alignment file
* formats
return f;
}
- public void openDialog(Component parent)
+ /**
+ * Overridden for JalviewJS compatibility: only one thread in Javascript,
+ * so we can't wait for user choice in another thread and then perform the
+ * desired action
+ */
+ @Override
+ public int showOpenDialog(Component parent)
{
runner.resetResponses();
- int value = showOpenDialog(this);
+ int value = super.showOpenDialog(this);
/**
* @j2sNative
*/
{
runner.firstRun(value);
}
+ return value;
}
/**
};
};
+ /**
+ * Overridden for JalviewJS compatibility: only one thread in Javascript,
+ * so we can't wait for user choice in another thread and then perform the
+ * desired action
+ */
@Override
public int showSaveDialog(Component parent) throws HeadlessException
{
class RecentlyOpened extends JPanel
{
- JList list;
+ JList<String> list;
public RecentlyOpened()
{
String historyItems = jalview.bin.Cache.getProperty("RECENT_FILE");
StringTokenizer st;
- Vector recent = new Vector();
+ Vector<String> recent = new Vector<>();
if (historyItems != null)
{
while (st.hasMoreTokens())
{
- recent.addElement(st.nextElement());
+ recent.addElement(st.nextToken());
}
}
- list = new JList(recent);
+ list = new JList<>(recent);
DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT);
layout.putConstraint(SpringLayout.NORTH, scroller, 5,
SpringLayout.NORTH, this);
- if (new Platform().isAMac())
+ if (Platform.isAMac())
{
scroller.setPreferredSize(new Dimension(500, 100));
}