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