JAL-3203 Overview show hidden default false also in Preferences
[jalview.git] / src / jalview / gui / Preferences.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.bin.Cache;
25 import jalview.gui.Help.HelpId;
26 import jalview.gui.StructureViewer.ViewerType;
27 import jalview.io.BackupFiles;
28 import jalview.io.FileFormatI;
29 import jalview.io.JalviewFileChooser;
30 import jalview.io.JalviewFileView;
31 import jalview.jbgui.GPreferences;
32 import jalview.jbgui.GSequenceLink;
33 import jalview.schemes.ColourSchemeI;
34 import jalview.schemes.ColourSchemes;
35 import jalview.schemes.ResidueColourScheme;
36 import jalview.urls.UrlLinkTableModel;
37 import jalview.urls.api.UrlProviderFactoryI;
38 import jalview.urls.api.UrlProviderI;
39 import jalview.urls.desktop.DesktopUrlProviderFactory;
40 import jalview.util.MessageManager;
41 import jalview.util.Platform;
42 import jalview.util.UrlConstants;
43 import jalview.ws.sifts.SiftsSettings;
44
45 import java.awt.BorderLayout;
46 import java.awt.Color;
47 import java.awt.Component;
48 import java.awt.Dimension;
49 import java.awt.Font;
50 import java.awt.event.ActionEvent;
51 import java.awt.event.ActionListener;
52 import java.awt.event.MouseEvent;
53 import java.io.File;
54 import java.util.ArrayList;
55 import java.util.List;
56
57 import javax.help.HelpSetException;
58 import javax.swing.JColorChooser;
59 import javax.swing.JFileChooser;
60 import javax.swing.JInternalFrame;
61 import javax.swing.JPanel;
62 import javax.swing.ListSelectionModel;
63 import javax.swing.RowFilter;
64 import javax.swing.RowSorter;
65 import javax.swing.SortOrder;
66 import javax.swing.event.DocumentEvent;
67 import javax.swing.event.DocumentListener;
68 import javax.swing.event.ListSelectionEvent;
69 import javax.swing.event.ListSelectionListener;
70 import javax.swing.table.TableCellRenderer;
71 import javax.swing.table.TableColumn;
72 import javax.swing.table.TableModel;
73 import javax.swing.table.TableRowSorter;
74
75 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
76
77 /**
78  * DOCUMENT ME!
79  * 
80  * @author $author$
81  * @version $Revision$
82  */
83 public class Preferences extends GPreferences
84 {
85   public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
86
87   public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
88
89   public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
90
91   public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
92
93   public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
94
95   public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
96
97   public static final String ADD_SS_ANN = "ADD_SS_ANN";
98
99   public static final String USE_RNAVIEW = "USE_RNAVIEW";
100
101   public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
102
103   public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
104
105   public static final String CHIMERA_PATH = "CHIMERA_PATH";
106
107   public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
108
109   public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
110
111   public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
112
113   public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
114
115   public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
116
117   public static final String GAP_COLOUR = "GAP_COLOUR";
118
119   public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
120
121   private static final int MIN_FONT_SIZE = 1;
122
123   private static final int MAX_FONT_SIZE = 30;
124
125   /**
126    * Holds name and link separated with | character. Sequence ID must be
127    * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
128    */
129   public static UrlProviderI sequenceUrlLinks;
130
131   public static UrlLinkTableModel dataModel;
132
133   /**
134    * Holds name and link separated with | character. Sequence IDS and Sequences
135    * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
136    * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
137    * for first and second token specified after a pipe character at end |,|.
138    * (TODO: proper escape for using | to separate ids or sequences
139    */
140
141   public static List<String> groupURLLinks;
142   static
143   {
144     // get links selected to be in the menu (SEQUENCE_LINKS)
145     // and links entered by the user but not selected (STORED_LINKS)
146     String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
147     String notInMenuString = Cache.getDefault("STORED_LINKS", "");
148     String defaultUrl = Cache.getDefault("DEFAULT_URL",
149             UrlConstants.DEFAULT_LABEL);
150
151     // if both links lists are empty, add the DEFAULT_URL link
152     // otherwise we assume the default link is in one of the lists
153     if (inMenuString.isEmpty() && notInMenuString.isEmpty())
154     {
155       inMenuString = UrlConstants.DEFAULT_STRING;
156     }
157     UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
158             inMenuString, notInMenuString);
159     sequenceUrlLinks = factory.createUrlProvider();
160     dataModel = new UrlLinkTableModel(sequenceUrlLinks);
161
162     /**
163      * TODO: reformulate groupURL encoding so two or more can be stored in the
164      * .properties file as '|' separated strings
165      */
166
167     groupURLLinks = new ArrayList<>();
168   }
169
170   JInternalFrame frame;
171
172   private WsPreferences wsPrefs;
173
174   private OptionsParam promptEachTimeOpt = new OptionsParam(
175           MessageManager.getString("label.prompt_each_time"),
176           "Prompt each time");
177
178   private OptionsParam lineArtOpt = new OptionsParam(
179           MessageManager.getString("label.lineart"), "Lineart");
180
181   private OptionsParam textOpt = new OptionsParam(
182           MessageManager.getString("action.text"), "Text");
183
184   /**
185    * Creates a new Preferences object.
186    */
187   public Preferences()
188   {
189     super();
190     frame = new JInternalFrame();
191     frame.setContentPane(this);
192     wsPrefs = new WsPreferences();
193     wsTab.add(wsPrefs, BorderLayout.CENTER);
194     int width = 500, height = 450;
195     new jalview.util.Platform();
196     if (Platform.isAMac())
197     {
198       width = 570;
199       height = 480;
200     }
201
202     Desktop.addInternalFrame(frame,
203             MessageManager.getString("label.preferences"), width, height);
204     frame.setMinimumSize(new Dimension(width, height));
205
206     /*
207      * Set Visual tab defaults
208      */
209     seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
210     rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
211     fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
212     annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
213
214     conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
215     quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
216     identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
217     openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
218     showUnconserved
219             .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
220     showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
221     showGroupConsensus
222             .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
223     showGroupConservation.setSelected(
224             Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
225     showConsensHistogram.setSelected(
226             Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
227     showConsensLogo
228             .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
229     showNpTooltip
230             .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
231     showDbRefTooltip
232             .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
233
234     String[] fonts = java.awt.GraphicsEnvironment
235             .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
236     for (int i = 0; i < fonts.length; i++)
237     {
238       fontNameCB.addItem(fonts[i]);
239     }
240
241     for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
242     {
243       fontSizeCB.addItem(i + "");
244     }
245
246     fontStyleCB.addItem("plain");
247     fontStyleCB.addItem("bold");
248     fontStyleCB.addItem("italic");
249
250     fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
251     fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
252     fontStyleCB.setSelectedItem(
253             Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
254
255     smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
256     scaleProteinToCdna
257             .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
258
259     idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
260
261     wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
262
263     gapSymbolCB.addItem("-");
264     gapSymbolCB.addItem(".");
265
266     gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
267
268     sortby.addItem("No sort");
269     sortby.addItem("Id");
270     sortby.addItem("Pairwise Identity");
271     sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
272
273     sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
274     sortAnnBy
275             .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
276     sortAnnBy
277             .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
278     SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
279             .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
280                     SequenceAnnotationOrder.NONE.name()));
281     sortAnnBy.setSelectedItem(savedSort.toString());
282
283     sortAutocalc.addItem("Autocalculated first");
284     sortAutocalc.addItem("Autocalculated last");
285     final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
286     sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
287             : sortAutocalc.getItemAt(1));
288     startupCheckbox
289             .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
290     startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
291             Cache.getDefault("www.jalview.org", "http://www.jalview.org")
292                     + "/examples/exampleFile_2_3.jar"));
293
294     /*
295      * Set Colours tab defaults
296      */
297     protColour.addItem(ResidueColourScheme.NONE);
298     nucColour.addItem(ResidueColourScheme.NONE);
299     for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
300     {
301       String name = cs.getSchemeName();
302       protColour.addItem(name);
303       nucColour.addItem(name);
304     }
305     String oldProp = Cache.getDefault(DEFAULT_COLOUR,
306             ResidueColourScheme.NONE);
307     String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
308     protColour.setSelectedItem(newProp != null ? newProp : oldProp);
309     newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
310     nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
311     minColour.setBackground(
312             Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
313     maxColour.setBackground(
314             Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
315
316     /*
317      * Set overview panel defaults
318      */
319     gapColour.setBackground(
320             Cache.getDefaultColour(GAP_COLOUR,
321                     jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
322     hiddenColour.setBackground(
323             Cache.getDefaultColour(HIDDEN_COLOUR,
324                     jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
325     useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
326     gapLabel.setEnabled(!useLegacyGap.isSelected());
327     gapColour.setEnabled(!useLegacyGap.isSelected());
328     showHiddenAtStart
329             .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
330
331     /*
332      * Set Structure tab defaults.
333      */
334     final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
335     structFromPdb.setSelected(structSelected);
336     useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
337     useRnaView.setEnabled(structSelected);
338     addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
339     addSecondaryStructure.setEnabled(structSelected);
340     addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
341     addTempFactor.setEnabled(structSelected);
342     structViewer.setSelectedItem(
343             Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
344     chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
345     chimeraPath.addActionListener(new ActionListener()
346     {
347       @Override
348       public void actionPerformed(ActionEvent e)
349       {
350         validateChimeraPath();
351       }
352     });
353
354     if (Cache.getDefault("MAP_WITH_SIFTS", false))
355     {
356       siftsMapping.setSelected(true);
357     }
358     else
359     {
360       nwMapping.setSelected(true);
361     }
362
363     SiftsSettings
364             .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
365
366     /*
367      * Set Connections tab defaults
368      */
369
370     // set up sorting
371     linkUrlTable.setModel(dataModel);
372     final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
373             linkUrlTable.getModel());
374     linkUrlTable.setRowSorter(sorter);
375     List<RowSorter.SortKey> sortKeys = new ArrayList<>();
376
377     UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
378     sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
379             SortOrder.DESCENDING));
380     sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
381             SortOrder.DESCENDING));
382     sortKeys.add(
383             new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
384
385     sorter.setSortKeys(sortKeys);
386     sorter.sort();
387
388     // set up filtering
389     ActionListener onReset;
390     onReset = new ActionListener()
391     {
392       @Override
393       public void actionPerformed(ActionEvent e)
394       {
395         filterTB.setText("");
396         sorter.setRowFilter(RowFilter.regexFilter(""));
397       }
398
399     };
400     doReset.addActionListener(onReset);
401
402     // filter to display only custom urls
403     final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
404     {
405       @Override
406       public boolean include(
407               Entry<? extends TableModel, ? extends Object> entry)
408       {
409         return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
410       }
411     };
412
413     final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
414             linkUrlTable.getModel());
415     customSorter.setRowFilter(customUrlFilter);
416
417     ActionListener onCustomOnly;
418     onCustomOnly = new ActionListener()
419     {
420       @Override
421       public void actionPerformed(ActionEvent e)
422       {
423         filterTB.setText("");
424         sorter.setRowFilter(customUrlFilter);
425       }
426     };
427     userOnly.addActionListener(onCustomOnly);
428
429     filterTB.getDocument().addDocumentListener(new DocumentListener()
430     {
431       String caseInsensitiveFlag = "(?i)";
432
433       @Override
434       public void changedUpdate(DocumentEvent e)
435       {
436         sorter.setRowFilter(RowFilter
437                 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
438       }
439
440       @Override
441       public void removeUpdate(DocumentEvent e)
442       {
443         sorter.setRowFilter(RowFilter
444                 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
445       }
446
447       @Override
448       public void insertUpdate(DocumentEvent e)
449       {
450         sorter.setRowFilter(RowFilter
451                 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
452       }
453     });
454
455     // set up list selection functionality
456     linkUrlTable.getSelectionModel()
457             .addListSelectionListener(new UrlListSelectionHandler());
458
459     // set up radio buttons
460     int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
461             .getPrimaryColumn();
462     String onClickName = linkUrlTable.getColumnName(onClickCol);
463     linkUrlTable.getColumn(onClickName)
464             .setCellRenderer(new RadioButtonRenderer());
465     linkUrlTable.getColumn(onClickName)
466             .setCellEditor(new RadioButtonEditor());
467
468     // get boolean columns and resize those to min possible
469     for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
470     {
471       if (linkUrlTable.getModel().getColumnClass(column)
472               .equals(Boolean.class))
473       {
474         TableColumn tableColumn = linkUrlTable.getColumnModel()
475                 .getColumn(column);
476         int preferredWidth = tableColumn.getMinWidth();
477
478         TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
479                 column);
480         Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
481         int cwidth = c.getPreferredSize().width
482                 + linkUrlTable.getIntercellSpacing().width;
483         preferredWidth = Math.max(preferredWidth, cwidth);
484
485         tableColumn.setPreferredWidth(preferredWidth);
486       }
487     }
488
489     useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
490     useProxy_actionPerformed(); // make sure useProxy is correctly initialised
491     proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
492     proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
493
494     defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
495
496     usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
497     // note antisense here: default is true
498     questionnaire
499             .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
500     versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
501
502     /*
503      * Set Output tab defaults
504      */
505     epsRendering.addItem(promptEachTimeOpt);
506     epsRendering.addItem(lineArtOpt);
507     epsRendering.addItem(textOpt);
508     String defaultEPS = Cache.getDefault("EPS_RENDERING",
509             "Prompt each time");
510     if (defaultEPS.equalsIgnoreCase("Text"))
511     {
512       epsRendering.setSelectedItem(textOpt);
513     }
514     else if (defaultEPS.equalsIgnoreCase("Lineart"))
515     {
516       epsRendering.setSelectedItem(lineArtOpt);
517     }
518     else
519     {
520       epsRendering.setSelectedItem(promptEachTimeOpt);
521     }
522     autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
523     userIdWidth.setEnabled(!autoIdWidth.isSelected());
524     userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
525     Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
526     userIdWidth.setText(wi == null ? "" : wi.toString());
527     // TODO: refactor to use common enum via FormatAdapter and allow extension
528     // for new flat file formats
529     blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
530     clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
531     fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
532     msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
533     pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
534     pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
535     pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
536     modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
537     embbedBioJSON
538             .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
539
540     /*
541      * Set Editing tab defaults
542      */
543     autoCalculateConsCheck
544             .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
545     padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
546     sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
547
548     annotations_actionPerformed(null); // update the display of the annotation
549                                        // settings
550     
551     
552     /*
553      * Set Backups tab defaults
554      */
555     loadLastSavedBackupsOptions();
556   }
557
558   /**
559    * Save user selections on the Preferences tabs to the Cache and write out to
560    * file.
561    * 
562    * @param e
563    */
564   @Override
565   public void ok_actionPerformed(ActionEvent e)
566   {
567     if (!validateSettings())
568     {
569       return;
570     }
571
572     /*
573      * Save Visual settings
574      */
575     Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
576             Boolean.toString(seqLimit.isSelected()));
577     Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
578             Boolean.toString(rightAlign.isSelected()));
579     Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
580             Boolean.toString(fullScreen.isSelected()));
581     Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
582             Boolean.toString(openoverv.isSelected()));
583     Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
584             Boolean.toString(annotations.isSelected()));
585     Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
586             Boolean.toString(conservation.isSelected()));
587     Cache.applicationProperties.setProperty("SHOW_QUALITY",
588             Boolean.toString(quality.isSelected()));
589     Cache.applicationProperties.setProperty("SHOW_IDENTITY",
590             Boolean.toString(identity.isSelected()));
591
592     Cache.applicationProperties.setProperty("GAP_SYMBOL",
593             gapSymbolCB.getSelectedItem().toString());
594
595     Cache.applicationProperties.setProperty("FONT_NAME",
596             fontNameCB.getSelectedItem().toString());
597     Cache.applicationProperties.setProperty("FONT_STYLE",
598             fontStyleCB.getSelectedItem().toString());
599     Cache.applicationProperties.setProperty("FONT_SIZE",
600             fontSizeCB.getSelectedItem().toString());
601
602     Cache.applicationProperties.setProperty("ID_ITALICS",
603             Boolean.toString(idItalics.isSelected()));
604     Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
605             Boolean.toString(showUnconserved.isSelected()));
606     Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
607             Boolean.toString(showOccupancy.isSelected()));
608     Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
609             Boolean.toString(showGroupConsensus.isSelected()));
610     Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
611             Boolean.toString(showGroupConservation.isSelected()));
612     Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
613             Boolean.toString(showConsensHistogram.isSelected()));
614     Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
615             Boolean.toString(showConsensLogo.isSelected()));
616     Cache.applicationProperties.setProperty("ANTI_ALIAS",
617             Boolean.toString(smoothFont.isSelected()));
618     Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
619             Boolean.toString(scaleProteinToCdna.isSelected()));
620     Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
621             Boolean.toString(showNpTooltip.isSelected()));
622     Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
623             Boolean.toString(showDbRefTooltip.isSelected()));
624
625     Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
626             Boolean.toString(wrap.isSelected()));
627
628     Cache.applicationProperties.setProperty("STARTUP_FILE",
629             startupFileTextfield.getText());
630     Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
631             Boolean.toString(startupCheckbox.isSelected()));
632
633     Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
634             sortby.getSelectedItem().toString());
635
636     // convert description of sort order to enum name for save
637     SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
638             .forDescription(sortAnnBy.getSelectedItem().toString());
639     if (annSortOrder != null)
640     {
641       Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
642               annSortOrder.name());
643     }
644
645     final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
646     Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
647             Boolean.valueOf(showAutocalcFirst).toString());
648
649     /*
650      * Save Colours settings
651      */
652     Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
653             protColour.getSelectedItem().toString());
654     Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
655             nucColour.getSelectedItem().toString());
656     Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
657             minColour.getBackground());
658     Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
659             maxColour.getBackground());
660
661     /*
662      * Save Overview settings
663      */
664     Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
665     Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
666     Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
667             Boolean.toString(useLegacyGap.isSelected()));
668     Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
669             Boolean.toString(showHiddenAtStart.isSelected()));
670
671     /*
672      * Save Structure settings
673      */
674     Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
675             Boolean.toString(addTempFactor.isSelected()));
676     Cache.applicationProperties.setProperty(ADD_SS_ANN,
677             Boolean.toString(addSecondaryStructure.isSelected()));
678     Cache.applicationProperties.setProperty(USE_RNAVIEW,
679             Boolean.toString(useRnaView.isSelected()));
680     Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
681             Boolean.toString(structFromPdb.isSelected()));
682     Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
683             structViewer.getSelectedItem().toString());
684     Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
685     Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
686             Boolean.toString(siftsMapping.isSelected()));
687     SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
688
689     /*
690      * Save Output settings
691      */
692     Cache.applicationProperties.setProperty("EPS_RENDERING",
693             ((OptionsParam) epsRendering.getSelectedItem()).getCode());
694
695     /*
696      * Save Connections settings
697      */
698     Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
699
700     jalview.util.BrowserLauncher.resetBrowser();
701
702     // save user-defined and selected links
703     String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
704     if (menuLinks.isEmpty())
705     {
706       Cache.applicationProperties.remove("SEQUENCE_LINKS");
707     }
708     else
709     {
710       Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
711               menuLinks.toString());
712     }
713
714     String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
715     if (nonMenuLinks.isEmpty())
716     {
717       Cache.applicationProperties.remove("STORED_LINKS");
718     }
719     else
720     {
721       Cache.applicationProperties.setProperty("STORED_LINKS",
722               nonMenuLinks.toString());
723     }
724
725     Cache.applicationProperties.setProperty("DEFAULT_URL",
726             sequenceUrlLinks.getPrimaryUrlId());
727
728     Cache.applicationProperties.setProperty("USE_PROXY",
729             Boolean.toString(useProxy.isSelected()));
730
731     Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
732
733     Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
734
735     if (useProxy.isSelected())
736     {
737       System.setProperty("http.proxyHost", proxyServerTB.getText());
738       System.setProperty("http.proxyPort", proxyPortTB.getText());
739     }
740     else
741     {
742       System.setProperty("http.proxyHost", "");
743       System.setProperty("http.proxyPort", "");
744     }
745     Cache.setProperty("VERSION_CHECK",
746             Boolean.toString(versioncheck.isSelected()));
747     if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
748     {
749       // default is false - we only set this if the user has actively agreed
750       Cache.setProperty("USAGESTATS",
751               Boolean.toString(usagestats.isSelected()));
752     }
753     if (!questionnaire.isSelected())
754     {
755       Cache.setProperty("NOQUESTIONNAIRES", "true");
756     }
757     else
758     {
759       // special - made easy to edit a property file to disable questionnaires
760       // by just adding the given line
761       Cache.removeProperty("NOQUESTIONNAIRES");
762     }
763
764     /*
765      * Save Output settings
766      */
767     Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
768             Boolean.toString(blcjv.isSelected()));
769     Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
770             Boolean.toString(clustaljv.isSelected()));
771     Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
772             Boolean.toString(fastajv.isSelected()));
773     Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
774             Boolean.toString(msfjv.isSelected()));
775     Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
776             Boolean.toString(pfamjv.isSelected()));
777     Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
778             Boolean.toString(pileupjv.isSelected()));
779     Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
780             Boolean.toString(pirjv.isSelected()));
781     Cache.applicationProperties.setProperty("PIR_MODELLER",
782             Boolean.toString(modellerOutput.isSelected()));
783     Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
784             Boolean.toString(embbedBioJSON.isSelected()));
785     jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
786
787     Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
788             Boolean.toString(autoIdWidth.isSelected()));
789     userIdWidth_actionPerformed();
790     Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
791             userIdWidth.getText());
792
793     /*
794      * Save Editing settings
795      */
796     Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
797             Boolean.toString(autoCalculateConsCheck.isSelected()));
798     Cache.applicationProperties.setProperty("SORT_BY_TREE",
799             Boolean.toString(sortByTree.isSelected()));
800     Cache.applicationProperties.setProperty("PAD_GAPS",
801             Boolean.toString(padGaps.isSelected()));
802
803     wsPrefs.updateAndRefreshWsMenuConfig(false);
804
805     /*
806      * Save Backups settings
807      */
808     Cache.applicationProperties.setProperty(BackupFiles.CONFIRM_DELETE_OLD,
809             Boolean.toString(backupfilesConfirmDelete.isSelected()));
810     Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
811             Boolean.toString(enableBackupFiles.isSelected()));
812     Cache.applicationProperties.setProperty(BackupFiles.NO_MAX,
813             Boolean.toString(backupfilesKeepAll.isSelected()));
814     Cache.applicationProperties.setProperty(BackupFiles.REVERSE_ORDER,
815             Boolean.toString(suffixReverse.isSelected()));
816     Cache.applicationProperties.setProperty(BackupFiles.SUFFIX,
817             suffixTemplate.getText());
818     Cache.applicationProperties.setProperty(BackupFiles.ROLL_MAX,
819             Integer.toString(getSpinnerInt(backupfilesRollMaxSpinner, 4)));
820     Cache.applicationProperties.setProperty(BackupFiles.SUFFIX_DIGITS,
821             Integer.toString(getSpinnerInt(suffixDigitsSpinner, 3)));
822     Cache.applicationProperties.setProperty(BackupFiles.NS+"_PRESET",
823             Integer.toString(getComboIntStringKey(backupfilesPresetsCombo)));
824
825     Cache.saveProperties();
826     Desktop.instance.doConfigureStructurePrefs();
827     try
828     {
829       frame.setClosed(true);
830     } catch (Exception ex)
831     {
832     }
833   }
834
835   /**
836    * Do any necessary validation before saving settings. Return focus to the
837    * first tab which fails validation.
838    * 
839    * @return
840    */
841   private boolean validateSettings()
842   {
843     if (!validateStructure())
844     {
845       structureTab.requestFocusInWindow();
846       return false;
847     }
848     return true;
849   }
850
851   @Override
852   protected boolean validateStructure()
853   {
854     return validateChimeraPath();
855
856   }
857
858   /**
859    * DOCUMENT ME!
860    */
861   @Override
862   public void startupFileTextfield_mouseClicked()
863   {
864     String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
865     JalviewFileChooser chooser = JalviewFileChooser
866             .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
867     chooser.setFileView(new JalviewFileView());
868     chooser.setDialogTitle(
869             MessageManager.getString("label.select_startup_file"));
870
871     int value = chooser.showOpenDialog(this);
872
873     if (value == JalviewFileChooser.APPROVE_OPTION)
874     {
875       FileFormatI format = chooser.getSelectedFormat();
876       if (format != null)
877       {
878         Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
879                 format.getName());
880       }
881       startupFileTextfield
882               .setText(chooser.getSelectedFile().getAbsolutePath());
883     }
884   }
885
886   /**
887    * DOCUMENT ME!
888    * 
889    * @param e
890    *          DOCUMENT ME!
891    */
892   @Override
893   public void cancel_actionPerformed(ActionEvent e)
894   {
895     try
896     {
897       wsPrefs.updateWsMenuConfig(true);
898       wsPrefs.refreshWs_actionPerformed(e);
899       frame.setClosed(true);
900     } catch (Exception ex)
901     {
902     }
903   }
904
905   /**
906    * DOCUMENT ME!
907    * 
908    * @param e
909    *          DOCUMENT ME!
910    */
911   @Override
912   public void annotations_actionPerformed(ActionEvent e)
913   {
914     conservation.setEnabled(annotations.isSelected());
915     quality.setEnabled(annotations.isSelected());
916     identity.setEnabled(annotations.isSelected());
917     showOccupancy.setEnabled(annotations.isSelected());
918     showGroupConsensus.setEnabled(annotations.isSelected());
919     showGroupConservation.setEnabled(annotations.isSelected());
920     showConsensHistogram.setEnabled(annotations.isSelected()
921             && (identity.isSelected() || showGroupConsensus.isSelected()));
922     showConsensLogo.setEnabled(annotations.isSelected()
923             && (identity.isSelected() || showGroupConsensus.isSelected()));
924   }
925
926   @Override
927   public void newLink_actionPerformed(ActionEvent e)
928   {
929     GSequenceLink link = new GSequenceLink();
930     boolean valid = false;
931     while (!valid)
932     {
933       if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
934               MessageManager.getString("label.new_sequence_url_link"),
935               JvOptionPane.OK_CANCEL_OPTION, -1,
936               null) == JvOptionPane.OK_OPTION)
937       {
938         if (link.checkValid())
939         {
940           if (((UrlLinkTableModel) linkUrlTable.getModel())
941                   .isUniqueName(link.getName()))
942           {
943             ((UrlLinkTableModel) linkUrlTable.getModel())
944                     .insertRow(link.getName(), link.getURL());
945             valid = true;
946           }
947           else
948           {
949             link.notifyDuplicate();
950             continue;
951           }
952         }
953       }
954       else
955       {
956         break;
957       }
958     }
959   }
960
961   @Override
962   public void editLink_actionPerformed(ActionEvent e)
963   {
964     GSequenceLink link = new GSequenceLink();
965
966     int index = linkUrlTable.getSelectedRow();
967     if (index == -1)
968     {
969       // button no longer enabled if row is not selected
970       Cache.log.debug("Edit with no row selected in linkUrlTable");
971       return;
972     }
973
974     int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
975             .getNameColumn();
976     int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
977             .getUrlColumn();
978     String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
979     link.setName(oldName);
980     link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
981
982     boolean valid = false;
983     while (!valid)
984     {
985       if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
986               MessageManager.getString("label.edit_sequence_url_link"),
987               JvOptionPane.OK_CANCEL_OPTION, -1,
988               null) == JvOptionPane.OK_OPTION)
989       {
990         if (link.checkValid())
991         {
992           if ((oldName.equals(link.getName()))
993                   || (((UrlLinkTableModel) linkUrlTable.getModel())
994                           .isUniqueName(link.getName())))
995           {
996             linkUrlTable.setValueAt(link.getName(), index, nameCol);
997             linkUrlTable.setValueAt(link.getURL(), index, urlCol);
998             valid = true;
999           }
1000           else
1001           {
1002             link.notifyDuplicate();
1003             continue;
1004           }
1005         }
1006       }
1007       else
1008       {
1009         break;
1010       }
1011     }
1012   }
1013
1014   @Override
1015   public void deleteLink_actionPerformed(ActionEvent e)
1016   {
1017     int index = linkUrlTable.getSelectedRow();
1018     int modelIndex = -1;
1019     if (index == -1)
1020     {
1021       // button no longer enabled if row is not selected
1022       Cache.log.debug("Delete with no row selected in linkUrlTable");
1023       return;
1024     }
1025     else
1026     {
1027       modelIndex = linkUrlTable.convertRowIndexToModel(index);
1028     }
1029
1030     // make sure we use the model index to delete, and not the table index
1031     ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1032   }
1033
1034   @Override
1035   public void defaultBrowser_mouseClicked(MouseEvent e)
1036   {
1037     JFileChooser chooser = new JFileChooser(".");
1038     chooser.setDialogTitle(
1039             MessageManager.getString("label.select_default_browser"));
1040
1041     int value = chooser.showOpenDialog(this);
1042
1043     if (value == JFileChooser.APPROVE_OPTION)
1044     {
1045       defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1046     }
1047
1048   }
1049
1050   /*
1051    * (non-Javadoc)
1052    * 
1053    * @see
1054    * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1055    * .ActionEvent)
1056    */
1057   @Override
1058   protected void showunconserved_actionPerformed(ActionEvent e)
1059   {
1060     // TODO Auto-generated method stub
1061     super.showunconserved_actionPerformed(e);
1062   }
1063
1064   public static List<String> getGroupURLLinks()
1065   {
1066     return groupURLLinks;
1067   }
1068
1069   @Override
1070   public void minColour_actionPerformed(JPanel panel)
1071   {
1072     Color col = JColorChooser.showDialog(this,
1073             MessageManager.getString("label.select_colour_minimum_value"),
1074             minColour.getBackground());
1075     if (col != null)
1076     {
1077       panel.setBackground(col);
1078     }
1079     panel.repaint();
1080   }
1081
1082   @Override
1083   public void maxColour_actionPerformed(JPanel panel)
1084   {
1085     Color col = JColorChooser.showDialog(this,
1086             MessageManager.getString("label.select_colour_maximum_value"),
1087             maxColour.getBackground());
1088     if (col != null)
1089     {
1090       panel.setBackground(col);
1091     }
1092     panel.repaint();
1093   }
1094
1095   @Override
1096   public void gapColour_actionPerformed(JPanel gap)
1097   {
1098     if (!useLegacyGap.isSelected())
1099     {
1100       Color col = JColorChooser.showDialog(this,
1101               MessageManager.getString("label.select_gap_colour"),
1102               gapColour.getBackground());
1103       if (col != null)
1104       {
1105         gap.setBackground(col);
1106       }
1107       gap.repaint();
1108     }
1109   }
1110
1111   @Override
1112   public void hiddenColour_actionPerformed(JPanel hidden)
1113   {
1114     Color col = JColorChooser.showDialog(this,
1115             MessageManager.getString("label.select_hidden_colour"),
1116             hiddenColour.getBackground());
1117     if (col != null)
1118     {
1119       hidden.setBackground(col);
1120     }
1121     hidden.repaint();
1122   }
1123
1124   @Override
1125   protected void useLegacyGaps_actionPerformed(ActionEvent e)
1126   {
1127     boolean enabled = useLegacyGap.isSelected();
1128     if (enabled)
1129     {
1130       gapColour.setBackground(
1131               jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1132     }
1133     else
1134     {
1135       gapColour.setBackground(
1136               jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1137     }
1138     gapColour.setEnabled(!enabled);
1139     gapLabel.setEnabled(!enabled);
1140   }
1141
1142   @Override
1143   protected void resetOvDefaults_actionPerformed(ActionEvent e)
1144   {
1145     useLegacyGap.setSelected(false);
1146     useLegacyGaps_actionPerformed(null);
1147     showHiddenAtStart.setSelected(false);
1148     hiddenColour.setBackground(
1149             jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1150   }
1151
1152   @Override
1153   protected void userIdWidth_actionPerformed()
1154   {
1155     try
1156     {
1157       String val = userIdWidth.getText().trim();
1158       if (val.length() > 0)
1159       {
1160         Integer iw = Integer.parseInt(val);
1161         if (iw.intValue() < 12)
1162         {
1163           throw new NumberFormatException();
1164         }
1165         userIdWidth.setText(iw.toString());
1166       }
1167     } catch (NumberFormatException x)
1168     {
1169       JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1170               MessageManager
1171                       .getString("warn.user_defined_width_requirements"),
1172               MessageManager.getString("label.invalid_id_column_width"),
1173               JvOptionPane.WARNING_MESSAGE);
1174       userIdWidth.setText("");
1175     }
1176   }
1177
1178   @Override
1179   protected void autoIdWidth_actionPerformed()
1180   {
1181     userIdWidth.setEnabled(!autoIdWidth.isSelected());
1182     userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1183   }
1184
1185   /**
1186    * Returns true if chimera path is to a valid executable, else show an error
1187    * dialog.
1188    */
1189   private boolean validateChimeraPath()
1190   {
1191     if (chimeraPath.getText().trim().length() > 0)
1192     {
1193       File f = new File(chimeraPath.getText());
1194       if (!f.canExecute())
1195       {
1196         JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1197                 MessageManager.getString("label.invalid_chimera_path"),
1198                 MessageManager.getString("label.invalid_name"),
1199                 JvOptionPane.ERROR_MESSAGE);
1200         return false;
1201       }
1202     }
1203     return true;
1204   }
1205
1206   /**
1207    * If Chimera is selected, check it can be found on default or user-specified
1208    * path, if not show a warning/help dialog.
1209    */
1210   @Override
1211   protected void structureViewer_actionPerformed(String selectedItem)
1212   {
1213     if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1214     {
1215       return;
1216     }
1217     boolean found = false;
1218
1219     /*
1220      * Try user-specified and standard paths for Chimera executable.
1221      */
1222     List<String> paths = StructureManager.getChimeraPaths();
1223     paths.add(0, chimeraPath.getText());
1224     for (String path : paths)
1225     {
1226       if (new File(path.trim()).canExecute())
1227       {
1228         found = true;
1229         break;
1230       }
1231     }
1232     if (!found)
1233     {
1234       String[] options = { "OK", "Help" };
1235       int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1236               JvSwingUtils.wrapTooltip(true,
1237                       MessageManager.getString("label.chimera_missing")),
1238               "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1239               null, options, options[0]);
1240       if (showHelp == JvOptionPane.NO_OPTION)
1241       {
1242         try
1243         {
1244           Help.showHelpWindow(HelpId.StructureViewer);
1245         } catch (HelpSetException e)
1246         {
1247           e.printStackTrace();
1248         }
1249       }
1250     }
1251   }
1252
1253   public class OptionsParam
1254   {
1255     private String name;
1256
1257     private String code;
1258
1259     public OptionsParam(String name, String code)
1260     {
1261       this.name = name;
1262       this.code = code;
1263     }
1264
1265     public String getName()
1266     {
1267       return name;
1268     }
1269
1270     public void setName(String name)
1271     {
1272       this.name = name;
1273     }
1274
1275     public String getCode()
1276     {
1277       return code;
1278     }
1279
1280     public void setCode(String code)
1281     {
1282       this.code = code;
1283     }
1284
1285     @Override
1286     public String toString()
1287     {
1288       return name;
1289     }
1290
1291     @Override
1292     public boolean equals(Object that)
1293     {
1294       if (!(that instanceof OptionsParam))
1295       {
1296         return false;
1297       }
1298       return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1299     }
1300
1301     @Override
1302     public int hashCode()
1303     {
1304       return name.hashCode() + code.hashCode();
1305     }
1306   }
1307
1308   private class UrlListSelectionHandler implements ListSelectionListener
1309   {
1310
1311     @Override
1312     public void valueChanged(ListSelectionEvent e)
1313     {
1314       ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1315
1316       int index = lsm.getMinSelectionIndex();
1317       if (index == -1)
1318       {
1319         // no selection, so disable delete/edit buttons
1320         editLink.setEnabled(false);
1321         deleteLink.setEnabled(false);
1322         return;
1323       }
1324       int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1325
1326       // enable/disable edit and delete link buttons
1327       if (((UrlLinkTableModel) linkUrlTable.getModel())
1328               .isRowDeletable(modelIndex))
1329       {
1330         deleteLink.setEnabled(true);
1331       }
1332       else
1333       {
1334         deleteLink.setEnabled(false);
1335       }
1336
1337       if (((UrlLinkTableModel) linkUrlTable.getModel())
1338               .isRowEditable(modelIndex))
1339       {
1340         editLink.setEnabled(true);
1341       }
1342       else
1343       {
1344         editLink.setEnabled(false);
1345       }
1346     }
1347   }
1348 }