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