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