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