9023864ab2ca9b3a2e91be48376ee9d989359c82
[jalview.git] / src / jalview / jbgui / GPreferences.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.jbgui;
22
23 import jalview.fts.core.FTSDataColumnPreferences;
24 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
25 import jalview.fts.service.pdb.PDBFTSRestClient;
26 import jalview.gui.JvSwingUtils;
27 import jalview.gui.StructureViewer.ViewerType;
28 import jalview.util.MessageManager;
29
30 import java.awt.BorderLayout;
31 import java.awt.Color;
32 import java.awt.Component;
33 import java.awt.Dimension;
34 import java.awt.FlowLayout;
35 import java.awt.Font;
36 import java.awt.GridBagConstraints;
37 import java.awt.GridBagLayout;
38 import java.awt.GridLayout;
39 import java.awt.Insets;
40 import java.awt.Rectangle;
41 import java.awt.event.ActionEvent;
42 import java.awt.event.ActionListener;
43 import java.awt.event.FocusEvent;
44 import java.awt.event.KeyEvent;
45 import java.awt.event.MouseAdapter;
46 import java.awt.event.MouseEvent;
47
48 import javax.swing.AbstractCellEditor;
49 import javax.swing.BorderFactory;
50 import javax.swing.ButtonGroup;
51 import javax.swing.DefaultListCellRenderer;
52 import javax.swing.JButton;
53 import javax.swing.JCheckBox;
54 import javax.swing.JComboBox;
55 import javax.swing.JFileChooser;
56 import javax.swing.JLabel;
57 import javax.swing.JPanel;
58 import javax.swing.JRadioButton;
59 import javax.swing.JScrollPane;
60 import javax.swing.JTabbedPane;
61 import javax.swing.JTable;
62 import javax.swing.JTextField;
63 import javax.swing.ListSelectionModel;
64 import javax.swing.SwingConstants;
65 import javax.swing.border.Border;
66 import javax.swing.border.EmptyBorder;
67 import javax.swing.border.EtchedBorder;
68 import javax.swing.border.TitledBorder;
69 import javax.swing.event.ChangeEvent;
70 import javax.swing.event.ChangeListener;
71 import javax.swing.table.TableCellEditor;
72 import javax.swing.table.TableCellRenderer;
73
74 /**
75  * Base class for the Preferences panel.
76  * 
77  * @author $author$
78  * @version $Revision$
79  */
80 public class GPreferences extends JPanel
81 {
82   private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
83
84   private static final Font LABEL_FONT_ITALIC = JvSwingUtils
85           .getLabelFont(false, true);
86
87   /*
88    * Visual tab components
89    */
90   protected JCheckBox fullScreen = new JCheckBox();
91
92   protected JCheckBox openoverv = new JCheckBox();
93
94   protected JCheckBox seqLimit = new JCheckBox();
95
96   protected JCheckBox rightAlign = new JCheckBox();
97
98   protected JComboBox<String> fontSizeCB = new JComboBox<>();
99
100   protected JComboBox<String> fontStyleCB = new JComboBox<>();
101
102   protected JComboBox<String> fontNameCB = new JComboBox<>();
103
104   protected JCheckBox showOccupancy = new JCheckBox();
105
106   protected JCheckBox showUnconserved = new JCheckBox();
107
108   protected JCheckBox idItalics = new JCheckBox();
109
110   protected JCheckBox smoothFont = new JCheckBox();
111
112   protected JCheckBox scaleProteinToCdna = new JCheckBox();
113
114   protected JComboBox<String> gapSymbolCB = new JComboBox<>();
115
116   protected JCheckBox wrap = new JCheckBox();
117
118   protected JComboBox<String> sortby = new JComboBox<>();
119
120   protected JComboBox<String> sortAnnBy = new JComboBox<>();
121
122   protected JComboBox<String> sortAutocalc = new JComboBox<>();
123
124   protected JCheckBox startupCheckbox = new JCheckBox();
125
126   protected JTextField startupFileTextfield = new JTextField();
127
128   // below are in the 'second column'
129   protected JCheckBox annotations = new JCheckBox();
130
131   protected JCheckBox quality = new JCheckBox();
132
133   protected JCheckBox conservation = new JCheckBox();
134
135   protected JCheckBox identity = new JCheckBox();
136
137   protected JCheckBox showGroupConsensus = new JCheckBox();
138
139   protected JCheckBox showGroupConservation = new JCheckBox();
140
141   protected JCheckBox showConsensHistogram = new JCheckBox();
142
143   protected JCheckBox showConsensLogo = new JCheckBox();
144
145   protected JCheckBox showDbRefTooltip = new JCheckBox();
146
147   protected JCheckBox showNpTooltip = new JCheckBox();
148
149   /*
150    * Structure tab and components
151    */
152   protected JPanel structureTab;
153
154   protected JCheckBox structFromPdb = new JCheckBox();
155
156   protected JCheckBox useRnaView = new JCheckBox();
157
158   protected JCheckBox addSecondaryStructure = new JCheckBox();
159
160   protected JCheckBox addTempFactor = new JCheckBox();
161
162   protected JComboBox<String> structViewer = new JComboBox<>();
163
164   protected JTextField chimeraPath = new JTextField();
165
166   protected ButtonGroup mappingMethod = new ButtonGroup();
167
168   protected JRadioButton siftsMapping = new JRadioButton();
169
170   protected JRadioButton nwMapping = new JRadioButton();
171
172   /*
173    * Colours tab components
174    */
175   protected JPanel minColour = new JPanel();
176
177   protected JPanel maxColour = new JPanel();
178
179   protected JComboBox<String> protColour = new JComboBox<>();
180
181   protected JComboBox<String> nucColour = new JComboBox<>();
182
183   /*
184    * Overview tab components
185    */
186   protected JPanel gapColour = new JPanel();
187
188   protected JPanel hiddenColour = new JPanel();
189
190   protected JCheckBox useLegacyGap;
191
192   protected JCheckBox showHiddenAtStart;
193
194   protected JLabel gapLabel;
195
196   /*
197    * Connections tab components
198    */
199   protected JTable linkUrlTable = new JTable();
200
201   protected JButton editLink = new JButton();
202
203   protected JButton deleteLink = new JButton();
204
205   protected JTextField filterTB = new JTextField();
206
207   protected JButton doReset = new JButton();
208
209   protected JButton userOnly = new JButton();
210
211   protected JLabel portLabel = new JLabel();
212
213   protected JLabel serverLabel = new JLabel();
214
215   protected JTextField proxyServerTB = new JTextField();
216
217   protected JTextField proxyPortTB = new JTextField();
218
219   protected JTextField defaultBrowser = new JTextField();
220
221   protected JCheckBox useProxy = new JCheckBox();
222
223   protected JCheckBox usagestats = new JCheckBox();
224
225   protected JCheckBox questionnaire = new JCheckBox();
226
227   protected JCheckBox versioncheck = new JCheckBox();
228
229   /*
230    * Output tab components
231    */
232   protected JComboBox<Object> epsRendering = new JComboBox<>();
233
234   protected JLabel userIdWidthlabel = new JLabel();
235
236   protected JCheckBox autoIdWidth = new JCheckBox();
237
238   protected JTextField userIdWidth = new JTextField();
239
240   protected JCheckBox blcjv = new JCheckBox();
241
242   protected JCheckBox pileupjv = new JCheckBox();
243
244   protected JCheckBox clustaljv = new JCheckBox();
245
246   protected JCheckBox msfjv = new JCheckBox();
247
248   protected JCheckBox fastajv = new JCheckBox();
249
250   protected JCheckBox pfamjv = new JCheckBox();
251
252   protected JCheckBox pirjv = new JCheckBox();
253
254   protected JCheckBox modellerOutput = new JCheckBox();
255
256   protected JCheckBox embbedBioJSON = new JCheckBox();
257
258   /*
259    * Editing tab components
260    */
261   protected JCheckBox autoCalculateConsCheck = new JCheckBox();
262
263   protected JCheckBox padGaps = new JCheckBox();
264
265   protected JCheckBox sortByTree = new JCheckBox();
266
267
268   /*
269    * Web Services tab
270    */
271   protected JPanel wsTab = new JPanel();
272
273   /**
274    * Creates a new GPreferences object.
275    */
276   public GPreferences()
277   {
278     try
279     {
280       jbInit();
281     } catch (Exception ex)
282     {
283       ex.printStackTrace();
284     }
285   }
286
287   /**
288    * Construct the panel and its tabbed sub-panels.
289    * 
290    * @throws Exception
291    */
292   private void jbInit() throws Exception
293   {
294     final JTabbedPane tabbedPane = new JTabbedPane();
295     this.setLayout(new BorderLayout());
296     JPanel okCancelPanel = initOkCancelPanel();
297     this.add(tabbedPane, BorderLayout.CENTER);
298     this.add(okCancelPanel, BorderLayout.SOUTH);
299
300     tabbedPane.add(initVisualTab(),
301             MessageManager.getString("label.visual"));
302
303     tabbedPane.add(initColoursTab(),
304             MessageManager.getString("label.colours"));
305
306     tabbedPane.add(initOverviewTab(),
307             MessageManager.getString("label.overview"));
308
309     tabbedPane.add(initStructureTab(),
310             MessageManager.getString("label.structure"));
311
312     tabbedPane.add(initConnectionsTab(),
313             MessageManager.getString("label.connections"));
314
315     tabbedPane.add(initLinksTab(),
316             MessageManager.getString("label.urllinks"));
317
318     tabbedPane.add(initOutputTab(),
319             MessageManager.getString("label.output"));
320
321     tabbedPane.add(initEditingTab(),
322             MessageManager.getString("label.editing"));
323
324     /*
325      * See WsPreferences for the real work of configuring this tab.
326      */
327     wsTab.setLayout(new BorderLayout());
328     tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
329
330     /*
331      * Handler to validate a tab before leaving it - currently only for
332      * Structure.
333      */
334     tabbedPane.addChangeListener(new ChangeListener()
335     {
336       private Component lastTab;
337
338       @Override
339       public void stateChanged(ChangeEvent e)
340       {
341         if (lastTab == structureTab
342                 && tabbedPane.getSelectedComponent() != structureTab)
343         {
344           if (!validateStructure())
345           {
346             tabbedPane.setSelectedComponent(structureTab);
347             return;
348           }
349         }
350         lastTab = tabbedPane.getSelectedComponent();
351       }
352
353     });
354   }
355
356   /**
357    * Initialises the Editing tabbed panel.
358    * 
359    * @return
360    */
361   private JPanel initEditingTab()
362   {
363     JPanel editingTab = new JPanel();
364     editingTab.setLayout(null);
365     autoCalculateConsCheck.setFont(LABEL_FONT);
366     autoCalculateConsCheck.setText(
367             MessageManager.getString("label.autocalculate_consensus"));
368     autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
369     padGaps.setFont(LABEL_FONT);
370     padGaps.setText(
371             MessageManager.getString("label.pad_gaps_when_editing"));
372     padGaps.setBounds(new Rectangle(22, 94, 168, 23));
373     sortByTree.setFont(LABEL_FONT);
374     sortByTree
375             .setText(MessageManager.getString("label.sort_with_new_tree"));
376     sortByTree.setToolTipText(MessageManager.getString(
377             "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
378     sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
379     editingTab.add(autoCalculateConsCheck);
380     editingTab.add(padGaps);
381     editingTab.add(sortByTree);
382     return editingTab;
383   }
384
385   /**
386    * Initialises the Output tabbed panel.
387    * 
388    * @return
389    */
390   private JPanel initOutputTab()
391   {
392     JPanel outputTab = new JPanel();
393     outputTab.setLayout(null);
394     JLabel epsLabel = new JLabel();
395     epsLabel.setFont(LABEL_FONT);
396     epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
397     epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
398     epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
399     epsRendering.setFont(LABEL_FONT);
400     epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
401     JLabel jLabel1 = new JLabel();
402     jLabel1.setFont(LABEL_FONT);
403     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
404     jLabel1.setText(MessageManager.getString("label.append_start_end"));
405     jLabel1.setFont(LABEL_FONT);
406     fastajv.setFont(LABEL_FONT);
407     fastajv.setHorizontalAlignment(SwingConstants.LEFT);
408     clustaljv.setText(MessageManager.getString("label.clustal") + "     ");
409     blcjv.setText(MessageManager.getString("label.blc") + "     ");
410     fastajv.setText(MessageManager.getString("label.fasta") + "     ");
411     msfjv.setText(MessageManager.getString("label.msf") + "     ");
412     pfamjv.setText(MessageManager.getString("label.pfam") + "     ");
413     pileupjv.setText(MessageManager.getString("label.pileup") + "     ");
414     msfjv.setFont(LABEL_FONT);
415     msfjv.setHorizontalAlignment(SwingConstants.LEFT);
416     pirjv.setText(MessageManager.getString("label.pir") + "     ");
417     JPanel jPanel11 = new JPanel();
418     jPanel11.setFont(LABEL_FONT);
419     TitledBorder titledBorder2 = new TitledBorder(
420             MessageManager.getString("label.file_output"));
421     jPanel11.setBorder(titledBorder2);
422     jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
423     GridLayout gridLayout3 = new GridLayout();
424     jPanel11.setLayout(gridLayout3);
425     gridLayout3.setRows(8);
426     blcjv.setFont(LABEL_FONT);
427     blcjv.setHorizontalAlignment(SwingConstants.LEFT);
428     clustaljv.setFont(LABEL_FONT);
429     clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
430     pfamjv.setFont(LABEL_FONT);
431     pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
432     pileupjv.setFont(LABEL_FONT);
433     pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
434     pirjv.setFont(LABEL_FONT);
435     pirjv.setHorizontalAlignment(SwingConstants.LEFT);
436     autoIdWidth.setFont(LABEL_FONT);
437     autoIdWidth.setText(
438             MessageManager.getString("label.automatically_set_id_width"));
439     autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
440             .getString("label.adjusts_width_generated_eps_png")));
441     autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
442     autoIdWidth.addActionListener(new ActionListener()
443     {
444
445       @Override
446       public void actionPerformed(ActionEvent e)
447       {
448         autoIdWidth_actionPerformed();
449       }
450     });
451     userIdWidthlabel.setFont(LABEL_FONT);
452     userIdWidthlabel.setText(
453             MessageManager.getString("label.figure_id_column_width"));
454     userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
455             .getString("label.manually_specify_width_left_column")));
456     userIdWidthlabel.setToolTipText(
457             JvSwingUtils.wrapTooltip(true, MessageManager.getString(
458                     "label.manually_specify_width_left_column")));
459     userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
460     userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
461     userIdWidth.setText("");
462     userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
463     userIdWidth.addActionListener(new ActionListener()
464     {
465
466       @Override
467       public void actionPerformed(ActionEvent e)
468       {
469         userIdWidth_actionPerformed();
470       }
471     });
472     modellerOutput.setFont(LABEL_FONT);
473     modellerOutput
474             .setText(MessageManager.getString("label.use_modeller_output"));
475     modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
476     embbedBioJSON.setFont(LABEL_FONT);
477     embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
478     embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
479
480     jPanel11.add(jLabel1);
481     jPanel11.add(blcjv);
482     jPanel11.add(clustaljv);
483     jPanel11.add(fastajv);
484     jPanel11.add(msfjv);
485     jPanel11.add(pfamjv);
486     jPanel11.add(pileupjv);
487     jPanel11.add(pirjv);
488     outputTab.add(autoIdWidth);
489     outputTab.add(userIdWidth);
490     outputTab.add(userIdWidthlabel);
491     outputTab.add(modellerOutput);
492     outputTab.add(embbedBioJSON);
493     outputTab.add(epsLabel);
494     outputTab.add(epsRendering);
495     outputTab.add(jPanel11);
496     return outputTab;
497   }
498
499   /**
500    * Initialises the Connections tabbed panel.
501    * 
502    * @return
503    */
504   private JPanel initConnectionsTab()
505   {
506     JPanel connectTab = new JPanel();
507     connectTab.setLayout(new GridBagLayout());
508
509     // Label for browser text box
510     JLabel browserLabel = new JLabel();
511     browserLabel.setFont(LABEL_FONT);
512     browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
513     browserLabel.setText(
514             MessageManager.getString("label.default_browser_unix"));
515     defaultBrowser.setFont(LABEL_FONT);
516     defaultBrowser.setText("");
517     final String tooltip = JvSwingUtils.wrapTooltip(true,
518             MessageManager.getString("label.double_click_to_browse"));
519     defaultBrowser.setToolTipText(tooltip);
520     defaultBrowser.addMouseListener(new MouseAdapter()
521     {
522       @Override
523       public void mouseClicked(MouseEvent e)
524       {
525         if (e.getClickCount() > 1)
526         {
527           defaultBrowser_mouseClicked(e);
528         }
529       }
530     });
531
532     JPanel proxyPanel = initConnTabProxyPanel();
533     initConnTabCheckboxes();
534
535     // Add default Browser text box
536     connectTab.add(browserLabel,
537             new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
538                     GridBagConstraints.WEST, GridBagConstraints.NONE,
539                     new Insets(10, 0, 5, 5), 5, 1));
540     defaultBrowser.setFont(LABEL_FONT);
541     defaultBrowser.setText("");
542
543     connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
544             0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
545             new Insets(10, 0, 5, 10), 30, 1));
546
547     // Add proxy server panel
548     connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
549             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
550             new Insets(10, 0, 5, 12), 4, 10));
551
552     // Add usage stats, version check and questionnaire checkboxes
553     connectTab.add(usagestats,
554             new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
555                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
556                     new Insets(0, 2, 5, 5), 70, 1));
557     connectTab.add(questionnaire,
558             new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
559                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
560                     new Insets(0, 2, 5, 10), 70, 1));
561     connectTab.add(versioncheck,
562             new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
563                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
564                     new Insets(0, 2, 5, 5), 70, 1));
565
566     // Add padding so the panel doesn't look ridiculous
567     JPanel spacePanel = new JPanel();
568     connectTab.add(spacePanel,
569             new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
570                     GridBagConstraints.WEST, GridBagConstraints.BOTH,
571                     new Insets(0, 0, 0, 5), 70, 1));
572
573     return connectTab;
574   }
575
576   /**
577    * Initialises the Links tabbed panel.
578    * 
579    * @return
580    */
581   private JPanel initLinksTab()
582   {
583     JPanel linkTab = new JPanel();
584     linkTab.setLayout(new GridBagLayout());
585
586     // Set up table for Url links
587     linkUrlTable.getTableHeader().setReorderingAllowed(false);
588     linkUrlTable.setFillsViewportHeight(true);
589     linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
590     linkUrlTable.setAutoCreateRowSorter(true);
591     linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
592
593     // adjust row height so radio buttons actually fit
594     // don't do this in the renderer, it causes the awt thread to activate
595     // constantly
596     JRadioButton temp = new JRadioButton();
597     linkUrlTable.setRowHeight(temp.getMinimumSize().height);
598
599     // Table in scrollpane so that the table is given a scrollbar
600     JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
601     linkScrollPane.setBorder(null);
602
603     // Panel for links functionality
604     JPanel linkPanel = new JPanel(new GridBagLayout());
605     linkPanel.setBorder(new TitledBorder(
606             MessageManager.getString("label.url_linkfrom_sequence_id")));
607
608     // Put the Url links panel together
609
610     // Buttons go at top right, resizing only resizes the blank space vertically
611     JPanel buttonPanel = initLinkTabUrlButtons();
612     GridBagConstraints linkConstraints1 = new GridBagConstraints();
613     linkConstraints1.insets = new Insets(0, 0, 5, 0);
614     linkConstraints1.gridx = 0;
615     linkConstraints1.gridy = 0;
616     linkConstraints1.weightx = 1.0;
617     linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
618     linkTab.add(buttonPanel, linkConstraints1);
619
620     // Links table goes at top left, resizing resizes the table
621     GridBagConstraints linkConstraints2 = new GridBagConstraints();
622     linkConstraints2.insets = new Insets(0, 0, 5, 5);
623     linkConstraints2.gridx = 0;
624     linkConstraints2.gridy = 1;
625     linkConstraints2.weightx = 1.0;
626     linkConstraints2.weighty = 1.0;
627     linkConstraints2.fill = GridBagConstraints.BOTH;
628     linkTab.add(linkScrollPane, linkConstraints2);
629
630     // Filter box and buttons goes at bottom left, resizing resizes the text box
631     JPanel filterPanel = initLinkTabFilterPanel();
632     GridBagConstraints linkConstraints3 = new GridBagConstraints();
633     linkConstraints3.insets = new Insets(0, 0, 0, 5);
634     linkConstraints3.gridx = 0;
635     linkConstraints3.gridy = 2;
636     linkConstraints3.weightx = 1.0;
637     linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
638     linkTab.add(filterPanel, linkConstraints3);
639
640     return linkTab;
641   }
642
643   private JPanel initLinkTabFilterPanel()
644   {
645     // Filter textbox and reset button
646     JLabel filterLabel = new JLabel(
647             MessageManager.getString("label.filter"));
648     filterLabel.setFont(LABEL_FONT);
649     filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
650     filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
651
652     filterTB.setFont(LABEL_FONT);
653     filterTB.setText("");
654
655     doReset.setText(MessageManager.getString("action.showall"));
656     userOnly.setText(MessageManager.getString("action.customfilter"));
657
658     // Panel for filter functionality
659     JPanel filterPanel = new JPanel(new GridBagLayout());
660     filterPanel.setBorder(new TitledBorder("Filter"));
661     GridBagConstraints gbc = new GridBagConstraints();
662     gbc.gridx = 0;
663     gbc.gridy = 0;
664     gbc.fill = GridBagConstraints.NONE;
665     gbc.anchor = GridBagConstraints.WEST;
666
667     filterPanel.add(filterLabel, gbc);
668
669     GridBagConstraints gbc1 = new GridBagConstraints();
670     gbc1.gridx = 1;
671     gbc1.gridwidth = 2;
672     gbc1.fill = GridBagConstraints.HORIZONTAL;
673     gbc1.anchor = GridBagConstraints.WEST;
674     gbc1.weightx = 1.0;
675     filterPanel.add(filterTB, gbc1);
676
677     GridBagConstraints gbc2 = new GridBagConstraints();
678     gbc2.gridx = 3;
679     gbc2.fill = GridBagConstraints.NONE;
680     gbc2.anchor = GridBagConstraints.WEST;
681     filterPanel.add(doReset, gbc2);
682
683     GridBagConstraints gbc3 = new GridBagConstraints();
684     gbc3.gridx = 4;
685     gbc3.fill = GridBagConstraints.NONE;
686     gbc3.anchor = GridBagConstraints.WEST;
687     filterPanel.add(userOnly, gbc3);
688
689     return filterPanel;
690   }
691
692   private JPanel initLinkTabUrlButtons()
693   {
694     // Buttons for new / edit / delete Url links
695     JButton newLink = new JButton();
696     newLink.setText(MessageManager.getString("action.new"));
697
698     editLink.setText(MessageManager.getString("action.edit"));
699
700     deleteLink.setText(MessageManager.getString("action.delete"));
701
702     // no current selection, so initially disable delete/edit buttons
703     editLink.setEnabled(false);
704     deleteLink.setEnabled(false);
705
706     newLink.addActionListener(new java.awt.event.ActionListener()
707     {
708       @Override
709       public void actionPerformed(ActionEvent e)
710       {
711         newLink_actionPerformed(e);
712       }
713     });
714
715     editLink.setText(MessageManager.getString("action.edit"));
716     editLink.addActionListener(new java.awt.event.ActionListener()
717     {
718       @Override
719       public void actionPerformed(ActionEvent e)
720       {
721         editLink_actionPerformed(e);
722       }
723     });
724
725     deleteLink.setText(MessageManager.getString("action.delete"));
726     deleteLink.addActionListener(new java.awt.event.ActionListener()
727     {
728       @Override
729       public void actionPerformed(ActionEvent e)
730       {
731         deleteLink_actionPerformed(e);
732       }
733     });
734
735     JPanel buttonPanel = new JPanel(new GridBagLayout());
736     buttonPanel.setBorder(new TitledBorder("Edit links"));
737     GridBagConstraints gbc = new GridBagConstraints();
738     gbc.gridx = 0;
739     gbc.gridy = 0;
740     gbc.fill = GridBagConstraints.NONE;
741     buttonPanel.add(newLink, gbc);
742
743     GridBagConstraints gbc1 = new GridBagConstraints();
744     gbc1.gridx = 1;
745     gbc1.gridy = 0;
746     gbc1.fill = GridBagConstraints.NONE;
747     buttonPanel.add(editLink, gbc1);
748
749     GridBagConstraints gbc2 = new GridBagConstraints();
750     gbc2.gridx = 2;
751     gbc2.gridy = 0;
752     gbc2.fill = GridBagConstraints.NONE;
753     buttonPanel.add(deleteLink, gbc2);
754
755     GridBagConstraints gbc3 = new GridBagConstraints();
756     gbc3.gridx = 3;
757     gbc3.gridy = 0;
758     gbc3.fill = GridBagConstraints.HORIZONTAL;
759     gbc3.weightx = 1.0;
760     JPanel spacePanel = new JPanel();
761     spacePanel.setBorder(null);
762     buttonPanel.add(spacePanel, gbc3);
763
764     return buttonPanel;
765   }
766
767   /**
768    * Initialises the proxy server panel in the Connections tab
769    * 
770    * @return the proxy server panel
771    */
772   private JPanel initConnTabProxyPanel()
773   {
774     // Label for server text box
775     serverLabel.setText(MessageManager.getString("label.address"));
776     serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
777     serverLabel.setFont(LABEL_FONT);
778
779     // Proxy server and port text boxes
780     proxyServerTB.setFont(LABEL_FONT);
781     proxyPortTB.setFont(LABEL_FONT);
782
783     // Label for Port text box
784     portLabel.setFont(LABEL_FONT);
785     portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
786     portLabel.setText(MessageManager.getString("label.port"));
787
788     // Use proxy server checkbox
789     useProxy.setFont(LABEL_FONT);
790     useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
791     useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
792     useProxy.setText(MessageManager.getString("label.use_proxy_server"));
793     useProxy.addActionListener(new ActionListener()
794     {
795       @Override
796       public void actionPerformed(ActionEvent e)
797       {
798         useProxy_actionPerformed();
799       }
800     });
801
802     // Make proxy server panel
803     JPanel proxyPanel = new JPanel();
804     TitledBorder titledBorder1 = new TitledBorder(
805             MessageManager.getString("label.proxy_server"));
806     proxyPanel.setBorder(titledBorder1);
807     proxyPanel.setLayout(new GridBagLayout());
808     proxyPanel.add(serverLabel,
809             new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
810                     GridBagConstraints.WEST, GridBagConstraints.NONE,
811                     new Insets(0, 2, 2, 0), 5, 0));
812     proxyPanel.add(portLabel,
813             new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
814                     GridBagConstraints.WEST, GridBagConstraints.NONE,
815                     new Insets(0, 0, 2, 0), 11, 0));
816     proxyPanel.add(useProxy,
817             new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
818                     GridBagConstraints.WEST, GridBagConstraints.NONE,
819                     new Insets(0, 2, 5, 185), 2, -4));
820     proxyPanel.add(proxyPortTB,
821             new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
822                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
823                     new Insets(0, 2, 2, 2), 54, 1));
824     proxyPanel.add(proxyServerTB,
825             new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
826                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
827                     new Insets(0, 2, 2, 0), 263, 1));
828
829     return proxyPanel;
830   }
831
832   /**
833    * Initialises the checkboxes in the Connections tab
834    */
835   private void initConnTabCheckboxes()
836   {
837     // Usage stats checkbox label
838     usagestats.setText(
839             MessageManager.getString("label.send_usage_statistics"));
840     usagestats.setFont(LABEL_FONT);
841     usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
842     usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
843
844     // Questionnaire checkbox label
845     questionnaire.setText(
846             MessageManager.getString("label.check_for_questionnaires"));
847     questionnaire.setFont(LABEL_FONT);
848     questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
849     questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
850
851     // Check for latest version checkbox label
852     versioncheck.setText(
853             MessageManager.getString("label.check_for_latest_version"));
854     versioncheck.setFont(LABEL_FONT);
855     versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
856     versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
857   }
858
859   /**
860    * Initialises the parent panel which contains the tabbed sections.
861    * 
862    * @return
863    */
864   private JPanel initOkCancelPanel()
865   {
866     JButton ok = new JButton();
867     ok.setText(MessageManager.getString("action.ok"));
868     ok.addActionListener(new ActionListener()
869     {
870       @Override
871       public void actionPerformed(ActionEvent e)
872       {
873         ok_actionPerformed(e);
874       }
875     });
876     JButton cancel = new JButton();
877     cancel.setText(MessageManager.getString("action.cancel"));
878     cancel.addActionListener(new ActionListener()
879     {
880       @Override
881       public void actionPerformed(ActionEvent e)
882       {
883         cancel_actionPerformed(e);
884       }
885     });
886     JPanel okCancelPanel = new JPanel();
887     okCancelPanel.add(ok);
888     okCancelPanel.add(cancel);
889     return okCancelPanel;
890   }
891
892   /**
893    * Initialises the Colours tabbed panel.
894    * 
895    * @return
896    */
897   private JPanel initColoursTab()
898   {
899     JPanel coloursTab = new JPanel();
900     coloursTab.setBorder(new TitledBorder(
901             MessageManager.getString("action.open_new_alignment")));
902     coloursTab.setLayout(new FlowLayout());
903     JLabel mincolourLabel = new JLabel();
904     mincolourLabel.setFont(LABEL_FONT);
905     mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
906     mincolourLabel.setText(MessageManager.getString("label.min_colour"));
907     minColour.setFont(LABEL_FONT);
908     minColour.setBorder(BorderFactory.createEtchedBorder());
909     minColour.setPreferredSize(new Dimension(40, 20));
910     minColour.addMouseListener(new MouseAdapter()
911     {
912       @Override
913       public void mousePressed(MouseEvent e)
914       {
915         minColour_actionPerformed(minColour);
916       }
917     });
918     JLabel maxcolourLabel = new JLabel();
919     maxcolourLabel.setFont(LABEL_FONT);
920     maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
921     maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
922     maxColour.setFont(LABEL_FONT);
923     maxColour.setBorder(BorderFactory.createEtchedBorder());
924     maxColour.setPreferredSize(new Dimension(40, 20));
925     maxColour.addMouseListener(new MouseAdapter()
926     {
927       @Override
928       public void mousePressed(MouseEvent e)
929       {
930         maxColour_actionPerformed(maxColour);
931       }
932     });
933
934     protColour.setFont(LABEL_FONT);
935     protColour.setBounds(new Rectangle(172, 225, 155, 21));
936     JLabel protColourLabel = new JLabel();
937     protColourLabel.setFont(LABEL_FONT);
938     protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
939     protColourLabel.setText(
940             MessageManager.getString("label.prot_alignment_colour") + " ");
941     JvSwingUtils.addtoLayout(coloursTab,
942             MessageManager
943                     .getString("label.default_colour_scheme_for_alignment"),
944             protColourLabel, protColour);
945
946     nucColour.setFont(LABEL_FONT);
947     nucColour.setBounds(new Rectangle(172, 240, 155, 21));
948     JLabel nucColourLabel = new JLabel();
949     nucColourLabel.setFont(LABEL_FONT);
950     nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
951     nucColourLabel.setText(
952             MessageManager.getString("label.nuc_alignment_colour") + " ");
953     JvSwingUtils.addtoLayout(coloursTab,
954             MessageManager
955                     .getString("label.default_colour_scheme_for_alignment"),
956             nucColourLabel, nucColour);
957
958     JPanel annotationShding = new JPanel();
959     annotationShding.setBorder(new TitledBorder(
960             MessageManager.getString("label.annotation_shading_default")));
961     annotationShding.setLayout(new GridLayout(1, 2));
962     JvSwingUtils.addtoLayout(annotationShding,
963             MessageManager.getString(
964                     "label.default_minimum_colour_annotation_shading"),
965             mincolourLabel, minColour);
966     JvSwingUtils.addtoLayout(annotationShding,
967             MessageManager.getString(
968                     "label.default_maximum_colour_annotation_shading"),
969             maxcolourLabel, maxColour);
970     coloursTab.add(annotationShding); // , FlowLayout.LEFT);
971     return coloursTab;
972   }
973
974   /**
975    * Initialises the Overview tabbed panel.
976    * 
977    * @return
978    */
979   private JPanel initOverviewTab()
980   {
981     JPanel overviewPanel = new JPanel();
982     overviewPanel.setBorder(new TitledBorder(
983             MessageManager.getString("label.overview_settings")));
984
985     gapColour.setFont(LABEL_FONT);
986     // fixing the border colours stops apparent colour bleed from the panel
987     gapColour.setBorder(
988             BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
989     gapColour.setPreferredSize(new Dimension(40, 20));
990     gapColour.addMouseListener(new MouseAdapter()
991     {
992       @Override
993       public void mousePressed(MouseEvent e)
994       {
995         gapColour_actionPerformed(gapColour);
996       }
997     });
998
999     hiddenColour.setFont(LABEL_FONT);
1000     // fixing the border colours stops apparent colour bleed from the panel
1001     hiddenColour.setBorder(
1002             BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1003     hiddenColour.setPreferredSize(new Dimension(40, 20));
1004     hiddenColour.addMouseListener(new MouseAdapter()
1005     {
1006       @Override
1007       public void mousePressed(MouseEvent e)
1008       {
1009         hiddenColour_actionPerformed(hiddenColour);
1010       }
1011     });
1012     
1013     useLegacyGap = new JCheckBox(
1014             MessageManager.getString("label.ov_legacy_gap"));
1015     useLegacyGap.setFont(LABEL_FONT);
1016     useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1017     useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1018     gapLabel = new JLabel(
1019             MessageManager.getString("label.gap_colour"));
1020     gapLabel.setFont(LABEL_FONT);
1021     gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1022     gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1023     showHiddenAtStart = new JCheckBox(
1024             MessageManager.getString("label.ov_show_hide_default"));
1025     showHiddenAtStart.setFont(LABEL_FONT);
1026     showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1027     showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1028     JLabel hiddenLabel = new JLabel(
1029             MessageManager.getString("label.hidden_colour"));
1030     hiddenLabel.setFont(LABEL_FONT);
1031     hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1032     hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1033
1034     useLegacyGap.addActionListener(new ActionListener()
1035     {
1036       @Override
1037       public void actionPerformed(ActionEvent e)
1038       {
1039         useLegacyGaps_actionPerformed(e);
1040       }
1041     });
1042
1043     overviewPanel.setLayout(new GridBagLayout());
1044     GridBagConstraints c1 = new GridBagConstraints();
1045
1046     c1.fill = GridBagConstraints.HORIZONTAL;
1047     c1.gridx = 0;
1048     c1.gridy = 0;
1049     c1.weightx = 1;
1050     c1.ipady = 20;
1051     c1.anchor = GridBagConstraints.FIRST_LINE_START;
1052     overviewPanel.add(useLegacyGap, c1);
1053
1054     GridBagConstraints c2 = new GridBagConstraints();
1055     c2.fill = GridBagConstraints.HORIZONTAL;
1056     c2.gridx = 1;
1057     c2.gridy = 0;
1058     c2.insets = new Insets(0, 15, 0, 10);
1059     overviewPanel.add(gapLabel, c2);
1060
1061     GridBagConstraints c3 = new GridBagConstraints();
1062     c3.fill = GridBagConstraints.HORIZONTAL;
1063     c3.gridx = 2;
1064     c3.gridy = 0;
1065     c3.insets = new Insets(0, 0, 0, 15);
1066     overviewPanel.add(gapColour, c3);
1067
1068     GridBagConstraints c4 = new GridBagConstraints();
1069     c4.fill = GridBagConstraints.HORIZONTAL;
1070     c4.gridx = 0;
1071     c4.gridy = 1;
1072     c4.weightx = 1;
1073     overviewPanel.add(showHiddenAtStart, c4);
1074
1075     GridBagConstraints c5 = new GridBagConstraints();
1076     c5.fill = GridBagConstraints.HORIZONTAL;
1077     c5.gridx = 1;
1078     c5.gridy = 1;
1079     c5.insets = new Insets(0, 15, 0, 10);
1080     overviewPanel.add(hiddenLabel, c5);
1081
1082     GridBagConstraints c6 = new GridBagConstraints();
1083     c6.fill = GridBagConstraints.HORIZONTAL;
1084     c6.gridx = 2;
1085     c6.gridy = 1;
1086     c6.insets = new Insets(0, 0, 0, 15);
1087     overviewPanel.add(hiddenColour, c6);
1088
1089     JButton resetButton = new JButton(
1090             MessageManager.getString("label.reset_to_defaults"));
1091
1092     resetButton.addActionListener(new ActionListener()
1093     {
1094       @Override
1095       public void actionPerformed(ActionEvent e)
1096       {
1097         resetOvDefaults_actionPerformed(e);
1098       }
1099     });
1100
1101     GridBagConstraints c7 = new GridBagConstraints();
1102     c7.fill = GridBagConstraints.NONE;
1103     c7.gridx = 0;
1104     c7.gridy = 2;
1105     c7.insets = new Insets(10, 0, 0, 0);
1106     c7.anchor = GridBagConstraints.WEST;
1107     overviewPanel.add(resetButton, c7);
1108
1109     // Add padding so the panel doesn't look ridiculous
1110     JPanel spacePanel = new JPanel();
1111     overviewPanel.add(spacePanel,
1112             new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1113                     GridBagConstraints.WEST, GridBagConstraints.BOTH,
1114                     new Insets(0, 0, 0, 5), 0, 0));
1115
1116     return overviewPanel;
1117   }
1118
1119   /**
1120    * Initialises the Structure tabbed panel.
1121    * 
1122    * @return
1123    */
1124   private JPanel initStructureTab()
1125   {
1126     structureTab = new JPanel();
1127
1128     structureTab.setBorder(new TitledBorder(
1129             MessageManager.getString("label.structure_options")));
1130     structureTab.setLayout(null);
1131     final int width = 400;
1132     final int height = 22;
1133     final int lineSpacing = 25;
1134     int ypos = 15;
1135
1136     structFromPdb.setFont(LABEL_FONT);
1137     structFromPdb
1138             .setText(MessageManager.getString("label.struct_from_pdb"));
1139     structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1140     structFromPdb.addActionListener(new ActionListener()
1141     {
1142       @Override
1143       public void actionPerformed(ActionEvent e)
1144       {
1145         boolean selected = structFromPdb.isSelected();
1146         // enable other options only when the first is checked
1147         useRnaView.setEnabled(selected);
1148         addSecondaryStructure.setEnabled(selected);
1149         addTempFactor.setEnabled(selected);
1150       }
1151     });
1152     structureTab.add(structFromPdb);
1153
1154     // indent checkboxes that are conditional on the first one
1155     ypos += lineSpacing;
1156     useRnaView.setFont(LABEL_FONT);
1157     useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1158     useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1159     structureTab.add(useRnaView);
1160
1161     ypos += lineSpacing;
1162     addSecondaryStructure.setFont(LABEL_FONT);
1163     addSecondaryStructure
1164             .setText(MessageManager.getString("label.autoadd_secstr"));
1165     addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1166     structureTab.add(addSecondaryStructure);
1167
1168     ypos += lineSpacing;
1169     addTempFactor.setFont(LABEL_FONT);
1170     addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1171     addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1172     structureTab.add(addTempFactor);
1173
1174     ypos += lineSpacing;
1175     JLabel viewerLabel = new JLabel();
1176     viewerLabel.setFont(LABEL_FONT);
1177     viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1178     viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1179     viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1180     structureTab.add(viewerLabel);
1181
1182     structViewer.setFont(LABEL_FONT);
1183     structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1184     structViewer.addItem(ViewerType.JMOL.name());
1185     structViewer.addItem(ViewerType.CHIMERA.name());
1186     structViewer.addActionListener(new ActionListener()
1187     {
1188       @Override
1189       public void actionPerformed(ActionEvent e)
1190       {
1191         structureViewer_actionPerformed(
1192                 (String) structViewer.getSelectedItem());
1193       }
1194     });
1195     structureTab.add(structViewer);
1196
1197     ypos += lineSpacing;
1198     JLabel pathLabel = new JLabel();
1199     pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1200     pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1201     pathLabel.setText(MessageManager.getString("label.chimera_path"));
1202     pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1203     structureTab.add(pathLabel);
1204
1205     chimeraPath.setFont(LABEL_FONT);
1206     chimeraPath.setText("");
1207     final String tooltip = JvSwingUtils.wrapTooltip(true,
1208             MessageManager.getString("label.chimera_path_tip"));
1209     chimeraPath.setToolTipText(tooltip);
1210     chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1211     chimeraPath.addMouseListener(new MouseAdapter()
1212     {
1213       @Override
1214       public void mouseClicked(MouseEvent e)
1215       {
1216         if (e.getClickCount() == 2)
1217         {
1218           String chosen = openFileChooser();
1219           if (chosen != null)
1220           {
1221             chimeraPath.setText(chosen);
1222           }
1223         }
1224       }
1225     });
1226     structureTab.add(chimeraPath);
1227
1228     ypos += lineSpacing;
1229     nwMapping.setFont(LABEL_FONT);
1230     nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1231     siftsMapping.setFont(LABEL_FONT);
1232     siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1233     mappingMethod.add(nwMapping);
1234     mappingMethod.add(siftsMapping);
1235     JPanel mappingPanel = new JPanel();
1236     mappingPanel.setFont(LABEL_FONT);
1237     TitledBorder mmTitledBorder = new TitledBorder(
1238             MessageManager.getString("label.mapping_method"));
1239     mmTitledBorder.setTitleFont(LABEL_FONT);
1240     mappingPanel.setBorder(mmTitledBorder);
1241     mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1242     // GridLayout mappingLayout = new GridLayout();
1243     mappingPanel.setLayout(new GridLayout());
1244     mappingPanel.add(nwMapping);
1245     mappingPanel.add(siftsMapping);
1246     structureTab.add(mappingPanel);
1247
1248     ypos += lineSpacing;
1249     ypos += lineSpacing;
1250     FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1251             PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1252     docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1253     structureTab.add(docFieldPref);
1254
1255     return structureTab;
1256   }
1257
1258   /**
1259    * Action on choosing a structure viewer from combobox options.
1260    * 
1261    * @param selectedItem
1262    */
1263   protected void structureViewer_actionPerformed(String selectedItem)
1264   {
1265   }
1266
1267   /**
1268    * Show a dialog for the user to choose a file. Returns the chosen path, or
1269    * null on Cancel.
1270    * 
1271    * @return
1272    */
1273   protected String openFileChooser()
1274   {
1275     String choice = null;
1276     JFileChooser chooser = new JFileChooser();
1277
1278     // chooser.setFileView(new JalviewFileView());
1279     chooser.setDialogTitle(
1280             MessageManager.getString("label.open_local_file"));
1281     chooser.setToolTipText(MessageManager.getString("action.open"));
1282
1283     int value = chooser.showOpenDialog(this);
1284
1285     if (value == JFileChooser.APPROVE_OPTION)
1286     {
1287       choice = chooser.getSelectedFile().getPath();
1288     }
1289     return choice;
1290   }
1291
1292   /**
1293    * Validate the structure tab preferences; if invalid, set focus on this tab.
1294    * 
1295    * @param e
1296    */
1297   protected boolean validateStructure(FocusEvent e)
1298   {
1299     if (!validateStructure())
1300     {
1301       e.getComponent().requestFocusInWindow();
1302       return false;
1303     }
1304     return true;
1305   }
1306
1307   protected boolean validateStructure()
1308   {
1309     return false;
1310   }
1311
1312   /**
1313    * Initialises the Visual tabbed panel.
1314    * 
1315    * @return
1316    */
1317   private JPanel initVisualTab()
1318   {
1319     JPanel visualTab = new JPanel();
1320     visualTab.setBorder(new TitledBorder(
1321             MessageManager.getString("action.open_new_alignment")));
1322     visualTab.setLayout(null);
1323     fullScreen.setFont(LABEL_FONT);
1324     fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1325     fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1326     fullScreen.setText(MessageManager.getString("label.maximize_window"));
1327     quality.setEnabled(false);
1328     quality.setFont(LABEL_FONT);
1329     quality.setHorizontalAlignment(SwingConstants.RIGHT);
1330     quality.setHorizontalTextPosition(SwingConstants.LEFT);
1331     quality.setSelected(true);
1332     quality.setText(MessageManager.getString("label.quality"));
1333     conservation.setEnabled(false);
1334     conservation.setFont(LABEL_FONT);
1335     conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1336     conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1337     conservation.setSelected(true);
1338     conservation.setText(MessageManager.getString("label.conservation"));
1339     identity.setEnabled(false);
1340     identity.setFont(LABEL_FONT);
1341     identity.setHorizontalAlignment(SwingConstants.RIGHT);
1342     identity.setHorizontalTextPosition(SwingConstants.LEFT);
1343     identity.setSelected(true);
1344     identity.setText(MessageManager.getString("label.consensus"));
1345     showOccupancy.setFont(LABEL_FONT);
1346     showOccupancy.setEnabled(false);
1347     showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1348     showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1349     showOccupancy.setSelected(true);
1350     showOccupancy.setText(MessageManager.getString("label.occupancy"));
1351
1352     JLabel showGroupbits = new JLabel();
1353     showGroupbits.setFont(LABEL_FONT);
1354     showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1355     showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1356     showGroupbits
1357             .setText(MessageManager.getString("action.show_group") + ":");
1358     JLabel showConsensbits = new JLabel();
1359     showConsensbits.setFont(LABEL_FONT);
1360     showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1361     showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1362     showConsensbits
1363             .setText(MessageManager.getString("label.consensus") + ":");
1364     showConsensHistogram.setEnabled(false);
1365     showConsensHistogram.setFont(LABEL_FONT);
1366     showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1367     showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1368     showConsensHistogram.setSelected(true);
1369     showConsensHistogram
1370             .setText(MessageManager.getString("label.histogram"));
1371     showConsensLogo.setEnabled(false);
1372     showConsensLogo.setFont(LABEL_FONT);
1373     showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1374     showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1375     showConsensLogo.setSelected(true);
1376     showConsensLogo.setText(MessageManager.getString("label.logo"));
1377     showGroupConsensus.setEnabled(false);
1378     showGroupConsensus.setFont(LABEL_FONT);
1379     showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1380     showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1381     showGroupConsensus.setSelected(true);
1382     showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1383     showGroupConservation.setEnabled(false);
1384     showGroupConservation.setFont(LABEL_FONT);
1385     showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1386     showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1387     showGroupConservation.setSelected(true);
1388     showGroupConservation
1389             .setText(MessageManager.getString("label.conservation"));
1390     showNpTooltip.setEnabled(true);
1391     showNpTooltip.setFont(LABEL_FONT);
1392     showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1393     showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1394     showNpTooltip.setSelected(true);
1395     showNpTooltip.setText(
1396             MessageManager.getString("label.non_positional_features"));
1397     showDbRefTooltip.setEnabled(true);
1398     showDbRefTooltip.setFont(LABEL_FONT);
1399     showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1400     showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1401     showDbRefTooltip.setSelected(true);
1402     showDbRefTooltip
1403             .setText(MessageManager.getString("label.database_references"));
1404     annotations.setFont(LABEL_FONT);
1405     annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1406     annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1407     annotations.setSelected(true);
1408     annotations.setText(MessageManager.getString("label.show_annotations"));
1409     // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1410     annotations.addActionListener(new ActionListener()
1411     {
1412       @Override
1413       public void actionPerformed(ActionEvent e)
1414       {
1415         annotations_actionPerformed(e);
1416       }
1417     });
1418     identity.addActionListener(new ActionListener()
1419     {
1420       @Override
1421       public void actionPerformed(ActionEvent e)
1422       {
1423         annotations_actionPerformed(e);
1424       }
1425     });
1426     showGroupConsensus.addActionListener(new ActionListener()
1427     {
1428       @Override
1429       public void actionPerformed(ActionEvent e)
1430       {
1431         annotations_actionPerformed(e);
1432       }
1433     });
1434     showUnconserved.setFont(LABEL_FONT);
1435     showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1436     showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1437     showUnconserved.setSelected(true);
1438     showUnconserved
1439             .setText(MessageManager.getString("action.show_unconserved"));
1440     showUnconserved.addActionListener(new ActionListener()
1441     {
1442       @Override
1443       public void actionPerformed(ActionEvent e)
1444       {
1445         showunconserved_actionPerformed(e);
1446       }
1447     });
1448
1449     // TODO these are not yet added to / action from Preferences
1450     // JCheckBox shareSelections = new JCheckBox();
1451     // shareSelections.setFont(verdana11);
1452     // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1453     // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1454     // shareSelections.setSelected(true);
1455     // shareSelections.setText(MessageManager
1456     // .getString("label.share_selection_across_views"));
1457     // JCheckBox followHighlight = new JCheckBox();
1458     // followHighlight.setFont(verdana11);
1459     // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1460     // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1461     // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1462     // followHighlight.setSelected(true);
1463     // followHighlight.setText(MessageManager
1464     // .getString("label.scroll_highlighted_regions"));
1465
1466     seqLimit.setFont(LABEL_FONT);
1467     seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1468     seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1469     seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1470     smoothFont.setFont(LABEL_FONT);
1471     smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1472     smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1473     smoothFont.setText(MessageManager.getString("label.smooth_font"));
1474     scaleProteinToCdna.setFont(LABEL_FONT);
1475     scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1476     scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1477     scaleProteinToCdna.setText(
1478             MessageManager.getString("label.scale_protein_to_cdna"));
1479     scaleProteinToCdna.setToolTipText(
1480             MessageManager.getString("label.scale_protein_to_cdna_tip"));
1481     JLabel gapLabel = new JLabel();
1482     gapLabel.setFont(LABEL_FONT);
1483     gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1484     gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1485     JLabel fontLabel = new JLabel();
1486     fontLabel.setFont(LABEL_FONT);
1487     fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1488     fontLabel.setText(MessageManager.getString("label.font"));
1489     fontSizeCB.setFont(LABEL_FONT);
1490     fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1491     fontStyleCB.setFont(LABEL_FONT);
1492     fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1493     fontNameCB.setFont(LABEL_FONT);
1494     fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1495     gapSymbolCB.setFont(LABEL_FONT);
1496     gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1497     DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1498     dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1499     gapSymbolCB.setRenderer(dlcr);
1500
1501     startupCheckbox.setText(MessageManager.getString("action.open_file"));
1502     startupCheckbox.setFont(LABEL_FONT);
1503     startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1504     startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1505     startupCheckbox.setSelected(true);
1506     startupFileTextfield.setFont(LABEL_FONT);
1507     startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1508     final String tooltip = JvSwingUtils.wrapTooltip(true,
1509             MessageManager.getString("label.double_click_to_browse"));
1510     startupFileTextfield.setToolTipText(tooltip);
1511     startupFileTextfield.addMouseListener(new MouseAdapter()
1512     {
1513       @Override
1514       public void mouseClicked(MouseEvent e)
1515       {
1516         if (e.getClickCount() > 1)
1517         {
1518           startupFileTextfield_mouseClicked();
1519         }
1520       }
1521     });
1522
1523     sortby.setFont(LABEL_FONT);
1524     sortby.setBounds(new Rectangle(172, 260, 155, 21));
1525     JLabel sortLabel = new JLabel();
1526     sortLabel.setFont(LABEL_FONT);
1527     sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1528     sortLabel.setText(MessageManager.getString("label.sort_by"));
1529     sortAnnBy.setFont(LABEL_FONT);
1530     sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1531     JLabel sortAnnLabel = new JLabel();
1532     sortAnnLabel.setFont(LABEL_FONT);
1533     sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1534     sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1535     sortAutocalc.setFont(LABEL_FONT);
1536     sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1537
1538     JPanel annsettingsPanel = new JPanel();
1539     annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1540     annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1541     annsettingsPanel.setBorder(new EtchedBorder());
1542     visualTab.add(annsettingsPanel);
1543     Border jb = new EmptyBorder(1, 1, 4, 5);
1544     annotations.setBorder(jb);
1545     showOccupancy.setBorder(jb);
1546     quality.setBorder(jb);
1547     conservation.setBorder(jb);
1548     identity.setBorder(jb);
1549     showConsensbits.setBorder(jb);
1550     showGroupbits.setBorder(jb);
1551     showGroupConsensus.setBorder(jb);
1552     showGroupConservation.setBorder(jb);
1553     showConsensHistogram.setBorder(jb);
1554     showConsensLogo.setBorder(jb);
1555
1556     JPanel autoAnnotSettings = new JPanel();
1557     annsettingsPanel.add(autoAnnotSettings);
1558     autoAnnotSettings.setLayout(new GridLayout(0, 2));
1559     autoAnnotSettings.add(annotations);
1560     autoAnnotSettings.add(quality);
1561     // second row of autoannotation box
1562     autoAnnotSettings = new JPanel();
1563     annsettingsPanel.add(autoAnnotSettings);
1564
1565     autoAnnotSettings.setLayout(new GridLayout(0, 3));
1566     autoAnnotSettings.add(conservation);
1567     autoAnnotSettings.add(identity);
1568     autoAnnotSettings.add(showOccupancy);
1569     autoAnnotSettings.add(showGroupbits);
1570     autoAnnotSettings.add(showGroupConservation);
1571     autoAnnotSettings.add(showGroupConsensus);
1572     autoAnnotSettings.add(showConsensbits);
1573     autoAnnotSettings.add(showConsensHistogram);
1574     autoAnnotSettings.add(showConsensLogo);
1575
1576     JPanel tooltipSettings = new JPanel();
1577     tooltipSettings.setBorder(new TitledBorder(
1578             MessageManager.getString("label.sequence_id_tooltip")));
1579     tooltipSettings.setBounds(173, 140, 220, 62);
1580     tooltipSettings.setLayout(new GridLayout(2, 1));
1581     tooltipSettings.add(showDbRefTooltip);
1582     tooltipSettings.add(showNpTooltip);
1583     visualTab.add(tooltipSettings);
1584
1585     wrap.setFont(LABEL_FONT);
1586     wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1587     wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1588     wrap.setText(MessageManager.getString("label.wrap_alignment"));
1589     rightAlign.setFont(LABEL_FONT);
1590     rightAlign.setForeground(Color.black);
1591     rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1592     rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1593     rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1594     idItalics.setFont(LABEL_FONT_ITALIC);
1595     idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1596     idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1597     idItalics.setText(
1598             MessageManager.getString("label.sequence_name_italics"));
1599     openoverv.setFont(LABEL_FONT);
1600     openoverv.setActionCommand(
1601             MessageManager.getString("label.open_overview"));
1602     openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1603     openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1604     openoverv.setText(MessageManager.getString("label.open_overview"));
1605     JPanel jPanel2 = new JPanel();
1606     jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1607     jPanel2.setLayout(new GridLayout(14, 1));
1608     jPanel2.add(fullScreen);
1609     jPanel2.add(openoverv);
1610     jPanel2.add(seqLimit);
1611     jPanel2.add(rightAlign);
1612     jPanel2.add(fontLabel);
1613     jPanel2.add(showUnconserved);
1614     jPanel2.add(idItalics);
1615     jPanel2.add(smoothFont);
1616     jPanel2.add(scaleProteinToCdna);
1617     jPanel2.add(gapLabel);
1618     jPanel2.add(wrap);
1619     jPanel2.add(sortLabel);
1620     jPanel2.add(sortAnnLabel);
1621     jPanel2.add(startupCheckbox);
1622     visualTab.add(jPanel2);
1623     visualTab.add(startupFileTextfield);
1624     visualTab.add(sortby);
1625     visualTab.add(sortAnnBy);
1626     visualTab.add(sortAutocalc);
1627     visualTab.add(gapSymbolCB);
1628     visualTab.add(fontNameCB);
1629     visualTab.add(fontSizeCB);
1630     visualTab.add(fontStyleCB);
1631     return visualTab;
1632   }
1633
1634   protected void autoIdWidth_actionPerformed()
1635   {
1636     // TODO Auto-generated method stub
1637
1638   }
1639
1640   protected void userIdWidth_actionPerformed()
1641   {
1642     // TODO Auto-generated method stub
1643
1644   }
1645
1646   protected void maxColour_actionPerformed(JPanel panel)
1647   {
1648   }
1649
1650   protected void minColour_actionPerformed(JPanel panel)
1651   {
1652   }
1653
1654   protected void gapColour_actionPerformed(JPanel panel)
1655   {
1656   }
1657
1658   protected void hiddenColour_actionPerformed(JPanel panel)
1659   {
1660   }
1661
1662   protected void showunconserved_actionPerformed(ActionEvent e)
1663   {
1664     // TODO Auto-generated method stub
1665
1666   }
1667
1668   protected void useLegacyGaps_actionPerformed(ActionEvent e)
1669   {
1670   }
1671
1672   protected void resetOvDefaults_actionPerformed(ActionEvent e)
1673   {
1674   }
1675
1676   /**
1677    * DOCUMENT ME!
1678    * 
1679    * @param e
1680    *          DOCUMENT ME!
1681    */
1682   public void ok_actionPerformed(ActionEvent e)
1683   {
1684   }
1685
1686   /**
1687    * DOCUMENT ME!
1688    * 
1689    * @param e
1690    *          DOCUMENT ME!
1691    */
1692   public void cancel_actionPerformed(ActionEvent e)
1693   {
1694   }
1695
1696   /**
1697    * DOCUMENT ME!
1698    * 
1699    * @param e
1700    *          DOCUMENT ME!
1701    */
1702   public void annotations_actionPerformed(ActionEvent e)
1703   {
1704   }
1705
1706   /**
1707    * DOCUMENT ME!
1708    */
1709   public void startupFileTextfield_mouseClicked()
1710   {
1711   }
1712
1713   public void newLink_actionPerformed(ActionEvent e)
1714   {
1715
1716   }
1717
1718   public void editLink_actionPerformed(ActionEvent e)
1719   {
1720
1721   }
1722
1723   public void deleteLink_actionPerformed(ActionEvent e)
1724   {
1725
1726   }
1727
1728   public void defaultBrowser_mouseClicked(MouseEvent e)
1729   {
1730
1731   }
1732
1733   public void linkURLList_keyTyped(KeyEvent e)
1734   {
1735
1736   }
1737
1738   public void useProxy_actionPerformed()
1739   {
1740     boolean enabled = useProxy.isSelected();
1741     portLabel.setEnabled(enabled);
1742     serverLabel.setEnabled(enabled);
1743     proxyServerTB.setEnabled(enabled);
1744     proxyPortTB.setEnabled(enabled);
1745   }
1746
1747   /**
1748    * Customer renderer for JTable: supports column of radio buttons
1749    */
1750   public class RadioButtonRenderer extends JRadioButton
1751           implements TableCellRenderer
1752   {
1753     public RadioButtonRenderer()
1754     {
1755       setHorizontalAlignment(CENTER);
1756       setToolTipText(MessageManager.getString("label.urltooltip"));
1757     }
1758
1759     @Override
1760     public Component getTableCellRendererComponent(JTable table,
1761             Object value, boolean isSelected, boolean hasFocus, int row,
1762             int column)
1763     {
1764       setSelected((boolean) value);
1765
1766       // set colours to match rest of table
1767       if (isSelected)
1768       {
1769         setBackground(table.getSelectionBackground());
1770         setForeground(table.getSelectionForeground());
1771       }
1772       else
1773       {
1774         setBackground(table.getBackground());
1775         setForeground(table.getForeground());
1776       }
1777       return this;
1778     }
1779   }
1780
1781   /**
1782    * Customer cell editor for JTable: supports column of radio buttons in
1783    * conjunction with renderer
1784    */
1785   public class RadioButtonEditor extends AbstractCellEditor
1786           implements TableCellEditor
1787   {
1788     private JRadioButton button = new JRadioButton();
1789
1790     public RadioButtonEditor()
1791     {
1792       button.setHorizontalAlignment(SwingConstants.CENTER);
1793       this.button.addActionListener(new ActionListener()
1794       {
1795         @Override
1796         public void actionPerformed(ActionEvent e)
1797         {
1798           fireEditingStopped();
1799         }
1800       });
1801     }
1802
1803     @Override
1804     public Component getTableCellEditorComponent(JTable table, Object value,
1805             boolean isSelected, int row, int column)
1806     {
1807       button.setSelected((boolean) value);
1808       return button;
1809     }
1810
1811     @Override
1812     public Object getCellEditorValue()
1813     {
1814       return button.isSelected();
1815     }
1816
1817   }
1818 }