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