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