+ public Object[] dialogData;
+
+ // @Override
+ @Override
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ // TODO this is obsolete with JAL-3048 - delete?
+ Object val = event.getNewValue();
+ String name = event.getPropertyName();
+ System.out.println(name);
+ switch (event.getSource().getClass().getName())
+ {
+ case "javax.swing.JOptionPane":
+ switch (name)
+ {
+ case "inputValue":
+ onDialogReturn(val);
+ return;
+ case "value":
+ if (val instanceof Integer)
+ {
+ onDialogReturn(((Integer) val).intValue());
+ }
+ else
+ {
+ onDialogReturn(val);
+ }
+ return;
+ }
+ break;
+ case "javax.swing.JFileChooser":
+ switch (name)
+ {
+ case "SelectedFile":
+ // in JavaScript, this File object will have a _bytes property,
+ // because the file data has already been loaded
+ onDialogReturn(new Object[] { (File) val });
+ return;
+ }
+ break;
+ }
+ System.out.println(event.getSource().getClass().getName() + " "
+ + event.getPropertyName() + ": " + event.getNewValue());
+ }
+
+ // JSCOmponent.DialogCaller interface
+ void onDialogReturn(Object value)
+ {
+ switch ((String) dialogData[0])
+ {
+ case "SelectedFile":
+ case "runnable":
+ dialogData[0] = value;
+ ((Runnable) dialogData[1]).run();
+ break;
+ default:
+ }
+ }
+
+ // JSCOmponent.DialogCaller interface
+ void onDialogReturn(int value)
+ {
+ if (value != Math.floor(value))
+ {
+ // in JavaScript, this will be NaN, oddly enough
+ return;
+ }
+
+ switch ((String) dialogData[0])
+ {
+ case "runnable":
+ dialogData[0] = Integer.valueOf(value);
+ ((Runnable) dialogData[1]).run();
+ break;
+ case "label.input_alignment_from_url":
+ // reconstruct the parameter data
+ int reply = value;
+ AlignViewport viewport = (AlignViewport) dialogData[1];
+ JComboBox history = (JComboBox) dialogData[2];
+ // the rest of this is unchangaed
+ if (reply != JvOptionPane.OK_OPTION)
+ {
+ return;
+ }
+
+ String url = history.getSelectedItem().toString();
+
+ if (url.toLowerCase().endsWith(".jar"))
+ {
+ if (viewport != null)
+ {
+ new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ FileFormat.Jalview);
+ }
+ else
+ {
+ new FileLoader().LoadFile(url, DataSourceType.URL,
+ FileFormat.Jalview);
+ }
+ }
+ else
+ {
+ FileFormatI format = null;
+ try
+ {
+ format = new IdentifyFile().identify(url, DataSourceType.URL);
+ } catch (FileFormatException e)
+ {
+ // TODO revise error handling, distinguish between
+ // URL not found and response not valid
+ }
+
+ if (format == null)
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.couldnt_locate",
+ new Object[]
+ { url }),
+ MessageManager.getString("label.url_not_found"),
+ JvOptionPane.WARNING_MESSAGE);
+
+ return;
+ }
+
+ if (viewport != null)
+ {
+ new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ format);
+ }
+ else
+ {
+ new FileLoader().LoadFile(url, DataSourceType.URL, format);
+ }
+ }
+
+ break;
+ }
+
+ }
+