X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=0b65c1bcc126c4ae8af0123445183f709e5ac537;hb=18a91cf8bf71500b0bfa020c8348227cce2fc279;hp=8dbe5e21794ecb65986487a0d96c346e6c32c429;hpb=37de9310bec3501cbc6381e0c3dcb282fcaad812;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 8dbe5e2..0b65c1b 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -20,10 +20,16 @@ */ 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; @@ -50,7 +56,6 @@ 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 ext.edu.ucsf.rbvi.strucviz2.StructureManager; @@ -110,10 +115,7 @@ public class Preferences extends GPreferences public static List groupURLLinks; static { - String string = Cache - .getDefault( - "SEQUENCE_LINKS", - "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$"); + String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING); sequenceURLLinks = new Vector(); try @@ -124,7 +126,11 @@ public class Preferences extends GPreferences String name = st.nextToken(); String url = st.nextToken(); // check for '|' within a regex - int rxstart = url.indexOf("$SEQUENCE_ID$"); + int rxstart = url.indexOf("$" + DB_ACCESSION + "$"); + if (rxstart == -1) + { + rxstart = url.indexOf("$" + SEQUENCE_ID + "$"); + } while (rxstart == -1 && url.indexOf("/=$") == -1) { url = url + "|" + st.nextToken(); @@ -137,14 +143,10 @@ public class Preferences extends GPreferences } { // upgrade old SRS link - int srsPos = sequenceURLLinks - .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry"); + int srsPos = sequenceURLLinks.indexOf(SRS_STRING); if (srsPos > -1) { - sequenceURLLinks - .setElementAt( - "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$", - srsPos); + sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos); } } @@ -565,6 +567,7 @@ public class Preferences extends GPreferences else { Cache.applicationProperties.remove("SEQUENCE_LINKS"); + sequenceURLLinks.clear(); } Cache.applicationProperties.setProperty("USE_PROXY", @@ -683,12 +686,9 @@ public class Preferences extends GPreferences @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")); @@ -697,8 +697,12 @@ public class Preferences extends GPreferences 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()); } @@ -751,9 +755,9 @@ public class Preferences extends GPreferences 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()) { @@ -778,10 +782,10 @@ public class Preferences extends GPreferences int index = linkNameList.getSelectedIndex(); if (index == -1) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.no_link_selected"), MessageManager.getString("label.no_link_selected"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); return; } @@ -792,9 +796,9 @@ public class Preferences extends GPreferences 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()) { @@ -818,10 +822,10 @@ public class Preferences extends GPreferences int index = linkNameList.getSelectedIndex(); if (index == -1) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.no_link_selected"), MessageManager.getString("label.no_link_selected"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); return; } nameLinks.removeElementAt(index); @@ -913,10 +917,10 @@ public class Preferences extends GPreferences } } 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(""); } } @@ -939,10 +943,10 @@ public class Preferences extends GPreferences 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; } } @@ -978,13 +982,13 @@ public class Preferences extends GPreferences 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 {