X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=7d0eb7f0fe562638ebbac244c8346c1f7db35fef;hb=f14246a28441f24b39b0516282513fbf6196e46c;hp=2e8644e8c958ef803c836e024a568af971fd5c70;hpb=7d67fb613ec026dc9a265e351e7fab542e3f1d61;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 2e8644e..7d0eb7f 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -20,7 +20,6 @@ */ package jalview.gui; -import static jalview.util.UrlConstants.EMBLEBI_STRING; import static jalview.util.UrlConstants.SEQUENCE_ID; import jalview.api.AlignViewportI; @@ -31,6 +30,7 @@ import jalview.io.DataSourceType; import jalview.io.FileFormat; import jalview.io.FileFormatException; import jalview.io.FileFormatI; +import jalview.io.FileFormats; import jalview.io.FileLoader; import jalview.io.IdentifyFile; import jalview.io.JalviewFileChooser; @@ -38,11 +38,14 @@ import jalview.io.JalviewFileView; import jalview.jbgui.GSplitFrame; import jalview.jbgui.GStructureViewer; import jalview.structure.StructureSelectionManager; +import jalview.urls.IdOrgSettings; import jalview.util.ImageMaker; import jalview.util.MessageManager; import jalview.util.Platform; +import jalview.util.UrlConstants; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.ParamManager; +import jalview.ws.utils.UrlDownloadClient; import java.awt.BorderLayout; import java.awt.Color; @@ -77,6 +80,7 @@ import java.beans.PropertyChangeListener; import java.io.BufferedInputStream; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Hashtable; @@ -102,7 +106,6 @@ import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JProgressBar; @@ -392,6 +395,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements showNews.setVisible(false); + getIdentifiersOrgData(); + checkURLLinks(); this.addWindowListener(new WindowAdapter() @@ -455,7 +460,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements } }); - // displayed. // Thread off a new instance of the file chooser - this reduces the time it // takes to open it later on. new Thread(new Runnable() @@ -466,9 +470,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements Cache.log.debug("Filechooser init thread started."); String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"), - // jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, - // jalview.io.AppletFormatAdapter.READABLE_FNAMES, - fileFormat, true); + fileFormat); Cache.log.debug("Filechooser init thread finished."); } }).start(); @@ -528,6 +530,29 @@ public class Desktop extends jalview.jbgui.GDesktop implements }); } + public void getIdentifiersOrgData() + { + // Thread off the identifiers fetcher + addDialogThread(new Runnable() + { + @Override + public void run() + { + Cache.log.debug("Downloading data from identifiers.org"); + UrlDownloadClient client = new UrlDownloadClient(); + try + { + client.download(IdOrgSettings.getUrl(), + IdOrgSettings.getDownloadLocation()); + } catch (IOException e) + { + Cache.log.debug("Exception downloading identifiers.org data" + + e.getMessage()); + } + } + }); + } + @Override protected void showNews_actionPerformed(ActionEvent e) { @@ -894,9 +919,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements } }); + desktop.add(frame); + windowMenu.add(menuItem); - desktop.add(frame); frame.toFront(); try { @@ -1013,10 +1039,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements { String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); JalviewFileChooser chooser = JalviewFileChooser.forRead( - Cache.getProperty("LAST_DIRECTORY"), - // AppletFormatAdapter.READABLE_EXTENSIONS, - // AppletFormatAdapter.READABLE_FNAMES, - fileFormat, true); + Cache.getProperty("LAST_DIRECTORY"), fileFormat); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@ -1031,20 +1054,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); - FileFormatI format = null; - FileFormatI selectedFormat = chooser.getSelectedFormat(); - if (FileFormat.Jalview.equals(selectedFormat)) - { - format = FileFormat.Jalview; - } - else + FileFormatI format = chooser.getSelectedFormat(); + + /* + * Call IdentifyFile to verify the file contains what its extension implies. + * Skip this step for dynamically added file formats, because + * IdentifyFile does not know how to recognise them. + */ + if (FileFormats.getInstance().isIdentifiable(format)) { try { format = new IdentifyFile().identify(choice, DataSourceType.FILE); } catch (FileFormatException e) { - // format is null + // format = null; //?? } } @@ -1096,11 +1120,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } - int reply = JOptionPane.showInternalConfirmDialog(desktop, panel, + int reply = JvOptionPane.showInternalConfirmDialog(desktop, panel, MessageManager.getString("label.input_alignment_from_url"), - JOptionPane.OK_CANCEL_OPTION); + JvOptionPane.OK_CANCEL_OPTION); - if (reply != JOptionPane.OK_OPTION) + if (reply != JvOptionPane.OK_OPTION) { return; } @@ -1134,11 +1158,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (format == null) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.formatMessage("label.couldnt_locate", new Object[] { url }), MessageManager .getString("label.url_not_found"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); return; } @@ -1234,9 +1258,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements public void aboutMenuItem_actionPerformed(ActionEvent e) { // StringBuffer message = getAboutMessage(false); - // JOptionPane.showInternalMessageDialog(Desktop.desktop, + // JvOptionPane.showInternalMessageDialog(Desktop.desktop, // - // message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE); + // message.toString(), "About Jalview", JvOptionPane.INFORMATION_MESSAGE); new Thread(new Runnable() { @Override @@ -1535,8 +1559,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements @Override public void saveState_actionPerformed(ActionEvent e) { - JalviewFileChooser chooser = new JalviewFileChooser( - Cache.getProperty("LAST_DIRECTORY"), "jvp", "Jalview Project", + JalviewFileChooser chooser = new JalviewFileChooser("jvp", "Jalview Project"); chooser.setFileView(new JalviewFileView()); @@ -1575,11 +1598,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements Cache.log.error( "Problems whilst trying to save to " + choice.getName(), ex); - JOptionPane.showMessageDialog(me, MessageManager.formatMessage( + JvOptionPane.showMessageDialog(me, MessageManager.formatMessage( "label.error_whilst_saving_current_state_to", new Object[] { choice.getName() }), MessageManager .getString("label.couldnt_save_project"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } setProgressBar(null, choice.hashCode()); } @@ -1641,12 +1664,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements { Cache.log.error("Problems whilst loading project from " + choice, ex); - JOptionPane.showMessageDialog(Desktop.desktop, MessageManager + JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager .formatMessage( "label.error_whilst_loading_project_from", new Object[] { choice }), MessageManager .getString("label.couldnt_load_project"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } setProgressBar(null, choice.hashCode()); } @@ -1931,7 +1954,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements String fle = chooser.getSelectedFile().toString(); if (!vamsasImport(chooser.getSelectedFile())) { - JOptionPane + JvOptionPane .showInternalMessageDialog( Desktop.desktop, MessageManager.formatMessage( @@ -1939,7 +1962,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements new Object[] { fle }), MessageManager .getString("label.vamsas_document_import_failed"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); } } } @@ -2190,9 +2213,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements { if (v_client != null) { - JalviewFileChooser chooser = new JalviewFileChooser( - Cache.getProperty("LAST_DIRECTORY"), "vdj",// TODO: VAMSAS DOCUMENT EXTENSION is VDJ - "Vamsas Document", "Vamsas Document"); + // TODO: VAMSAS DOCUMENT EXTENSION is VDJ + JalviewFileChooser chooser = new JalviewFileChooser("vdj", + "Vamsas Document"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@ -2230,9 +2253,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements removeProgressPanel(progpanel); if (warnmsg != null) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, - warnmsg, warnttl, JOptionPane.ERROR_MESSAGE); + warnmsg, warnttl, JvOptionPane.ERROR_MESSAGE); } } } @@ -2295,7 +2318,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements { // check what the actual links are - if it's just the default don't // bother with the warning - Vector links = Preferences.sequenceURLLinks; + List 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 @@ -2305,7 +2329,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements while (li.hasNext()) { String link = li.next(); - if (link.contains(SEQUENCE_ID) && !link.equals(EMBLEBI_STRING)) + if (link.contains(SEQUENCE_ID) + && !link.equals(UrlConstants.DEFAULT_STRING)) { check = true; int barPos = link.indexOf("|"); @@ -2352,10 +2377,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements }); msgPanel.add(jcb); - JOptionPane.showMessageDialog(Desktop.desktop, msgPanel, + JvOptionPane.showMessageDialog(Desktop.desktop, msgPanel, MessageManager .getString("label.SEQUENCE_ID_no_longer_used"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } } }); @@ -2562,11 +2587,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements } catch (Exception ex) { jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex); - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.couldnt_create_groovy_shell"), MessageManager.getString("label.groovy_support_failed"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); } } @@ -2829,13 +2854,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (Cache.getDefault("SHOW_JWS2_SERVICES", true)) { - if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning()) - { - jalview.ws.jws2.Jws2Discoverer.getDiscoverer().setAborted(true); - } t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer( changeSupport); - } Thread t3 = null; { @@ -2907,7 +2927,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements * * jd.waitForInput(); */ - JOptionPane + JvOptionPane .showConfirmDialog( Desktop.desktop, new JLabel( @@ -2919,8 +2939,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements + "

Check the Connections and Web services tab
of the" + " Tools->Preferences dialog box to change them.

"), "Web Service Configuration Problem", - JOptionPane.DEFAULT_OPTION, - JOptionPane.ERROR_MESSAGE); + JvOptionPane.DEFAULT_OPTION, + JvOptionPane.ERROR_MESSAGE); serviceChangedDialog = null; } @@ -2977,11 +2997,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements jalview.util.BrowserLauncher.openURL(url); } catch (Exception ex) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager .getString("label.web_browser_not_found_unix"), MessageManager.getString("label.web_browser_not_found"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); ex.printStackTrace(); }