- /**
- * Checks the given url to see if it gives a response indicating that the user
- * should be informed of a new questionnaire.
- *
- * @param url
- */
- public void checkForQuestionnaire(String url)
- {
- UserQuestionnaireCheck jvq = new UserQuestionnaireCheck(url);
- // javax.swing.SwingUtilities.invokeLater(jvq);
- new Thread(jvq).start();
- }
-
- public void checkURLLinks()
- {
- // Thread off the URL link checker
- addDialogThread(new Runnable()
- {
- @Override
- public void run()
- {
- if (/** @j2sNative false && */ // BH 2018
- Cache.getDefault("CHECKURLLINKS", true))
- {
- // check what the actual links are - if it's just the default don't
- // bother with the warning
- List<String> links = Preferences.sequenceUrlLinks
- .getLinksForMenu();
-
- // only need to check links if there is one with a
- // SEQUENCE_ID which is not the default EMBL_EBI link
- ListIterator<String> li = links.listIterator();
- boolean check = false;
- List<JLabel> urls = new ArrayList<>();
- while (li.hasNext())
- {
- String link = li.next();
- if (link.contains(SEQUENCE_ID)
- && !UrlConstants.isDefaultString(link))
- {
- check = true;
- int barPos = link.indexOf("|");
- String urlMsg = barPos == -1 ? link
- : link.substring(0, barPos) + ": "
- + link.substring(barPos + 1);
- urls.add(new JLabel(urlMsg));
- }
- }
- if (!check)
- {
- return;
- }
-
- // ask user to check in case URL links use old style tokens
- // ($SEQUENCE_ID$ for sequence id _or_ accession id)
- JPanel msgPanel = new JPanel();
- msgPanel.setLayout(new BoxLayout(msgPanel, BoxLayout.PAGE_AXIS));
- msgPanel.add(Box.createVerticalGlue());
- JLabel msg = new JLabel(MessageManager
- .getString("label.SEQUENCE_ID_for_DB_ACCESSION1"));
- JLabel msg2 = new JLabel(MessageManager
- .getString("label.SEQUENCE_ID_for_DB_ACCESSION2"));
- msgPanel.add(msg);
- for (JLabel url : urls)
- {
- msgPanel.add(url);
- }
- msgPanel.add(msg2);
-
- final JCheckBox jcb = new JCheckBox(
- MessageManager.getString("label.do_not_display_again"));
- jcb.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- // update Cache settings for "don't show this again"
- boolean showWarningAgain = !jcb.isSelected();
- Cache.setProperty("CHECKURLLINKS",
- Boolean.valueOf(showWarningAgain).toString());
- }
- });
- msgPanel.add(jcb);
-
- JvOptionPane.showMessageDialog(Desktop.desktop, msgPanel,
- MessageManager
- .getString("label.SEQUENCE_ID_no_longer_used"),
- JvOptionPane.WARNING_MESSAGE);
- }
- }
- });
- }
-
- /**
- * Proxy class for JDesktopPane which optionally displays the current memory
- * usage and highlights the desktop area with a red bar if free memory runs
- * low.
- *
- * @author AMW
- */
- public class MyDesktopPane extends JDesktopPane
- implements Runnable, PropertyChangeListener
- {
-
- public Object[] dialogData;
-
- // @Override
- @Override
- public void propertyChange(PropertyChangeEvent event)
- {
- 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.ColorChooserDialog":
- switch (name)
- {
- case "SelectedColor":
- 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;
- case "label.select_feature_colour":
- ((FeatureRenderer) dialogData[1]).processColorDialog((Color) value);
- break;
- }
- }
-
- // 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
- }