Merge branch 'Release_2_7_Branch_hotfix_JAL-962' into develop
[jalview.git] / src / jalview / gui / Preferences.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.gui;
19
20 import java.util.*;
21
22 import java.awt.*;
23 import java.awt.event.*;
24
25 import javax.swing.*;
26
27 import jalview.bin.*;
28 import jalview.io.*;
29 import jalview.jbgui.*;
30 import jalview.schemes.*;
31 import jalview.ws.EnfinEnvision2OneWay;
32
33 /**
34  * DOCUMENT ME!
35  * 
36  * @author $author$
37  * @version $Revision$
38  */
39 public class Preferences extends GPreferences
40 {
41
42   /**
43    * Holds name and link separated with | character. Sequence ID must be
44    * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
45    */
46   public static Vector sequenceURLLinks;
47
48   /**
49    * Holds name and link separated with | character. Sequence IDS and Sequences
50    * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
51    * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
52    * for first and second token specified after a pipe character at end |,|.
53    * (TODO: proper escape for using | to separate ids or sequences
54    */
55
56   public static Vector groupURLLinks;
57   static
58   {
59     String string = Cache
60             .getDefault(
61                     "SEQUENCE_LINKS",
62                     "SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
63     sequenceURLLinks = new Vector();
64
65     try
66     {
67       StringTokenizer st = new StringTokenizer(string, "|");
68       while (st.hasMoreElements())
69       {
70         String name = st.nextToken();
71         String url = st.nextToken();
72         // check for '|' within a regex
73         int rxstart = url.indexOf("$SEQUENCE_ID$");
74         while (rxstart == -1 && url.indexOf("/=$") == -1)
75         {
76           url = url + "|" + st.nextToken();
77         }
78         sequenceURLLinks.addElement(name + "|" + url);
79       }
80     } catch (Exception ex)
81     {
82       System.out.println(ex + "\nError parsing sequence links");
83     }
84     /**
85      * TODO: reformulate groupURL encoding so two or more can be stored in the
86      * .properties file as '|' separated strings
87      */
88
89     groupURLLinks = new Vector();
90     // groupURLLinks.addElement("UNIPROT|EnVision2|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?tool=Jalview&workflow=Default&datasetName=JalviewIDs$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,");
91     // groupURLLinks.addElement("Seqs|EnVision2|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?tool=Jalview&workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([A-Za-z]+)+/=$&inputType=1|,");
92
93   }
94
95   Vector nameLinks, urlLinks;
96
97   JInternalFrame frame;
98
99   DasSourceBrowser dasSource;
100
101   private WsPreferences wsPrefs;
102
103   /**
104    * Creates a new Preferences object.
105    */
106   public Preferences()
107   {
108
109     frame = new JInternalFrame();
110     frame.setContentPane(this);
111     dasSource = new DasSourceBrowser();
112     dasPanel.add(dasSource, BorderLayout.CENTER);
113     wsPrefs = new WsPreferences();
114     wsPanel.add(wsPrefs, BorderLayout.CENTER);
115     int width = 500, height = 420;
116     if (new jalview.util.Platform().isAMac())
117     {
118       width = 570;
119       height = 460;
120     }
121
122     Desktop.addInternalFrame(frame, "Preferences", width, height);
123     frame.setMinimumSize(new Dimension(width, height));
124
125     seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
126     rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
127     fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
128     annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
129
130     conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
131     quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
132     identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
133     openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
134     showUnconserved
135             .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
136     showNpTooltip.setSelected(Cache
137             .getDefault("SHOW_NPFEATS_TOOLTIP", true));
138     showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
139             true));
140     sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
141     for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
142     {
143       colour.addItem(ColourSchemeProperty.getColourName(i));
144     }
145
146     String string = Cache.getDefault("DEFAULT_COLOUR", "None");
147
148     colour.setSelectedItem(string);
149
150     /**
151      * default min-max colours for annotation shading
152      */
153     minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
154     maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
155
156     String[] fonts = java.awt.GraphicsEnvironment
157             .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
158
159     for (int i = 0; i < fonts.length; i++)
160     {
161       fontNameCB.addItem(fonts[i]);
162     }
163
164     for (int i = 1; i < 31; i++)
165     {
166       fontSizeCB.addItem(i + "");
167     }
168
169     fontStyleCB.addItem("plain");
170     fontStyleCB.addItem("bold");
171     fontStyleCB.addItem("italic");
172
173     fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
174     fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
175     fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
176             + ""));
177
178     smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
179
180     idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
181
182     wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
183
184     gapSymbolCB.addItem("-");
185     gapSymbolCB.addItem(".");
186
187     gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
188
189     startupCheckbox
190             .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
191     startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
192             Cache.getDefault("www.jalview.org","http://www.jalview.org")+"/examples/exampleFile_2_3.jar"));
193
194     sortby.addItem("No sort");
195     sortby.addItem("Id");
196     sortby.addItem("Pairwise Identity");
197     sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
198
199     epsRendering.addItem("Prompt each time");
200     epsRendering.addItem("Lineart");
201     epsRendering.addItem("Text");
202     epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
203             "Prompt each time"));
204
205     blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
206     clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
207     fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
208     msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
209     pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
210     pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
211     pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
212
213     modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
214
215     autoCalculateConsCheck.setSelected(Cache.getDefault(
216             "AUTO_CALC_CONSENSUS", true));
217     showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
218             false));
219     showGroupConservation.setSelected(Cache.getDefault(
220             "SHOW_GROUP_CONSERVATION", false));
221     showConsensHistogram.setSelected(Cache.getDefault(
222             "SHOW_CONSENSUS_HISTOGRAM", true));
223     showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
224             false));
225
226     padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
227
228     /***************************************************************************
229      * Set up Connections
230      */
231     nameLinks = new Vector();
232     urlLinks = new Vector();
233     for (int i = 0; i < sequenceURLLinks.size(); i++)
234     {
235       String link = sequenceURLLinks.elementAt(i).toString();
236       nameLinks.addElement(link.substring(0, link.indexOf("|")));
237       urlLinks.addElement(link.substring(link.indexOf("|") + 1));
238     }
239
240     updateLinkData();
241
242     useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
243     proxyServerTB.setEnabled(useProxy.isSelected());
244     proxyPortTB.setEnabled(useProxy.isSelected());
245     proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
246     proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
247
248     defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
249
250     usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
251     questionnaire
252             .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null); // note
253                                                                          // antisense
254                                                                          // here
255     versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true)); // default
256                                                                        // is
257                                                                        // true
258     annotations_actionPerformed(null); // update the display of the annotation
259                                        // settings
260     try
261     {
262       jbInit();
263     } catch (Exception ex)
264     {
265       ex.printStackTrace();
266     }
267
268   }
269
270   /**
271    * DOCUMENT ME!
272    * 
273    * @param e
274    *          DOCUMENT ME!
275    */
276   public void ok_actionPerformed(ActionEvent e)
277   {
278
279     Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
280             Boolean.toString(seqLimit.isSelected()));
281     Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
282             Boolean.toString(rightAlign.isSelected()));
283     Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
284             Boolean.toString(fullScreen.isSelected()));
285     Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
286             Boolean.toString(openoverv.isSelected()));
287     Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
288             Boolean.toString(annotations.isSelected()));
289     Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
290             Boolean.toString(conservation.isSelected()));
291     Cache.applicationProperties.setProperty("SHOW_QUALITY",
292             Boolean.toString(quality.isSelected()));
293     Cache.applicationProperties.setProperty("SHOW_IDENTITY",
294             Boolean.toString(identity.isSelected()));
295
296     Cache.applicationProperties.setProperty("DEFAULT_COLOUR", colour
297             .getSelectedItem().toString());
298     Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
299             .getSelectedItem().toString());
300
301     Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
302             .getSelectedItem().toString());
303     Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
304             .getSelectedItem().toString());
305     Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
306             .getSelectedItem().toString());
307
308     Cache.applicationProperties.setProperty("ID_ITALICS",
309             Boolean.toString(idItalics.isSelected()));
310     Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
311             Boolean.toString(showUnconserved.isSelected()));
312     Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
313             Boolean.toString(showGroupConsensus.isSelected()));
314     Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
315             Boolean.toString(showGroupConservation.isSelected()));
316     Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
317             Boolean.toString(showConsensHistogram.isSelected()));
318     Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
319             Boolean.toString(showConsensLogo.isSelected()));
320     Cache.applicationProperties.setProperty("ANTI_ALIAS",
321             Boolean.toString(smoothFont.isSelected()));
322     Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
323             Boolean.toString(showNpTooltip.isSelected()));
324     Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
325             Boolean.toString(showDbRefTooltip.isSelected()));
326
327     Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
328             Boolean.toString(wrap.isSelected()));
329
330     Cache.applicationProperties.setProperty("STARTUP_FILE",
331             startupFileTextfield.getText());
332     Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
333             Boolean.toString(startupCheckbox.isSelected()));
334
335     Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
336             .getSelectedItem().toString());
337
338     Cache.setColourProperty("ANNOTATIONCOLOUR_MIN", minColour.getBackground());
339     Cache.setColourProperty("ANNOTATIONCOLOUR_MAX", maxColour.getBackground());
340     
341     if (epsRendering.getSelectedItem().equals("Prompt each time"))
342     {
343       Cache.applicationProperties.remove("EPS_RENDERING");
344     }
345     else
346     {
347       Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
348               .getSelectedItem().toString());
349     }
350
351     if (defaultBrowser.getText().trim().length() < 1)
352     {
353       Cache.applicationProperties.remove("DEFAULT_BROWSER");
354     }
355     else
356     {
357       Cache.applicationProperties.setProperty("DEFAULT_BROWSER",
358               defaultBrowser.getText());
359     }
360
361     jalview.util.BrowserLauncher.resetBrowser();
362
363     if (nameLinks.size() > 0)
364     {
365       StringBuffer links = new StringBuffer();
366       sequenceURLLinks = new Vector();
367       for (int i = 0; i < nameLinks.size(); i++)
368       {
369         sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
370                 + urlLinks.elementAt(i));
371         links.append(sequenceURLLinks.elementAt(i).toString());
372         links.append("|");
373       }
374       // remove last "|"
375       links.setLength(links.length() - 1);
376       Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
377               links.toString());
378     }
379     else
380     {
381       Cache.applicationProperties.remove("SEQUENCE_LINKS");
382     }
383
384     Cache.applicationProperties.setProperty("USE_PROXY",
385             Boolean.toString(useProxy.isSelected()));
386
387     if (proxyServerTB.getText().trim().length() < 1)
388     {
389       Cache.applicationProperties.remove("PROXY_SERVER");
390     }
391     else
392     {
393       Cache.applicationProperties.setProperty("PROXY_SERVER",
394               proxyServerTB.getText());
395     }
396
397     if (proxyPortTB.getText().trim().length() < 1)
398     {
399       Cache.applicationProperties.remove("PROXY_PORT");
400     }
401     else
402     {
403       Cache.applicationProperties.setProperty("PROXY_PORT",
404               proxyPortTB.getText());
405     }
406
407     if (useProxy.isSelected())
408     {
409       System.setProperty("http.proxyHost", proxyServerTB.getText());
410       System.setProperty("http.proxyPort", proxyPortTB.getText());
411     }
412     else
413     {
414       System.setProperty("http.proxyHost", "");
415       System.setProperty("http.proxyPort", "");
416     }
417     Cache.setProperty("VERSION_CHECK",
418             Boolean.toString(versioncheck.isSelected()));
419     if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
420     {
421       // default is false - we only set this if the user has actively agreed
422       Cache.setProperty("USAGESTATS",
423               Boolean.toString(usagestats.isSelected()));
424     }
425     if (!questionnaire.isSelected())
426     {
427       Cache.setProperty("NOQUESTIONNAIRES", "true");
428     }
429     else
430     {
431       // special - made easy to edit a property file to disable questionnaires
432       // by just adding the given line
433       Cache.removeProperty("NOQUESTIONNAIRES");
434     }
435     Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
436             Boolean.toString(blcjv.isSelected()));
437     Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
438             Boolean.toString(clustaljv.isSelected()));
439     Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
440             Boolean.toString(fastajv.isSelected()));
441     Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
442             Boolean.toString(msfjv.isSelected()));
443     Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
444             Boolean.toString(pfamjv.isSelected()));
445     Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
446             Boolean.toString(pileupjv.isSelected()));
447     Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
448             Boolean.toString(pirjv.isSelected()));
449     Cache.applicationProperties.setProperty("PIR_MODELLER",
450             Boolean.toString(modellerOutput.isSelected()));
451     jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
452
453     Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
454             Boolean.toString(autoCalculateConsCheck.isSelected()));
455     Cache.applicationProperties.setProperty("SORT_BY_TREE",
456             Boolean.toString(sortByTree.isSelected()));
457     Cache.applicationProperties.setProperty("PAD_GAPS",
458             Boolean.toString(padGaps.isSelected()));
459
460     dasSource.saveProperties(Cache.applicationProperties);
461     wsPrefs.updateAndRefreshWsMenuConfig(false);
462     Cache.saveProperties();
463     try
464     {
465       frame.setClosed(true);
466     } catch (Exception ex)
467     {
468     }
469   }
470
471   /**
472    * DOCUMENT ME!
473    */
474   public void startupFileTextfield_mouseClicked()
475   {
476     JalviewFileChooser chooser = new JalviewFileChooser(
477             jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
478             new String[]
479             { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
480             new String[]
481             { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
482             jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
483     chooser.setFileView(new JalviewFileView());
484     chooser.setDialogTitle("Select startup file");
485
486     int value = chooser.showOpenDialog(this);
487
488     if (value == JalviewFileChooser.APPROVE_OPTION)
489     {
490       jalview.bin.Cache.applicationProperties.setProperty(
491               "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
492       startupFileTextfield.setText(chooser.getSelectedFile()
493               .getAbsolutePath());
494     }
495   }
496
497   /**
498    * DOCUMENT ME!
499    * 
500    * @param e
501    *          DOCUMENT ME!
502    */
503   public void cancel_actionPerformed(ActionEvent e)
504   {
505     try
506     {
507       wsPrefs.updateWsMenuConfig(true);
508       wsPrefs.refreshWs_actionPerformed(e);
509       frame.setClosed(true);
510     } catch (Exception ex)
511     {
512     }
513   }
514
515   /**
516    * DOCUMENT ME!
517    * 
518    * @param e
519    *          DOCUMENT ME!
520    */
521   public void annotations_actionPerformed(ActionEvent e)
522   {
523     conservation.setEnabled(annotations.isSelected());
524     quality.setEnabled(annotations.isSelected());
525     identity.setEnabled(annotations.isSelected());
526     showGroupConsensus.setEnabled(annotations.isSelected());
527     showGroupConservation.setEnabled(annotations.isSelected());
528     showConsensHistogram.setEnabled(annotations.isSelected()
529             && (identity.isSelected() || showGroupConsensus.isSelected()));
530     showConsensLogo.setEnabled(annotations.isSelected()
531             && (identity.isSelected() || showGroupConsensus.isSelected()));
532   }
533
534   public void newLink_actionPerformed(ActionEvent e)
535   {
536
537     GSequenceLink link = new GSequenceLink();
538     boolean valid = false;
539     while (!valid)
540     {
541       if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
542               "New sequence URL link", JOptionPane.OK_CANCEL_OPTION, -1,
543               null) == JOptionPane.OK_OPTION)
544       {
545         if (link.checkValid())
546         {
547           nameLinks.addElement(link.getName());
548           urlLinks.addElement(link.getURL());
549           updateLinkData();
550           valid = true;
551         }
552       }
553       else
554       {
555         break;
556       }
557     }
558   }
559
560   public void editLink_actionPerformed(ActionEvent e)
561   {
562     GSequenceLink link = new GSequenceLink();
563
564     int index = linkNameList.getSelectedIndex();
565     if (index == -1)
566     {
567       JOptionPane.showInternalMessageDialog(Desktop.desktop,
568               "No link selected!", "No link selected",
569               JOptionPane.WARNING_MESSAGE);
570       return;
571     }
572
573     link.setName(nameLinks.elementAt(index).toString());
574     link.setURL(urlLinks.elementAt(index).toString());
575
576     boolean valid = false;
577     while (!valid)
578     {
579
580       if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
581               "New sequence URL link", JOptionPane.OK_CANCEL_OPTION, -1,
582               null) == JOptionPane.OK_OPTION)
583       {
584         if (link.checkValid())
585         {
586           nameLinks.setElementAt(link.getName(), index);
587           urlLinks.setElementAt(link.getURL(), index);
588           updateLinkData();
589           valid = true;
590         }
591       }
592
593       else
594       {
595         break;
596       }
597     }
598   }
599
600   public void deleteLink_actionPerformed(ActionEvent e)
601   {
602     int index = linkNameList.getSelectedIndex();
603     if (index == -1)
604     {
605       JOptionPane.showInternalMessageDialog(Desktop.desktop,
606               "No link selected!", "No link selected",
607               JOptionPane.WARNING_MESSAGE);
608       return;
609     }
610     nameLinks.removeElementAt(index);
611     urlLinks.removeElementAt(index);
612     updateLinkData();
613   }
614
615   void updateLinkData()
616   {
617     linkNameList.setListData(nameLinks);
618     linkURLList.setListData(urlLinks);
619   }
620
621   public void defaultBrowser_mouseClicked(MouseEvent e)
622   {
623     JFileChooser chooser = new JFileChooser(".");
624     chooser.setDialogTitle("Select default web browser");
625
626     int value = chooser.showOpenDialog(this);
627
628     if (value == JFileChooser.APPROVE_OPTION)
629     {
630       defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
631     }
632
633   }
634
635   /*
636    * (non-Javadoc)
637    * 
638    * @see
639    * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
640    * .ActionEvent)
641    */
642   protected void showunconserved_actionPerformed(ActionEvent e)
643   {
644     // TODO Auto-generated method stub
645     super.showunconserved_actionPerformed(e);
646   }
647
648   private void jbInit() throws Exception
649   {
650   }
651
652   public static Collection getGroupURLLinks()
653   {
654     return groupURLLinks;
655   }
656   public void minColour_actionPerformed()
657   {
658     Color col = JColorChooser.showDialog(this,
659             "Select Colour for Minimum Value", minColour.getBackground());
660     if (col != null)
661     {
662       minColour.setBackground(col);
663     }
664     minColour.repaint();
665   }
666
667   public void maxColour_actionPerformed()
668   {
669     Color col = JColorChooser.showDialog(this,
670             "Select Colour for Maximum Value", maxColour.getBackground());
671     if (col != null)
672     {
673       maxColour.setBackground(col);
674     }
675     maxColour.repaint();
676   }
677
678 }