JAL-2629 add HMMER tab in preferences menu
[jalview.git] / src / jalview / jbgui / GPreferences.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.jbgui;
22
23 import jalview.fts.core.FTSDataColumnPreferences;
24 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
25 import jalview.fts.service.pdb.PDBFTSRestClient;
26 import jalview.gui.JvSwingUtils;
27 import jalview.gui.StructureViewer.ViewerType;
28 import jalview.util.MessageManager;
29
30 import java.awt.BorderLayout;
31 import java.awt.Color;
32 import java.awt.Component;
33 import java.awt.Dimension;
34 import java.awt.FlowLayout;
35 import java.awt.Font;
36 import java.awt.GridBagConstraints;
37 import java.awt.GridBagLayout;
38 import java.awt.GridLayout;
39 import java.awt.Insets;
40 import java.awt.Rectangle;
41 import java.awt.event.ActionEvent;
42 import java.awt.event.ActionListener;
43 import java.awt.event.FocusEvent;
44 import java.awt.event.KeyEvent;
45 import java.awt.event.MouseAdapter;
46 import java.awt.event.MouseEvent;
47
48 import javax.swing.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 installationLocationField = 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         lastTab = tabbedPane.getSelectedComponent();
380       }
381
382     });
383   }
384
385   /**
386    * Initialises the Editing tabbed panel.
387    * 
388    * @return
389    */
390   private JPanel initEditingTab()
391   {
392     JPanel editingTab = new JPanel();
393     editingTab.setLayout(null);
394     autoCalculateConsCheck.setFont(LABEL_FONT);
395     autoCalculateConsCheck.setText(MessageManager
396             .getString("label.autocalculate_consensus"));
397     autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
398     padGaps.setFont(LABEL_FONT);
399     padGaps.setText(MessageManager.getString("label.pad_gaps_when_editing"));
400     padGaps.setBounds(new Rectangle(22, 94, 168, 23));
401     sortByTree.setFont(LABEL_FONT);
402     sortByTree
403             .setText(MessageManager.getString("label.sort_with_new_tree"));
404     sortByTree
405             .setToolTipText(MessageManager
406                     .getString("label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
407     sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
408     editingTab.add(autoCalculateConsCheck);
409     editingTab.add(padGaps);
410     editingTab.add(sortByTree);
411     return editingTab;
412   }
413
414   /**
415    * Initialises the hmmer tabbed panel.
416    * 
417    * @return
418    */
419   private JPanel initHMMERTab()
420   {
421     JPanel hmmerTab = new JPanel();
422     hmmerTab.setLayout(null);
423
424     hmmalign.setFont(LABEL_FONT);
425     hmmalign.setText(MessageManager.getString("label.hmmalign_label"));
426     hmmalign.setBounds(new Rectangle(22, 10, 200, 23));
427
428     trimTermini.setFont(LABEL_FONT);
429     trimTermini.setText(MessageManager.getString("label.trim_termini"));
430     trimTermini.setBounds(new Rectangle(22, 30, 200, 23));
431
432     hmmsearch.setFont(LABEL_FONT);
433     hmmsearch.setText(MessageManager.getString("label.hmmsearch_label"));
434     hmmsearch.setBounds(new Rectangle(250, 10, 200, 23));
435
436     sequencesToKeep.setFont(LABEL_FONT);
437     sequencesToKeep
438             .setText(MessageManager.getString("label.no_of_sequences"));
439     sequencesToKeep.setBounds(new Rectangle(250, 30, 125, 23));
440     numberOfSequencesToKeepField.setBounds(new Rectangle(375, 30, 40, 23));
441
442     installationLocation.setFont(LABEL_FONT);
443     installationLocation.setText(
444             MessageManager.getString("label.change_hmmer_location"));
445     installationLocation.setBounds(new Rectangle(22, 200, 200, 23));
446     installationLocationField.setBounds(new Rectangle(22, 220, 200, 23));
447     installationLocationField.addMouseListener(new MouseAdapter()
448     {
449       @Override
450       public void mouseClicked(MouseEvent e)
451       {
452         if (e.getClickCount() == 2)
453         {
454           String chosen = openFileChooser();
455           if (chosen != null)
456           {
457             installationLocationField.setText(chosen);
458           }
459         }
460       }
461     });
462
463     backgroundFreqSource.add(uniprot);
464     backgroundFreqSource.add(alignment);
465     backgroundFreqSource.setSelected(uniprot.getModel(), true);
466
467     uniprot.setText(MessageManager.getString("label.freq_uniprot"));
468     uniprot.setFont(LABEL_FONT);
469     uniprot.setBounds(new Rectangle(22, 260, 255, 23));
470
471     alignment.setText(MessageManager.getString("label.freq_alignment"));
472     alignment.setFont(LABEL_FONT);
473     alignment.setBounds(new Rectangle(22, 280, 255, 23));
474
475     hmmerTab.add(uniprot);
476     hmmerTab.add(alignment);
477     hmmerTab.add(hmmalign);
478     hmmerTab.add(hmmsearch);
479     hmmerTab.add(installationLocation);
480     hmmerTab.add(installationLocationField);
481     hmmerTab.add(trimTermini);
482     hmmerTab.add(sequencesToKeep);
483     hmmerTab.add(sequencesToKeep);
484     hmmerTab.add(numberOfSequencesToKeepField);
485     return hmmerTab;
486   }
487
488   /**
489    * Initialises the Output tabbed panel.
490    * 
491    * @return
492    */
493   private JPanel initOutputTab()
494   {
495     JPanel outputTab = new JPanel();
496     outputTab.setLayout(null);
497     JLabel epsLabel = new JLabel();
498     epsLabel.setFont(LABEL_FONT);
499     epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
500     epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
501     epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
502     epsRendering.setFont(LABEL_FONT);
503     epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
504     JLabel jLabel1 = new JLabel();
505     jLabel1.setFont(LABEL_FONT);
506     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
507     jLabel1.setText(MessageManager.getString("label.append_start_end"));
508     jLabel1.setFont(LABEL_FONT);
509     fastajv.setFont(LABEL_FONT);
510     fastajv.setHorizontalAlignment(SwingConstants.LEFT);
511     clustaljv.setText(MessageManager.getString("label.clustal") + "     ");
512     blcjv.setText(MessageManager.getString("label.blc") + "     ");
513     fastajv.setText(MessageManager.getString("label.fasta") + "     ");
514     msfjv.setText(MessageManager.getString("label.msf") + "     ");
515     pfamjv.setText(MessageManager.getString("label.pfam") + "     ");
516     pileupjv.setText(MessageManager.getString("label.pileup") + "     ");
517     msfjv.setFont(LABEL_FONT);
518     msfjv.setHorizontalAlignment(SwingConstants.LEFT);
519     pirjv.setText(MessageManager.getString("label.pir") + "     ");
520     JPanel jPanel11 = new JPanel();
521     jPanel11.setFont(LABEL_FONT);
522     TitledBorder titledBorder2 = new TitledBorder(
523             MessageManager.getString("label.file_output"));
524     jPanel11.setBorder(titledBorder2);
525     jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
526     GridLayout gridLayout3 = new GridLayout();
527     jPanel11.setLayout(gridLayout3);
528     gridLayout3.setRows(8);
529     blcjv.setFont(LABEL_FONT);
530     blcjv.setHorizontalAlignment(SwingConstants.LEFT);
531     clustaljv.setFont(LABEL_FONT);
532     clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
533     pfamjv.setFont(LABEL_FONT);
534     pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
535     pileupjv.setFont(LABEL_FONT);
536     pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
537     pirjv.setFont(LABEL_FONT);
538     pirjv.setHorizontalAlignment(SwingConstants.LEFT);
539     autoIdWidth.setFont(LABEL_FONT);
540     autoIdWidth.setText(MessageManager
541             .getString("label.automatically_set_id_width"));
542     autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true,
543             MessageManager
544                     .getString("label.adjusts_width_generated_eps_png")));
545     autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
546     autoIdWidth.addActionListener(new ActionListener()
547     {
548
549       @Override
550       public void actionPerformed(ActionEvent e)
551       {
552         autoIdWidth_actionPerformed();
553       }
554     });
555     userIdWidthlabel.setFont(LABEL_FONT);
556     userIdWidthlabel.setText(MessageManager
557             .getString("label.figure_id_column_width"));
558     userIdWidth
559             .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
560                     .getString("label.manually_specify_width_left_column")));
561     userIdWidthlabel
562             .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
563                     .getString("label.manually_specify_width_left_column")));
564     userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
565     userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
566     userIdWidth.setText("");
567     userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
568     userIdWidth.addActionListener(new ActionListener()
569     {
570
571       @Override
572       public void actionPerformed(ActionEvent e)
573       {
574         userIdWidth_actionPerformed();
575       }
576     });
577     modellerOutput.setFont(LABEL_FONT);
578     modellerOutput.setText(MessageManager
579             .getString("label.use_modeller_output"));
580     modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
581     embbedBioJSON.setFont(LABEL_FONT);
582     embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
583     embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
584
585     jPanel11.add(jLabel1);
586     jPanel11.add(blcjv);
587     jPanel11.add(clustaljv);
588     jPanel11.add(fastajv);
589     jPanel11.add(msfjv);
590     jPanel11.add(pfamjv);
591     jPanel11.add(pileupjv);
592     jPanel11.add(pirjv);
593     outputTab.add(autoIdWidth);
594     outputTab.add(userIdWidth);
595     outputTab.add(userIdWidthlabel);
596     outputTab.add(modellerOutput);
597     outputTab.add(embbedBioJSON);
598     outputTab.add(epsLabel);
599     outputTab.add(epsRendering);
600     outputTab.add(jPanel11);
601     return outputTab;
602   }
603
604   /**
605    * Initialises the Connections tabbed panel.
606    * 
607    * @return
608    */
609   private JPanel initConnectionsTab()
610   {
611     JPanel connectTab = new JPanel();
612     connectTab.setLayout(new GridBagLayout());
613
614     // Label for browser text box
615     JLabel browserLabel = new JLabel();
616     browserLabel.setFont(LABEL_FONT);
617     browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
618     browserLabel.setText(MessageManager
619             .getString("label.default_browser_unix"));
620     defaultBrowser.setFont(LABEL_FONT);
621     defaultBrowser.setText("");
622
623     defaultBrowser.addMouseListener(new MouseAdapter()
624     {
625       @Override
626       public void mouseClicked(MouseEvent e)
627       {
628         if (e.getClickCount() > 1)
629         {
630           defaultBrowser_mouseClicked(e);
631         }
632       }
633     });
634
635     JPanel proxyPanel = initConnTabProxyPanel();
636     initConnTabCheckboxes();
637
638     // Add default Browser text box
639     connectTab.add(browserLabel, new GridBagConstraints(0, 0, 1, 1, 0.0,
640             0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
641             new Insets(10, 0, 5, 5), 5, 1));
642     defaultBrowser.setFont(LABEL_FONT);
643     defaultBrowser.setText("");
644
645     connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
646             0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
647             new Insets(10, 0, 5, 10), 30, 1));
648
649     // Add proxy server panel
650     connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
651             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
652             new Insets(10, 0, 5, 12), 4, 10));
653
654     // Add usage stats, version check and questionnaire checkboxes
655     connectTab.add(usagestats, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
656             GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
657             new Insets(0, 2, 5, 5), 70, 1));
658     connectTab.add(questionnaire, new GridBagConstraints(1, 2, 1, 1, 1.0,
659             0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
660             new Insets(0, 2, 5, 10), 70, 1));
661     connectTab.add(versioncheck, new GridBagConstraints(0, 3, 1, 1, 1.0,
662             0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
663             new Insets(0, 2, 5, 5), 70, 1));
664
665     // Add padding so the panel doesn't look ridiculous
666     JPanel spacePanel = new JPanel();
667     connectTab.add(spacePanel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
668             GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0,
669                     0, 0, 5), 70, 1));
670
671     return connectTab;
672   }
673
674   /**
675    * Initialises the Links tabbed panel.
676    * 
677    * @return
678    */
679   private JPanel initLinksTab()
680   {
681     JPanel linkTab = new JPanel();
682     linkTab.setLayout(new GridBagLayout());
683
684     // Set up table for Url links
685     linkUrlTable.setFillsViewportHeight(true);
686     linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
687     linkUrlTable.setAutoCreateRowSorter(true);
688     linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
689
690     // adjust row height so radio buttons actually fit
691     // don't do this in the renderer, it causes the awt thread to activate
692     // constantly
693     JRadioButton temp = new JRadioButton();
694     linkUrlTable.setRowHeight(temp.getMinimumSize().height);
695
696     // Table in scrollpane so that the table is given a scrollbar
697     JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
698     linkScrollPane.setBorder(null);
699
700     // Panel for links functionality
701     JPanel linkPanel = new JPanel(new GridBagLayout());
702     linkPanel.setBorder(new TitledBorder(MessageManager
703             .getString("label.url_linkfrom_sequence_id")));
704
705     // Put the Url links panel together
706
707     // Buttons go at top right, resizing only resizes the blank space vertically
708     JPanel buttonPanel = initLinkTabUrlButtons();
709     GridBagConstraints linkConstraints1 = new GridBagConstraints();
710     linkConstraints1.insets = new Insets(0, 0, 5, 0);
711     linkConstraints1.gridx = 0;
712     linkConstraints1.gridy = 0;
713     linkConstraints1.weightx = 1.0;
714     linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
715     linkTab.add(buttonPanel, linkConstraints1);
716
717     // Links table goes at top left, resizing resizes the table
718     GridBagConstraints linkConstraints2 = new GridBagConstraints();
719     linkConstraints2.insets = new Insets(0, 0, 5, 5);
720     linkConstraints2.gridx = 0;
721     linkConstraints2.gridy = 1;
722     linkConstraints2.weightx = 1.0;
723     linkConstraints2.weighty = 1.0;
724     linkConstraints2.fill = GridBagConstraints.BOTH;
725     linkTab.add(linkScrollPane, linkConstraints2);
726
727     // Filter box and buttons goes at bottom left, resizing resizes the text box
728     JPanel filterPanel = initLinkTabFilterPanel();
729     GridBagConstraints linkConstraints3 = new GridBagConstraints();
730     linkConstraints3.insets = new Insets(0, 0, 0, 5);
731     linkConstraints3.gridx = 0;
732     linkConstraints3.gridy = 2;
733     linkConstraints3.weightx = 1.0;
734     linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
735     linkTab.add(filterPanel, linkConstraints3);
736
737     return linkTab;
738   }
739
740   private JPanel initLinkTabFilterPanel()
741   {
742     // Filter textbox and reset button
743     JLabel filterLabel = new JLabel(
744             MessageManager.getString("label.filter"));
745     filterLabel.setFont(LABEL_FONT);
746     filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
747     filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
748
749     filterTB.setFont(LABEL_FONT);
750     filterTB.setText("");
751
752     doReset.setText(MessageManager.getString("action.showall"));
753     userOnly.setText(MessageManager.getString("action.customfilter"));
754
755     // Panel for filter functionality
756     JPanel filterPanel = new JPanel(new GridBagLayout());
757     filterPanel.setBorder(new TitledBorder("Filter"));
758     GridBagConstraints gbc = new GridBagConstraints();
759     gbc.gridx = 0;
760     gbc.gridy = 0;
761     gbc.fill = GridBagConstraints.NONE;
762     gbc.anchor = GridBagConstraints.WEST;
763
764     filterPanel.add(filterLabel, gbc);
765
766     GridBagConstraints gbc1 = new GridBagConstraints();
767     gbc1.gridx = 1;
768     gbc1.gridwidth = 2;
769     gbc1.fill = GridBagConstraints.HORIZONTAL;
770     gbc1.anchor = GridBagConstraints.WEST;
771     gbc1.weightx = 1.0;
772     filterPanel.add(filterTB, gbc1);
773
774     GridBagConstraints gbc2 = new GridBagConstraints();
775     gbc2.gridx = 3;
776     gbc2.fill = GridBagConstraints.NONE;
777     gbc2.anchor = GridBagConstraints.WEST;
778     filterPanel.add(doReset, gbc2);
779
780     GridBagConstraints gbc3 = new GridBagConstraints();
781     gbc3.gridx = 4;
782     gbc3.fill = GridBagConstraints.NONE;
783     gbc3.anchor = GridBagConstraints.WEST;
784     filterPanel.add(userOnly, gbc3);
785
786     return filterPanel;
787   }
788
789   private JPanel initLinkTabUrlButtons()
790   {
791     // Buttons for new / edit / delete Url links
792     JButton newLink = new JButton();
793     newLink.setText(MessageManager.getString("action.new"));
794
795     editLink.setText(MessageManager.getString("action.edit"));
796
797     deleteLink.setText(MessageManager.getString("action.delete"));
798
799     // no current selection, so initially disable delete/edit buttons
800     editLink.setEnabled(false);
801     deleteLink.setEnabled(false);
802     
803     newLink.addActionListener(new java.awt.event.ActionListener()
804     {
805       @Override
806       public void actionPerformed(ActionEvent e)
807       {
808         newLink_actionPerformed(e);
809       }
810     });
811
812     editLink.setText(MessageManager.getString("action.edit"));
813     editLink.addActionListener(new java.awt.event.ActionListener()
814     {
815       @Override
816       public void actionPerformed(ActionEvent e)
817       {
818         editLink_actionPerformed(e);
819       }
820     });
821
822     deleteLink.setText(MessageManager.getString("action.delete"));
823     deleteLink.addActionListener(new java.awt.event.ActionListener()
824     {
825       @Override
826       public void actionPerformed(ActionEvent e)
827       {
828         deleteLink_actionPerformed(e);
829       }
830     });
831
832     JPanel buttonPanel = new JPanel(new GridBagLayout());
833     buttonPanel.setBorder(new TitledBorder("Edit links"));
834     GridBagConstraints gbc = new GridBagConstraints();
835     gbc.gridx = 0;
836     gbc.gridy = 0;
837     gbc.fill = GridBagConstraints.NONE;
838     buttonPanel.add(newLink, gbc);
839
840     GridBagConstraints gbc1 = new GridBagConstraints();
841     gbc1.gridx = 1;
842     gbc1.gridy = 0;
843     gbc1.fill = GridBagConstraints.NONE;
844     buttonPanel.add(editLink, gbc1);
845
846     GridBagConstraints gbc2 = new GridBagConstraints();
847     gbc2.gridx = 2;
848     gbc2.gridy = 0;
849     gbc2.fill = GridBagConstraints.NONE;
850     buttonPanel.add(deleteLink, gbc2);
851
852     GridBagConstraints gbc3 = new GridBagConstraints();
853     gbc3.gridx = 3;
854     gbc3.gridy = 0;
855     gbc3.fill = GridBagConstraints.HORIZONTAL;
856     gbc3.weightx = 1.0;
857     JPanel spacePanel = new JPanel();
858     spacePanel.setBorder(null);
859     buttonPanel.add(spacePanel, gbc3);
860
861     return buttonPanel;
862   }
863
864   /**
865    * Initialises the proxy server panel in the Connections tab
866    * 
867    * @return the proxy server panel
868    */
869   private JPanel initConnTabProxyPanel()
870   {
871     // Label for server text box
872     serverLabel.setText(MessageManager.getString("label.address"));
873     serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
874     serverLabel.setFont(LABEL_FONT);
875
876     // Proxy server and port text boxes
877     proxyServerTB.setFont(LABEL_FONT);
878     proxyPortTB.setFont(LABEL_FONT);
879
880     // Label for Port text box
881     portLabel.setFont(LABEL_FONT);
882     portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
883     portLabel.setText(MessageManager.getString("label.port"));
884
885     // Use proxy server checkbox
886     useProxy.setFont(LABEL_FONT);
887     useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
888     useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
889     useProxy.setText(MessageManager.getString("label.use_proxy_server"));
890     useProxy.addActionListener(new ActionListener()
891     {
892       @Override
893       public void actionPerformed(ActionEvent e)
894       {
895         useProxy_actionPerformed();
896       }
897     });
898
899     // Make proxy server panel
900     JPanel proxyPanel = new JPanel();
901     TitledBorder titledBorder1 = new TitledBorder(
902             MessageManager.getString("label.proxy_server"));
903     proxyPanel.setBorder(titledBorder1);
904     proxyPanel.setLayout(new GridBagLayout());
905     proxyPanel.add(serverLabel, new GridBagConstraints(0, 1, 1, 1, 0.0,
906             0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
907             new Insets(0, 2, 2, 0), 5, 0));
908     proxyPanel.add(portLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
909             GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
910                     0, 2, 0), 11, 0));
911     proxyPanel.add(useProxy, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
912             GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
913                     2, 5, 185), 2, -4));
914     proxyPanel.add(proxyPortTB, new GridBagConstraints(3, 1, 1, 1, 1.0,
915             0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
916             new Insets(0, 2, 2, 2), 54, 1));
917     proxyPanel.add(proxyServerTB, new GridBagConstraints(1, 1, 1, 1, 1.0,
918             0.0, 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(MessageManager
931             .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(MessageManager
938             .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(MessageManager
945             .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(MessageManager
993             .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(MessageManager
1032             .getString("label.prot_alignment_colour") + " ");
1033     JvSwingUtils.addtoLayout(coloursTab, MessageManager
1034             .getString("label.default_colour_scheme_for_alignment"),
1035             protColourLabel, protColour);
1036
1037     nucColour.setFont(LABEL_FONT);
1038     nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1039     JLabel nucColourLabel = new JLabel();
1040     nucColourLabel.setFont(LABEL_FONT);
1041     nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1042     nucColourLabel.setText(MessageManager
1043             .getString("label.nuc_alignment_colour") + " ");
1044     JvSwingUtils.addtoLayout(coloursTab, MessageManager
1045             .getString("label.default_colour_scheme_for_alignment"),
1046             nucColourLabel, nucColour);
1047
1048     JPanel annotationShding = new JPanel();
1049     annotationShding.setBorder(new TitledBorder(MessageManager
1050             .getString("label.annotation_shading_default")));
1051     annotationShding.setLayout(new GridLayout(1, 2));
1052     JvSwingUtils.addtoLayout(annotationShding, MessageManager
1053             .getString("label.default_minimum_colour_annotation_shading"),
1054             mincolourLabel, minColour);
1055     JvSwingUtils.addtoLayout(annotationShding, MessageManager
1056             .getString("label.default_maximum_colour_annotation_shading"),
1057             maxcolourLabel, maxColour);
1058     coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1059     return coloursTab;
1060   }
1061
1062   /**
1063    * Initialises the Structure tabbed panel.
1064    * 
1065    * @return
1066    */
1067   private JPanel initStructureTab()
1068   {
1069     structureTab = new JPanel();
1070
1071     structureTab.setBorder(new TitledBorder(MessageManager
1072             .getString("label.structure_options")));
1073     structureTab.setLayout(null);
1074     final int width = 400;
1075     final int height = 22;
1076     final int lineSpacing = 25;
1077     int ypos = 15;
1078
1079     structFromPdb.setFont(LABEL_FONT);
1080     structFromPdb
1081             .setText(MessageManager.getString("label.struct_from_pdb"));
1082     structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1083     structFromPdb.addActionListener(new ActionListener()
1084     {
1085       @Override
1086       public void actionPerformed(ActionEvent e)
1087       {
1088         boolean selected = structFromPdb.isSelected();
1089         // enable other options only when the first is checked
1090         useRnaView.setEnabled(selected);
1091         addSecondaryStructure.setEnabled(selected);
1092         addTempFactor.setEnabled(selected);
1093       }
1094     });
1095     structureTab.add(structFromPdb);
1096
1097     // indent checkboxes that are conditional on the first one
1098     ypos += lineSpacing;
1099     useRnaView.setFont(LABEL_FONT);
1100     useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1101     useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1102     structureTab.add(useRnaView);
1103
1104     ypos += lineSpacing;
1105     addSecondaryStructure.setFont(LABEL_FONT);
1106     addSecondaryStructure.setText(MessageManager
1107             .getString("label.autoadd_secstr"));
1108     addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1109     structureTab.add(addSecondaryStructure);
1110
1111     ypos += lineSpacing;
1112     addTempFactor.setFont(LABEL_FONT);
1113     addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1114     addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1115     structureTab.add(addTempFactor);
1116
1117     ypos += lineSpacing;
1118     JLabel viewerLabel = new JLabel();
1119     viewerLabel.setFont(LABEL_FONT);
1120     viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1121     viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1122     viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1123     structureTab.add(viewerLabel);
1124
1125     structViewer.setFont(LABEL_FONT);
1126     structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1127     structViewer.addItem(ViewerType.JMOL.name());
1128     structViewer.addItem(ViewerType.CHIMERA.name());
1129     structViewer.addActionListener(new ActionListener()
1130     {
1131       @Override
1132       public void actionPerformed(ActionEvent e)
1133       {
1134         structureViewer_actionPerformed((String) structViewer
1135                 .getSelectedItem());
1136       }
1137     });
1138     structureTab.add(structViewer);
1139
1140     ypos += lineSpacing;
1141     JLabel pathLabel = new JLabel();
1142     pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1143     pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1144     pathLabel.setText(MessageManager.getString("label.chimera_path"));
1145     final String tooltip = JvSwingUtils.wrapTooltip(true,
1146             MessageManager.getString("label.chimera_path_tip"));
1147     pathLabel.setToolTipText(tooltip);
1148     pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1149     structureTab.add(pathLabel);
1150
1151     chimeraPath.setFont(LABEL_FONT);
1152     chimeraPath.setText("");
1153     chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1154     chimeraPath.addMouseListener(new MouseAdapter()
1155     {
1156       @Override
1157       public void mouseClicked(MouseEvent e)
1158       {
1159         if (e.getClickCount() == 2)
1160         {
1161           String chosen = openFileChooser();
1162           if (chosen != null)
1163           {
1164             chimeraPath.setText(chosen);
1165           }
1166         }
1167       }
1168     });
1169     structureTab.add(chimeraPath);
1170
1171     ypos += lineSpacing;
1172     nwMapping.setFont(LABEL_FONT);
1173     nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1174     siftsMapping.setFont(LABEL_FONT);
1175     siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1176     mappingMethod.add(nwMapping);
1177     mappingMethod.add(siftsMapping);
1178     JPanel mappingPanel = new JPanel();
1179     mappingPanel.setFont(LABEL_FONT);
1180     TitledBorder mmTitledBorder = new TitledBorder(
1181             MessageManager.getString("label.mapping_method"));
1182     mmTitledBorder.setTitleFont(LABEL_FONT);
1183     mappingPanel.setBorder(mmTitledBorder);
1184     mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1185     // GridLayout mappingLayout = new GridLayout();
1186     mappingPanel.setLayout(new GridLayout());
1187     mappingPanel.add(nwMapping);
1188     mappingPanel.add(siftsMapping);
1189     structureTab.add(mappingPanel);
1190
1191     ypos += lineSpacing;
1192     ypos += lineSpacing;
1193     FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1194             PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1195     docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1196     structureTab.add(docFieldPref);
1197
1198     return structureTab;
1199   }
1200
1201   /**
1202    * Action on choosing a structure viewer from combobox options.
1203    * 
1204    * @param selectedItem
1205    */
1206   protected void structureViewer_actionPerformed(String selectedItem)
1207   {
1208   }
1209
1210   /**
1211    * Show a dialog for the user to choose a file. Returns the chosen path, or
1212    * null on Cancel.
1213    * 
1214    * @return
1215    */
1216   protected String openFileChooser()
1217   {
1218     String choice = null;
1219     JFileChooser chooser = new JFileChooser();
1220
1221     // chooser.setFileView(new JalviewFileView());
1222     chooser.setDialogTitle(MessageManager
1223             .getString("label.open_local_file"));
1224     chooser.setToolTipText(MessageManager.getString("action.open"));
1225
1226     int value = chooser.showOpenDialog(this);
1227
1228     if (value == JFileChooser.APPROVE_OPTION)
1229     {
1230       choice = chooser.getSelectedFile().getPath();
1231     }
1232     return choice;
1233   }
1234
1235   /**
1236    * Validate the structure tab preferences; if invalid, set focus on this tab.
1237    * 
1238    * @param e
1239    */
1240   protected boolean validateStructure(FocusEvent e)
1241   {
1242     if (!validateStructure())
1243     {
1244       e.getComponent().requestFocusInWindow();
1245       return false;
1246     }
1247     return true;
1248   }
1249
1250   protected boolean validateStructure()
1251   {
1252     return false;
1253   }
1254
1255   /**
1256    * Initialises the Visual tabbed panel.
1257    * 
1258    * @return
1259    */
1260   private JPanel initVisualTab()
1261   {
1262     JPanel visualTab = new JPanel();
1263     visualTab.setBorder(new TitledBorder(MessageManager
1264             .getString("action.open_new_alignment")));
1265     visualTab.setLayout(null);
1266     fullScreen.setFont(LABEL_FONT);
1267     fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1268     fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1269     fullScreen.setText(MessageManager.getString("label.maximize_window"));
1270     quality.setEnabled(false);
1271     quality.setFont(LABEL_FONT);
1272     quality.setHorizontalAlignment(SwingConstants.RIGHT);
1273     quality.setHorizontalTextPosition(SwingConstants.LEFT);
1274     quality.setSelected(true);
1275     quality.setText(MessageManager.getString("label.quality"));
1276     conservation.setEnabled(false);
1277     conservation.setFont(LABEL_FONT);
1278     conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1279     conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1280     conservation.setSelected(true);
1281     conservation.setText(MessageManager.getString("label.conservation"));
1282     identity.setEnabled(false);
1283     identity.setFont(LABEL_FONT);
1284     identity.setHorizontalAlignment(SwingConstants.RIGHT);
1285     identity.setHorizontalTextPosition(SwingConstants.LEFT);
1286     identity.setSelected(true);
1287     identity.setText(MessageManager.getString("label.consensus"));
1288     showOccupancy.setFont(LABEL_FONT);
1289     showOccupancy.setEnabled(false);
1290     showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1291     showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1292     showOccupancy.setSelected(true);
1293     showOccupancy.setText(MessageManager.getString("label.occupancy"));
1294
1295     JLabel showGroupbits = new JLabel();
1296     showGroupbits.setFont(LABEL_FONT);
1297     showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1298     showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1299     showGroupbits.setText(MessageManager.getString("action.show_group")
1300             + ":");
1301     JLabel showConsensbits = new JLabel();
1302     showConsensbits.setFont(LABEL_FONT);
1303     showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1304     showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1305     showConsensbits.setText(MessageManager.getString("label.consensus")
1306             + ":");
1307     showConsensHistogram.setEnabled(false);
1308     showConsensHistogram.setFont(LABEL_FONT);
1309     showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1310     showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1311     showConsensHistogram.setSelected(true);
1312     showConsensHistogram.setText(MessageManager
1313             .getString("label.histogram"));
1314     showConsensLogo.setEnabled(false);
1315     showConsensLogo.setFont(LABEL_FONT);
1316     showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1317     showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1318     showConsensLogo.setSelected(true);
1319     showConsensLogo.setText(MessageManager.getString("label.logo"));
1320     showGroupConsensus.setEnabled(false);
1321     showGroupConsensus.setFont(LABEL_FONT);
1322     showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1323     showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1324     showGroupConsensus.setSelected(true);
1325     showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1326     showGroupConservation.setEnabled(false);
1327     showGroupConservation.setFont(LABEL_FONT);
1328     showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1329     showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1330     showGroupConservation.setSelected(true);
1331     showGroupConservation.setText(MessageManager
1332             .getString("label.conservation"));
1333     showNpTooltip.setEnabled(true);
1334     showNpTooltip.setFont(LABEL_FONT);
1335     showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1336     showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1337     showNpTooltip.setSelected(true);
1338     showNpTooltip.setText(MessageManager
1339             .getString("label.non_positional_features"));
1340     showDbRefTooltip.setEnabled(true);
1341     showDbRefTooltip.setFont(LABEL_FONT);
1342     showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1343     showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1344     showDbRefTooltip.setSelected(true);
1345     showDbRefTooltip.setText(MessageManager
1346             .getString("label.database_references"));
1347     annotations.setFont(LABEL_FONT);
1348     annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1349     annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1350     annotations.setSelected(true);
1351     annotations.setText(MessageManager.getString("label.show_annotations"));
1352     // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1353     annotations.addActionListener(new ActionListener()
1354     {
1355       @Override
1356       public void actionPerformed(ActionEvent e)
1357       {
1358         annotations_actionPerformed(e);
1359       }
1360     });
1361     identity.addActionListener(new ActionListener()
1362     {
1363       @Override
1364       public void actionPerformed(ActionEvent e)
1365       {
1366         annotations_actionPerformed(e);
1367       }
1368     });
1369     showGroupConsensus.addActionListener(new ActionListener()
1370     {
1371       @Override
1372       public void actionPerformed(ActionEvent e)
1373       {
1374         annotations_actionPerformed(e);
1375       }
1376     });
1377     showUnconserved.setFont(LABEL_FONT);
1378     showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1379     showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1380     showUnconserved.setSelected(true);
1381     showUnconserved.setText(MessageManager
1382             .getString("action.show_unconserved"));
1383     showUnconserved.addActionListener(new ActionListener()
1384     {
1385       @Override
1386       public void actionPerformed(ActionEvent e)
1387       {
1388         showunconserved_actionPerformed(e);
1389       }
1390     });
1391
1392     // TODO these are not yet added to / action from Preferences
1393     // JCheckBox shareSelections = new JCheckBox();
1394     // shareSelections.setFont(verdana11);
1395     // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1396     // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1397     // shareSelections.setSelected(true);
1398     // shareSelections.setText(MessageManager
1399     // .getString("label.share_selection_across_views"));
1400     // JCheckBox followHighlight = new JCheckBox();
1401     // followHighlight.setFont(verdana11);
1402     // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1403     // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1404     // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1405     // followHighlight.setSelected(true);
1406     // followHighlight.setText(MessageManager
1407     // .getString("label.scroll_highlighted_regions"));
1408
1409     seqLimit.setFont(LABEL_FONT);
1410     seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1411     seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1412     seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1413     smoothFont.setFont(LABEL_FONT);
1414     smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1415     smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1416     smoothFont.setText(MessageManager.getString("label.smooth_font"));
1417     scaleProteinToCdna.setFont(LABEL_FONT);
1418     scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1419     scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1420     scaleProteinToCdna.setText(MessageManager
1421             .getString("label.scale_protein_to_cdna"));
1422     scaleProteinToCdna.setToolTipText(MessageManager
1423             .getString("label.scale_protein_to_cdna_tip"));
1424     JLabel gapLabel = new JLabel();
1425     gapLabel.setFont(LABEL_FONT);
1426     gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1427     gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1428     JLabel fontLabel = new JLabel();
1429     fontLabel.setFont(LABEL_FONT);
1430     fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1431     fontLabel.setText(MessageManager.getString("label.font"));
1432     fontSizeCB.setFont(LABEL_FONT);
1433     fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1434     fontStyleCB.setFont(LABEL_FONT);
1435     fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1436     fontNameCB.setFont(LABEL_FONT);
1437     fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1438     gapSymbolCB.setFont(LABEL_FONT);
1439     gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1440     DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1441     dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1442     gapSymbolCB.setRenderer(dlcr);
1443
1444     startupCheckbox.setText(MessageManager.getString("action.open_file"));
1445     startupCheckbox.setFont(LABEL_FONT);
1446     startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1447     startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1448     startupCheckbox.setSelected(true);
1449     startupFileTextfield.setFont(LABEL_FONT);
1450     startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1451     startupFileTextfield.addMouseListener(new MouseAdapter()
1452     {
1453       @Override
1454       public void mouseClicked(MouseEvent e)
1455       {
1456         if (e.getClickCount() > 1)
1457         {
1458           startupFileTextfield_mouseClicked();
1459         }
1460       }
1461     });
1462
1463     sortby.setFont(LABEL_FONT);
1464     sortby.setBounds(new Rectangle(172, 260, 155, 21));
1465     JLabel sortLabel = new JLabel();
1466     sortLabel.setFont(LABEL_FONT);
1467     sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1468     sortLabel.setText(MessageManager.getString("label.sort_by"));
1469     sortAnnBy.setFont(LABEL_FONT);
1470     sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1471     JLabel sortAnnLabel = new JLabel();
1472     sortAnnLabel.setFont(LABEL_FONT);
1473     sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1474     sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1475     sortAutocalc.setFont(LABEL_FONT);
1476     sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1477
1478     JPanel annsettingsPanel = new JPanel();
1479     annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1480     annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1481     annsettingsPanel.setBorder(new EtchedBorder());
1482     visualTab.add(annsettingsPanel);
1483     Border jb = new EmptyBorder(1, 1, 4, 5);
1484     annotations.setBorder(jb);
1485     showOccupancy.setBorder(jb);
1486     quality.setBorder(jb);
1487     conservation.setBorder(jb);
1488     identity.setBorder(jb);
1489     showConsensbits.setBorder(jb);
1490     showGroupbits.setBorder(jb);
1491     showGroupConsensus.setBorder(jb);
1492     showGroupConservation.setBorder(jb);
1493     showConsensHistogram.setBorder(jb);
1494     showConsensLogo.setBorder(jb);
1495
1496     JPanel autoAnnotSettings = new JPanel();
1497     annsettingsPanel.add(autoAnnotSettings);
1498     autoAnnotSettings.setLayout(new GridLayout(0, 2));
1499     autoAnnotSettings.add(annotations);
1500     autoAnnotSettings.add(quality);
1501     // second row of autoannotation box
1502     autoAnnotSettings = new JPanel();
1503     annsettingsPanel.add(autoAnnotSettings);
1504
1505     autoAnnotSettings.setLayout(new GridLayout(0, 3));
1506     autoAnnotSettings.add(conservation);
1507     autoAnnotSettings.add(identity);
1508     autoAnnotSettings.add(showOccupancy);
1509     autoAnnotSettings.add(showGroupbits);
1510     autoAnnotSettings.add(showGroupConservation);
1511     autoAnnotSettings.add(showGroupConsensus);
1512     autoAnnotSettings.add(showConsensbits);
1513     autoAnnotSettings.add(showConsensHistogram);
1514     autoAnnotSettings.add(showConsensLogo);
1515     
1516     
1517
1518     JPanel tooltipSettings = new JPanel();
1519     tooltipSettings.setBorder(new TitledBorder(MessageManager
1520             .getString("label.sequence_id_tooltip")));
1521     tooltipSettings.setBounds(173, 140, 220, 62);
1522     tooltipSettings.setLayout(new GridLayout(2, 1));
1523     tooltipSettings.add(showDbRefTooltip);
1524     tooltipSettings.add(showNpTooltip);
1525     visualTab.add(tooltipSettings);
1526
1527     wrap.setFont(LABEL_FONT);
1528     wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1529     wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1530     wrap.setText(MessageManager.getString("label.wrap_alignment"));
1531     rightAlign.setFont(LABEL_FONT);
1532     rightAlign.setForeground(Color.black);
1533     rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1534     rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1535     rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1536     idItalics.setFont(LABEL_FONT_ITALIC);
1537     idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1538     idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1539     idItalics.setText(MessageManager
1540             .getString("label.sequence_name_italics"));
1541     openoverv.setFont(LABEL_FONT);
1542     openoverv.setActionCommand(MessageManager
1543             .getString("label.open_overview"));
1544     openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1545     openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1546     openoverv.setText(MessageManager.getString("label.open_overview"));
1547     JPanel jPanel2 = new JPanel();
1548     jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1549     jPanel2.setLayout(new GridLayout(14, 1));
1550     jPanel2.add(fullScreen);
1551     jPanel2.add(openoverv);
1552     jPanel2.add(seqLimit);
1553     jPanel2.add(rightAlign);
1554     jPanel2.add(fontLabel);
1555     jPanel2.add(showUnconserved);
1556     jPanel2.add(idItalics);
1557     jPanel2.add(smoothFont);
1558     jPanel2.add(scaleProteinToCdna);
1559     jPanel2.add(gapLabel);
1560     jPanel2.add(wrap);
1561     jPanel2.add(sortLabel);
1562     jPanel2.add(sortAnnLabel);
1563     jPanel2.add(startupCheckbox);
1564     visualTab.add(jPanel2);
1565     visualTab.add(startupFileTextfield);
1566     visualTab.add(sortby);
1567     visualTab.add(sortAnnBy);
1568     visualTab.add(sortAutocalc);
1569     visualTab.add(gapSymbolCB);
1570     visualTab.add(fontNameCB);
1571     visualTab.add(fontSizeCB);
1572     visualTab.add(fontStyleCB);
1573     return visualTab;
1574   }
1575
1576   protected void autoIdWidth_actionPerformed()
1577   {
1578     // TODO Auto-generated method stub
1579
1580   }
1581
1582   protected void userIdWidth_actionPerformed()
1583   {
1584     // TODO Auto-generated method stub
1585
1586   }
1587
1588   protected void maxColour_actionPerformed(JPanel panel)
1589   {
1590   }
1591
1592   protected void minColour_actionPerformed(JPanel panel)
1593   {
1594   }
1595
1596   protected void showunconserved_actionPerformed(ActionEvent e)
1597   {
1598     // TODO Auto-generated method stub
1599
1600   }
1601
1602   /**
1603    * DOCUMENT ME!
1604    * 
1605    * @param e
1606    *          DOCUMENT ME!
1607    */
1608   public void ok_actionPerformed(ActionEvent e)
1609   {
1610   }
1611
1612   /**
1613    * DOCUMENT ME!
1614    * 
1615    * @param e
1616    *          DOCUMENT ME!
1617    */
1618   public void cancel_actionPerformed(ActionEvent e)
1619   {
1620   }
1621
1622   /**
1623    * DOCUMENT ME!
1624    * 
1625    * @param e
1626    *          DOCUMENT ME!
1627    */
1628   public void annotations_actionPerformed(ActionEvent e)
1629   {
1630   }
1631
1632   /**
1633    * DOCUMENT ME!
1634    */
1635   public void startupFileTextfield_mouseClicked()
1636   {
1637   }
1638
1639   public void newLink_actionPerformed(ActionEvent e)
1640   {
1641
1642   }
1643
1644   public void editLink_actionPerformed(ActionEvent e)
1645   {
1646
1647   }
1648
1649   public void deleteLink_actionPerformed(ActionEvent e)
1650   {
1651
1652   }
1653
1654   public void defaultBrowser_mouseClicked(MouseEvent e)
1655   {
1656
1657   }
1658
1659   public void linkURLList_keyTyped(KeyEvent e)
1660   {
1661
1662   }
1663
1664   public void useProxy_actionPerformed()
1665   {
1666     boolean enabled = useProxy.isSelected();
1667     portLabel.setEnabled(enabled);
1668     serverLabel.setEnabled(enabled);
1669     proxyServerTB.setEnabled(enabled);
1670     proxyPortTB.setEnabled(enabled);
1671   }
1672
1673   /**
1674    * Customer renderer for JTable: supports column of radio buttons
1675    */
1676   public class RadioButtonRenderer extends JRadioButton implements
1677           TableCellRenderer
1678   {
1679     public RadioButtonRenderer()
1680     {
1681       setHorizontalAlignment(CENTER);
1682       setToolTipText(MessageManager.getString("label.urltooltip"));
1683     }
1684
1685     @Override
1686     public Component getTableCellRendererComponent(JTable table,
1687             Object value, boolean isSelected, boolean hasFocus, int row,
1688             int column)
1689     {
1690       setSelected((boolean) value);
1691
1692       // set colours to match rest of table
1693       if (isSelected)
1694        {
1695          setBackground(table.getSelectionBackground());
1696          setForeground(table.getSelectionForeground());
1697        }
1698        else
1699        {
1700          setBackground(table.getBackground());
1701          setForeground(table.getForeground());
1702       }
1703       return this;
1704     }
1705   }
1706
1707   /**
1708    * Customer cell editor for JTable: supports column of radio buttons in
1709    * conjunction with renderer
1710    */
1711   public class RadioButtonEditor extends AbstractCellEditor implements
1712             TableCellEditor
1713     {
1714       private JRadioButton button = new JRadioButton();
1715
1716       public RadioButtonEditor()
1717       {
1718       button.setHorizontalAlignment(SwingConstants.CENTER);
1719       this.button.addActionListener(new ActionListener()
1720         {
1721           @Override
1722           public void actionPerformed(ActionEvent e)
1723           {
1724             fireEditingStopped();
1725           }
1726         });
1727       }
1728
1729       @Override
1730       public Component getTableCellEditorComponent(JTable table,
1731               Object value, boolean isSelected, int row, int column)
1732       {
1733       button.setSelected((boolean) value);
1734         return button;
1735       }
1736
1737       @Override
1738       public Object getCellEditorValue()
1739       {
1740       return button.isSelected();
1741       }
1742
1743   }
1744 }