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