JAL-3141 Change of label
[jalview.git] / src / jalview / jbgui / GPreferences.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.jbgui;
22
23 import jalview.bin.Cache;
24 import jalview.fts.core.FTSDataColumnPreferences;
25 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
26 import jalview.fts.service.pdb.PDBFTSRestClient;
27 import jalview.gui.JalviewBooleanRadioButtons;
28 import jalview.gui.JvSwingUtils;
29 import jalview.gui.StructureViewer.ViewerType;
30 import jalview.io.BackupFilenameFilter;
31 import jalview.io.BackupFiles;
32 import jalview.util.MessageManager;
33
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Component;
37 import java.awt.Dimension;
38 import java.awt.FlowLayout;
39 import java.awt.Font;
40 import java.awt.GridBagConstraints;
41 import java.awt.GridBagLayout;
42 import java.awt.GridLayout;
43 import java.awt.Insets;
44 import java.awt.Rectangle;
45 import java.awt.event.ActionEvent;
46 import java.awt.event.ActionListener;
47 import java.awt.event.FocusEvent;
48 import java.awt.event.KeyEvent;
49 import java.awt.event.KeyListener;
50 import java.awt.event.MouseAdapter;
51 import java.awt.event.MouseEvent;
52 import java.util.HashMap;
53 import java.util.Map;
54
55 import javax.swing.AbstractCellEditor;
56 import javax.swing.BorderFactory;
57 import javax.swing.ButtonGroup;
58 import javax.swing.DefaultListCellRenderer;
59 import javax.swing.JButton;
60 import javax.swing.JCheckBox;
61 import javax.swing.JComboBox;
62 import javax.swing.JFileChooser;
63 import javax.swing.JLabel;
64 import javax.swing.JList;
65 import javax.swing.JPanel;
66 import javax.swing.JRadioButton;
67 import javax.swing.JScrollPane;
68 import javax.swing.JSpinner;
69 import javax.swing.JTabbedPane;
70 import javax.swing.JTable;
71 import javax.swing.JTextArea;
72 import javax.swing.JTextField;
73 import javax.swing.ListSelectionModel;
74 import javax.swing.SpinnerModel;
75 import javax.swing.SpinnerNumberModel;
76 import javax.swing.SwingConstants;
77 import javax.swing.border.Border;
78 import javax.swing.border.EmptyBorder;
79 import javax.swing.border.EtchedBorder;
80 import javax.swing.border.TitledBorder;
81 import javax.swing.event.ChangeEvent;
82 import javax.swing.event.ChangeListener;
83 import javax.swing.table.TableCellEditor;
84 import javax.swing.table.TableCellRenderer;
85
86 /**
87  * Base class for the Preferences panel.
88  * 
89  * @author $author$
90  * @version $Revision$
91  */
92 public class GPreferences extends JPanel
93 {
94   private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
95
96   private static final Font LABEL_FONT_ITALIC = JvSwingUtils
97           .getLabelFont(false, true);
98
99   private static final Font LABEL_FONT_BOLD = JvSwingUtils
100           .getLabelFont(true, false);
101
102   /*
103    * Visual tab components
104    */
105   protected JCheckBox fullScreen = new JCheckBox();
106
107   protected JCheckBox openoverv = new JCheckBox();
108
109   protected JCheckBox seqLimit = new JCheckBox();
110
111   protected JCheckBox rightAlign = new JCheckBox();
112
113   protected JComboBox<String> fontSizeCB = new JComboBox<>();
114
115   protected JComboBox<String> fontStyleCB = new JComboBox<>();
116
117   protected JComboBox<String> fontNameCB = new JComboBox<>();
118
119   protected JCheckBox showOccupancy = new JCheckBox();
120
121   protected JCheckBox showUnconserved = new JCheckBox();
122
123   protected JCheckBox idItalics = new JCheckBox();
124
125   protected JCheckBox smoothFont = new JCheckBox();
126
127   protected JCheckBox scaleProteinToCdna = new JCheckBox();
128
129   protected JComboBox<String> gapSymbolCB = new JComboBox<>();
130
131   protected JCheckBox wrap = new JCheckBox();
132
133   protected JComboBox<String> sortby = new JComboBox<>();
134
135   protected JComboBox<String> sortAnnBy = new JComboBox<>();
136
137   protected JComboBox<String> sortAutocalc = new JComboBox<>();
138
139   protected JCheckBox startupCheckbox = new JCheckBox();
140
141   protected JTextField startupFileTextfield = new JTextField();
142
143   // below are in the 'second column'
144   protected JCheckBox annotations = new JCheckBox();
145
146   protected JCheckBox quality = new JCheckBox();
147
148   protected JCheckBox conservation = new JCheckBox();
149
150   protected JCheckBox identity = new JCheckBox();
151
152   protected JCheckBox showGroupConsensus = new JCheckBox();
153
154   protected JCheckBox showGroupConservation = new JCheckBox();
155
156   protected JCheckBox showConsensHistogram = new JCheckBox();
157
158   protected JCheckBox showConsensLogo = new JCheckBox();
159
160   protected JCheckBox showDbRefTooltip = new JCheckBox();
161
162   protected JCheckBox showNpTooltip = new JCheckBox();
163
164   /*
165    * Structure tab and components
166    */
167   protected JPanel structureTab;
168
169   protected JCheckBox structFromPdb = new JCheckBox();
170
171   protected JCheckBox useRnaView = new JCheckBox();
172
173   protected JCheckBox addSecondaryStructure = new JCheckBox();
174
175   protected JCheckBox addTempFactor = new JCheckBox();
176
177   protected JComboBox<String> structViewer = new JComboBox<>();
178
179   protected JTextField chimeraPath = new JTextField();
180
181   protected ButtonGroup mappingMethod = new ButtonGroup();
182
183   protected JRadioButton siftsMapping = new JRadioButton();
184
185   protected JRadioButton nwMapping = new JRadioButton();
186
187   /*
188    * Colours tab components
189    */
190   protected JPanel minColour = new JPanel();
191
192   protected JPanel maxColour = new JPanel();
193
194   protected JComboBox<String> protColour = new JComboBox<>();
195
196   protected JComboBox<String> nucColour = new JComboBox<>();
197
198   /*
199    * Overview tab components
200    */
201   protected JPanel gapColour = new JPanel();
202
203   protected JPanel hiddenColour = new JPanel();
204
205   protected JCheckBox useLegacyGap;
206
207   protected JCheckBox showHiddenAtStart;
208
209   protected JLabel gapLabel;
210
211   /*
212    * Connections tab components
213    */
214   protected JTable linkUrlTable = new JTable();
215
216   protected JButton editLink = new JButton();
217
218   protected JButton deleteLink = new JButton();
219
220   protected JTextField filterTB = new JTextField();
221
222   protected JButton doReset = new JButton();
223
224   protected JButton userOnly = new JButton();
225
226   protected JLabel portLabel = new JLabel();
227
228   protected JLabel serverLabel = new JLabel();
229
230   protected JTextField proxyServerTB = new JTextField();
231
232   protected JTextField proxyPortTB = new JTextField();
233
234   protected JTextField defaultBrowser = new JTextField();
235
236   protected JCheckBox useProxy = new JCheckBox();
237
238   protected JCheckBox usagestats = new JCheckBox();
239
240   protected JCheckBox questionnaire = new JCheckBox();
241
242   protected JCheckBox versioncheck = new JCheckBox();
243
244   /*
245    * Output tab components
246    */
247   protected JComboBox<Object> epsRendering = new JComboBox<>();
248
249   protected JLabel userIdWidthlabel = new JLabel();
250
251   protected JCheckBox autoIdWidth = new JCheckBox();
252
253   protected JTextField userIdWidth = new JTextField();
254
255   protected JCheckBox blcjv = new JCheckBox();
256
257   protected JCheckBox pileupjv = new JCheckBox();
258
259   protected JCheckBox clustaljv = new JCheckBox();
260
261   protected JCheckBox msfjv = new JCheckBox();
262
263   protected JCheckBox fastajv = new JCheckBox();
264
265   protected JCheckBox pfamjv = new JCheckBox();
266
267   protected JCheckBox pirjv = new JCheckBox();
268
269   protected JCheckBox modellerOutput = new JCheckBox();
270
271   protected JCheckBox embbedBioJSON = new JCheckBox();
272
273   /*
274    * Editing tab components
275    */
276   protected JCheckBox autoCalculateConsCheck = new JCheckBox();
277
278   protected JCheckBox padGaps = new JCheckBox();
279
280   protected JCheckBox sortByTree = new JCheckBox();
281
282   /*
283    * Web Services tab
284    */
285   protected JPanel wsTab = new JPanel();
286
287   /*
288    * Backups tab components
289    * a lot of these are member variables instead of local variables only so that they
290    * can be enabled/disabled easily in one go
291    */
292
293   protected JCheckBox enableBackupFiles = new JCheckBox();
294
295   protected JPanel presetsPanel = new JPanel();
296
297   protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
298
299   protected JPanel suffixPanel = new JPanel();
300
301   protected JPanel keepfilesPanel = new JPanel();
302
303   protected JPanel exampleFilesPanel = new JPanel();
304
305   protected JTextField suffixTemplate = new JTextField(null, 8);
306
307   protected JLabel suffixTemplateLabel = new JLabel();
308
309   protected JLabel suffixDigitsLabel = new JLabel();
310
311   protected JSpinner suffixDigitsSpinner = new JSpinner();
312
313   protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
314
315   protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
316
317   public JSpinner backupfilesRollMaxSpinner = new JSpinner();
318
319   protected JLabel oldBackupFilesLabel = new JLabel();
320
321   protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
322
323   protected JTextArea backupfilesExampleLabel = new JTextArea();
324
325   /**
326    * Creates a new GPreferences object.
327    */
328   public GPreferences()
329   {
330     try
331     {
332       jbInit();
333     } catch (Exception ex)
334     {
335       ex.printStackTrace();
336     }
337   }
338
339   /**
340    * Construct the panel and its tabbed sub-panels.
341    * 
342    * @throws Exception
343    */
344   private void jbInit() throws Exception
345   {
346     final JTabbedPane tabbedPane = new JTabbedPane();
347     this.setLayout(new BorderLayout());
348     JPanel okCancelPanel = initOkCancelPanel();
349     this.add(tabbedPane, BorderLayout.CENTER);
350     this.add(okCancelPanel, BorderLayout.SOUTH);
351
352     tabbedPane.add(initVisualTab(),
353             MessageManager.getString("label.visual"));
354
355     tabbedPane.add(initColoursTab(),
356             MessageManager.getString("label.colours"));
357
358     tabbedPane.add(initOverviewTab(),
359             MessageManager.getString("label.overview"));
360
361     tabbedPane.add(initStructureTab(),
362             MessageManager.getString("label.structure"));
363
364     tabbedPane.add(initConnectionsTab(),
365             MessageManager.getString("label.connections"));
366
367     tabbedPane.add(initBackupsTab(),
368             MessageManager.getString("label.backups"));
369
370     tabbedPane.add(initLinksTab(),
371             MessageManager.getString("label.urllinks"));
372
373     tabbedPane.add(initOutputTab(),
374             MessageManager.getString("label.output"));
375
376     tabbedPane.add(initEditingTab(),
377             MessageManager.getString("label.editing"));
378
379     /*
380      * See WsPreferences for the real work of configuring this tab.
381      */
382     wsTab.setLayout(new BorderLayout());
383     tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
384
385     /*
386      * Handler to validate a tab before leaving it - currently only for
387      * Structure.
388      */
389     tabbedPane.addChangeListener(new ChangeListener()
390     {
391       private Component lastTab;
392
393       @Override
394       public void stateChanged(ChangeEvent e)
395       {
396         if (lastTab == structureTab
397                 && tabbedPane.getSelectedComponent() != structureTab)
398         {
399           if (!validateStructure())
400           {
401             tabbedPane.setSelectedComponent(structureTab);
402             return;
403           }
404         }
405         lastTab = tabbedPane.getSelectedComponent();
406       }
407
408     });
409   }
410
411   /**
412    * Initialises the Editing tabbed panel.
413    * 
414    * @return
415    */
416   private JPanel initEditingTab()
417   {
418     JPanel editingTab = new JPanel();
419     editingTab.setLayout(null);
420     autoCalculateConsCheck.setFont(LABEL_FONT);
421     autoCalculateConsCheck.setText(
422             MessageManager.getString("label.autocalculate_consensus"));
423     autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
424     padGaps.setFont(LABEL_FONT);
425     padGaps.setText(
426             MessageManager.getString("label.pad_gaps_when_editing"));
427     padGaps.setBounds(new Rectangle(22, 94, 168, 23));
428     sortByTree.setFont(LABEL_FONT);
429     sortByTree
430             .setText(MessageManager.getString("label.sort_with_new_tree"));
431     sortByTree.setToolTipText(MessageManager.getString(
432             "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
433     sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
434     editingTab.add(autoCalculateConsCheck);
435     editingTab.add(padGaps);
436     editingTab.add(sortByTree);
437     return editingTab;
438   }
439
440   /**
441    * Initialises the Output tabbed panel.
442    * 
443    * @return
444    */
445   private JPanel initOutputTab()
446   {
447     JPanel outputTab = new JPanel();
448     outputTab.setLayout(null);
449     JLabel epsLabel = new JLabel();
450     epsLabel.setFont(LABEL_FONT);
451     epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
452     epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
453     epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
454     epsRendering.setFont(LABEL_FONT);
455     epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
456     JLabel jLabel1 = new JLabel();
457     jLabel1.setFont(LABEL_FONT);
458     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
459     jLabel1.setText(MessageManager.getString("label.append_start_end"));
460     jLabel1.setFont(LABEL_FONT);
461     fastajv.setFont(LABEL_FONT);
462     fastajv.setHorizontalAlignment(SwingConstants.LEFT);
463     clustaljv.setText(MessageManager.getString("label.clustal") + "     ");
464     blcjv.setText(MessageManager.getString("label.blc") + "     ");
465     fastajv.setText(MessageManager.getString("label.fasta") + "     ");
466     msfjv.setText(MessageManager.getString("label.msf") + "     ");
467     pfamjv.setText(MessageManager.getString("label.pfam") + "     ");
468     pileupjv.setText(MessageManager.getString("label.pileup") + "     ");
469     msfjv.setFont(LABEL_FONT);
470     msfjv.setHorizontalAlignment(SwingConstants.LEFT);
471     pirjv.setText(MessageManager.getString("label.pir") + "     ");
472     JPanel jPanel11 = new JPanel();
473     jPanel11.setFont(LABEL_FONT);
474     TitledBorder titledBorder2 = new TitledBorder(
475             MessageManager.getString("label.file_output"));
476     jPanel11.setBorder(titledBorder2);
477     jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
478     GridLayout gridLayout3 = new GridLayout();
479     jPanel11.setLayout(gridLayout3);
480     gridLayout3.setRows(8);
481     blcjv.setFont(LABEL_FONT);
482     blcjv.setHorizontalAlignment(SwingConstants.LEFT);
483     clustaljv.setFont(LABEL_FONT);
484     clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
485     pfamjv.setFont(LABEL_FONT);
486     pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
487     pileupjv.setFont(LABEL_FONT);
488     pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
489     pirjv.setFont(LABEL_FONT);
490     pirjv.setHorizontalAlignment(SwingConstants.LEFT);
491     autoIdWidth.setFont(LABEL_FONT);
492     autoIdWidth.setText(
493             MessageManager.getString("label.automatically_set_id_width"));
494     autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
495             .getString("label.adjusts_width_generated_eps_png")));
496     autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
497     autoIdWidth.addActionListener(new ActionListener()
498     {
499
500       @Override
501       public void actionPerformed(ActionEvent e)
502       {
503         autoIdWidth_actionPerformed();
504       }
505     });
506     userIdWidthlabel.setFont(LABEL_FONT);
507     userIdWidthlabel.setText(
508             MessageManager.getString("label.figure_id_column_width"));
509     userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
510             .getString("label.manually_specify_width_left_column")));
511     userIdWidthlabel.setToolTipText(
512             JvSwingUtils.wrapTooltip(true, MessageManager.getString(
513                     "label.manually_specify_width_left_column")));
514     userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
515     userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
516     userIdWidth.setText("");
517     userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
518     userIdWidth.addActionListener(new ActionListener()
519     {
520
521       @Override
522       public void actionPerformed(ActionEvent e)
523       {
524         userIdWidth_actionPerformed();
525       }
526     });
527     modellerOutput.setFont(LABEL_FONT);
528     modellerOutput
529             .setText(MessageManager.getString("label.use_modeller_output"));
530     modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
531     embbedBioJSON.setFont(LABEL_FONT);
532     embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
533     embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
534
535     TitledBorder backupFilesBorder = new TitledBorder(
536             MessageManager.getString("label.backup_files"));
537
538     jPanel11.add(jLabel1);
539     jPanel11.add(blcjv);
540     jPanel11.add(clustaljv);
541     jPanel11.add(fastajv);
542     jPanel11.add(msfjv);
543     jPanel11.add(pfamjv);
544     jPanel11.add(pileupjv);
545     jPanel11.add(pirjv);
546     outputTab.add(autoIdWidth);
547     outputTab.add(userIdWidth);
548     outputTab.add(userIdWidthlabel);
549     outputTab.add(modellerOutput);
550     outputTab.add(embbedBioJSON);
551     outputTab.add(epsLabel);
552     outputTab.add(epsRendering);
553     outputTab.add(jPanel11);
554     return outputTab;
555   }
556
557   /**
558    * Initialises the Connections tabbed panel.
559    * 
560    * @return
561    */
562   private JPanel initConnectionsTab()
563   {
564     JPanel connectTab = new JPanel();
565     connectTab.setLayout(new GridBagLayout());
566
567     // Label for browser text box
568     JLabel browserLabel = new JLabel();
569     browserLabel.setFont(LABEL_FONT);
570     browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
571     browserLabel.setText(
572             MessageManager.getString("label.default_browser_unix"));
573     defaultBrowser.setFont(LABEL_FONT);
574     defaultBrowser.setText("");
575     final String tooltip = JvSwingUtils.wrapTooltip(true,
576             MessageManager.getString("label.double_click_to_browse"));
577     defaultBrowser.setToolTipText(tooltip);
578     defaultBrowser.addMouseListener(new MouseAdapter()
579     {
580       @Override
581       public void mouseClicked(MouseEvent e)
582       {
583         if (e.getClickCount() > 1)
584         {
585           defaultBrowser_mouseClicked(e);
586         }
587       }
588     });
589
590     JPanel proxyPanel = initConnTabProxyPanel();
591     initConnTabCheckboxes();
592
593     // Add default Browser text box
594     connectTab.add(browserLabel,
595             new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
596                     GridBagConstraints.WEST, GridBagConstraints.NONE,
597                     new Insets(10, 0, 5, 5), 5, 1));
598     defaultBrowser.setFont(LABEL_FONT);
599     defaultBrowser.setText("");
600
601     connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
602             0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
603             new Insets(10, 0, 5, 10), 30, 1));
604
605     // Add proxy server panel
606     connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
607             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
608             new Insets(10, 0, 5, 12), 4, 10));
609
610     // Add usage stats, version check and questionnaire checkboxes
611     connectTab.add(usagestats,
612             new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
613                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
614                     new Insets(0, 2, 5, 5), 70, 1));
615     connectTab.add(questionnaire,
616             new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
617                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
618                     new Insets(0, 2, 5, 10), 70, 1));
619     connectTab.add(versioncheck,
620             new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
621                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
622                     new Insets(0, 2, 5, 5), 70, 1));
623
624     // Add padding so the panel doesn't look ridiculous
625     JPanel spacePanel = new JPanel();
626     connectTab.add(spacePanel,
627             new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
628                     GridBagConstraints.WEST, GridBagConstraints.BOTH,
629                     new Insets(0, 0, 0, 5), 70, 1));
630
631     return connectTab;
632   }
633
634   /**
635    * Initialises the Links tabbed panel.
636    * 
637    * @return
638    */
639   private JPanel initLinksTab()
640   {
641     JPanel linkTab = new JPanel();
642     linkTab.setLayout(new GridBagLayout());
643
644     // Set up table for Url links
645     linkUrlTable.setFillsViewportHeight(true);
646     linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
647     linkUrlTable.setAutoCreateRowSorter(true);
648     linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
649
650     // adjust row height so radio buttons actually fit
651     // don't do this in the renderer, it causes the awt thread to activate
652     // constantly
653     JRadioButton temp = new JRadioButton();
654     linkUrlTable.setRowHeight(temp.getMinimumSize().height);
655
656     // Table in scrollpane so that the table is given a scrollbar
657     JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
658     linkScrollPane.setBorder(null);
659
660     // Panel for links functionality
661     JPanel linkPanel = new JPanel(new GridBagLayout());
662     linkPanel.setBorder(new TitledBorder(
663             MessageManager.getString("label.url_linkfrom_sequence_id")));
664
665     // Put the Url links panel together
666
667     // Buttons go at top right, resizing only resizes the blank space vertically
668     JPanel buttonPanel = initLinkTabUrlButtons();
669     GridBagConstraints linkConstraints1 = new GridBagConstraints();
670     linkConstraints1.insets = new Insets(0, 0, 5, 0);
671     linkConstraints1.gridx = 0;
672     linkConstraints1.gridy = 0;
673     linkConstraints1.weightx = 1.0;
674     linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
675     linkTab.add(buttonPanel, linkConstraints1);
676
677     // Links table goes at top left, resizing resizes the table
678     GridBagConstraints linkConstraints2 = new GridBagConstraints();
679     linkConstraints2.insets = new Insets(0, 0, 5, 5);
680     linkConstraints2.gridx = 0;
681     linkConstraints2.gridy = 1;
682     linkConstraints2.weightx = 1.0;
683     linkConstraints2.weighty = 1.0;
684     linkConstraints2.fill = GridBagConstraints.BOTH;
685     linkTab.add(linkScrollPane, linkConstraints2);
686
687     // Filter box and buttons goes at bottom left, resizing resizes the text box
688     JPanel filterPanel = initLinkTabFilterPanel();
689     GridBagConstraints linkConstraints3 = new GridBagConstraints();
690     linkConstraints3.insets = new Insets(0, 0, 0, 5);
691     linkConstraints3.gridx = 0;
692     linkConstraints3.gridy = 2;
693     linkConstraints3.weightx = 1.0;
694     linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
695     linkTab.add(filterPanel, linkConstraints3);
696
697     return linkTab;
698   }
699
700   private JPanel initLinkTabFilterPanel()
701   {
702     // Filter textbox and reset button
703     JLabel filterLabel = new JLabel(
704             MessageManager.getString("label.filter"));
705     filterLabel.setFont(LABEL_FONT);
706     filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
707     filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
708
709     filterTB.setFont(LABEL_FONT);
710     filterTB.setText("");
711
712     doReset.setText(MessageManager.getString("action.showall"));
713     userOnly.setText(MessageManager.getString("action.customfilter"));
714
715     // Panel for filter functionality
716     JPanel filterPanel = new JPanel(new GridBagLayout());
717     filterPanel.setBorder(new TitledBorder("Filter"));
718     GridBagConstraints gbc = new GridBagConstraints();
719     gbc.gridx = 0;
720     gbc.gridy = 0;
721     gbc.fill = GridBagConstraints.NONE;
722     gbc.anchor = GridBagConstraints.WEST;
723
724     filterPanel.add(filterLabel, gbc);
725
726     GridBagConstraints gbc1 = new GridBagConstraints();
727     gbc1.gridx = 1;
728     gbc1.gridwidth = 2;
729     gbc1.fill = GridBagConstraints.HORIZONTAL;
730     gbc1.anchor = GridBagConstraints.WEST;
731     gbc1.weightx = 1.0;
732     filterPanel.add(filterTB, gbc1);
733
734     GridBagConstraints gbc2 = new GridBagConstraints();
735     gbc2.gridx = 3;
736     gbc2.fill = GridBagConstraints.NONE;
737     gbc2.anchor = GridBagConstraints.WEST;
738     filterPanel.add(doReset, gbc2);
739
740     GridBagConstraints gbc3 = new GridBagConstraints();
741     gbc3.gridx = 4;
742     gbc3.fill = GridBagConstraints.NONE;
743     gbc3.anchor = GridBagConstraints.WEST;
744     filterPanel.add(userOnly, gbc3);
745
746     return filterPanel;
747   }
748
749   private JPanel initLinkTabUrlButtons()
750   {
751     // Buttons for new / edit / delete Url links
752     JButton newLink = new JButton();
753     newLink.setText(MessageManager.getString("action.new"));
754
755     editLink.setText(MessageManager.getString("action.edit"));
756
757     deleteLink.setText(MessageManager.getString("action.delete"));
758
759     // no current selection, so initially disable delete/edit buttons
760     editLink.setEnabled(false);
761     deleteLink.setEnabled(false);
762
763     newLink.addActionListener(new java.awt.event.ActionListener()
764     {
765       @Override
766       public void actionPerformed(ActionEvent e)
767       {
768         newLink_actionPerformed(e);
769       }
770     });
771
772     editLink.setText(MessageManager.getString("action.edit"));
773     editLink.addActionListener(new java.awt.event.ActionListener()
774     {
775       @Override
776       public void actionPerformed(ActionEvent e)
777       {
778         editLink_actionPerformed(e);
779       }
780     });
781
782     deleteLink.setText(MessageManager.getString("action.delete"));
783     deleteLink.addActionListener(new java.awt.event.ActionListener()
784     {
785       @Override
786       public void actionPerformed(ActionEvent e)
787       {
788         deleteLink_actionPerformed(e);
789       }
790     });
791
792     JPanel buttonPanel = new JPanel(new GridBagLayout());
793     buttonPanel.setBorder(new TitledBorder("Edit links"));
794     GridBagConstraints gbc = new GridBagConstraints();
795     gbc.gridx = 0;
796     gbc.gridy = 0;
797     gbc.fill = GridBagConstraints.NONE;
798     buttonPanel.add(newLink, gbc);
799
800     GridBagConstraints gbc1 = new GridBagConstraints();
801     gbc1.gridx = 1;
802     gbc1.gridy = 0;
803     gbc1.fill = GridBagConstraints.NONE;
804     buttonPanel.add(editLink, gbc1);
805
806     GridBagConstraints gbc2 = new GridBagConstraints();
807     gbc2.gridx = 2;
808     gbc2.gridy = 0;
809     gbc2.fill = GridBagConstraints.NONE;
810     buttonPanel.add(deleteLink, gbc2);
811
812     GridBagConstraints gbc3 = new GridBagConstraints();
813     gbc3.gridx = 3;
814     gbc3.gridy = 0;
815     gbc3.fill = GridBagConstraints.HORIZONTAL;
816     gbc3.weightx = 1.0;
817     JPanel spacePanel = new JPanel();
818     spacePanel.setBorder(null);
819     buttonPanel.add(spacePanel, gbc3);
820
821     return buttonPanel;
822   }
823
824   /**
825    * Initialises the proxy server panel in the Connections tab
826    * 
827    * @return the proxy server panel
828    */
829   private JPanel initConnTabProxyPanel()
830   {
831     // Label for server text box
832     serverLabel.setText(MessageManager.getString("label.address"));
833     serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
834     serverLabel.setFont(LABEL_FONT);
835
836     // Proxy server and port text boxes
837     proxyServerTB.setFont(LABEL_FONT);
838     proxyPortTB.setFont(LABEL_FONT);
839
840     // Label for Port text box
841     portLabel.setFont(LABEL_FONT);
842     portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
843     portLabel.setText(MessageManager.getString("label.port"));
844
845     // Use proxy server checkbox
846     useProxy.setFont(LABEL_FONT);
847     useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
848     useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
849     useProxy.setText(MessageManager.getString("label.use_proxy_server"));
850     useProxy.addActionListener(new ActionListener()
851     {
852       @Override
853       public void actionPerformed(ActionEvent e)
854       {
855         useProxy_actionPerformed();
856       }
857     });
858
859     // Make proxy server panel
860     JPanel proxyPanel = new JPanel();
861     TitledBorder titledBorder1 = new TitledBorder(
862             MessageManager.getString("label.proxy_server"));
863     proxyPanel.setBorder(titledBorder1);
864     proxyPanel.setLayout(new GridBagLayout());
865     proxyPanel.add(serverLabel,
866             new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
867                     GridBagConstraints.WEST, GridBagConstraints.NONE,
868                     new Insets(0, 2, 2, 0), 5, 0));
869     proxyPanel.add(portLabel,
870             new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
871                     GridBagConstraints.WEST, GridBagConstraints.NONE,
872                     new Insets(0, 0, 2, 0), 11, 0));
873     proxyPanel.add(useProxy,
874             new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
875                     GridBagConstraints.WEST, GridBagConstraints.NONE,
876                     new Insets(0, 2, 5, 185), 2, -4));
877     proxyPanel.add(proxyPortTB,
878             new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
879                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
880                     new Insets(0, 2, 2, 2), 54, 1));
881     proxyPanel.add(proxyServerTB,
882             new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
883                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
884                     new Insets(0, 2, 2, 0), 263, 1));
885
886     return proxyPanel;
887   }
888
889   /**
890    * Initialises the checkboxes in the Connections tab
891    */
892   private void initConnTabCheckboxes()
893   {
894     // Usage stats checkbox label
895     usagestats.setText(
896             MessageManager.getString("label.send_usage_statistics"));
897     usagestats.setFont(LABEL_FONT);
898     usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
899     usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
900
901     // Questionnaire checkbox label
902     questionnaire.setText(
903             MessageManager.getString("label.check_for_questionnaires"));
904     questionnaire.setFont(LABEL_FONT);
905     questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
906     questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
907
908     // Check for latest version checkbox label
909     versioncheck.setText(
910             MessageManager.getString("label.check_for_latest_version"));
911     versioncheck.setFont(LABEL_FONT);
912     versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
913     versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
914   }
915
916   /**
917    * Initialises the parent panel which contains the tabbed sections.
918    * 
919    * @return
920    */
921   private JPanel initOkCancelPanel()
922   {
923     JButton ok = new JButton();
924     ok.setText(MessageManager.getString("action.ok"));
925     ok.addActionListener(new ActionListener()
926     {
927       @Override
928       public void actionPerformed(ActionEvent e)
929       {
930         ok_actionPerformed(e);
931       }
932     });
933     JButton cancel = new JButton();
934     cancel.setText(MessageManager.getString("action.cancel"));
935     cancel.addActionListener(new ActionListener()
936     {
937       @Override
938       public void actionPerformed(ActionEvent e)
939       {
940         cancel_actionPerformed(e);
941       }
942     });
943     JPanel okCancelPanel = new JPanel();
944     okCancelPanel.add(ok);
945     okCancelPanel.add(cancel);
946     return okCancelPanel;
947   }
948
949   /**
950    * Initialises the Colours tabbed panel.
951    * 
952    * @return
953    */
954   private JPanel initColoursTab()
955   {
956     JPanel coloursTab = new JPanel();
957     coloursTab.setBorder(new TitledBorder(
958             MessageManager.getString("action.open_new_alignment")));
959     coloursTab.setLayout(new FlowLayout());
960     JLabel mincolourLabel = new JLabel();
961     mincolourLabel.setFont(LABEL_FONT);
962     mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
963     mincolourLabel.setText(MessageManager.getString("label.min_colour"));
964     minColour.setFont(LABEL_FONT);
965     minColour.setBorder(BorderFactory.createEtchedBorder());
966     minColour.setPreferredSize(new Dimension(40, 20));
967     minColour.addMouseListener(new MouseAdapter()
968     {
969       @Override
970       public void mousePressed(MouseEvent e)
971       {
972         minColour_actionPerformed(minColour);
973       }
974     });
975     JLabel maxcolourLabel = new JLabel();
976     maxcolourLabel.setFont(LABEL_FONT);
977     maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
978     maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
979     maxColour.setFont(LABEL_FONT);
980     maxColour.setBorder(BorderFactory.createEtchedBorder());
981     maxColour.setPreferredSize(new Dimension(40, 20));
982     maxColour.addMouseListener(new MouseAdapter()
983     {
984       @Override
985       public void mousePressed(MouseEvent e)
986       {
987         maxColour_actionPerformed(maxColour);
988       }
989     });
990
991     protColour.setFont(LABEL_FONT);
992     protColour.setBounds(new Rectangle(172, 225, 155, 21));
993     JLabel protColourLabel = new JLabel();
994     protColourLabel.setFont(LABEL_FONT);
995     protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
996     protColourLabel.setText(
997             MessageManager.getString("label.prot_alignment_colour") + " ");
998     JvSwingUtils.addtoLayout(coloursTab,
999             MessageManager
1000                     .getString("label.default_colour_scheme_for_alignment"),
1001             protColourLabel, protColour);
1002
1003     nucColour.setFont(LABEL_FONT);
1004     nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1005     JLabel nucColourLabel = new JLabel();
1006     nucColourLabel.setFont(LABEL_FONT);
1007     nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1008     nucColourLabel.setText(
1009             MessageManager.getString("label.nuc_alignment_colour") + " ");
1010     JvSwingUtils.addtoLayout(coloursTab,
1011             MessageManager
1012                     .getString("label.default_colour_scheme_for_alignment"),
1013             nucColourLabel, nucColour);
1014
1015     JPanel annotationShding = new JPanel();
1016     annotationShding.setBorder(new TitledBorder(
1017             MessageManager.getString("label.annotation_shading_default")));
1018     annotationShding.setLayout(new GridLayout(1, 2));
1019     JvSwingUtils.addtoLayout(annotationShding,
1020             MessageManager.getString(
1021                     "label.default_minimum_colour_annotation_shading"),
1022             mincolourLabel, minColour);
1023     JvSwingUtils.addtoLayout(annotationShding,
1024             MessageManager.getString(
1025                     "label.default_maximum_colour_annotation_shading"),
1026             maxcolourLabel, maxColour);
1027     coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1028     return coloursTab;
1029   }
1030
1031   /**
1032    * Initialises the Overview tabbed panel.
1033    * 
1034    * @return
1035    */
1036   private JPanel initOverviewTab()
1037   {
1038     JPanel overviewPanel = new JPanel();
1039     overviewPanel.setBorder(new TitledBorder(
1040             MessageManager.getString("label.overview_settings")));
1041
1042     gapColour.setFont(LABEL_FONT);
1043     // fixing the border colours stops apparent colour bleed from the panel
1044     gapColour.setBorder(
1045             BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1046     gapColour.setPreferredSize(new Dimension(40, 20));
1047     gapColour.addMouseListener(new MouseAdapter()
1048     {
1049       @Override
1050       public void mousePressed(MouseEvent e)
1051       {
1052         gapColour_actionPerformed(gapColour);
1053       }
1054     });
1055
1056     hiddenColour.setFont(LABEL_FONT);
1057     // fixing the border colours stops apparent colour bleed from the panel
1058     hiddenColour.setBorder(
1059             BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1060     hiddenColour.setPreferredSize(new Dimension(40, 20));
1061     hiddenColour.addMouseListener(new MouseAdapter()
1062     {
1063       @Override
1064       public void mousePressed(MouseEvent e)
1065       {
1066         hiddenColour_actionPerformed(hiddenColour);
1067       }
1068     });
1069
1070     useLegacyGap = new JCheckBox(
1071             MessageManager.getString("label.ov_legacy_gap"));
1072     useLegacyGap.setFont(LABEL_FONT);
1073     useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1074     useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1075     gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1076     gapLabel.setFont(LABEL_FONT);
1077     gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1078     gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1079     showHiddenAtStart = new JCheckBox(
1080             MessageManager.getString("label.ov_show_hide_default"));
1081     showHiddenAtStart.setFont(LABEL_FONT);
1082     showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1083     showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1084     JLabel hiddenLabel = new JLabel(
1085             MessageManager.getString("label.hidden_colour"));
1086     hiddenLabel.setFont(LABEL_FONT);
1087     hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1088     hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1089
1090     useLegacyGap.addActionListener(new ActionListener()
1091     {
1092       @Override
1093       public void actionPerformed(ActionEvent e)
1094       {
1095         useLegacyGaps_actionPerformed(e);
1096       }
1097     });
1098
1099     overviewPanel.setLayout(new GridBagLayout());
1100     GridBagConstraints c1 = new GridBagConstraints();
1101
1102     c1.fill = GridBagConstraints.HORIZONTAL;
1103     c1.gridx = 0;
1104     c1.gridy = 0;
1105     c1.weightx = 1;
1106     c1.ipady = 20;
1107     c1.anchor = GridBagConstraints.FIRST_LINE_START;
1108     overviewPanel.add(useLegacyGap, c1);
1109
1110     GridBagConstraints c2 = new GridBagConstraints();
1111     c2.fill = GridBagConstraints.HORIZONTAL;
1112     c2.gridx = 1;
1113     c2.gridy = 0;
1114     c2.insets = new Insets(0, 15, 0, 10);
1115     overviewPanel.add(gapLabel, c2);
1116
1117     GridBagConstraints c3 = new GridBagConstraints();
1118     c3.fill = GridBagConstraints.HORIZONTAL;
1119     c3.gridx = 2;
1120     c3.gridy = 0;
1121     c3.insets = new Insets(0, 0, 0, 15);
1122     overviewPanel.add(gapColour, c3);
1123
1124     GridBagConstraints c4 = new GridBagConstraints();
1125     c4.fill = GridBagConstraints.HORIZONTAL;
1126     c4.gridx = 0;
1127     c4.gridy = 1;
1128     c4.weightx = 1;
1129     overviewPanel.add(showHiddenAtStart, c4);
1130
1131     GridBagConstraints c5 = new GridBagConstraints();
1132     c5.fill = GridBagConstraints.HORIZONTAL;
1133     c5.gridx = 1;
1134     c5.gridy = 1;
1135     c5.insets = new Insets(0, 15, 0, 10);
1136     overviewPanel.add(hiddenLabel, c5);
1137
1138     GridBagConstraints c6 = new GridBagConstraints();
1139     c6.fill = GridBagConstraints.HORIZONTAL;
1140     c6.gridx = 2;
1141     c6.gridy = 1;
1142     c6.insets = new Insets(0, 0, 0, 15);
1143     overviewPanel.add(hiddenColour, c6);
1144
1145     JButton resetButton = new JButton(
1146             MessageManager.getString("label.reset_to_defaults"));
1147
1148     resetButton.addActionListener(new ActionListener()
1149     {
1150       @Override
1151       public void actionPerformed(ActionEvent e)
1152       {
1153         resetOvDefaults_actionPerformed(e);
1154       }
1155     });
1156
1157     GridBagConstraints c7 = new GridBagConstraints();
1158     c7.fill = GridBagConstraints.NONE;
1159     c7.gridx = 0;
1160     c7.gridy = 2;
1161     c7.insets = new Insets(10, 0, 0, 0);
1162     c7.anchor = GridBagConstraints.WEST;
1163     overviewPanel.add(resetButton, c7);
1164
1165     // Add padding so the panel doesn't look ridiculous
1166     JPanel spacePanel = new JPanel();
1167     overviewPanel.add(spacePanel,
1168             new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1169                     GridBagConstraints.WEST, GridBagConstraints.BOTH,
1170                     new Insets(0, 0, 0, 5), 0, 0));
1171
1172     return overviewPanel;
1173   }
1174
1175   /**
1176    * Initialises the Structure tabbed panel.
1177    * 
1178    * @return
1179    */
1180   private JPanel initStructureTab()
1181   {
1182     structureTab = new JPanel();
1183
1184     structureTab.setBorder(new TitledBorder(
1185             MessageManager.getString("label.structure_options")));
1186     structureTab.setLayout(null);
1187     final int width = 400;
1188     final int height = 22;
1189     final int lineSpacing = 25;
1190     int ypos = 15;
1191
1192     structFromPdb.setFont(LABEL_FONT);
1193     structFromPdb
1194             .setText(MessageManager.getString("label.struct_from_pdb"));
1195     structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1196     structFromPdb.addActionListener(new ActionListener()
1197     {
1198       @Override
1199       public void actionPerformed(ActionEvent e)
1200       {
1201         boolean selected = structFromPdb.isSelected();
1202         // enable other options only when the first is checked
1203         useRnaView.setEnabled(selected);
1204         addSecondaryStructure.setEnabled(selected);
1205         addTempFactor.setEnabled(selected);
1206       }
1207     });
1208     structureTab.add(structFromPdb);
1209
1210     // indent checkboxes that are conditional on the first one
1211     ypos += lineSpacing;
1212     useRnaView.setFont(LABEL_FONT);
1213     useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1214     useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1215     structureTab.add(useRnaView);
1216
1217     ypos += lineSpacing;
1218     addSecondaryStructure.setFont(LABEL_FONT);
1219     addSecondaryStructure
1220             .setText(MessageManager.getString("label.autoadd_secstr"));
1221     addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1222     structureTab.add(addSecondaryStructure);
1223
1224     ypos += lineSpacing;
1225     addTempFactor.setFont(LABEL_FONT);
1226     addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1227     addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1228     structureTab.add(addTempFactor);
1229
1230     ypos += lineSpacing;
1231     JLabel viewerLabel = new JLabel();
1232     viewerLabel.setFont(LABEL_FONT);
1233     viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1234     viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1235     viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1236     structureTab.add(viewerLabel);
1237
1238     structViewer.setFont(LABEL_FONT);
1239     structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1240     structViewer.addItem(ViewerType.JMOL.name());
1241     structViewer.addItem(ViewerType.CHIMERA.name());
1242     structViewer.addActionListener(new ActionListener()
1243     {
1244       @Override
1245       public void actionPerformed(ActionEvent e)
1246       {
1247         structureViewer_actionPerformed(
1248                 (String) structViewer.getSelectedItem());
1249       }
1250     });
1251     structureTab.add(structViewer);
1252
1253     ypos += lineSpacing;
1254     JLabel pathLabel = new JLabel();
1255     pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1256     pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1257     pathLabel.setText(MessageManager.getString("label.chimera_path"));
1258     pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1259     structureTab.add(pathLabel);
1260
1261     chimeraPath.setFont(LABEL_FONT);
1262     chimeraPath.setText("");
1263     final String tooltip = JvSwingUtils.wrapTooltip(true,
1264             MessageManager.getString("label.chimera_path_tip"));
1265     chimeraPath.setToolTipText(tooltip);
1266     chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1267     chimeraPath.addMouseListener(new MouseAdapter()
1268     {
1269       @Override
1270       public void mouseClicked(MouseEvent e)
1271       {
1272         if (e.getClickCount() == 2)
1273         {
1274           String chosen = openFileChooser();
1275           if (chosen != null)
1276           {
1277             chimeraPath.setText(chosen);
1278           }
1279         }
1280       }
1281     });
1282     structureTab.add(chimeraPath);
1283
1284     ypos += lineSpacing;
1285     nwMapping.setFont(LABEL_FONT);
1286     nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1287     siftsMapping.setFont(LABEL_FONT);
1288     siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1289     mappingMethod.add(nwMapping);
1290     mappingMethod.add(siftsMapping);
1291     JPanel mappingPanel = new JPanel();
1292     mappingPanel.setFont(LABEL_FONT);
1293     TitledBorder mmTitledBorder = new TitledBorder(
1294             MessageManager.getString("label.mapping_method"));
1295     mmTitledBorder.setTitleFont(LABEL_FONT);
1296     mappingPanel.setBorder(mmTitledBorder);
1297     mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1298     // GridLayout mappingLayout = new GridLayout();
1299     mappingPanel.setLayout(new GridLayout());
1300     mappingPanel.add(nwMapping);
1301     mappingPanel.add(siftsMapping);
1302     structureTab.add(mappingPanel);
1303
1304     ypos += lineSpacing;
1305     ypos += lineSpacing;
1306     FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1307             PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1308     docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1309     structureTab.add(docFieldPref);
1310
1311     return structureTab;
1312   }
1313
1314   /**
1315    * Action on choosing a structure viewer from combobox options.
1316    * 
1317    * @param selectedItem
1318    */
1319   protected void structureViewer_actionPerformed(String selectedItem)
1320   {
1321   }
1322
1323   /**
1324    * Show a dialog for the user to choose a file. Returns the chosen path, or
1325    * null on Cancel.
1326    * 
1327    * @return
1328    */
1329   protected String openFileChooser()
1330   {
1331     String choice = null;
1332     JFileChooser chooser = new JFileChooser();
1333
1334     // chooser.setFileView(new JalviewFileView());
1335     chooser.setDialogTitle(
1336             MessageManager.getString("label.open_local_file"));
1337     chooser.setToolTipText(MessageManager.getString("action.open"));
1338
1339     int value = chooser.showOpenDialog(this);
1340
1341     if (value == JFileChooser.APPROVE_OPTION)
1342     {
1343       choice = chooser.getSelectedFile().getPath();
1344     }
1345     return choice;
1346   }
1347
1348   /**
1349    * Validate the structure tab preferences; if invalid, set focus on this tab.
1350    * 
1351    * @param e
1352    */
1353   protected boolean validateStructure(FocusEvent e)
1354   {
1355     if (!validateStructure())
1356     {
1357       e.getComponent().requestFocusInWindow();
1358       return false;
1359     }
1360     return true;
1361   }
1362
1363   protected boolean validateStructure()
1364   {
1365     return false;
1366   }
1367
1368   /**
1369    * Initialises the Visual tabbed panel.
1370    * 
1371    * @return
1372    */
1373   private JPanel initVisualTab()
1374   {
1375     JPanel visualTab = new JPanel();
1376     visualTab.setBorder(new TitledBorder(
1377             MessageManager.getString("action.open_new_alignment")));
1378     visualTab.setLayout(null);
1379     fullScreen.setFont(LABEL_FONT);
1380     fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1381     fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1382     fullScreen.setText(MessageManager.getString("label.maximize_window"));
1383     quality.setEnabled(false);
1384     quality.setFont(LABEL_FONT);
1385     quality.setHorizontalAlignment(SwingConstants.RIGHT);
1386     quality.setHorizontalTextPosition(SwingConstants.LEFT);
1387     quality.setSelected(true);
1388     quality.setText(MessageManager.getString("label.quality"));
1389     conservation.setEnabled(false);
1390     conservation.setFont(LABEL_FONT);
1391     conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1392     conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1393     conservation.setSelected(true);
1394     conservation.setText(MessageManager.getString("label.conservation"));
1395     identity.setEnabled(false);
1396     identity.setFont(LABEL_FONT);
1397     identity.setHorizontalAlignment(SwingConstants.RIGHT);
1398     identity.setHorizontalTextPosition(SwingConstants.LEFT);
1399     identity.setSelected(true);
1400     identity.setText(MessageManager.getString("label.consensus"));
1401     showOccupancy.setFont(LABEL_FONT);
1402     showOccupancy.setEnabled(false);
1403     showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1404     showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1405     showOccupancy.setSelected(true);
1406     showOccupancy.setText(MessageManager.getString("label.occupancy"));
1407
1408     JLabel showGroupbits = new JLabel();
1409     showGroupbits.setFont(LABEL_FONT);
1410     showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1411     showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1412     showGroupbits
1413             .setText(MessageManager.getString("action.show_group") + ":");
1414     JLabel showConsensbits = new JLabel();
1415     showConsensbits.setFont(LABEL_FONT);
1416     showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1417     showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1418     showConsensbits
1419             .setText(MessageManager.getString("label.consensus") + ":");
1420     showConsensHistogram.setEnabled(false);
1421     showConsensHistogram.setFont(LABEL_FONT);
1422     showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1423     showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1424     showConsensHistogram.setSelected(true);
1425     showConsensHistogram
1426             .setText(MessageManager.getString("label.histogram"));
1427     showConsensLogo.setEnabled(false);
1428     showConsensLogo.setFont(LABEL_FONT);
1429     showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1430     showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1431     showConsensLogo.setSelected(true);
1432     showConsensLogo.setText(MessageManager.getString("label.logo"));
1433     showGroupConsensus.setEnabled(false);
1434     showGroupConsensus.setFont(LABEL_FONT);
1435     showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1436     showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1437     showGroupConsensus.setSelected(true);
1438     showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1439     showGroupConservation.setEnabled(false);
1440     showGroupConservation.setFont(LABEL_FONT);
1441     showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1442     showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1443     showGroupConservation.setSelected(true);
1444     showGroupConservation
1445             .setText(MessageManager.getString("label.conservation"));
1446     showNpTooltip.setEnabled(true);
1447     showNpTooltip.setFont(LABEL_FONT);
1448     showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1449     showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1450     showNpTooltip.setSelected(true);
1451     showNpTooltip.setText(
1452             MessageManager.getString("label.non_positional_features"));
1453     showDbRefTooltip.setEnabled(true);
1454     showDbRefTooltip.setFont(LABEL_FONT);
1455     showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1456     showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1457     showDbRefTooltip.setSelected(true);
1458     showDbRefTooltip
1459             .setText(MessageManager.getString("label.database_references"));
1460     annotations.setFont(LABEL_FONT);
1461     annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1462     annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1463     annotations.setSelected(true);
1464     annotations.setText(MessageManager.getString("label.show_annotations"));
1465     // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1466     annotations.addActionListener(new ActionListener()
1467     {
1468       @Override
1469       public void actionPerformed(ActionEvent e)
1470       {
1471         annotations_actionPerformed(e);
1472       }
1473     });
1474     identity.addActionListener(new ActionListener()
1475     {
1476       @Override
1477       public void actionPerformed(ActionEvent e)
1478       {
1479         annotations_actionPerformed(e);
1480       }
1481     });
1482     showGroupConsensus.addActionListener(new ActionListener()
1483     {
1484       @Override
1485       public void actionPerformed(ActionEvent e)
1486       {
1487         annotations_actionPerformed(e);
1488       }
1489     });
1490     showUnconserved.setFont(LABEL_FONT);
1491     showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1492     showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1493     showUnconserved.setSelected(true);
1494     showUnconserved
1495             .setText(MessageManager.getString("action.show_unconserved"));
1496     showUnconserved.addActionListener(new ActionListener()
1497     {
1498       @Override
1499       public void actionPerformed(ActionEvent e)
1500       {
1501         showunconserved_actionPerformed(e);
1502       }
1503     });
1504
1505     // TODO these are not yet added to / action from Preferences
1506     // JCheckBox shareSelections = new JCheckBox();
1507     // shareSelections.setFont(verdana11);
1508     // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1509     // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1510     // shareSelections.setSelected(true);
1511     // shareSelections.setText(MessageManager
1512     // .getString("label.share_selection_across_views"));
1513     // JCheckBox followHighlight = new JCheckBox();
1514     // followHighlight.setFont(verdana11);
1515     // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1516     // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1517     // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1518     // followHighlight.setSelected(true);
1519     // followHighlight.setText(MessageManager
1520     // .getString("label.scroll_highlighted_regions"));
1521
1522     seqLimit.setFont(LABEL_FONT);
1523     seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1524     seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1525     seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1526     smoothFont.setFont(LABEL_FONT);
1527     smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1528     smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1529     smoothFont.setText(MessageManager.getString("label.smooth_font"));
1530     scaleProteinToCdna.setFont(LABEL_FONT);
1531     scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1532     scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1533     scaleProteinToCdna.setText(
1534             MessageManager.getString("label.scale_protein_to_cdna"));
1535     scaleProteinToCdna.setToolTipText(
1536             MessageManager.getString("label.scale_protein_to_cdna_tip"));
1537     JLabel gapLabel = new JLabel();
1538     gapLabel.setFont(LABEL_FONT);
1539     gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1540     gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1541     JLabel fontLabel = new JLabel();
1542     fontLabel.setFont(LABEL_FONT);
1543     fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1544     fontLabel.setText(MessageManager.getString("label.font"));
1545     fontSizeCB.setFont(LABEL_FONT);
1546     fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1547     fontStyleCB.setFont(LABEL_FONT);
1548     fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1549     fontNameCB.setFont(LABEL_FONT);
1550     fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1551     gapSymbolCB.setFont(LABEL_FONT);
1552     gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1553     DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1554     dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1555     gapSymbolCB.setRenderer(dlcr);
1556
1557     startupCheckbox.setText(MessageManager.getString("action.open_file"));
1558     startupCheckbox.setFont(LABEL_FONT);
1559     startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1560     startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1561     startupCheckbox.setSelected(true);
1562     startupFileTextfield.setFont(LABEL_FONT);
1563     startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1564     final String tooltip = JvSwingUtils.wrapTooltip(true,
1565             MessageManager.getString("label.double_click_to_browse"));
1566     startupFileTextfield.setToolTipText(tooltip);
1567     startupFileTextfield.addMouseListener(new MouseAdapter()
1568     {
1569       @Override
1570       public void mouseClicked(MouseEvent e)
1571       {
1572         if (e.getClickCount() > 1)
1573         {
1574           startupFileTextfield_mouseClicked();
1575         }
1576       }
1577     });
1578
1579     sortby.setFont(LABEL_FONT);
1580     sortby.setBounds(new Rectangle(172, 260, 155, 21));
1581     JLabel sortLabel = new JLabel();
1582     sortLabel.setFont(LABEL_FONT);
1583     sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1584     sortLabel.setText(MessageManager.getString("label.sort_by"));
1585     sortAnnBy.setFont(LABEL_FONT);
1586     sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1587     JLabel sortAnnLabel = new JLabel();
1588     sortAnnLabel.setFont(LABEL_FONT);
1589     sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1590     sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1591     sortAutocalc.setFont(LABEL_FONT);
1592     sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1593
1594     JPanel annsettingsPanel = new JPanel();
1595     annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1596     annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1597     annsettingsPanel.setBorder(new EtchedBorder());
1598     visualTab.add(annsettingsPanel);
1599     Border jb = new EmptyBorder(1, 1, 4, 5);
1600     annotations.setBorder(jb);
1601     showOccupancy.setBorder(jb);
1602     quality.setBorder(jb);
1603     conservation.setBorder(jb);
1604     identity.setBorder(jb);
1605     showConsensbits.setBorder(jb);
1606     showGroupbits.setBorder(jb);
1607     showGroupConsensus.setBorder(jb);
1608     showGroupConservation.setBorder(jb);
1609     showConsensHistogram.setBorder(jb);
1610     showConsensLogo.setBorder(jb);
1611
1612     JPanel autoAnnotSettings = new JPanel();
1613     annsettingsPanel.add(autoAnnotSettings);
1614     autoAnnotSettings.setLayout(new GridLayout(0, 2));
1615     autoAnnotSettings.add(annotations);
1616     autoAnnotSettings.add(quality);
1617     // second row of autoannotation box
1618     autoAnnotSettings = new JPanel();
1619     annsettingsPanel.add(autoAnnotSettings);
1620
1621     autoAnnotSettings.setLayout(new GridLayout(0, 3));
1622     autoAnnotSettings.add(conservation);
1623     autoAnnotSettings.add(identity);
1624     autoAnnotSettings.add(showOccupancy);
1625     autoAnnotSettings.add(showGroupbits);
1626     autoAnnotSettings.add(showGroupConservation);
1627     autoAnnotSettings.add(showGroupConsensus);
1628     autoAnnotSettings.add(showConsensbits);
1629     autoAnnotSettings.add(showConsensHistogram);
1630     autoAnnotSettings.add(showConsensLogo);
1631
1632     JPanel tooltipSettings = new JPanel();
1633     tooltipSettings.setBorder(new TitledBorder(
1634             MessageManager.getString("label.sequence_id_tooltip")));
1635     tooltipSettings.setBounds(173, 140, 220, 62);
1636     tooltipSettings.setLayout(new GridLayout(2, 1));
1637     tooltipSettings.add(showDbRefTooltip);
1638     tooltipSettings.add(showNpTooltip);
1639     visualTab.add(tooltipSettings);
1640
1641     wrap.setFont(LABEL_FONT);
1642     wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1643     wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1644     wrap.setText(MessageManager.getString("label.wrap_alignment"));
1645     rightAlign.setFont(LABEL_FONT);
1646     rightAlign.setForeground(Color.black);
1647     rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1648     rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1649     rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1650     idItalics.setFont(LABEL_FONT_ITALIC);
1651     idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1652     idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1653     idItalics.setText(
1654             MessageManager.getString("label.sequence_name_italics"));
1655     openoverv.setFont(LABEL_FONT);
1656     openoverv.setActionCommand(
1657             MessageManager.getString("label.open_overview"));
1658     openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1659     openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1660     openoverv.setText(MessageManager.getString("label.open_overview"));
1661     JPanel jPanel2 = new JPanel();
1662     jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1663     jPanel2.setLayout(new GridLayout(14, 1));
1664     jPanel2.add(fullScreen);
1665     jPanel2.add(openoverv);
1666     jPanel2.add(seqLimit);
1667     jPanel2.add(rightAlign);
1668     jPanel2.add(fontLabel);
1669     jPanel2.add(showUnconserved);
1670     jPanel2.add(idItalics);
1671     jPanel2.add(smoothFont);
1672     jPanel2.add(scaleProteinToCdna);
1673     jPanel2.add(gapLabel);
1674     jPanel2.add(wrap);
1675     jPanel2.add(sortLabel);
1676     jPanel2.add(sortAnnLabel);
1677     jPanel2.add(startupCheckbox);
1678     visualTab.add(jPanel2);
1679     visualTab.add(startupFileTextfield);
1680     visualTab.add(sortby);
1681     visualTab.add(sortAnnBy);
1682     visualTab.add(sortAutocalc);
1683     visualTab.add(gapSymbolCB);
1684     visualTab.add(fontNameCB);
1685     visualTab.add(fontSizeCB);
1686     visualTab.add(fontStyleCB);
1687     return visualTab;
1688   }
1689
1690   /**
1691    * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1692    */
1693
1694   protected void loadLastSavedBackupsOptions()
1695   {
1696     enableBackupFiles
1697             .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1698     setComboIntStringKey(backupfilesPresetsCombo,
1699             Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1700     suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1701             ".bak" + BackupFiles.NUM_PLACEHOLDER));
1702     suffixDigitsSpinner
1703             .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1704     suffixReverse.setSelected(
1705             Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1706     backupfilesKeepAll
1707             .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1708     backupfilesRollMaxSpinner
1709             .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1710     backupfilesConfirmDelete.setSelected(
1711             Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1712
1713     backupsOptionsSetEnabled();
1714     updateBackupFilesExampleLabel();
1715   }
1716
1717   /**
1718    * Initialises the Backups tabbed panel.
1719    * 
1720    * @return
1721    */
1722   private JPanel initBackupsTab()
1723   {
1724     JPanel backupsTab = new JPanel();
1725     backupsTab.setBorder(new TitledBorder(
1726             MessageManager.getString("label.backup_files")));
1727     backupsTab.setLayout(new GridBagLayout());
1728
1729     GridBagConstraints gbc = new GridBagConstraints();
1730     gbc.weightx = 1.0;
1731     gbc.weighty = 0.0;
1732     gbc.anchor = GridBagConstraints.NORTHWEST;
1733     gbc.fill = GridBagConstraints.NONE;
1734
1735     initBackupsTabPresetsPanel();
1736     initBackupsTabSuffixPanel();
1737     initBackupsTabKeepFilesPanel();
1738     initBackupsTabFilenameExamplesPanel();
1739
1740     gbc.weightx = 0.5;
1741     enableBackupFiles.setFont(LABEL_FONT_BOLD);
1742     enableBackupFiles
1743             .setText(MessageManager.getString("label.enable_backupfiles"));
1744     enableBackupFiles.addActionListener(new ActionListener()
1745     {
1746       @Override
1747       public void actionPerformed(ActionEvent e)
1748       {
1749         boolean selected = enableBackupFiles.isSelected();
1750         // enable other options only when the first is checked
1751         backupsOptionsSetEnabled();
1752       }
1753     });
1754
1755     // enable checkbox 1 row
1756     gbc.gridwidth = 1;
1757     gbc.gridx = 0;
1758     gbc.gridy = 0;
1759     backupsTab.add(enableBackupFiles, gbc);
1760
1761     gbc.gridx = 1;
1762     gbc.weightx = 1.0;
1763     gbc.gridheight = 2;
1764     // gbc.anchor = GridBagConstraints.NORTHEAST;
1765     // gbc.fill = GridBagConstraints.HORIZONTAL;
1766     backupsTab.add(exampleFilesPanel, gbc);
1767
1768     gbc.gridx = 0;
1769     gbc.gridy = 1;
1770     backupsTab.add(presetsPanel, gbc);
1771
1772     gbc.anchor = GridBagConstraints.NORTHWEST;
1773     gbc.fill = GridBagConstraints.NONE;
1774     gbc.gridwidth = 2;
1775     gbc.gridheight = 1;
1776     // whole suffix panel next row
1777     gbc.gridx = 0;
1778     gbc.gridy = 2;
1779     backupsTab.add(keepfilesPanel, gbc);
1780
1781     // keep files panel
1782     gbc.gridy = 3;
1783     backupsTab.add(suffixPanel, gbc);
1784
1785     // fill empty space
1786     gbc.gridy = 4;
1787     gbc.weighty = 1.0;
1788     backupsTab.add(new JPanel(), gbc);
1789
1790     backupsOptionsSetEnabled();
1791     return backupsTab;
1792   }
1793
1794   private final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1795       new IntKeyStringValueEntry(1,
1796               MessageManager.getString("label.default")),
1797       new IntKeyStringValueEntry(2,
1798               MessageManager.getString("label.single_file")),
1799       new IntKeyStringValueEntry(3,
1800               MessageManager.getString("label.keep_all_versions")),
1801       new IntKeyStringValueEntry(4,
1802               MessageManager.getString("label.rolled_backups")),
1803       // ...
1804       new IntKeyStringValueEntry(255,
1805               MessageManager.getString("label.previously_saved_scheme")),
1806       // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1807       new IntKeyStringValueEntry(0,
1808               MessageManager.getString("label.customise")) };
1809
1810   private final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1811   {
1812     {
1813       put(1, new BackupFilesPresetEntry(
1814               ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1815               false));
1816       put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1817       put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1818               3, false, true, 10, true));
1819       put(4, new BackupFilesPresetEntry(
1820               "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1821               false));
1822     }
1823   };
1824
1825   private JPanel initBackupsTabPresetsPanel()
1826   {
1827     presetsPanel.setBorder(
1828             new TitledBorder(MessageManager.getString("label.schemes")));
1829
1830     for (int i = 0; i < backupfilesPresetEntries.length; i++)
1831     {
1832       backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1833     }
1834
1835     // put "Previously saved scheme" item in italics (it's not really
1836     // selectable, as such -- it deselects itself when selected) and
1837     // "Customise" in bold
1838     backupfilesPresetsCombo
1839             .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1840     backupfilesPresetsCombo.addActionListener(new ActionListener()
1841     {
1842       @Override
1843       public void actionPerformed(ActionEvent e)
1844       {
1845         backupsTabUpdatePresets();
1846       }
1847     });
1848
1849     presetsPanel.add(backupfilesPresetsCombo);
1850     return presetsPanel;
1851   }
1852
1853   private void backupsTabUpdatePresets()
1854   {
1855     IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1856             .getSelectedItem();
1857     int key = entry.getKey();
1858     String value = entry.getValue();
1859     // 0 reserved for "Custom" and 255 reserved or "Previously saved scheme"
1860     boolean special = key == 0 || key == 255;
1861
1862     if (special)
1863     {
1864       if (key == 0)
1865       {
1866         // backupsSetCustomOptions();
1867       }
1868       else if (key == 255)
1869       {
1870         loadLastSavedBackupsOptions();
1871         // switch to "Customise" scheme? probably not
1872         // setComboIntStringKey(backupfilesPresetsCombo, 0);
1873       }
1874     }
1875     else
1876     {
1877       if (backupfilesPresetEntriesValues.containsKey(key))
1878       {
1879         backupsSetOptions(backupfilesPresetEntriesValues.get(key));
1880       }
1881       else
1882       {
1883         System.out.println("Preset '" + value + "' not implemented");
1884       }
1885     }
1886
1887     backupfilesCustomOptionsSetEnabled();
1888     updateBackupFilesExampleLabel();
1889   }
1890
1891   protected int getComboIntStringKey(JComboBox c)
1892   {
1893     IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
1894     return e != null ? e.getKey() : 0;
1895   }
1896
1897   protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
1898           int key)
1899   {
1900     for (int i = 0; i < c.getItemCount(); i++)
1901     {
1902       IntKeyStringValueEntry e = c.getItemAt(i);
1903       int k = e.getKey();
1904       String v = e.getValue();
1905       if (e.getKey() == key)
1906       {
1907         c.setSelectedIndex(i);
1908         break;
1909       }
1910     }
1911     backupsTabUpdatePresets();
1912   }
1913
1914   private JPanel initBackupsTabSuffixPanel()
1915   {
1916     suffixPanel.setBorder(new TitledBorder(
1917             MessageManager.getString("label.backup_filename_strategy")));
1918     suffixPanel.setLayout(new GridBagLayout());
1919
1920     suffixTemplateLabel
1921             .setText(MessageManager.getString("label.append_to_filename"));
1922     suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
1923     suffixTemplateLabel.setFont(LABEL_FONT);
1924
1925     final String tooltip = JvSwingUtils.wrapTooltip(true,
1926             MessageManager.getString("label.append_to_filename_tooltip"));
1927     suffixTemplate.setToolTipText(tooltip);
1928     suffixTemplate.addActionListener(new ActionListener()
1929     {
1930       @Override
1931       public void actionPerformed(ActionEvent e)
1932       {
1933         updateBackupFilesExampleLabel();
1934         backupfilesCustomOptionsSetEnabled();
1935       }
1936
1937     });
1938     KeyListener kl = new KeyListener()
1939     {
1940       @Override
1941       public void keyReleased(KeyEvent e)
1942       {
1943         updateBackupFilesExampleLabel();
1944         backupfilesCustomOptionsSetEnabled();
1945       }
1946
1947       @Override
1948       public void keyPressed(KeyEvent e)
1949       {
1950       }
1951
1952       // disable use of ':' or '/' or '\'
1953       @Override
1954       public void keyTyped(KeyEvent e)
1955       {
1956         char c = e.getKeyChar();
1957         if (c == ':' || c == '/' || c == '\\')
1958         {
1959           // don't process ':' or '/' or '\'
1960           e.consume();
1961         }
1962       }
1963
1964     };
1965     suffixTemplate.addKeyListener(kl);
1966
1967     // digits spinner
1968     suffixDigitsLabel
1969             .setText(MessageManager.getString("label.index_digits"));
1970     suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1971     suffixDigitsLabel.setFont(LABEL_FONT);
1972     int defaultmin = 1;
1973     int defaultmax = 6;
1974     ChangeListener c = new ChangeListener()
1975     {
1976       @Override
1977       public void stateChanged(ChangeEvent e)
1978       {
1979         updateBackupFilesExampleLabel();
1980       }
1981
1982     };
1983     setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
1984
1985     suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
1986             MessageManager.getString("label.increment_index"));
1987     suffixReverse.addActionListener(new ActionListener()
1988     {
1989       @Override
1990       public void actionPerformed(ActionEvent e)
1991       {
1992         updateBackupFilesExampleLabel();
1993       }
1994     });
1995
1996     GridBagConstraints sgbc = new GridBagConstraints();
1997
1998     // first row (template text box)
1999     sgbc.anchor = GridBagConstraints.WEST;
2000     sgbc.gridx = 0;
2001     sgbc.gridy = 0;
2002     sgbc.gridwidth = 1;
2003     sgbc.gridheight = 1;
2004     sgbc.weightx = 1.0;
2005     sgbc.weighty = 0.0;
2006     sgbc.fill = GridBagConstraints.NONE;
2007     suffixPanel.add(suffixTemplateLabel, sgbc);
2008
2009     sgbc.gridx = 1;
2010     sgbc.fill = GridBagConstraints.HORIZONTAL;
2011     suffixPanel.add(suffixTemplate, sgbc);
2012
2013     // second row (number of digits spinner)
2014     sgbc.gridy = 1;
2015
2016     sgbc.gridx = 0;
2017     sgbc.fill = GridBagConstraints.NONE;
2018     suffixPanel.add(suffixDigitsLabel, sgbc);
2019
2020     sgbc.gridx = 1;
2021     sgbc.fill = GridBagConstraints.HORIZONTAL;
2022     suffixPanel.add(suffixDigitsSpinner, sgbc);
2023
2024     // third row (forward order radio selection)
2025     sgbc.gridx = 0;
2026     sgbc.gridy = 2;
2027     sgbc.gridwidth = GridBagConstraints.REMAINDER;
2028     sgbc.fill = GridBagConstraints.HORIZONTAL;
2029     suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2030
2031     // fourth row (reverse order radio selection)
2032     sgbc.gridy = 3;
2033     suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2034     return suffixPanel;
2035   }
2036
2037   private JPanel initBackupsTabKeepFilesPanel()
2038   {
2039     keepfilesPanel.setBorder(
2040             new TitledBorder(MessageManager.getString("label.keep_files")));
2041     keepfilesPanel.setLayout(new GridBagLayout());
2042
2043     backupfilesKeepAll.setLabels(
2044             MessageManager.getString("label.keep_all_backup_files"),
2045             MessageManager.getString(
2046                     "label.keep_only_this_number_of_backup_files"));
2047     backupfilesKeepAll.addTrueActionListener(new ActionListener()
2048     {
2049       @Override
2050       public void actionPerformed(ActionEvent e)
2051       {
2052         updateBackupFilesExampleLabel();
2053       }
2054     });
2055     backupfilesKeepAll.addActionListener(new ActionListener()
2056     {
2057       @Override
2058       public void actionPerformed(ActionEvent e)
2059       {
2060         boolean selected = backupfilesKeepAll.isSelected();
2061         keepRollMaxOptionsEnabled();
2062         updateBackupFilesExampleLabel();
2063       }
2064     });
2065
2066     ChangeListener c = new ChangeListener()
2067     {
2068       @Override
2069       public void stateChanged(ChangeEvent e)
2070       {
2071         updateBackupFilesExampleLabel();
2072       }
2073
2074     };
2075     setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2076
2077     backupfilesConfirmDelete.setLabels(
2078             MessageManager.getString("label.confirm_delete"),
2079             MessageManager.getString("label.auto_delete"));
2080     // update the enabled section
2081     keepRollMaxOptionsEnabled();
2082
2083     GridBagConstraints kgbc = new GridBagConstraints();
2084
2085     // first row (template text box)
2086     kgbc.anchor = GridBagConstraints.WEST;
2087     kgbc.gridx = 0;
2088     kgbc.gridy = 0;
2089     kgbc.gridwidth = GridBagConstraints.REMAINDER;
2090     kgbc.gridheight = 1;
2091     kgbc.weightx = 1.0;
2092     kgbc.weighty = 0.0;
2093     kgbc.fill = GridBagConstraints.HORIZONTAL;
2094     keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2095
2096     // second row
2097     kgbc.gridy = 1;
2098
2099     kgbc.gridx = 0;
2100     kgbc.gridwidth = GridBagConstraints.RELATIVE;
2101     keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2102
2103     kgbc.gridx = 1;
2104     kgbc.gridwidth = GridBagConstraints.REMAINDER;
2105     keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2106
2107     // third row (indented)
2108     kgbc.gridy = 2;
2109     kgbc.insets = new Insets(0, 20, 0, 0);
2110
2111     kgbc.gridx = 0;
2112     kgbc.gridwidth = GridBagConstraints.REMAINDER;
2113     kgbc.fill = GridBagConstraints.HORIZONTAL;
2114     kgbc.weightx = 1.0;
2115     /*
2116     keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2117     
2118     // fourth row (indented)
2119     kgbc.gridy = 3;
2120     keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2121     */
2122
2123     JPanel jp = new JPanel();
2124     jp.setLayout(new FlowLayout());
2125     oldBackupFilesLabel
2126             .setText(MessageManager
2127                     .getString("label.autodelete_old_backup_files"));
2128     oldBackupFilesLabel.setFont(LABEL_FONT);
2129     oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2130     jp.add(oldBackupFilesLabel);
2131     jp.add(backupfilesConfirmDelete.getTrueButton());
2132     jp.add(backupfilesConfirmDelete.getFalseButton());
2133     keepfilesPanel.add(jp, kgbc);
2134
2135     return keepfilesPanel;
2136   }
2137
2138   private JPanel initBackupsTabFilenameExamplesPanel()
2139   {
2140     String title = MessageManager
2141             .getString("label.summary_of_backups_scheme");
2142     TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
2143     // tb.setTitleFont(LABEL_FONT);
2144     exampleFilesPanel.setBorder(tb);
2145     exampleFilesPanel.setLayout(new GridBagLayout());
2146
2147     // inordinately difficult to get this titledborder the right size for the
2148     // title
2149
2150     backupfilesExampleLabel.setEditable(false);
2151     backupfilesExampleLabel.setPreferredSize(new Dimension(280, 85));
2152     backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
2153     backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
2154
2155     backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2156     backupfilesExampleLabel
2157             .setBackground(exampleFilesPanel.getBackground());
2158
2159     updateBackupFilesExampleLabel();
2160     exampleFilesPanel.setMinimumSize(new Dimension(280, 85));
2161
2162     GridBagConstraints gbc = new GridBagConstraints();
2163     gbc.anchor = GridBagConstraints.EAST;
2164
2165     gbc.gridy = 0;
2166     exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2167     return exampleFilesPanel;
2168   }
2169
2170   protected void updateBackupFilesExampleLabel()
2171   {
2172     int exampleindex = 12;
2173     String base = MessageManager.getString("label.filename");
2174     if (base == null || base.length() == 0)
2175     {
2176       base = "file_name.fa";
2177     }
2178
2179     boolean reverse = suffixReverse.isSelected();
2180     boolean keepAll = backupfilesKeepAll.isSelected();
2181     int rollMax = 4;
2182     String suffix = suffixTemplate.getText();
2183     int digits = 3;
2184
2185     backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2186     if (suffix == null || suffix.length() == 0)
2187     {
2188       backupfilesExampleLabel
2189               .setText(MessageManager.getString("label.no_backup_files"));
2190       backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2191       return;
2192     }
2193
2194     try
2195     {
2196       backupfilesRollMaxSpinner.commitEdit();
2197       rollMax = (Integer) backupfilesRollMaxSpinner.getValue();
2198       rollMax = rollMax < 1 ? 1 : rollMax;
2199     } catch (Exception e)
2200     {
2201       System.out.println(
2202               "Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
2203     }
2204
2205     if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2206     {
2207       rollMax = 1;
2208     }
2209
2210     try
2211     {
2212       suffixDigitsSpinner.commitEdit();
2213       digits = (Integer) suffixDigitsSpinner.getValue();
2214       digits = digits < 1 ? 1 : digits;
2215     } catch (Exception e)
2216     {
2217       System.out.println(
2218               "Failed casting (Integer) suffixTemplateSpinner.getValue()");
2219     }
2220
2221     int lowersurround = 2;
2222     int uppersurround = 0;
2223     StringBuilder exampleSB = new StringBuilder();
2224     boolean firstLine = true;
2225     if (reverse)
2226     {
2227
2228       int min = 1;
2229       int max = keepAll ? exampleindex : rollMax;
2230       for (int index = min; index <= max; index++)
2231       {
2232         if (index == min + lowersurround && index < max - uppersurround - 1)
2233         {
2234           exampleSB.append("\n...");
2235         }
2236         else if (index > min + lowersurround && index < max - uppersurround)
2237         {
2238           // nothing
2239         }
2240         else
2241         {
2242           if (firstLine)
2243           {
2244             firstLine = false;
2245           }
2246           else
2247           {
2248             exampleSB.append("\n");
2249           }
2250           exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2251                   base, suffix, digits));
2252           if (min == max)
2253           {
2254             // no extra text needed
2255           }
2256           else if (index == min)
2257           {
2258             String newest = MessageManager.getString("label.braced_newest");
2259             if (newest != null && newest.length() > 0)
2260             {
2261               exampleSB.append(" " + newest);
2262             }
2263           }
2264           else if (index == max)
2265           {
2266             String oldest = MessageManager.getString("label.braced_oldest");
2267             if (oldest != null && oldest.length() > 0)
2268             {
2269               exampleSB.append(" " + oldest);
2270             }
2271           }
2272         }
2273       }
2274     }
2275     else
2276     {
2277
2278       int min = (keepAll || exampleindex - rollMax < 0) ? 1
2279               : exampleindex - rollMax + 1;
2280       int max = exampleindex;
2281
2282       for (int index = min; index <= max; index++)
2283       {
2284
2285         if (index == min + lowersurround && index < max - uppersurround - 1)
2286         {
2287           exampleSB.append("\n...");
2288         }
2289         else if (index > min + lowersurround && index < max - uppersurround)
2290         {
2291           // nothing
2292         }
2293         else
2294         {
2295           if (firstLine)
2296           {
2297             firstLine = false;
2298           }
2299           else
2300           {
2301             exampleSB.append("\n");
2302           }
2303           exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2304                   base, suffix, digits));
2305           if (min == max)
2306           {
2307             // no extra text needed
2308           }
2309           else if (index == min)
2310           {
2311             String oldest = MessageManager.getString("label.braced_oldest");
2312             if (oldest != null && oldest.length() > 0)
2313             {
2314               exampleSB.append(" " + oldest);
2315             }
2316           }
2317           else if (index == max)
2318           {
2319             String newest = MessageManager.getString("label.braced_newest");
2320             if (newest != null && newest.length() > 0)
2321             {
2322               exampleSB.append(" " + newest);
2323             }
2324           }
2325         }
2326       }
2327
2328     }
2329
2330     backupfilesExampleLabel.setText(exampleSB.toString());
2331   }
2332
2333   protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2334           boolean useExistingVal, ChangeListener c)
2335   {
2336     int i = def;
2337     if (useExistingVal)
2338     {
2339       try
2340       {
2341         i = Integer.parseInt((String) s.getValue());
2342       } catch (Exception e)
2343       {
2344         System.out.println(
2345                 "Exception casting the initial value of s.getValue()");
2346       }
2347     }
2348
2349     setIntegerSpinner(s, min, max, i, c);
2350   }
2351
2352   protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2353           ChangeListener c)
2354   {
2355     // integer spinner for number of digits
2356     if (def > max)
2357     {
2358       max = def;
2359     }
2360     SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2361     s.setModel(sModel);
2362
2363     s.addChangeListener(c);
2364
2365   }
2366
2367   protected static int getSpinnerInt(JSpinner s, int def)
2368   {
2369     int i = def;
2370     try
2371     {
2372       s.commitEdit();
2373       i = (Integer) s.getValue();
2374     } catch (Exception e)
2375     {
2376       System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2377     }
2378     return i;
2379   }
2380
2381   private void keepRollMaxOptionsEnabled()
2382   {
2383     boolean enabled = backupfilesKeepAll.isEnabled()
2384             && !backupfilesKeepAll.isSelected();
2385     oldBackupFilesLabel.setEnabled(enabled);
2386     backupfilesRollMaxSpinner.setEnabled(enabled);
2387     backupfilesConfirmDelete.setEnabled(enabled);
2388   }
2389
2390   private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2391   {
2392     boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2393             && getComboIntStringKey(backupfilesPresetsCombo) == 0
2394             && suffixTemplate.getText()
2395                     .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2396     keepfilesPanel.setEnabled(enabled);
2397     backupfilesKeepAll.setEnabled(enabled);
2398     oldBackupFilesLabel.setEnabled(enabled);
2399     keepRollMaxOptionsEnabled();
2400   }
2401
2402   private void backupfilesSuffixTemplateDigitsSetEnabled()
2403   {
2404     boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2405             .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2406     suffixDigitsLabel.setEnabled(enabled);
2407     suffixDigitsSpinner.setEnabled(enabled);
2408     suffixReverse.setEnabled(enabled);
2409   }
2410
2411   private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2412   {
2413     boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2414             && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2415     suffixPanel.setEnabled(enabled);
2416     suffixTemplateLabel.setEnabled(enabled);
2417     suffixTemplate.setEnabled(enabled);
2418     backupfilesSuffixTemplateDigitsSetEnabled();
2419   }
2420
2421   protected void backupfilesCustomOptionsSetEnabled()
2422   {
2423     int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2424     boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2425
2426     backupfilesSuffixTemplateSetEnabled(enabled);
2427     backupfilesKeepAllSetEnabled(enabled);
2428   }
2429
2430   private void backupfilesSummarySetEnabled()
2431   {
2432     boolean enabled = enableBackupFiles.isSelected();
2433     backupfilesExampleLabel.setEnabled(enabled);
2434     exampleFilesPanel.setEnabled(enabled);
2435   }
2436
2437   private void backupfilesPresetsSetEnabled()
2438   {
2439     boolean enabled = enableBackupFiles.isSelected();
2440     presetsPanel.setEnabled(enabled);
2441     backupfilesPresetsCombo.setEnabled(enabled);
2442   }
2443
2444   protected void backupsOptionsSetEnabled()
2445   {
2446     backupfilesPresetsSetEnabled();
2447     backupfilesSummarySetEnabled();
2448     backupfilesCustomOptionsSetEnabled();
2449   }
2450
2451   protected void backupsSetOptions(String suffix, int digits,
2452           boolean reverse, boolean keepAll, int rollMax,
2453           boolean confirmDelete)
2454   {
2455     suffixTemplate.setText(suffix);
2456     suffixDigitsSpinner.setValue(digits);
2457     suffixReverse.setSelected(reverse);
2458     backupfilesKeepAll.setSelected(keepAll);
2459     backupfilesRollMaxSpinner.setValue(rollMax);
2460     backupfilesConfirmDelete.setSelected(confirmDelete);
2461   }
2462
2463   protected void backupsSetOptions(BackupFilesPresetEntry p)
2464   {
2465     backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2466             p.confirmDelete);
2467   }
2468
2469   protected void autoIdWidth_actionPerformed()
2470   {
2471     // TODO Auto-generated method stub
2472
2473   }
2474
2475   protected void userIdWidth_actionPerformed()
2476   {
2477     // TODO Auto-generated method stub
2478
2479   }
2480
2481   protected void maxColour_actionPerformed(JPanel panel)
2482   {
2483   }
2484
2485   protected void minColour_actionPerformed(JPanel panel)
2486   {
2487   }
2488
2489   protected void gapColour_actionPerformed(JPanel panel)
2490   {
2491   }
2492
2493   protected void hiddenColour_actionPerformed(JPanel panel)
2494   {
2495   }
2496
2497   protected void showunconserved_actionPerformed(ActionEvent e)
2498   {
2499     // TODO Auto-generated method stub
2500
2501   }
2502
2503   protected void useLegacyGaps_actionPerformed(ActionEvent e)
2504   {
2505   }
2506
2507   protected void resetOvDefaults_actionPerformed(ActionEvent e)
2508   {
2509   }
2510
2511   /**
2512    * DOCUMENT ME!
2513    * 
2514    * @param e
2515    *          DOCUMENT ME!
2516    */
2517   public void ok_actionPerformed(ActionEvent e)
2518   {
2519   }
2520
2521   /**
2522    * DOCUMENT ME!
2523    * 
2524    * @param e
2525    *          DOCUMENT ME!
2526    */
2527   public void cancel_actionPerformed(ActionEvent e)
2528   {
2529   }
2530
2531   /**
2532    * DOCUMENT ME!
2533    * 
2534    * @param e
2535    *          DOCUMENT ME!
2536    */
2537   public void annotations_actionPerformed(ActionEvent e)
2538   {
2539   }
2540
2541   /**
2542    * DOCUMENT ME!
2543    */
2544   public void startupFileTextfield_mouseClicked()
2545   {
2546   }
2547
2548   public void newLink_actionPerformed(ActionEvent e)
2549   {
2550
2551   }
2552
2553   public void editLink_actionPerformed(ActionEvent e)
2554   {
2555
2556   }
2557
2558   public void deleteLink_actionPerformed(ActionEvent e)
2559   {
2560
2561   }
2562
2563   public void defaultBrowser_mouseClicked(MouseEvent e)
2564   {
2565
2566   }
2567
2568   public void linkURLList_keyTyped(KeyEvent e)
2569   {
2570
2571   }
2572
2573   public void useProxy_actionPerformed()
2574   {
2575     boolean enabled = useProxy.isSelected();
2576     portLabel.setEnabled(enabled);
2577     serverLabel.setEnabled(enabled);
2578     proxyServerTB.setEnabled(enabled);
2579     proxyPortTB.setEnabled(enabled);
2580   }
2581
2582   /**
2583    * Customer renderer for JTable: supports column of radio buttons
2584    */
2585   public class RadioButtonRenderer extends JRadioButton
2586           implements TableCellRenderer
2587   {
2588     public RadioButtonRenderer()
2589     {
2590       setHorizontalAlignment(CENTER);
2591       setToolTipText(MessageManager.getString("label.urltooltip"));
2592     }
2593
2594     @Override
2595     public Component getTableCellRendererComponent(JTable table,
2596             Object value, boolean isSelected, boolean hasFocus, int row,
2597             int column)
2598     {
2599       setSelected((boolean) value);
2600
2601       // set colours to match rest of table
2602       if (isSelected)
2603       {
2604         setBackground(table.getSelectionBackground());
2605         setForeground(table.getSelectionForeground());
2606       }
2607       else
2608       {
2609         setBackground(table.getBackground());
2610         setForeground(table.getForeground());
2611       }
2612       return this;
2613     }
2614   }
2615
2616   /**
2617    * Customer cell editor for JTable: supports column of radio buttons in
2618    * conjunction with renderer
2619    */
2620   public class RadioButtonEditor extends AbstractCellEditor
2621           implements TableCellEditor
2622   {
2623     private JRadioButton button = new JRadioButton();
2624
2625     public RadioButtonEditor()
2626     {
2627       button.setHorizontalAlignment(SwingConstants.CENTER);
2628       this.button.addActionListener(new ActionListener()
2629       {
2630         @Override
2631         public void actionPerformed(ActionEvent e)
2632         {
2633           fireEditingStopped();
2634         }
2635       });
2636     }
2637
2638     @Override
2639     public Component getTableCellEditorComponent(JTable table, Object value,
2640             boolean isSelected, int row, int column)
2641     {
2642       button.setSelected((boolean) value);
2643       return button;
2644     }
2645
2646     @Override
2647     public Object getCellEditorValue()
2648     {
2649       return button.isSelected();
2650     }
2651
2652   }
2653 }
2654
2655 class IntKeyStringValueEntry
2656 {
2657   int k;
2658
2659   String v;
2660
2661   public IntKeyStringValueEntry(int k, String v)
2662   {
2663     this.k = k;
2664     this.v = v;
2665   }
2666
2667   @Override
2668   public String toString()
2669   {
2670     return this.getValue();
2671   }
2672
2673   public int getKey()
2674   {
2675     return k;
2676   }
2677
2678   public String getValue()
2679   {
2680     return v;
2681   }
2682 }
2683
2684 class BackupFilesPresetEntry
2685 {
2686   String suffix;
2687
2688   int digits;
2689
2690   boolean reverse;
2691
2692   boolean keepAll;
2693
2694   int rollMax;
2695
2696   boolean confirmDelete;
2697
2698   public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2699           boolean keepAll, int rollMax, boolean confirmDelete)
2700   {
2701     this.suffix = suffix;
2702     this.digits = digits;
2703     this.reverse = reverse;
2704     this.keepAll = keepAll;
2705     this.rollMax = rollMax;
2706     this.confirmDelete = confirmDelete;
2707   }
2708 }
2709
2710 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2711 {
2712   @Override
2713   public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
2714     super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2715     
2716     try {
2717       IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2718       if (e.getKey() == 255)
2719       {
2720         // "Previously saved scheme" item
2721         this.setFont(this.getFont().deriveFont(Font.ITALIC));
2722       }
2723       else if (e.getKey() == 0)
2724       {
2725         // "Customise" item
2726         this.setFont(this.getFont().deriveFont(Font.BOLD));
2727       }
2728     } catch (Exception e) {
2729       return this;
2730     }
2731
2732     return this;
2733   }
2734 }