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