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