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