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