From: kiramt Date: Tue, 13 Dec 2016 11:10:05 +0000 (+0000) Subject: Merge branch 'develop' into features/JAL-2316 X-Git-Tag: Release_2_10_3b1~346^2~14 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0fcc08f1f633aa9eae854ebe0c78b5fb75471898;hp=-c;p=jalview.git Merge branch 'develop' into features/JAL-2316 Conflicts (resolved): resources/lang/Messages.properties resources/lang/Messages_es.properties src/jalview/gui/Preferences.java --- 0fcc08f1f633aa9eae854ebe0c78b5fb75471898 diff --combined help/html/webServices/urllinks.html index 7ac76c1,088a539..d99633a --- a/help/html/webServices/urllinks.html +++ b/help/html/webServices/urllinks.html @@@ -27,9 -27,7 +27,9 @@@ Opening URLs from Jalview
Both the applet and the desktop application are able to open URLs as 'popups' in your web browser.
Double-clicking on the ID of a sequence - will open the first URL that can be generated from its sequence ID. + will open the URL designated for 'popups' in the "Connections" tab of the Jalview desktop + preferences. This is by default the EMBL-EBI site, but you can easily configure your own sequence URL links.

@@@ -45,39 -43,14 +45,39 @@@ href="../features/preferences.html">Jalview desktop preferences, or specified as applet - parameters.
By default the item "EMBL-EBI Search" is added - to this link menu. This link will show a web page in your default - browser with the selected sequence id as part of the URL.
- In the preferences dialog box, click new to add a + parameters.

+

+ By default, the list of available links in the preferences dialog box + contains the item "EMBL-EBI Search", + which is set as the URL which opens on double-clicking on a sequence ID, and as a + menu item in the Links menu. This link will show a web page in your default + browser with the selected sequence id as part of the URL. +
+ Also by default, the list of available links contains persistent URLs for many common + bioinformatics databases. These links are downloaded by Jalview from + the identifiers.org website, and the names and URLs are not user editable. +
+ The list of links is sortable, by clicking on the headers of the table. The list + can be filtered using the free text search box below the table, or the + "Custom Only" button, which displays only user-defined links. +

+

+ In the preferences dialog box, the links which appear in the Links menu + can be configured by selecting or deselecting links in the "In Menu" + column. The names of selected links will be displayed + on new menu items under the "Link" menu when you right + click on a sequence id.
+ You can configure which link is used when double-clicking on a sequence + by selecting or deselecting links in the "On Click" column. Exactly one + link must be configured for double-clicking. Since the link uses the sequence id + to construct the URL to open, the selected link must contain the + "$SEQUENCE_ID$" token (see below for details of the "$SEQUENCE_ID$" + and other tokens).

+

+ Additionally you can click new to add a new link, and edit to modify an existing link, or delete - to remove it.
You can name the link, this will be displayed - on a new menu item under the "Link" menu when you right - click on a sequence id.
The URL string must contain a + to remove it. Only URLs entered by the user (or the default EMBL-EBI link) may + be edited or deleted. When adding or editing a link, the URL string must contain a token that can be replaced with a sequence ID or DB accession ID. The simplest token is "$SEQUENCE_ID$", which will be replaced by the chosen sequence id when you click on it. @@@ -93,6 -66,21 +93,21 @@@ the sequence ID for the sequence (since Jalview 2.10.1).

+ Warning dialog about updating + your configured URL links
In the desktop + prior to Jalview 2.10.1, the only way to configure custom links for + a particular database cross-reference for a sequence was to give it + a name that + exactly matched the database source, and a regular + expression for filtering out any spurious matches generated when the + custom linked was tested against the Sequence's ID string. Since the + introduction of the $DB_ACCESSION$ token, however, $SEQUENCE_ID$ + will not be used for database cross-reference accession strings, and + if you have custom links configured, Jalview will raise a warning + message so let you know that you may need to update your links to + use $DB_ACCESSION$. +

+

Regular Expression Substitution
A url may contain a string of the form $SEQUENCE_ID=/regular expression/=$ or $DB_ACCESSION=/regular expression/=$. diff --combined resources/lang/Messages.properties index bee4809,6360dc7..7833903 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@@ -125,6 -125,8 +125,8 @@@ action.change_font_tree_panel = Change action.colour = Colour action.calculate = Calculate action.select_all = Select all + action.select_highlighted_columns = Select Highlighted Columns + tooltip.select_highlighted_columns = Press B to mark highlighted columns, Ctrl-(or Cmd)-B to toggle, and Alt-B to mark all but highlighted columns action.deselect_all = Deselect all action.invert_selection = Invert selection action.using_jmol = Using Jmol @@@ -137,8 -139,7 +139,8 @@@ action.view_flanking_regions = Show fla label.view_flanking_regions = Show sequence data either side of the subsequences involved in this alignment label.structures_manager = Structures Manager label.nickname = Nickname: -label.url = URL: +label.url = URL +label.url\: = URL: label.input_file_url = Enter URL or Input File label.select_feature = Select feature label.name = Name @@@ -410,6 -411,7 +412,6 @@@ label.couldnt_import_as_vamsas_session label.vamsas_document_import_failed = Vamsas Document Import Failed label.couldnt_locate = Couldn't locate {0} label.url_not_found = URL not found -label.no_link_selected = No link selected label.new_sequence_url_link = New sequence URL link label.cannot_edit_annotations_in_wrapped_view = Cannot edit annotations in wrapped view label.wrapped_view_no_edit = Wrapped view - no edit @@@ -1272,18 -1274,4 +1274,19 @@@ label.SEQUENCE_ID_no_longer_used = $SEQ label.SEQUENCE_ID_for_DB_ACCESSION1 = Please review your URL links in the 'Connections' tab of the Preferences window: label.SEQUENCE_ID_for_DB_ACCESSION2 = URL links using '$SEQUENCE_ID$' for DB accessions now use '$DB_ACCESSION$'. label.do_not_display_again = Do not display this message again -label.output_seq_details = Output Sequence Details to list all database references +exception.url_cannot_have_miriam_id = {0} is a MIRIAM id and cannot be used as a custom url name +exception.url_cannot_have_duplicate_id = {0} cannot be used as a label for more than one line +label.filter = Filter text: +action.customfilter = Custom only +action.showall = Show All +label.insert = Insert: +action.seq_id = $SEQUENCE_ID$ +action.db_acc = $DB_ACCESSION$ +label.default = On Click +label.inmenu = In Menu +label.id = ID +label.urltooltip = Only one url, which must use a sequence id, can be selected for the 'On Click' option +label.edit_sequence_url_link = Edit sequence URL link +warn.name_cannot_be_duplicate = URL names must be unique and cannot be MIRIAM ids - label.invalid_name = Invalid Name ! ++label.invalid_name = Invalid Name ! ++label.output_seq_details = Output Sequence Details to list all database references diff --combined resources/lang/Messages_es.properties index 99aeed5,e5b5e27..88fb0a4 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@@ -122,6 -122,8 +122,8 @@@ action.change_font_tree_panel = Cambia action.colour = Color action.calculate = Calcular action.select_all = Seleccionar Todo + action.select_highlighted_columns = Seleccionar columnas resaltadas + tooltip.select_highlighted_columns = Presione B para marcar las columnas resaltadas, Ctrl (o Cmd)-B para cambiarlas, y Alt-B para marcar todas menos las columnas resaltadas action.deselect_all = Deseleccionar Todo action.invert_selection = Invertir selección action.using_jmol = Usar Jmol @@@ -134,8 -136,7 +136,8 @@@ action.view_flanking_regions = Mostrar label.view_flanking_regions = Mostrar los datos de la secuencia a ambos lados de las subsecuencias implicadas en este alineamiento label.structures_manager = Administrar estructuras label.nickname = Sobrenombre: -label.url = URL: +label.url\: = URL: +label.url = URL label.input_file_url = Introducir URL en el fichero de entrada label.select_feature = Seleccionar característica label.name = Nombre @@@ -378,6 -379,7 +380,6 @@@ label.couldnt_import_as_vamsas_session label.vamsas_document_import_failed = Fallo en la importación del documento Vamsas label.couldnt_locate = No se pudo localizar {0} label.url_not_found = URL no encontrada -label.no_link_selected = Enlace no seleccionado label.new_sequence_url_link = Enlace a una nueva secuencia URL label.cannot_edit_annotations_in_wrapped_view = No se pueden editar anotaciones en vista envolvente label.wrapped_view_no_edit = Vista envolvente - no editar @@@ -1273,18 -1275,4 +1275,19 @@@ label.SEQUENCE_ID_no_longer_used = $SEQ label.SEQUENCE_ID_for_DB_ACCESSION1 = Por favor, revise sus URLs en la pestaña 'Conexiones' de la ventana de Preferencias: label.SEQUENCE_ID_for_DB_ACCESSION2 = URL enlaza usando '$SEQUENCE_ID$' para accesiones DB ahora usar '$DB_ACCESSION$'. label.do_not_display_again = No mostrar este mensaje de nuevo -label.output_seq_details = Seleccionar Detalles de la secuencia para ver todas +exception.url_cannot_have_miriam_id = {0} is a MIRIAM id and cannot be used as a custom url name +exception.url_cannot_have_duplicate_id = {0} cannot be used as a label for more than one link +label.filter = Filter text: +action.customfilter = Custom only +action.showall = Show All +label.insert = Insert: +action.seq_id = $SEQUENCE_ID$ +action.db_acc = $DB_ACCESSION$ +label.default = On Click +label.inmenu = In Menu +label.id = ID +label.urltooltip = Only one url, which must use a sequence id, can be selected for the 'On Click' option +label.edit_sequence_url_link = Edit sequence URL link +warn.name_cannot_be_duplicate = URL names must be unique and cannot be MIRIAM ids - label.invalid_name = Invalid Name ! ++label.invalid_name = Invalid Name ! ++label.output_seq_details = Seleccionar Detalles de la secuencia para ver todas diff --combined src/jalview/gui/DasSourceBrowser.java index 26e9708,8c8f228..c5ec067 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@@ -453,18 -453,18 +453,18 @@@ public class DasSourceBrowser extends G pane12.add(nametf, BorderLayout.EAST); panel.add(pane12, BorderLayout.NORTH); pane12 = new JPanel(new BorderLayout()); - pane12.add(new JLabel(MessageManager.getString("label.url")), + pane12.add(new JLabel(MessageManager.getString("label.url:")), BorderLayout.NORTH); pane12.add(seqs, BorderLayout.SOUTH); pane12.add(urltf, BorderLayout.EAST); panel.add(pane12, BorderLayout.SOUTH); - int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, panel, MessageManager.getString("label.enter_local_das_source"), - JOptionPane.OK_CANCEL_OPTION); + JvOptionPane.OK_CANCEL_OPTION); - if (reply != JOptionPane.OK_OPTION) + if (reply != JvOptionPane.OK_OPTION) { return; } @@@ -534,21 -534,21 +534,21 @@@ if (!sourceRegistry.getSource(nickname).isLocal()) { - JOptionPane + JvOptionPane .showInternalMessageDialog( Desktop.desktop, MessageManager .getString("label.you_can_only_edit_or_remove_local_das_sources"), MessageManager.getString("label.public_das_source"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); return; } Object[] options = { "Edit", "Remove", "Cancel" }; - int choice = JOptionPane.showInternalOptionDialog(Desktop.desktop, + int choice = JvOptionPane.showInternalOptionDialog(Desktop.desktop, "Do you want to edit or remove " + nickname + "?", "Edit / Remove Local DAS Source", - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, + JvOptionPane.YES_NO_CANCEL_OPTION, JvOptionPane.QUESTION_MESSAGE, null, options, options[2]); switch (choice) diff --combined src/jalview/gui/Desktop.java index 41ce9a7,ac957d8..b4b41a3 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@@ -20,27 -20,28 +20,30 @@@ */ package jalview.gui; -import static jalview.util.UrlConstants.EMBLEBI_STRING; import static jalview.util.UrlConstants.SEQUENCE_ID; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.Cache; import jalview.bin.Jalview; + import jalview.io.DataSourceType; + import jalview.io.FileFormat; + import jalview.io.FileFormatException; + import jalview.io.FileFormatI; import jalview.io.FileLoader; - import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; import jalview.io.JalviewFileChooser; 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.UrlDownloadClient; import jalview.ws.params.ParamManager; import java.awt.BorderLayout; @@@ -76,7 -77,6 +79,7 @@@ import java.beans.PropertyChangeListene 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 -102,6 +105,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,8 -391,6 +394,8 @@@ public class Desktop extends jalview.jb showNews.setVisible(false); + getIdentifiersOrgData(); + checkURLLinks(); this.addWindowListener(new WindowAdapter() @@@ -457,7 -454,6 +459,6 @@@ } }); - // 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,11 -462,9 +467,9 @@@ public void run() { Cache.log.debug("Filechooser init thread started."); - new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, - jalview.io.AppletFormatAdapter.READABLE_FNAMES, - jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"), + fileFormat); Cache.log.debug("Filechooser init thread finished."); } }).start(); @@@ -530,29 -524,6 +529,29 @@@ }); } + 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) { @@@ -713,10 -684,10 +712,10 @@@ String file = (String) contents .getTransferData(DataFlavor.stringFlavor); - String format = new IdentifyFile().identify(file, - FormatAdapter.PASTE); + FileFormatI format = new IdentifyFile().identify(file, + DataSourceType.PASTE); - new FileLoader().LoadFile(file, FormatAdapter.PASTE, format); + new FileLoader().LoadFile(file, DataSourceType.PASTE, format); } } catch (Exception ex) @@@ -919,9 -890,10 +918,10 @@@ } }); + desktop.add(frame); + windowMenu.add(menuItem); - desktop.add(frame); frame.toFront(); try { @@@ -982,8 -954,8 +982,8 @@@ // Java's Transferable for native dnd evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Transferable t = evt.getTransferable(); - java.util.List files = new ArrayList(); - java.util.List protocols = new ArrayList(); + List files = new ArrayList(); + List protocols = new ArrayList(); try { @@@ -1001,13 -973,13 +1001,13 @@@ for (int i = 0; i < files.size(); i++) { String file = files.get(i).toString(); - String protocol = (protocols == null) ? FormatAdapter.FILE - : (String) protocols.get(i); - String format = null; + DataSourceType protocol = (protocols == null) ? DataSourceType.FILE + : protocols.get(i); + FileFormatI format = null; if (file.endsWith(".jar")) { - format = "Jalview"; + format = FileFormat.Jalview; } else @@@ -1036,11 -1008,9 +1036,9 @@@ @Override public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport) { - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, - jalview.io.AppletFormatAdapter.READABLE_FNAMES, - jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + JalviewFileChooser chooser = JalviewFileChooser.forRead( + Cache.getProperty("LAST_DIRECTORY"), fileFormat); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@@ -1052,28 -1022,34 +1050,34 @@@ if (value == JalviewFileChooser.APPROVE_OPTION) { String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser + Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); - String format = null; - if (chooser.getSelectedFormat() != null - && chooser.getSelectedFormat().equals("Jalview")) + FileFormatI format = null; + FileFormatI selectedFormat = chooser.getSelectedFormat(); + if (FileFormat.Jalview.equals(selectedFormat)) { - format = "Jalview"; + format = FileFormat.Jalview; } else { - format = new IdentifyFile().identify(choice, FormatAdapter.FILE); + try + { + format = new IdentifyFile().identify(choice, DataSourceType.FILE); + } catch (FileFormatException e) + { + // format is null + } } if (viewport != null) { - new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE, + new FileLoader().LoadFile(viewport, choice, DataSourceType.FILE, format); } else { - new FileLoader().LoadFile(choice, FormatAdapter.FILE, format); + new FileLoader().LoadFile(choice, DataSourceType.FILE, format); } } } @@@ -1114,11 -1090,11 +1118,11 @@@ } } - 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; } @@@ -1129,36 -1105,46 +1133,46 @@@ { if (viewport != null) { - new FileLoader().LoadFile(viewport, url, FormatAdapter.URL, - "Jalview"); + new FileLoader().LoadFile(viewport, url, DataSourceType.URL, + FileFormat.Jalview); } else { - new FileLoader().LoadFile(url, FormatAdapter.URL, "Jalview"); + new FileLoader().LoadFile(url, DataSourceType.URL, + FileFormat.Jalview); } } else { - String format = new IdentifyFile().identify(url, FormatAdapter.URL); + 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.equals("URL NOT FOUND")) + 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; } if (viewport != null) { - new FileLoader().LoadFile(viewport, url, FormatAdapter.URL, format); + new FileLoader() + .LoadFile(viewport, url, DataSourceType.URL, format); } else { - new FileLoader().LoadFile(url, FormatAdapter.URL, format); + new FileLoader().LoadFile(url, DataSourceType.URL, format); } } } @@@ -1242,9 -1228,9 +1256,9 @@@ 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 @@@ -1544,9 -1530,7 +1558,7 @@@ public void saveState_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - new String[] { "jvp" }, new String[] { "Jalview Project" }, - "Jalview Project"); + Cache.getProperty("LAST_DIRECTORY"), "jvp", "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager.getString("label.save_state")); @@@ -1584,11 -1568,11 +1596,11 @@@ 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()); } @@@ -1616,7 -1600,7 +1628,7 @@@ public void loadState_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] { + Cache.getProperty("LAST_DIRECTORY"), new String[] { "jvp", "jar" }, new String[] { "Jalview Project", "Jalview Project (old)" }, "Jalview Project"); chooser.setFileView(new JalviewFileView()); @@@ -1629,7 -1613,7 +1641,7 @@@ final File selectedFile = chooser.getSelectedFile(); setProjectFile(selectedFile); final String choice = selectedFile.getAbsolutePath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", + Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent()); new Thread(new Runnable() { @@@ -1650,12 -1634,12 +1662,12 @@@ { 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()); } @@@ -1940,7 -1924,7 +1952,7 @@@ String fle = chooser.getSelectedFile().toString(); if (!vamsasImport(chooser.getSelectedFile())) { - JOptionPane + JvOptionPane .showInternalMessageDialog( Desktop.desktop, MessageManager.formatMessage( @@@ -1948,7 -1932,7 +1960,7 @@@ new Object[] { fle }), MessageManager .getString("label.vamsas_document_import_failed"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); } } } @@@ -2200,9 -2184,8 +2212,8 @@@ if (v_client != null) { JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] - { "vdj" }, // TODO: VAMSAS DOCUMENT EXTENSION is VDJ - new String[] { "Vamsas Document" }, "Vamsas Document"); + Cache.getProperty("LAST_DIRECTORY"), "vdj",// TODO: VAMSAS DOCUMENT EXTENSION is VDJ + "Vamsas Document"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@@ -2216,7 -2199,7 +2227,7 @@@ JPanel progpanel = addProgressPanel(MessageManager.formatMessage( "label.saving_vamsas_doc", new Object[] { choice.getName() })); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); + Cache.setProperty("LAST_DIRECTORY", choice.getParent()); String warnmsg = null; String warnttl = null; try @@@ -2240,9 -2223,9 +2251,9 @@@ removeProgressPanel(progpanel); if (warnmsg != null) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, - warnmsg, warnttl, JOptionPane.ERROR_MESSAGE); + warnmsg, warnttl, JvOptionPane.ERROR_MESSAGE); } } } @@@ -2258,7 -2241,7 +2269,7 @@@ */ public void setVamsasUpdate(boolean b) { - jalview.bin.Cache.log.debug("Setting gui for Vamsas update " + Cache.log.debug("Setting gui for Vamsas update " + (b ? "in progress" : "finished")); if (vamUpdate != null) @@@ -2305,8 -2288,7 +2316,8 @@@ { // check what the actual links are - if it's just the default don't // bother with the warning - Vector links = Preferences.sequenceURLLinks; + Vector 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 @@@ -2316,8 -2298,7 +2327,8 @@@ 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("|"); @@@ -2364,10 -2345,10 +2375,10 @@@ }); 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); } } }); @@@ -2574,11 -2555,11 +2585,11 @@@ } 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); } } @@@ -2919,7 -2900,7 +2930,7 @@@ * * jd.waitForInput(); */ - JOptionPane + JvOptionPane .showConfirmDialog( Desktop.desktop, new JLabel( @@@ -2931,8 -2912,8 +2942,8 @@@ + "

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; } @@@ -2989,11 -2970,11 +3000,11 @@@ 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(); } @@@ -3290,7 -3271,8 +3301,8 @@@ } public static void transferFromDropTarget(List files, - List protocols, DropTargetDropEvent evt, Transferable t) + List protocols, DropTargetDropEvent evt, + Transferable t) throws Exception { @@@ -3304,7 -3286,7 +3316,7 @@@ .getTransferData(DataFlavor.javaFileListFlavor)) { files.add(((File) file).toString()); - protocols.add(FormatAdapter.FILE); + protocols.add(DataSourceType.FILE); } } else @@@ -3334,7 -3316,7 +3346,7 @@@ { Cache.log.debug("Adding missing FILE protocol for " + files.get(protocols.size())); - protocols.add(FormatAdapter.FILE); + protocols.add(DataSourceType.FILE); } for (java.util.StringTokenizer st = new java.util.StringTokenizer( data, "\r\n"); st.hasMoreTokens();) @@@ -3349,14 -3331,14 +3361,14 @@@ java.net.URI uri = new java.net.URI(s); if (uri.getScheme().toLowerCase().startsWith("http")) { - protocols.add(FormatAdapter.URL); + protocols.add(DataSourceType.URL); files.add(uri.toString()); } else { // otherwise preserve old behaviour: catch all for file objects java.io.File file = new java.io.File(uri); - protocols.add(FormatAdapter.FILE); + protocols.add(DataSourceType.FILE); files.add(file.toString()); } } diff --combined src/jalview/gui/IdPanel.java index fb9bcbb,59d12d9..e326a7a --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@@ -27,6 -27,7 +27,6 @@@ import jalview.datamodel.SequenceI import jalview.io.SequenceAnnotationReport; import jalview.util.MessageManager; import jalview.util.Platform; -import jalview.util.UrlLink; import jalview.viewmodel.AlignmentViewport; import java.awt.BorderLayout; @@@ -108,8 -109,8 +108,8 @@@ public class IdPanel extends JPanel imp if (seq > -1 && seq < av.getAlignment().getHeight()) { SequenceI sequence = av.getAlignment().getSequenceAt(seq); - StringBuffer tip = new StringBuffer(64); - seqAnnotReport.createSequenceAnnotationReport(tip, sequence, + StringBuilder tip = new StringBuilder(64); + seqAnnotReport.createTooltipAnnotationReport(tip, sequence, av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr.getMinMax()); setToolTipText(JvSwingUtils.wrapTooltip(true, @@@ -198,19 -199,65 +198,19 @@@ return; } - Vector links = Preferences.sequenceURLLinks; - if (links == null || links.size() < 1) - { - return; - } - int seq = alignPanel.getSeqPanel().findSeq(e); - String url = null; - int i = 0; String id = av.getAlignment().getSequenceAt(seq).getName(); - while (url == null && i < links.size()) - { - // DEFAULT LINK IS FIRST IN THE LINK LIST - // BUT IF ITS A REGEX AND DOES NOT MATCH THE NEXT ONE WILL BE TRIED - url = links.elementAt(i++).toString(); - jalview.util.UrlLink urlLink = null; - try - { - urlLink = new UrlLink(url); - } catch (Exception foo) - { - jalview.bin.Cache.log.error("Exception for URLLink '" + url + "'", - foo); - url = null; - continue; - } + String url = Preferences.sequenceUrlLinks.getDefaultUrl(id); - if (urlLink.usesDBAccession()) - { - // this URL requires an accession id, not the name of a sequence - url = null; - continue; - } - - if (!urlLink.isValid()) - { - jalview.bin.Cache.log.error(urlLink.getInvalidMessage()); - url = null; - continue; - } - - String urls[] = urlLink.makeUrls(id, true); - if (urls == null || urls[0] == null || urls[0].length() < 4) - { - url = null; - continue; - } - // just take first URL made from regex - url = urls[1]; - } try { 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(); } } @@@ -328,7 -375,7 +328,7 @@@ Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq2); // build a new links menu based on the current links + any non-positional // features - Vector nlinks = new Vector(Preferences.sequenceURLLinks); + Vector nlinks = Preferences.sequenceUrlLinks.getLinksForMenu(); SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures(); if (sfs != null) { diff --combined src/jalview/gui/Preferences.java index b46ae10,0b65c1b..00b2a38 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@@ -20,27 -20,27 +20,28 @@@ */ package jalview.gui; -import static jalview.util.UrlConstants.DB_ACCESSION; -import static jalview.util.UrlConstants.EMBLEBI_STRING; -import static jalview.util.UrlConstants.SEQUENCE_ID; -import static jalview.util.UrlConstants.SRS_STRING; - import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; import jalview.gui.Help.HelpId; import jalview.gui.StructureViewer.ViewerType; + import jalview.io.FileFormatI; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; import jalview.jbgui.GPreferences; import jalview.jbgui.GSequenceLink; import jalview.schemes.ColourSchemeProperty; +import jalview.urls.UrlLinkTableModel; +import jalview.urls.api.UrlProviderFactoryI; +import jalview.urls.api.UrlProviderI; +import jalview.urls.desktop.DesktopUrlProviderFactory; import jalview.util.MessageManager; import jalview.util.Platform; +import jalview.util.UrlConstants; import jalview.ws.sifts.SiftsSettings; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; @@@ -49,25 -49,14 +50,24 @@@ import java.awt.event.MouseEvent import java.io.File; import java.util.ArrayList; import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; import javax.help.HelpSetException; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; - import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; import ext.edu.ucsf.rbvi.strucviz2.StructureManager; @@@ -113,9 -102,7 +113,9 @@@ public class Preferences extends GPrefe * Holds name and link separated with | character. Sequence ID must be * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$ */ - public static Vector sequenceURLLinks; + public static UrlProviderI sequenceUrlLinks; + + public static UrlLinkTableModel dataModel; /** * Holds name and link separated with | character. Sequence IDS and Sequences @@@ -128,23 -115,40 +128,23 @@@ public static List groupURLLinks; static { - String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING); - sequenceURLLinks = new Vector(); - - try + // get links selected to be in the menu (SEQUENCE_LINKS) + // and links entered by the user but not selected (STORED_LINKS) + String inMenuString = Cache.getDefault("SEQUENCE_LINKS", ""); + String notInMenuString = Cache.getDefault("STORED_LINKS", ""); + String defaultUrl = Cache.getDefault("DEFAULT_URL", + UrlConstants.DEFAULT_LABEL); + + // if both links lists are empty, add the DEFAULT_URL link + // otherwise we assume the default link is in one of the lists + if (inMenuString.isEmpty() && notInMenuString.isEmpty()) { - StringTokenizer st = new StringTokenizer(string, "|"); - while (st.hasMoreElements()) - { - String name = st.nextToken(); - String url = st.nextToken(); - // check for '|' within a regex - int rxstart = url.indexOf("$" + DB_ACCESSION + "$"); - if (rxstart == -1) - { - rxstart = url.indexOf("$" + SEQUENCE_ID + "$"); - } - while (rxstart == -1 && url.indexOf("/=$") == -1) - { - url = url + "|" + st.nextToken(); - } - sequenceURLLinks.addElement(name + "|" + url); - } - } catch (Exception ex) - { - System.out.println(ex + "\nError parsing sequence links"); - } - { - // upgrade old SRS link - int srsPos = sequenceURLLinks.indexOf(SRS_STRING); - if (srsPos > -1) - { - sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos); - } + inMenuString = UrlConstants.DEFAULT_STRING; } + UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl, + inMenuString, notInMenuString); + sequenceUrlLinks = factory.createUrlProvider(); + dataModel = new UrlLinkTableModel(sequenceUrlLinks); /** * TODO: reformulate groupURL encoding so two or more can be stored in the @@@ -154,6 -158,8 +154,6 @@@ groupURLLinks = new ArrayList(); } - Vector nameLinks, urlLinks; - JInternalFrame frame; DasSourceBrowser dasSource; @@@ -337,128 -343,18 +337,128 @@@ /* * Set Connections tab defaults */ - nameLinks = new Vector(); - urlLinks = new Vector(); - for (int i = 0; i < sequenceURLLinks.size(); i++) + + // set up sorting + linkUrlTable.setModel(dataModel); + final TableRowSorter sorter = new TableRowSorter<>( + linkUrlTable.getModel()); + linkUrlTable.setRowSorter(sorter); + List sortKeys = new ArrayList<>(); + + UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel(); + sortKeys.add(new RowSorter.SortKey(m.getDefaultColumn(), + SortOrder.DESCENDING)); + sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(), + SortOrder.DESCENDING)); + sortKeys.add(new RowSorter.SortKey(m.getNameColumn(), + SortOrder.ASCENDING)); + + sorter.setSortKeys(sortKeys); + sorter.sort(); + + // set up filtering + ActionListener onReset; + onReset = new ActionListener() { - String link = sequenceURLLinks.elementAt(i).toString(); - nameLinks.addElement(link.substring(0, link.indexOf("|"))); - urlLinks.addElement(link.substring(link.indexOf("|") + 1)); - } + @Override + public void actionPerformed(ActionEvent e) + { + filterTB.setText(""); + sorter.setRowFilter(RowFilter.regexFilter("")); + } + + }; + doReset.addActionListener(onReset); + + // filter to display only custom urls + final RowFilter customUrlFilter = new RowFilter() + { + @Override + public boolean include( + Entry entry) + { + return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry); + } + }; + + final TableRowSorter customSorter = new TableRowSorter<>( + linkUrlTable.getModel()); + customSorter.setRowFilter(customUrlFilter); + + ActionListener onCustomOnly; + onCustomOnly = new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + filterTB.setText(""); + sorter.setRowFilter(customUrlFilter); + } + }; + userOnly.addActionListener(onCustomOnly); + + filterTB.getDocument().addDocumentListener(new DocumentListener() + { + String caseInsensitiveFlag = "(?i)"; - updateLinkData(); + @Override + public void changedUpdate(DocumentEvent e) + { + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + + filterTB.getText())); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + + filterTB.getText())); + } + + @Override + public void insertUpdate(DocumentEvent e) + { + sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag + + filterTB.getText())); + } + }); + + // set up list selection functionality + linkUrlTable.getSelectionModel().addListSelectionListener( + new UrlListSelectionHandler()); + + // set up radio buttons + int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel()) + .getDefaultColumn(); + String onClickName = linkUrlTable.getColumnName(onClickCol); + linkUrlTable.getColumn(onClickName).setCellRenderer( + new RadioButtonRenderer()); + linkUrlTable.getColumn(onClickName) + .setCellEditor(new RadioButtonEditor()); + + // get boolean columns and resize those to min possible + for (int column = 0; column < linkUrlTable.getColumnCount(); column++) + { + if (linkUrlTable.getModel().getColumnClass(column) + .equals(Boolean.class)) + { + TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn( + column); + int preferredWidth = tableColumn.getMinWidth(); + + TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0, + column); + Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column); + int cwidth = c.getPreferredSize().width + + linkUrlTable.getIntercellSpacing().width; + preferredWidth = Math.max(preferredWidth, cwidth); + + tableColumn.setPreferredWidth(preferredWidth); + } + } useProxy.setSelected(Cache.getDefault("USE_PROXY", false)); + useProxy_actionPerformed(); // make sure useProxy is correctly initialised proxyServerTB.setEnabled(useProxy.isSelected()); proxyPortTB.setEnabled(useProxy.isSelected()); proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", "")); @@@ -652,32 -548,28 +652,32 @@@ jalview.util.BrowserLauncher.resetBrowser(); - if (nameLinks.size() > 0) + // save user-defined and selected links + String menuLinks = sequenceUrlLinks.writeUrlsAsString(true); + if (menuLinks.isEmpty()) + { + Cache.applicationProperties.remove("SEQUENCE_LINKS"); + } + else { - StringBuffer links = new StringBuffer(); - sequenceURLLinks = new Vector(); - for (int i = 0; i < nameLinks.size(); i++) - { - sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|" - + urlLinks.elementAt(i)); - links.append(sequenceURLLinks.elementAt(i).toString()); - links.append("|"); - } - // remove last "|" - links.setLength(links.length() - 1); Cache.applicationProperties.setProperty("SEQUENCE_LINKS", - links.toString()); + menuLinks.toString()); + } + + String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false); + if (nonMenuLinks.isEmpty()) + { + Cache.applicationProperties.remove("STORED_LINKS"); } else { - Cache.applicationProperties.remove("SEQUENCE_LINKS"); - sequenceURLLinks.clear(); + Cache.applicationProperties.setProperty("STORED_LINKS", + nonMenuLinks.toString()); } + Cache.applicationProperties.setProperty("DEFAULT_URL", + sequenceUrlLinks.getDefaultUrlId()); + Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected())); @@@ -794,12 -686,9 +794,9 @@@ @Override public void startupFileTextfield_mouseClicked() { - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF", - "PIR", "BLC", "Jalview" }, - jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + JalviewFileChooser chooser = JalviewFileChooser.forRead( + Cache.getProperty("LAST_DIRECTORY"), fileFormat); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.select_startup_file")); @@@ -808,8 -697,12 +805,12 @@@ if (value == JalviewFileChooser.APPROVE_OPTION) { - jalview.bin.Cache.applicationProperties.setProperty( - "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat()); + FileFormatI format = chooser.getSelectedFormat(); + if (format != null) + { + Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT", + format.toString()); + } startupFileTextfield.setText(chooser.getSelectedFile() .getAbsolutePath()); } @@@ -857,28 -750,21 +858,28 @@@ @Override public void newLink_actionPerformed(ActionEvent e) { - GSequenceLink link = new GSequenceLink(); boolean valid = false; while (!valid) { - if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link, + if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link, MessageManager.getString("label.new_sequence_url_link"), - JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION) + JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION) { if (link.checkValid()) { - nameLinks.addElement(link.getName()); - urlLinks.addElement(link.getURL()); - updateLinkData(); - valid = true; + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isUniqueName(link.getName())) + { + ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow( + link.getName(), link.getURL()); + valid = true; + } + else + { + link.notifyDuplicate(); + continue; + } } } else @@@ -893,40 -779,36 +894,40 @@@ { GSequenceLink link = new GSequenceLink(); - int index = linkNameList.getSelectedIndex(); + int index = linkUrlTable.getSelectedRow(); if (index == -1) { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString("label.no_link_selected"), - MessageManager.getString("label.no_link_selected"), - JvOptionPane.WARNING_MESSAGE); + // button no longer enabled if row is not selected + Cache.log.debug("Edit with no row selected in linkUrlTable"); return; } - link.setName(nameLinks.elementAt(index).toString()); - link.setURL(urlLinks.elementAt(index).toString()); + link.setName(linkUrlTable.getValueAt(index, 0).toString()); + link.setURL(linkUrlTable.getValueAt(index, 1).toString()); boolean valid = false; while (!valid) { - if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link, - + if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link, - MessageManager.getString("label.new_sequence_url_link"), + MessageManager.getString("label.edit_sequence_url_link"), - JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION) + JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION) { if (link.checkValid()) { - nameLinks.setElementAt(link.getName(), index); - urlLinks.setElementAt(link.getURL(), index); - updateLinkData(); - valid = true; + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isUniqueName(link.getName())) + { + linkUrlTable.setValueAt(link.getName(), index, 0); + linkUrlTable.setValueAt(link.getURL(), index, 1); + valid = true; + } + else + { + link.notifyDuplicate(); + continue; + } } } - else { break; @@@ -937,24 -819,26 +938,24 @@@ @Override public void deleteLink_actionPerformed(ActionEvent e) { - int index = linkNameList.getSelectedIndex(); + int index = linkUrlTable.getSelectedRow(); + int modelIndex = -1; if (index == -1) { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString("label.no_link_selected"), - MessageManager.getString("label.no_link_selected"), - JvOptionPane.WARNING_MESSAGE); + // button no longer enabled if row is not selected + Cache.log.debug("Delete with no row selected in linkUrlTable"); return; } - nameLinks.removeElementAt(index); - urlLinks.removeElementAt(index); - updateLinkData(); - } + else + { + modelIndex = linkUrlTable.convertRowIndexToModel(index); + } - void updateLinkData() - { - linkNameList.setListData(nameLinks); - linkURLList.setListData(urlLinks); + // make sure we use the model index to delete, and not the table index + ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex); } + @Override public void defaultBrowser_mouseClicked(MouseEvent e) { @@@ -1033,10 -917,10 +1034,10 @@@ } } catch (NumberFormatException x) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager .getString("warn.user_defined_width_requirements"), MessageManager.getString("label.invalid_id_column_width"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); userIdWidth.setText(""); } } @@@ -1059,10 -943,10 +1060,10 @@@ File f = new File(chimeraPath.getText()); if (!f.canExecute()) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.invalid_chimera_path"), MessageManager.getString("label.invalid_name"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); return false; } } @@@ -1098,13 -982,13 +1099,13 @@@ if (!found) { String[] options = { "OK", "Help" }; - int showHelp = JOptionPane.showInternalOptionDialog( + int showHelp = JvOptionPane.showInternalOptionDialog( Desktop.desktop, JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.chimera_missing")), - "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, + "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE, null, options, options[0]); - if (showHelp == JOptionPane.NO_OPTION) + if (showHelp == JvOptionPane.NO_OPTION) { try { @@@ -1171,45 -1055,4 +1172,45 @@@ return name.hashCode() + code.hashCode(); } } + + private class UrlListSelectionHandler implements ListSelectionListener + { + + @Override + public void valueChanged(ListSelectionEvent e) + { + ListSelectionModel lsm = (ListSelectionModel) e.getSource(); + + int index = lsm.getMinSelectionIndex(); + if (index == -1) + { + // no selection, so disable delete/edit buttons + editLink.setEnabled(false); + deleteLink.setEnabled(false); + return; + } + int modelIndex = linkUrlTable.convertRowIndexToModel(index); + + // enable/disable edit and delete link buttons + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isRowDeletable(modelIndex)) + { + deleteLink.setEnabled(true); + } + else + { + deleteLink.setEnabled(false); + } + + if (((UrlLinkTableModel) linkUrlTable.getModel()) + .isRowEditable(modelIndex)) + { + editLink.setEnabled(true); + } + else + { + editLink.setEnabled(false); + } + } +} } diff --combined src/jalview/gui/WsPreferences.java index 632535b,165e8f2..32671d5 --- a/src/jalview/gui/WsPreferences.java +++ b/src/jalview/gui/WsPreferences.java @@@ -454,16 -454,16 +454,16 @@@ public class WsPreferences extends GWsP JTextField urltf = new JTextField(url, 40); JPanel panel = new JPanel(new BorderLayout()); JPanel pane12 = new JPanel(new BorderLayout()); - pane12.add(new JLabel(MessageManager.getString("label.url")), + pane12.add(new JLabel(MessageManager.getString("label.url:")), BorderLayout.CENTER); pane12.add(urltf, BorderLayout.EAST); panel.add(pane12, BorderLayout.NORTH); boolean valid = false; - int resp = JOptionPane.CANCEL_OPTION; + int resp = JvOptionPane.CANCEL_OPTION; while (!valid - && (resp = JOptionPane.showInternalConfirmDialog( + && (resp = JvOptionPane.showInternalConfirmDialog( Desktop.desktop, panel, title, - JOptionPane.OK_CANCEL_OPTION)) == JOptionPane.OK_OPTION) + JvOptionPane.OK_CANCEL_OPTION)) == JvOptionPane.OK_OPTION) { try { @@@ -480,18 -480,18 +480,18 @@@ } catch (Exception e) { valid = false; - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.invalid_url")); } } - if (valid && resp == JOptionPane.OK_OPTION) + if (valid && resp == JvOptionPane.OK_OPTION) { - int validate = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + int validate = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, MessageManager.getString("info.validate_jabaws_server"), MessageManager.getString("label.test_server"), - JOptionPane.YES_NO_OPTION); + JvOptionPane.YES_NO_OPTION); - if (validate == JOptionPane.OK_OPTION) + if (validate == JvOptionPane.OK_OPTION) { if (Jws2Discoverer.testServiceUrl(foo)) { @@@ -499,22 -499,22 +499,22 @@@ } else { - int opt = JOptionPane + int opt = JvOptionPane .showInternalOptionDialog( Desktop.desktop, "The Server '" + foo.toString() + "' failed validation,\ndo you want to add it anyway? ", "Server Validation Failed", - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE, null, null, null); - if (opt == JOptionPane.YES_OPTION) + JvOptionPane.YES_NO_OPTION, + JvOptionPane.INFORMATION_MESSAGE, null, null, null); + if (opt == JvOptionPane.YES_OPTION) { return foo.toString(); } else { - JOptionPane + JvOptionPane .showInternalMessageDialog( Desktop.desktop, MessageManager @@@ -574,7 -574,6 +574,7 @@@ new Thread(new Runnable() { + @Override public void run() { // force a refresh. @@@ -600,7 -599,6 +600,7 @@@ new Thread(new Runnable() { + @Override public void run() { progressBar.setVisible(true); @@@ -626,7 -624,6 +626,7 @@@ new Thread(new Runnable() { + @Override public void run() { long ct = System.currentTimeMillis(); @@@ -684,7 -681,6 +684,7 @@@ new Thread(new Runnable() { + @Override public void run() { updateWsMenuConfig(false); diff --combined src/jalview/jbgui/GSequenceLink.java index 93b7935,dbce5f3..ab3ea2c --- a/src/jalview/jbgui/GSequenceLink.java +++ b/src/jalview/jbgui/GSequenceLink.java @@@ -20,6 -20,7 +20,7 @@@ */ package jalview.jbgui; + import jalview.gui.JvOptionPane; import jalview.gui.JvSwingUtils; import jalview.util.MessageManager; import jalview.util.UrlLink; @@@ -28,49 -29,19 +29,48 @@@ import java.awt.Font import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.Panel; import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.BorderFactory; +import javax.swing.JButton; import javax.swing.JLabel; - import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants; -public class GSequenceLink extends Panel +public class GSequenceLink extends JPanel { + + JTextField nameTB = new JTextField(); + + JTextField urlTB = new JTextField(); + + JButton insertSeq = new JButton(); + + JButton insertDBAcc = new JButton(); + + JLabel insert = new JLabel(); + + JLabel jLabel1 = new JLabel(); + + JLabel jLabel2 = new JLabel(); + + JLabel jLabel3 = new JLabel(); + + JLabel jLabel4 = new JLabel(); + + JLabel jLabel5 = new JLabel(); + + JLabel jLabel6 = new JLabel(); + + JPanel jPanel1 = new JPanel(); + + GridBagLayout gridBagLayout1 = new GridBagLayout(); + public GSequenceLink() { try @@@ -106,53 -77,23 +106,53 @@@ urlTB_keyTyped(e); } }); + + insertSeq.setLocation(77, 75); + insertSeq.setSize(141, 24); + insertSeq.setText(MessageManager.getString("action.seq_id")); + insertSeq.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + insertSeq_action(e); + } + }); + + insertDBAcc.setLocation(210, 75); + insertDBAcc.setSize(141, 24); + insertDBAcc.setText(MessageManager.getString("action.db_acc")); + insertDBAcc.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + insertDBAcc_action(e); + } + }); + + insert.setText(MessageManager.getString("label.insert")); + insert.setFont(JvSwingUtils.getLabelFont()); + insert.setHorizontalAlignment(SwingConstants.RIGHT); + insert.setBounds(17, 78, 58, 16); + jLabel1.setFont(JvSwingUtils.getLabelFont()); jLabel1.setHorizontalAlignment(SwingConstants.TRAILING); jLabel1.setText(MessageManager.getString("label.link_name")); jLabel1.setBounds(new Rectangle(4, 10, 71, 24)); jLabel2.setFont(JvSwingUtils.getLabelFont()); jLabel2.setHorizontalAlignment(SwingConstants.TRAILING); - jLabel2.setText(MessageManager.getString("label.url")); + jLabel2.setText(MessageManager.getString("label.url:")); jLabel2.setBounds(new Rectangle(17, 37, 54, 27)); jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11)); jLabel3.setText(MessageManager.getString("label.use_sequence_id_1")); - jLabel3.setBounds(new Rectangle(21, 72, 351, 15)); + jLabel3.setBounds(new Rectangle(21, 102, 351, 15)); jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11)); jLabel4.setText(MessageManager.getString("label.use_sequence_id_2")); - jLabel4.setBounds(new Rectangle(21, 88, 351, 15)); + jLabel4.setBounds(new Rectangle(21, 118, 351, 15)); jLabel5.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11)); jLabel5.setText(MessageManager.getString("label.use_sequence_id_3")); - jLabel5.setBounds(new Rectangle(21, 106, 351, 15)); + jLabel5.setBounds(new Rectangle(21, 136, 351, 15)); String lastLabel = MessageManager.getString("label.use_sequence_id_4"); if (lastLabel.length() > 0) @@@ -160,7 -101,7 +160,7 @@@ // e.g. Spanish version has longer text jLabel6.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11)); jLabel6.setText(lastLabel); - jLabel6.setBounds(new Rectangle(21, 122, 351, 15)); + jLabel6.setBounds(new Rectangle(21, 152, 351, 15)); } jPanel1.setBorder(BorderFactory.createEtchedBorder()); @@@ -168,19 -109,16 +168,19 @@@ jPanel1.add(jLabel1); jPanel1.add(nameTB); jPanel1.add(urlTB); + jPanel1.add(insertSeq); + jPanel1.add(insertDBAcc); + jPanel1.add(insert); jPanel1.add(jLabel2); jPanel1.add(jLabel3); jPanel1.add(jLabel4); jPanel1.add(jLabel5); - int height = 130; + int height = 160; if (lastLabel.length() > 0) { jPanel1.add(jLabel6); - height = 146; + height = 176; } this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, @@@ -218,20 -156,32 +218,20 @@@ return true; } - JOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop, + JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop, MessageManager.getString("warn.url_must_contain"), MessageManager.getString("label.invalid_url"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); return false; } - JTextField nameTB = new JTextField(); - - JTextField urlTB = new JTextField(); - - JLabel jLabel1 = new JLabel(); - - JLabel jLabel2 = new JLabel(); - - JLabel jLabel3 = new JLabel(); - - JLabel jLabel4 = new JLabel(); - - JLabel jLabel5 = new JLabel(); - - JLabel jLabel6 = new JLabel(); - - JPanel jPanel1 = new JPanel(); - - GridBagLayout gridBagLayout1 = new GridBagLayout(); + public void notifyDuplicate() + { - JOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop, ++ JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop, + MessageManager.getString("warn.name_cannot_be_duplicate"), + MessageManager.getString("label.invalid_name"), - JOptionPane.WARNING_MESSAGE); ++ JvOptionPane.WARNING_MESSAGE); + } public void nameTB_keyTyped(KeyEvent e) { @@@ -250,23 -200,4 +250,23 @@@ // } } + + public void insertSeq_action(ActionEvent e) + { + insertIntoUrl(insertSeq.getText()); + } + + public void insertDBAcc_action(ActionEvent e) + { + insertIntoUrl(insertDBAcc.getText()); + } + + private void insertIntoUrl(String insertion) + { + int pos = urlTB.getCaretPosition(); + String text = urlTB.getText(); + String newText = text.substring(0, pos) + insertion + + text.substring(pos); + urlTB.setText(newText); + } }