JAL-2527 Updates following code review
[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
528     defaultBrowser.addMouseListener(new MouseAdapter()
529     {
530       @Override
531       public void mouseClicked(MouseEvent e)
532       {
533         if (e.getClickCount() > 1)
534         {
535           defaultBrowser_mouseClicked(e);
536         }
537       }
538     });
539
540     JPanel proxyPanel = initConnTabProxyPanel();
541     initConnTabCheckboxes();
542
543     // Add default Browser text box
544     connectTab.add(browserLabel,
545             new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
546                     GridBagConstraints.WEST, GridBagConstraints.NONE,
547                     new Insets(10, 0, 5, 5), 5, 1));
548     defaultBrowser.setFont(LABEL_FONT);
549     defaultBrowser.setText("");
550
551     connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
552             0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
553             new Insets(10, 0, 5, 10), 30, 1));
554
555     // Add proxy server panel
556     connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
557             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
558             new Insets(10, 0, 5, 12), 4, 10));
559
560     // Add usage stats, version check and questionnaire checkboxes
561     connectTab.add(usagestats,
562             new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
563                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
564                     new Insets(0, 2, 5, 5), 70, 1));
565     connectTab.add(questionnaire,
566             new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
567                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
568                     new Insets(0, 2, 5, 10), 70, 1));
569     connectTab.add(versioncheck,
570             new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
571                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
572                     new Insets(0, 2, 5, 5), 70, 1));
573
574     // Add padding so the panel doesn't look ridiculous
575     JPanel spacePanel = new JPanel();
576     connectTab.add(spacePanel,
577             new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
578                     GridBagConstraints.WEST, GridBagConstraints.BOTH,
579                     new Insets(0, 0, 0, 5), 70, 1));
580
581     return connectTab;
582   }
583
584   /**
585    * Initialises the Links tabbed panel.
586    * 
587    * @return
588    */
589   private JPanel initLinksTab()
590   {
591     JPanel linkTab = new JPanel();
592     linkTab.setLayout(new GridBagLayout());
593
594     // Set up table for Url links
595     linkUrlTable.setFillsViewportHeight(true);
596     linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
597     linkUrlTable.setAutoCreateRowSorter(true);
598     linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
599
600     // adjust row height so radio buttons actually fit
601     // don't do this in the renderer, it causes the awt thread to activate
602     // constantly
603     JRadioButton temp = new JRadioButton();
604     linkUrlTable.setRowHeight(temp.getMinimumSize().height);
605
606     // Table in scrollpane so that the table is given a scrollbar
607     JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
608     linkScrollPane.setBorder(null);
609
610     // Panel for links functionality
611     JPanel linkPanel = new JPanel(new GridBagLayout());
612     linkPanel.setBorder(new TitledBorder(
613             MessageManager.getString("label.url_linkfrom_sequence_id")));
614
615     // Put the Url links panel together
616
617     // Buttons go at top right, resizing only resizes the blank space vertically
618     JPanel buttonPanel = initLinkTabUrlButtons();
619     GridBagConstraints linkConstraints1 = new GridBagConstraints();
620     linkConstraints1.insets = new Insets(0, 0, 5, 0);
621     linkConstraints1.gridx = 0;
622     linkConstraints1.gridy = 0;
623     linkConstraints1.weightx = 1.0;
624     linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
625     linkTab.add(buttonPanel, linkConstraints1);
626
627     // Links table goes at top left, resizing resizes the table
628     GridBagConstraints linkConstraints2 = new GridBagConstraints();
629     linkConstraints2.insets = new Insets(0, 0, 5, 5);
630     linkConstraints2.gridx = 0;
631     linkConstraints2.gridy = 1;
632     linkConstraints2.weightx = 1.0;
633     linkConstraints2.weighty = 1.0;
634     linkConstraints2.fill = GridBagConstraints.BOTH;
635     linkTab.add(linkScrollPane, linkConstraints2);
636
637     // Filter box and buttons goes at bottom left, resizing resizes the text box
638     JPanel filterPanel = initLinkTabFilterPanel();
639     GridBagConstraints linkConstraints3 = new GridBagConstraints();
640     linkConstraints3.insets = new Insets(0, 0, 0, 5);
641     linkConstraints3.gridx = 0;
642     linkConstraints3.gridy = 2;
643     linkConstraints3.weightx = 1.0;
644     linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
645     linkTab.add(filterPanel, linkConstraints3);
646
647     return linkTab;
648   }
649
650   private JPanel initLinkTabFilterPanel()
651   {
652     // Filter textbox and reset button
653     JLabel filterLabel = new JLabel(
654             MessageManager.getString("label.filter"));
655     filterLabel.setFont(LABEL_FONT);
656     filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
657     filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
658
659     filterTB.setFont(LABEL_FONT);
660     filterTB.setText("");
661
662     doReset.setText(MessageManager.getString("action.showall"));
663     userOnly.setText(MessageManager.getString("action.customfilter"));
664
665     // Panel for filter functionality
666     JPanel filterPanel = new JPanel(new GridBagLayout());
667     filterPanel.setBorder(new TitledBorder("Filter"));
668     GridBagConstraints gbc = new GridBagConstraints();
669     gbc.gridx = 0;
670     gbc.gridy = 0;
671     gbc.fill = GridBagConstraints.NONE;
672     gbc.anchor = GridBagConstraints.WEST;
673
674     filterPanel.add(filterLabel, gbc);
675
676     GridBagConstraints gbc1 = new GridBagConstraints();
677     gbc1.gridx = 1;
678     gbc1.gridwidth = 2;
679     gbc1.fill = GridBagConstraints.HORIZONTAL;
680     gbc1.anchor = GridBagConstraints.WEST;
681     gbc1.weightx = 1.0;
682     filterPanel.add(filterTB, gbc1);
683
684     GridBagConstraints gbc2 = new GridBagConstraints();
685     gbc2.gridx = 3;
686     gbc2.fill = GridBagConstraints.NONE;
687     gbc2.anchor = GridBagConstraints.WEST;
688     filterPanel.add(doReset, gbc2);
689
690     GridBagConstraints gbc3 = new GridBagConstraints();
691     gbc3.gridx = 4;
692     gbc3.fill = GridBagConstraints.NONE;
693     gbc3.anchor = GridBagConstraints.WEST;
694     filterPanel.add(userOnly, gbc3);
695
696     return filterPanel;
697   }
698
699   private JPanel initLinkTabUrlButtons()
700   {
701     // Buttons for new / edit / delete Url links
702     JButton newLink = new JButton();
703     newLink.setText(MessageManager.getString("action.new"));
704
705     editLink.setText(MessageManager.getString("action.edit"));
706
707     deleteLink.setText(MessageManager.getString("action.delete"));
708
709     // no current selection, so initially disable delete/edit buttons
710     editLink.setEnabled(false);
711     deleteLink.setEnabled(false);
712
713     newLink.addActionListener(new java.awt.event.ActionListener()
714     {
715       @Override
716       public void actionPerformed(ActionEvent e)
717       {
718         newLink_actionPerformed(e);
719       }
720     });
721
722     editLink.setText(MessageManager.getString("action.edit"));
723     editLink.addActionListener(new java.awt.event.ActionListener()
724     {
725       @Override
726       public void actionPerformed(ActionEvent e)
727       {
728         editLink_actionPerformed(e);
729       }
730     });
731
732     deleteLink.setText(MessageManager.getString("action.delete"));
733     deleteLink.addActionListener(new java.awt.event.ActionListener()
734     {
735       @Override
736       public void actionPerformed(ActionEvent e)
737       {
738         deleteLink_actionPerformed(e);
739       }
740     });
741
742     JPanel buttonPanel = new JPanel(new GridBagLayout());
743     buttonPanel.setBorder(new TitledBorder("Edit links"));
744     GridBagConstraints gbc = new GridBagConstraints();
745     gbc.gridx = 0;
746     gbc.gridy = 0;
747     gbc.fill = GridBagConstraints.NONE;
748     buttonPanel.add(newLink, gbc);
749
750     GridBagConstraints gbc1 = new GridBagConstraints();
751     gbc1.gridx = 1;
752     gbc1.gridy = 0;
753     gbc1.fill = GridBagConstraints.NONE;
754     buttonPanel.add(editLink, gbc1);
755
756     GridBagConstraints gbc2 = new GridBagConstraints();
757     gbc2.gridx = 2;
758     gbc2.gridy = 0;
759     gbc2.fill = GridBagConstraints.NONE;
760     buttonPanel.add(deleteLink, gbc2);
761
762     GridBagConstraints gbc3 = new GridBagConstraints();
763     gbc3.gridx = 3;
764     gbc3.gridy = 0;
765     gbc3.fill = GridBagConstraints.HORIZONTAL;
766     gbc3.weightx = 1.0;
767     JPanel spacePanel = new JPanel();
768     spacePanel.setBorder(null);
769     buttonPanel.add(spacePanel, gbc3);
770
771     return buttonPanel;
772   }
773
774   /**
775    * Initialises the proxy server panel in the Connections tab
776    * 
777    * @return the proxy server panel
778    */
779   private JPanel initConnTabProxyPanel()
780   {
781     // Label for server text box
782     serverLabel.setText(MessageManager.getString("label.address"));
783     serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
784     serverLabel.setFont(LABEL_FONT);
785
786     // Proxy server and port text boxes
787     proxyServerTB.setFont(LABEL_FONT);
788     proxyPortTB.setFont(LABEL_FONT);
789
790     // Label for Port text box
791     portLabel.setFont(LABEL_FONT);
792     portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
793     portLabel.setText(MessageManager.getString("label.port"));
794
795     // Use proxy server checkbox
796     useProxy.setFont(LABEL_FONT);
797     useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
798     useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
799     useProxy.setText(MessageManager.getString("label.use_proxy_server"));
800     useProxy.addActionListener(new ActionListener()
801     {
802       @Override
803       public void actionPerformed(ActionEvent e)
804       {
805         useProxy_actionPerformed();
806       }
807     });
808
809     // Make proxy server panel
810     JPanel proxyPanel = new JPanel();
811     TitledBorder titledBorder1 = new TitledBorder(
812             MessageManager.getString("label.proxy_server"));
813     proxyPanel.setBorder(titledBorder1);
814     proxyPanel.setLayout(new GridBagLayout());
815     proxyPanel.add(serverLabel,
816             new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
817                     GridBagConstraints.WEST, GridBagConstraints.NONE,
818                     new Insets(0, 2, 2, 0), 5, 0));
819     proxyPanel.add(portLabel,
820             new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
821                     GridBagConstraints.WEST, GridBagConstraints.NONE,
822                     new Insets(0, 0, 2, 0), 11, 0));
823     proxyPanel.add(useProxy,
824             new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
825                     GridBagConstraints.WEST, GridBagConstraints.NONE,
826                     new Insets(0, 2, 5, 185), 2, -4));
827     proxyPanel.add(proxyPortTB,
828             new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
829                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
830                     new Insets(0, 2, 2, 2), 54, 1));
831     proxyPanel.add(proxyServerTB,
832             new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
833                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
834                     new Insets(0, 2, 2, 0), 263, 1));
835
836     return proxyPanel;
837   }
838
839   /**
840    * Initialises the checkboxes in the Connections tab
841    */
842   private void initConnTabCheckboxes()
843   {
844     // Usage stats checkbox label
845     usagestats.setText(
846             MessageManager.getString("label.send_usage_statistics"));
847     usagestats.setFont(LABEL_FONT);
848     usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
849     usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
850
851     // Questionnaire checkbox label
852     questionnaire.setText(
853             MessageManager.getString("label.check_for_questionnaires"));
854     questionnaire.setFont(LABEL_FONT);
855     questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
856     questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
857
858     // Check for latest version checkbox label
859     versioncheck.setText(
860             MessageManager.getString("label.check_for_latest_version"));
861     versioncheck.setFont(LABEL_FONT);
862     versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
863     versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
864   }
865
866   /**
867    * Initialises the parent panel which contains the tabbed sections.
868    * 
869    * @return
870    */
871   private JPanel initOkCancelPanel()
872   {
873     JButton ok = new JButton();
874     ok.setText(MessageManager.getString("action.ok"));
875     ok.addActionListener(new ActionListener()
876     {
877       @Override
878       public void actionPerformed(ActionEvent e)
879       {
880         ok_actionPerformed(e);
881       }
882     });
883     JButton cancel = new JButton();
884     cancel.setText(MessageManager.getString("action.cancel"));
885     cancel.addActionListener(new ActionListener()
886     {
887       @Override
888       public void actionPerformed(ActionEvent e)
889       {
890         cancel_actionPerformed(e);
891       }
892     });
893     JPanel okCancelPanel = new JPanel();
894     okCancelPanel.add(ok);
895     okCancelPanel.add(cancel);
896     return okCancelPanel;
897   }
898
899   /**
900    * Initialises the Colours tabbed panel.
901    * 
902    * @return
903    */
904   private JPanel initColoursTab()
905   {
906     JPanel coloursTab = new JPanel();
907     coloursTab.setBorder(new TitledBorder(
908             MessageManager.getString("action.open_new_alignment")));
909     coloursTab.setLayout(new FlowLayout());
910     JLabel mincolourLabel = new JLabel();
911     mincolourLabel.setFont(LABEL_FONT);
912     mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
913     mincolourLabel.setText(MessageManager.getString("label.min_colour"));
914     minColour.setFont(LABEL_FONT);
915     minColour.setBorder(BorderFactory.createEtchedBorder());
916     minColour.setPreferredSize(new Dimension(40, 20));
917     minColour.addMouseListener(new MouseAdapter()
918     {
919       @Override
920       public void mousePressed(MouseEvent e)
921       {
922         minColour_actionPerformed(minColour);
923       }
924     });
925     JLabel maxcolourLabel = new JLabel();
926     maxcolourLabel.setFont(LABEL_FONT);
927     maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
928     maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
929     maxColour.setFont(LABEL_FONT);
930     maxColour.setBorder(BorderFactory.createEtchedBorder());
931     maxColour.setPreferredSize(new Dimension(40, 20));
932     maxColour.addMouseListener(new MouseAdapter()
933     {
934       @Override
935       public void mousePressed(MouseEvent e)
936       {
937         maxColour_actionPerformed(maxColour);
938       }
939     });
940
941     protColour.setFont(LABEL_FONT);
942     protColour.setBounds(new Rectangle(172, 225, 155, 21));
943     JLabel protColourLabel = new JLabel();
944     protColourLabel.setFont(LABEL_FONT);
945     protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
946     protColourLabel.setText(
947             MessageManager.getString("label.prot_alignment_colour") + " ");
948     JvSwingUtils.addtoLayout(coloursTab,
949             MessageManager
950                     .getString("label.default_colour_scheme_for_alignment"),
951             protColourLabel, protColour);
952
953     nucColour.setFont(LABEL_FONT);
954     nucColour.setBounds(new Rectangle(172, 240, 155, 21));
955     JLabel nucColourLabel = new JLabel();
956     nucColourLabel.setFont(LABEL_FONT);
957     nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
958     nucColourLabel.setText(
959             MessageManager.getString("label.nuc_alignment_colour") + " ");
960     JvSwingUtils.addtoLayout(coloursTab,
961             MessageManager
962                     .getString("label.default_colour_scheme_for_alignment"),
963             nucColourLabel, nucColour);
964
965     JPanel annotationShding = new JPanel();
966     annotationShding.setBorder(new TitledBorder(
967             MessageManager.getString("label.annotation_shading_default")));
968     annotationShding.setLayout(new GridLayout(1, 2));
969     JvSwingUtils.addtoLayout(annotationShding,
970             MessageManager.getString(
971                     "label.default_minimum_colour_annotation_shading"),
972             mincolourLabel, minColour);
973     JvSwingUtils.addtoLayout(annotationShding,
974             MessageManager.getString(
975                     "label.default_maximum_colour_annotation_shading"),
976             maxcolourLabel, maxColour);
977     coloursTab.add(annotationShding); // , FlowLayout.LEFT);
978     return coloursTab;
979   }
980
981   /**
982    * Initialises the Overview tabbed panel.
983    * 
984    * @return
985    */
986   private JPanel initOverviewTab()
987   {
988     JPanel overviewPanel = new JPanel();
989     overviewPanel.setBorder(new TitledBorder(
990             MessageManager.getString("label.overview_settings")));
991
992     gapColour.setFont(LABEL_FONT);
993     // fixing the border colours stops apparent colour bleed from the panel
994     gapColour.setBorder(
995             BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
996     gapColour.setPreferredSize(new Dimension(40, 20));
997     gapColour.addMouseListener(new MouseAdapter()
998     {
999       @Override
1000       public void mousePressed(MouseEvent e)
1001       {
1002         gapColour_actionPerformed(gapColour);
1003       }
1004     });
1005
1006     hiddenColour.setFont(LABEL_FONT);
1007     // fixing the border colours stops apparent colour bleed from the panel
1008     hiddenColour.setBorder(
1009             BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1010     hiddenColour.setPreferredSize(new Dimension(40, 20));
1011     hiddenColour.addMouseListener(new MouseAdapter()
1012     {
1013       @Override
1014       public void mousePressed(MouseEvent e)
1015       {
1016         hiddenColour_actionPerformed(hiddenColour);
1017       }
1018     });
1019     
1020     useLegacyGap = new JCheckBox(
1021             MessageManager.getString("label.ov_legacy_gap"));
1022     useLegacyGap.setFont(LABEL_FONT);
1023     useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1024     gapLabel = new JLabel(
1025             MessageManager.getString("label.gap_colour"));
1026     gapLabel.setFont(LABEL_FONT);
1027     gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1028     showHiddenAtStart = new JCheckBox(
1029             MessageManager.getString("label.ov_show_hide_default"));
1030     showHiddenAtStart.setFont(LABEL_FONT);
1031     showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1032     JLabel hiddenLabel = new JLabel(
1033             MessageManager.getString("label.hidden_colour"));
1034     hiddenLabel.setFont(LABEL_FONT);
1035     hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1036
1037     useLegacyGap.addActionListener(new ActionListener()
1038     {
1039       @Override
1040       public void actionPerformed(ActionEvent e)
1041       {
1042         useLegacyGaps_actionPerformed(e);
1043       }
1044     });
1045
1046     overviewPanel.setLayout(new GridBagLayout());
1047     GridBagConstraints c1 = new GridBagConstraints();
1048
1049     c1.fill = GridBagConstraints.HORIZONTAL;
1050     c1.gridx = 0;
1051     c1.gridy = 0;
1052     c1.weightx = 1;
1053     c1.ipady = 20;
1054     c1.anchor = GridBagConstraints.FIRST_LINE_START;
1055     overviewPanel.add(useLegacyGap, c1);
1056
1057     GridBagConstraints c2 = new GridBagConstraints();
1058     c2.fill = GridBagConstraints.HORIZONTAL;
1059     c2.gridx = 1;
1060     c2.gridy = 0;
1061     c2.insets = new Insets(0, 15, 0, 10);
1062     overviewPanel.add(gapLabel, c2);
1063
1064     GridBagConstraints c3 = new GridBagConstraints();
1065     c3.fill = GridBagConstraints.HORIZONTAL;
1066     c3.gridx = 2;
1067     c3.gridy = 0;
1068     c3.insets = new Insets(0, 0, 0, 15);
1069     overviewPanel.add(gapColour, c3);
1070
1071     GridBagConstraints c4 = new GridBagConstraints();
1072     c4.fill = GridBagConstraints.HORIZONTAL;
1073     c4.gridx = 0;
1074     c4.gridy = 1;
1075     c4.weightx = 1;
1076     overviewPanel.add(showHiddenAtStart, c4);
1077
1078     GridBagConstraints c5 = new GridBagConstraints();
1079     c5.fill = GridBagConstraints.HORIZONTAL;
1080     c5.gridx = 1;
1081     c5.gridy = 1;
1082     c5.insets = new Insets(0, 15, 0, 10);
1083     overviewPanel.add(hiddenLabel, c5);
1084
1085     GridBagConstraints c6 = new GridBagConstraints();
1086     c6.fill = GridBagConstraints.HORIZONTAL;
1087     c6.gridx = 2;
1088     c6.gridy = 1;
1089     c6.insets = new Insets(0, 0, 0, 15);
1090     overviewPanel.add(hiddenColour, c6);
1091
1092     JButton resetButton = new JButton(
1093             MessageManager.getString("label.reset_to_defaults"));
1094
1095     resetButton.addActionListener(new ActionListener()
1096     {
1097       @Override
1098       public void actionPerformed(ActionEvent e)
1099       {
1100         resetOvDefaults_actionPerformed(e);
1101       }
1102     });
1103
1104     GridBagConstraints c7 = new GridBagConstraints();
1105     c7.fill = GridBagConstraints.NONE;
1106     c7.gridx = 0;
1107     c7.gridy = 2;
1108     c7.insets = new Insets(10, 0, 0, 0);
1109     c7.anchor = GridBagConstraints.WEST;
1110     overviewPanel.add(resetButton, c7);
1111
1112     // Add padding so the panel doesn't look ridiculous
1113     JPanel spacePanel = new JPanel();
1114     overviewPanel.add(spacePanel,
1115             new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1116                     GridBagConstraints.WEST, GridBagConstraints.BOTH,
1117                     new Insets(0, 0, 0, 5), 0, 0));
1118
1119     return overviewPanel;
1120   }
1121
1122   /**
1123    * Initialises the Structure tabbed panel.
1124    * 
1125    * @return
1126    */
1127   private JPanel initStructureTab()
1128   {
1129     structureTab = new JPanel();
1130
1131     structureTab.setBorder(new TitledBorder(
1132             MessageManager.getString("label.structure_options")));
1133     structureTab.setLayout(null);
1134     final int width = 400;
1135     final int height = 22;
1136     final int lineSpacing = 25;
1137     int ypos = 15;
1138
1139     structFromPdb.setFont(LABEL_FONT);
1140     structFromPdb
1141             .setText(MessageManager.getString("label.struct_from_pdb"));
1142     structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1143     structFromPdb.addActionListener(new ActionListener()
1144     {
1145       @Override
1146       public void actionPerformed(ActionEvent e)
1147       {
1148         boolean selected = structFromPdb.isSelected();
1149         // enable other options only when the first is checked
1150         useRnaView.setEnabled(selected);
1151         addSecondaryStructure.setEnabled(selected);
1152         addTempFactor.setEnabled(selected);
1153       }
1154     });
1155     structureTab.add(structFromPdb);
1156
1157     // indent checkboxes that are conditional on the first one
1158     ypos += lineSpacing;
1159     useRnaView.setFont(LABEL_FONT);
1160     useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1161     useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1162     structureTab.add(useRnaView);
1163
1164     ypos += lineSpacing;
1165     addSecondaryStructure.setFont(LABEL_FONT);
1166     addSecondaryStructure
1167             .setText(MessageManager.getString("label.autoadd_secstr"));
1168     addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1169     structureTab.add(addSecondaryStructure);
1170
1171     ypos += lineSpacing;
1172     addTempFactor.setFont(LABEL_FONT);
1173     addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1174     addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1175     structureTab.add(addTempFactor);
1176
1177     ypos += lineSpacing;
1178     JLabel viewerLabel = new JLabel();
1179     viewerLabel.setFont(LABEL_FONT);
1180     viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1181     viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1182     viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1183     structureTab.add(viewerLabel);
1184
1185     structViewer.setFont(LABEL_FONT);
1186     structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1187     structViewer.addItem(ViewerType.JMOL.name());
1188     structViewer.addItem(ViewerType.CHIMERA.name());
1189     structViewer.addActionListener(new ActionListener()
1190     {
1191       @Override
1192       public void actionPerformed(ActionEvent e)
1193       {
1194         structureViewer_actionPerformed(
1195                 (String) structViewer.getSelectedItem());
1196       }
1197     });
1198     structureTab.add(structViewer);
1199
1200     ypos += lineSpacing;
1201     JLabel pathLabel = new JLabel();
1202     pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1203     pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1204     pathLabel.setText(MessageManager.getString("label.chimera_path"));
1205     final String tooltip = JvSwingUtils.wrapTooltip(true,
1206             MessageManager.getString("label.chimera_path_tip"));
1207     pathLabel.setToolTipText(tooltip);
1208     pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1209     structureTab.add(pathLabel);
1210
1211     chimeraPath.setFont(LABEL_FONT);
1212     chimeraPath.setText("");
1213     chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1214     chimeraPath.addMouseListener(new MouseAdapter()
1215     {
1216       @Override
1217       public void mouseClicked(MouseEvent e)
1218       {
1219         if (e.getClickCount() == 2)
1220         {
1221           String chosen = openFileChooser();
1222           if (chosen != null)
1223           {
1224             chimeraPath.setText(chosen);
1225           }
1226         }
1227       }
1228     });
1229     structureTab.add(chimeraPath);
1230
1231     ypos += lineSpacing;
1232     nwMapping.setFont(LABEL_FONT);
1233     nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1234     siftsMapping.setFont(LABEL_FONT);
1235     siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1236     mappingMethod.add(nwMapping);
1237     mappingMethod.add(siftsMapping);
1238     JPanel mappingPanel = new JPanel();
1239     mappingPanel.setFont(LABEL_FONT);
1240     TitledBorder mmTitledBorder = new TitledBorder(
1241             MessageManager.getString("label.mapping_method"));
1242     mmTitledBorder.setTitleFont(LABEL_FONT);
1243     mappingPanel.setBorder(mmTitledBorder);
1244     mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1245     // GridLayout mappingLayout = new GridLayout();
1246     mappingPanel.setLayout(new GridLayout());
1247     mappingPanel.add(nwMapping);
1248     mappingPanel.add(siftsMapping);
1249     structureTab.add(mappingPanel);
1250
1251     ypos += lineSpacing;
1252     ypos += lineSpacing;
1253     FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1254             PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1255     docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1256     structureTab.add(docFieldPref);
1257
1258     return structureTab;
1259   }
1260
1261   /**
1262    * Action on choosing a structure viewer from combobox options.
1263    * 
1264    * @param selectedItem
1265    */
1266   protected void structureViewer_actionPerformed(String selectedItem)
1267   {
1268   }
1269
1270   /**
1271    * Show a dialog for the user to choose a file. Returns the chosen path, or
1272    * null on Cancel.
1273    * 
1274    * @return
1275    */
1276   protected String openFileChooser()
1277   {
1278     String choice = null;
1279     JFileChooser chooser = new JFileChooser();
1280
1281     // chooser.setFileView(new JalviewFileView());
1282     chooser.setDialogTitle(
1283             MessageManager.getString("label.open_local_file"));
1284     chooser.setToolTipText(MessageManager.getString("action.open"));
1285
1286     int value = chooser.showOpenDialog(this);
1287
1288     if (value == JFileChooser.APPROVE_OPTION)
1289     {
1290       choice = chooser.getSelectedFile().getPath();
1291     }
1292     return choice;
1293   }
1294
1295   /**
1296    * Validate the structure tab preferences; if invalid, set focus on this tab.
1297    * 
1298    * @param e
1299    */
1300   protected boolean validateStructure(FocusEvent e)
1301   {
1302     if (!validateStructure())
1303     {
1304       e.getComponent().requestFocusInWindow();
1305       return false;
1306     }
1307     return true;
1308   }
1309
1310   protected boolean validateStructure()
1311   {
1312     return false;
1313   }
1314
1315   /**
1316    * Initialises the Visual tabbed panel.
1317    * 
1318    * @return
1319    */
1320   private JPanel initVisualTab()
1321   {
1322     JPanel visualTab = new JPanel();
1323     visualTab.setBorder(new TitledBorder(
1324             MessageManager.getString("action.open_new_alignment")));
1325     visualTab.setLayout(null);
1326     fullScreen.setFont(LABEL_FONT);
1327     fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1328     fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1329     fullScreen.setText(MessageManager.getString("label.maximize_window"));
1330     quality.setEnabled(false);
1331     quality.setFont(LABEL_FONT);
1332     quality.setHorizontalAlignment(SwingConstants.RIGHT);
1333     quality.setHorizontalTextPosition(SwingConstants.LEFT);
1334     quality.setSelected(true);
1335     quality.setText(MessageManager.getString("label.quality"));
1336     conservation.setEnabled(false);
1337     conservation.setFont(LABEL_FONT);
1338     conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1339     conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1340     conservation.setSelected(true);
1341     conservation.setText(MessageManager.getString("label.conservation"));
1342     identity.setEnabled(false);
1343     identity.setFont(LABEL_FONT);
1344     identity.setHorizontalAlignment(SwingConstants.RIGHT);
1345     identity.setHorizontalTextPosition(SwingConstants.LEFT);
1346     identity.setSelected(true);
1347     identity.setText(MessageManager.getString("label.consensus"));
1348     showOccupancy.setFont(LABEL_FONT);
1349     showOccupancy.setEnabled(false);
1350     showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1351     showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1352     showOccupancy.setSelected(true);
1353     showOccupancy.setText(MessageManager.getString("label.occupancy"));
1354
1355     JLabel showGroupbits = new JLabel();
1356     showGroupbits.setFont(LABEL_FONT);
1357     showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1358     showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1359     showGroupbits
1360             .setText(MessageManager.getString("action.show_group") + ":");
1361     JLabel showConsensbits = new JLabel();
1362     showConsensbits.setFont(LABEL_FONT);
1363     showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1364     showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1365     showConsensbits
1366             .setText(MessageManager.getString("label.consensus") + ":");
1367     showConsensHistogram.setEnabled(false);
1368     showConsensHistogram.setFont(LABEL_FONT);
1369     showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1370     showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1371     showConsensHistogram.setSelected(true);
1372     showConsensHistogram
1373             .setText(MessageManager.getString("label.histogram"));
1374     showConsensLogo.setEnabled(false);
1375     showConsensLogo.setFont(LABEL_FONT);
1376     showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1377     showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1378     showConsensLogo.setSelected(true);
1379     showConsensLogo.setText(MessageManager.getString("label.logo"));
1380     showGroupConsensus.setEnabled(false);
1381     showGroupConsensus.setFont(LABEL_FONT);
1382     showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1383     showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1384     showGroupConsensus.setSelected(true);
1385     showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1386     showGroupConservation.setEnabled(false);
1387     showGroupConservation.setFont(LABEL_FONT);
1388     showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1389     showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1390     showGroupConservation.setSelected(true);
1391     showGroupConservation
1392             .setText(MessageManager.getString("label.conservation"));
1393     showNpTooltip.setEnabled(true);
1394     showNpTooltip.setFont(LABEL_FONT);
1395     showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1396     showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1397     showNpTooltip.setSelected(true);
1398     showNpTooltip.setText(
1399             MessageManager.getString("label.non_positional_features"));
1400     showDbRefTooltip.setEnabled(true);
1401     showDbRefTooltip.setFont(LABEL_FONT);
1402     showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1403     showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1404     showDbRefTooltip.setSelected(true);
1405     showDbRefTooltip
1406             .setText(MessageManager.getString("label.database_references"));
1407     annotations.setFont(LABEL_FONT);
1408     annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1409     annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1410     annotations.setSelected(true);
1411     annotations.setText(MessageManager.getString("label.show_annotations"));
1412     // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1413     annotations.addActionListener(new ActionListener()
1414     {
1415       @Override
1416       public void actionPerformed(ActionEvent e)
1417       {
1418         annotations_actionPerformed(e);
1419       }
1420     });
1421     identity.addActionListener(new ActionListener()
1422     {
1423       @Override
1424       public void actionPerformed(ActionEvent e)
1425       {
1426         annotations_actionPerformed(e);
1427       }
1428     });
1429     showGroupConsensus.addActionListener(new ActionListener()
1430     {
1431       @Override
1432       public void actionPerformed(ActionEvent e)
1433       {
1434         annotations_actionPerformed(e);
1435       }
1436     });
1437     showUnconserved.setFont(LABEL_FONT);
1438     showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1439     showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1440     showUnconserved.setSelected(true);
1441     showUnconserved
1442             .setText(MessageManager.getString("action.show_unconserved"));
1443     showUnconserved.addActionListener(new ActionListener()
1444     {
1445       @Override
1446       public void actionPerformed(ActionEvent e)
1447       {
1448         showunconserved_actionPerformed(e);
1449       }
1450     });
1451
1452     // TODO these are not yet added to / action from Preferences
1453     // JCheckBox shareSelections = new JCheckBox();
1454     // shareSelections.setFont(verdana11);
1455     // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1456     // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1457     // shareSelections.setSelected(true);
1458     // shareSelections.setText(MessageManager
1459     // .getString("label.share_selection_across_views"));
1460     // JCheckBox followHighlight = new JCheckBox();
1461     // followHighlight.setFont(verdana11);
1462     // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1463     // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1464     // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1465     // followHighlight.setSelected(true);
1466     // followHighlight.setText(MessageManager
1467     // .getString("label.scroll_highlighted_regions"));
1468
1469     seqLimit.setFont(LABEL_FONT);
1470     seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1471     seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1472     seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1473     smoothFont.setFont(LABEL_FONT);
1474     smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1475     smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1476     smoothFont.setText(MessageManager.getString("label.smooth_font"));
1477     scaleProteinToCdna.setFont(LABEL_FONT);
1478     scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1479     scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1480     scaleProteinToCdna.setText(
1481             MessageManager.getString("label.scale_protein_to_cdna"));
1482     scaleProteinToCdna.setToolTipText(
1483             MessageManager.getString("label.scale_protein_to_cdna_tip"));
1484     JLabel gapLabel = new JLabel();
1485     gapLabel.setFont(LABEL_FONT);
1486     gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1487     gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1488     JLabel fontLabel = new JLabel();
1489     fontLabel.setFont(LABEL_FONT);
1490     fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1491     fontLabel.setText(MessageManager.getString("label.font"));
1492     fontSizeCB.setFont(LABEL_FONT);
1493     fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1494     fontStyleCB.setFont(LABEL_FONT);
1495     fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1496     fontNameCB.setFont(LABEL_FONT);
1497     fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1498     gapSymbolCB.setFont(LABEL_FONT);
1499     gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1500     DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1501     dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1502     gapSymbolCB.setRenderer(dlcr);
1503
1504     startupCheckbox.setText(MessageManager.getString("action.open_file"));
1505     startupCheckbox.setFont(LABEL_FONT);
1506     startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1507     startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1508     startupCheckbox.setSelected(true);
1509     startupFileTextfield.setFont(LABEL_FONT);
1510     startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
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 }