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