JAL-2316 Unit test updates and associated minor changes and fixes.
[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     // adjust row height so radio buttons actually fit
658     // don't do this in the renderer, it causes the awt thread to activate
659     // constantly
660     JRadioButton temp = new JRadioButton();
661     linkUrlTable.setRowHeight(temp.getMinimumSize().height);
662
663     // Table in scrollpane so that the table is given a scrollbar
664     JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
665     linkScrollPane.setBorder(null);
666
667     // Panel for links functionality
668     JPanel linkPanel = new JPanel(new GridBagLayout());
669     linkPanel.setBorder(new TitledBorder(MessageManager
670             .getString("label.url_linkfrom_sequence_id")));
671
672     // Put the Url links panel together
673
674     // Buttons go at top right, resizing only resizes the blank space vertically
675     JPanel buttonPanel = initConnTabUrlButtons();
676     GridBagConstraints linkConstraints1 = new GridBagConstraints();
677     linkConstraints1.gridx = 1;
678     linkConstraints1.gridy = 0;
679     linkConstraints1.fill = GridBagConstraints.VERTICAL;
680     linkPanel.add(buttonPanel, linkConstraints1);
681
682     // Links table goes at top left, resizing resizes the table
683     GridBagConstraints linkConstraints2 = new GridBagConstraints();
684     linkConstraints2.gridx = 0;
685     linkConstraints2.gridy = 0;
686     linkConstraints2.weightx = 1.0;
687     linkConstraints2.weighty = 1.0;
688     linkConstraints2.fill = GridBagConstraints.BOTH;
689     linkPanel.add(linkScrollPane, linkConstraints2);
690
691     // Filter box and buttons goes at bottom left, resizing resizes the text box
692     JPanel filterPanel = initConnTabFilterPanel();
693     GridBagConstraints linkConstraints3 = new GridBagConstraints();
694     linkConstraints3.gridx = 0;
695     linkConstraints3.gridy = 1;
696     linkConstraints3.weightx = 1.0;
697     linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
698     linkPanel.add(filterPanel, linkConstraints3);
699
700     return linkPanel;
701   }
702
703   private JPanel initConnTabFilterPanel()
704   {
705     // Filter textbox and reset button
706     JLabel filterLabel = new JLabel(
707             MessageManager.getString("label.filter"));
708     filterLabel.setFont(LABEL_FONT);
709     filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
710     filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
711
712     filterTB.setFont(LABEL_FONT);
713     filterTB.setText("");
714
715     doReset.setText(MessageManager.getString("action.showall"));
716     userOnly.setText(MessageManager.getString("action.customfilter"));
717
718     // Panel for filter functionality
719     JPanel filterPanel = new JPanel(new GridBagLayout());
720     GridBagConstraints gbc = new GridBagConstraints();
721     gbc.gridx = 0;
722     gbc.gridy = 0;
723     gbc.fill = GridBagConstraints.NONE;
724     gbc.anchor = GridBagConstraints.WEST;
725
726     filterPanel.add(filterLabel, gbc);
727
728     GridBagConstraints gbc1 = new GridBagConstraints();
729     gbc1.gridx = 0;
730     gbc1.gridx = 1;
731     gbc1.fill = GridBagConstraints.HORIZONTAL;
732     gbc1.anchor = GridBagConstraints.WEST;
733     gbc1.weightx = 1.0;
734     filterPanel.add(filterTB, gbc1);
735
736     GridBagConstraints gbc2 = new GridBagConstraints();
737     gbc2.gridx = 2;
738     gbc2.fill = GridBagConstraints.NONE;
739     gbc2.anchor = GridBagConstraints.WEST;
740     filterPanel.add(doReset, gbc2);
741
742     GridBagConstraints gbc3 = new GridBagConstraints();
743     gbc3.gridx = 3;
744     gbc3.fill = GridBagConstraints.NONE;
745     gbc3.anchor = GridBagConstraints.WEST;
746     filterPanel.add(userOnly, gbc3);
747
748     return filterPanel;
749   }
750
751   private JPanel initConnTabUrlButtons()
752   {
753     // Buttons for new / edit / delete Url links
754     JButton newLink = new JButton();
755     newLink.setText(MessageManager.getString("action.new"));
756     newLink.addActionListener(new java.awt.event.ActionListener()
757     {
758       @Override
759       public void actionPerformed(ActionEvent e)
760       {
761         newLink_actionPerformed(e);
762       }
763     });
764
765     editLink.setText(MessageManager.getString("action.edit"));
766     editLink.addActionListener(new java.awt.event.ActionListener()
767     {
768       @Override
769       public void actionPerformed(ActionEvent e)
770       {
771         editLink_actionPerformed(e);
772       }
773     });
774
775     deleteLink.setText(MessageManager.getString("action.delete"));
776     deleteLink.addActionListener(new java.awt.event.ActionListener()
777     {
778       @Override
779       public void actionPerformed(ActionEvent e)
780       {
781         deleteLink_actionPerformed(e);
782       }
783     });
784
785     // no current selection, so initially disable delete/edit buttons
786     editLink.setEnabled(false);
787     deleteLink.setEnabled(false);
788
789     // Panels for new/edit/delete link buttons
790     // buttonContent prevents the buttons from being resized when the window is
791     JPanel buttonContent = new JPanel(new GridLayout(0, 1, 0, 0));
792     JPanel buttonPanel = new JPanel(new BorderLayout());
793
794     buttonContent.add(newLink, null);
795     buttonContent.add(editLink, null);
796     buttonContent.add(deleteLink, null);
797     buttonPanel.add(buttonContent, BorderLayout.NORTH);
798
799     return buttonPanel;
800   }
801
802   /**
803    * Initialises the parent panel which contains the tabbed sections.
804    * 
805    * @return
806    */
807   private JPanel initOkCancelPanel()
808   {
809     JButton ok = new JButton();
810     ok.setText(MessageManager.getString("action.ok"));
811     ok.addActionListener(new ActionListener()
812     {
813       @Override
814       public void actionPerformed(ActionEvent e)
815       {
816         ok_actionPerformed(e);
817       }
818     });
819     JButton cancel = new JButton();
820     cancel.setText(MessageManager.getString("action.cancel"));
821     cancel.addActionListener(new ActionListener()
822     {
823       @Override
824       public void actionPerformed(ActionEvent e)
825       {
826         cancel_actionPerformed(e);
827       }
828     });
829     JPanel okCancelPanel = new JPanel();
830     okCancelPanel.add(ok);
831     okCancelPanel.add(cancel);
832     return okCancelPanel;
833   }
834
835   /**
836    * Initialises the Colours tabbed panel.
837    * 
838    * @return
839    */
840   private JPanel initColoursTab()
841   {
842     JPanel coloursTab = new JPanel();
843     coloursTab.setBorder(new TitledBorder(MessageManager
844             .getString("action.open_new_alignment")));
845     coloursTab.setLayout(new FlowLayout());
846     JLabel mincolourLabel = new JLabel();
847     mincolourLabel.setFont(LABEL_FONT);
848     mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
849     mincolourLabel.setText(MessageManager.getString("label.min_colour"));
850     minColour.setFont(LABEL_FONT);
851     minColour.setBorder(BorderFactory.createEtchedBorder());
852     minColour.setPreferredSize(new Dimension(40, 20));
853     minColour.addMouseListener(new MouseAdapter()
854     {
855       @Override
856       public void mousePressed(MouseEvent e)
857       {
858         minColour_actionPerformed(minColour);
859       }
860     });
861     JLabel maxcolourLabel = new JLabel();
862     maxcolourLabel.setFont(LABEL_FONT);
863     maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
864     maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
865     maxColour.setFont(LABEL_FONT);
866     maxColour.setBorder(BorderFactory.createEtchedBorder());
867     maxColour.setPreferredSize(new Dimension(40, 20));
868     maxColour.addMouseListener(new MouseAdapter()
869     {
870       @Override
871       public void mousePressed(MouseEvent e)
872       {
873         maxColour_actionPerformed(maxColour);
874       }
875     });
876
877     protColour.setFont(LABEL_FONT);
878     protColour.setBounds(new Rectangle(172, 225, 155, 21));
879     JLabel protColourLabel = new JLabel();
880     protColourLabel.setFont(LABEL_FONT);
881     protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
882     protColourLabel.setText(MessageManager
883             .getString("label.prot_alignment_colour") + " ");
884     JvSwingUtils.addtoLayout(coloursTab, MessageManager
885             .getString("label.default_colour_scheme_for_alignment"),
886             protColourLabel, protColour);
887
888     nucColour.setFont(LABEL_FONT);
889     nucColour.setBounds(new Rectangle(172, 240, 155, 21));
890     JLabel nucColourLabel = new JLabel();
891     nucColourLabel.setFont(LABEL_FONT);
892     nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
893     nucColourLabel.setText(MessageManager
894             .getString("label.nuc_alignment_colour") + " ");
895     JvSwingUtils.addtoLayout(coloursTab, MessageManager
896             .getString("label.default_colour_scheme_for_alignment"),
897             nucColourLabel, nucColour);
898
899     JPanel annotationShding = new JPanel();
900     annotationShding.setBorder(new TitledBorder(MessageManager
901             .getString("label.annotation_shading_default")));
902     annotationShding.setLayout(new GridLayout(1, 2));
903     JvSwingUtils.addtoLayout(annotationShding, MessageManager
904             .getString("label.default_minimum_colour_annotation_shading"),
905             mincolourLabel, minColour);
906     JvSwingUtils.addtoLayout(annotationShding, MessageManager
907             .getString("label.default_maximum_colour_annotation_shading"),
908             maxcolourLabel, maxColour);
909     coloursTab.add(annotationShding); // , FlowLayout.LEFT);
910     return coloursTab;
911   }
912
913   /**
914    * Initialises the Structure tabbed panel.
915    * 
916    * @return
917    */
918   private JPanel initStructureTab()
919   {
920     structureTab = new JPanel();
921
922     structureTab.setBorder(new TitledBorder(MessageManager
923             .getString("label.structure_options")));
924     structureTab.setLayout(null);
925     final int width = 400;
926     final int height = 22;
927     final int lineSpacing = 25;
928     int ypos = 15;
929
930     structFromPdb.setFont(LABEL_FONT);
931     structFromPdb
932             .setText(MessageManager.getString("label.struct_from_pdb"));
933     structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
934     structFromPdb.addActionListener(new ActionListener()
935     {
936       @Override
937       public void actionPerformed(ActionEvent e)
938       {
939         boolean selected = structFromPdb.isSelected();
940         // enable other options only when the first is checked
941         useRnaView.setEnabled(selected);
942         addSecondaryStructure.setEnabled(selected);
943         addTempFactor.setEnabled(selected);
944       }
945     });
946     structureTab.add(structFromPdb);
947
948     // indent checkboxes that are conditional on the first one
949     ypos += lineSpacing;
950     useRnaView.setFont(LABEL_FONT);
951     useRnaView.setText(MessageManager.getString("label.use_rnaview"));
952     useRnaView.setBounds(new Rectangle(25, ypos, width, height));
953     structureTab.add(useRnaView);
954
955     ypos += lineSpacing;
956     addSecondaryStructure.setFont(LABEL_FONT);
957     addSecondaryStructure.setText(MessageManager
958             .getString("label.autoadd_secstr"));
959     addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
960     structureTab.add(addSecondaryStructure);
961
962     ypos += lineSpacing;
963     addTempFactor.setFont(LABEL_FONT);
964     addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
965     addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
966     structureTab.add(addTempFactor);
967
968     ypos += lineSpacing;
969     JLabel viewerLabel = new JLabel();
970     viewerLabel.setFont(LABEL_FONT);
971     viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
972     viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
973     viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
974     structureTab.add(viewerLabel);
975
976     structViewer.setFont(LABEL_FONT);
977     structViewer.setBounds(new Rectangle(160, ypos, 120, height));
978     structViewer.addItem(ViewerType.JMOL.name());
979     structViewer.addItem(ViewerType.CHIMERA.name());
980     structViewer.addActionListener(new ActionListener()
981     {
982       @Override
983       public void actionPerformed(ActionEvent e)
984       {
985         structureViewer_actionPerformed((String) structViewer
986                 .getSelectedItem());
987       }
988     });
989     structureTab.add(structViewer);
990
991     ypos += lineSpacing;
992     JLabel pathLabel = new JLabel();
993     pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
994     pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
995     pathLabel.setText(MessageManager.getString("label.chimera_path"));
996     final String tooltip = JvSwingUtils.wrapTooltip(true,
997             MessageManager.getString("label.chimera_path_tip"));
998     pathLabel.setToolTipText(tooltip);
999     pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1000     structureTab.add(pathLabel);
1001
1002     chimeraPath.setFont(LABEL_FONT);
1003     chimeraPath.setText("");
1004     chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1005     chimeraPath.addMouseListener(new MouseAdapter()
1006     {
1007       @Override
1008       public void mouseClicked(MouseEvent e)
1009       {
1010         if (e.getClickCount() == 2)
1011         {
1012           String chosen = openFileChooser();
1013           if (chosen != null)
1014           {
1015             chimeraPath.setText(chosen);
1016           }
1017         }
1018       }
1019     });
1020     structureTab.add(chimeraPath);
1021
1022     ypos += lineSpacing;
1023     nwMapping.setFont(LABEL_FONT);
1024     nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1025     siftsMapping.setFont(LABEL_FONT);
1026     siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1027     mappingMethod.add(nwMapping);
1028     mappingMethod.add(siftsMapping);
1029     JPanel mappingPanel = new JPanel();
1030     mappingPanel.setFont(LABEL_FONT);
1031     TitledBorder mmTitledBorder = new TitledBorder(
1032             MessageManager.getString("label.mapping_method"));
1033     mmTitledBorder.setTitleFont(LABEL_FONT);
1034     mappingPanel.setBorder(mmTitledBorder);
1035     mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1036     // GridLayout mappingLayout = new GridLayout();
1037     mappingPanel.setLayout(new GridLayout());
1038     mappingPanel.add(nwMapping);
1039     mappingPanel.add(siftsMapping);
1040     structureTab.add(mappingPanel);
1041
1042     ypos += lineSpacing;
1043     ypos += lineSpacing;
1044     FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1045             PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1046     docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1047     structureTab.add(docFieldPref);
1048
1049     return structureTab;
1050   }
1051
1052   /**
1053    * Action on choosing a structure viewer from combobox options.
1054    * 
1055    * @param selectedItem
1056    */
1057   protected void structureViewer_actionPerformed(String selectedItem)
1058   {
1059   }
1060
1061   /**
1062    * Show a dialog for the user to choose a file. Returns the chosen path, or
1063    * null on Cancel.
1064    * 
1065    * @return
1066    */
1067   protected String openFileChooser()
1068   {
1069     String choice = null;
1070     JFileChooser chooser = new JFileChooser();
1071
1072     // chooser.setFileView(new JalviewFileView());
1073     chooser.setDialogTitle(MessageManager
1074             .getString("label.open_local_file"));
1075     chooser.setToolTipText(MessageManager.getString("action.open"));
1076
1077     int value = chooser.showOpenDialog(this);
1078
1079     if (value == JFileChooser.APPROVE_OPTION)
1080     {
1081       choice = chooser.getSelectedFile().getPath();
1082     }
1083     return choice;
1084   }
1085
1086   /**
1087    * Validate the structure tab preferences; if invalid, set focus on this tab.
1088    * 
1089    * @param e
1090    */
1091   protected boolean validateStructure(FocusEvent e)
1092   {
1093     if (!validateStructure())
1094     {
1095       e.getComponent().requestFocusInWindow();
1096       return false;
1097     }
1098     return true;
1099   }
1100
1101   protected boolean validateStructure()
1102   {
1103     return false;
1104   }
1105
1106   /**
1107    * Initialises the Visual tabbed panel.
1108    * 
1109    * @return
1110    */
1111   private JPanel initVisualTab()
1112   {
1113     JPanel visualTab = new JPanel();
1114     visualTab.setBorder(new TitledBorder(MessageManager
1115             .getString("action.open_new_alignment")));
1116     visualTab.setLayout(null);
1117     fullScreen.setFont(LABEL_FONT);
1118     fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1119     fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1120     fullScreen.setText(MessageManager.getString("label.maximize_window"));
1121     quality.setEnabled(false);
1122     quality.setFont(LABEL_FONT);
1123     quality.setHorizontalAlignment(SwingConstants.RIGHT);
1124     quality.setHorizontalTextPosition(SwingConstants.LEFT);
1125     quality.setSelected(true);
1126     quality.setText(MessageManager.getString("label.quality"));
1127     conservation.setEnabled(false);
1128     conservation.setFont(LABEL_FONT);
1129     conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1130     conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1131     conservation.setSelected(true);
1132     conservation.setText(MessageManager.getString("label.conservation"));
1133     identity.setEnabled(false);
1134     identity.setFont(LABEL_FONT);
1135     identity.setHorizontalAlignment(SwingConstants.RIGHT);
1136     identity.setHorizontalTextPosition(SwingConstants.LEFT);
1137     identity.setSelected(true);
1138     identity.setText(MessageManager.getString("label.consensus"));
1139     JLabel showGroupbits = new JLabel();
1140     showGroupbits.setFont(LABEL_FONT);
1141     showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1142     showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1143     showGroupbits.setText(MessageManager.getString("action.show_group")
1144             + ":");
1145     JLabel showConsensbits = new JLabel();
1146     showConsensbits.setFont(LABEL_FONT);
1147     showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1148     showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1149     showConsensbits.setText(MessageManager.getString("label.consensus")
1150             + ":");
1151     showConsensHistogram.setEnabled(false);
1152     showConsensHistogram.setFont(LABEL_FONT);
1153     showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1154     showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1155     showConsensHistogram.setSelected(true);
1156     showConsensHistogram.setText(MessageManager
1157             .getString("label.histogram"));
1158     showConsensLogo.setEnabled(false);
1159     showConsensLogo.setFont(LABEL_FONT);
1160     showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1161     showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1162     showConsensLogo.setSelected(true);
1163     showConsensLogo.setText(MessageManager.getString("label.logo"));
1164     showGroupConsensus.setEnabled(false);
1165     showGroupConsensus.setFont(LABEL_FONT);
1166     showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1167     showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1168     showGroupConsensus.setSelected(true);
1169     showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1170     showGroupConservation.setEnabled(false);
1171     showGroupConservation.setFont(LABEL_FONT);
1172     showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1173     showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1174     showGroupConservation.setSelected(true);
1175     showGroupConservation.setText(MessageManager
1176             .getString("label.conservation"));
1177     showNpTooltip.setEnabled(true);
1178     showNpTooltip.setFont(LABEL_FONT);
1179     showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1180     showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1181     showNpTooltip.setSelected(true);
1182     showNpTooltip.setText(MessageManager
1183             .getString("label.non_positional_features"));
1184     showDbRefTooltip.setEnabled(true);
1185     showDbRefTooltip.setFont(LABEL_FONT);
1186     showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1187     showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1188     showDbRefTooltip.setSelected(true);
1189     showDbRefTooltip.setText(MessageManager
1190             .getString("label.database_references"));
1191     annotations.setFont(LABEL_FONT);
1192     annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1193     annotations.setHorizontalTextPosition(SwingConstants.LEADING);
1194     annotations.setSelected(true);
1195     annotations.setText(MessageManager.getString("label.show_annotations"));
1196     annotations.setBounds(new Rectangle(169, 12, 200, 23));
1197     annotations.addActionListener(new ActionListener()
1198     {
1199       @Override
1200       public void actionPerformed(ActionEvent e)
1201       {
1202         annotations_actionPerformed(e);
1203       }
1204     });
1205     identity.addActionListener(new ActionListener()
1206     {
1207       @Override
1208       public void actionPerformed(ActionEvent e)
1209       {
1210         annotations_actionPerformed(e);
1211       }
1212     });
1213     showGroupConsensus.addActionListener(new ActionListener()
1214     {
1215       @Override
1216       public void actionPerformed(ActionEvent e)
1217       {
1218         annotations_actionPerformed(e);
1219       }
1220     });
1221     showUnconserved.setFont(LABEL_FONT);
1222     showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1223     showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1224     showUnconserved.setSelected(true);
1225     showUnconserved.setText(MessageManager
1226             .getString("action.show_unconserved"));
1227     showUnconserved.addActionListener(new ActionListener()
1228     {
1229       @Override
1230       public void actionPerformed(ActionEvent e)
1231       {
1232         showunconserved_actionPerformed(e);
1233       }
1234     });
1235
1236     // TODO these are not yet added to / action from Preferences
1237     // JCheckBox shareSelections = new JCheckBox();
1238     // shareSelections.setFont(verdana11);
1239     // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1240     // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1241     // shareSelections.setSelected(true);
1242     // shareSelections.setText(MessageManager
1243     // .getString("label.share_selection_across_views"));
1244     // JCheckBox followHighlight = new JCheckBox();
1245     // followHighlight.setFont(verdana11);
1246     // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1247     // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1248     // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1249     // followHighlight.setSelected(true);
1250     // followHighlight.setText(MessageManager
1251     // .getString("label.scroll_highlighted_regions"));
1252
1253     seqLimit.setFont(LABEL_FONT);
1254     seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1255     seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1256     seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1257     smoothFont.setFont(LABEL_FONT);
1258     smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1259     smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1260     smoothFont.setText(MessageManager.getString("label.smooth_font"));
1261     scaleProteinToCdna.setFont(LABEL_FONT);
1262     scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1263     scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1264     scaleProteinToCdna.setText(MessageManager
1265             .getString("label.scale_protein_to_cdna"));
1266     scaleProteinToCdna.setToolTipText(MessageManager
1267             .getString("label.scale_protein_to_cdna_tip"));
1268     JLabel gapLabel = new JLabel();
1269     gapLabel.setFont(LABEL_FONT);
1270     gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1271     gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1272     JLabel fontLabel = new JLabel();
1273     fontLabel.setFont(LABEL_FONT);
1274     fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1275     fontLabel.setText(MessageManager.getString("label.font"));
1276     fontSizeCB.setFont(LABEL_FONT);
1277     fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1278     fontStyleCB.setFont(LABEL_FONT);
1279     fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1280     fontNameCB.setFont(LABEL_FONT);
1281     fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1282     gapSymbolCB.setFont(LABEL_FONT);
1283     gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1284     DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1285     dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1286     gapSymbolCB.setRenderer(dlcr);
1287
1288     startupCheckbox.setText(MessageManager.getString("action.open_file"));
1289     startupCheckbox.setFont(LABEL_FONT);
1290     startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1291     startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1292     startupCheckbox.setSelected(true);
1293     startupFileTextfield.setFont(LABEL_FONT);
1294     startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1295     startupFileTextfield.addMouseListener(new MouseAdapter()
1296     {
1297       @Override
1298       public void mouseClicked(MouseEvent e)
1299       {
1300         if (e.getClickCount() > 1)
1301         {
1302           startupFileTextfield_mouseClicked();
1303         }
1304       }
1305     });
1306
1307     sortby.setFont(LABEL_FONT);
1308     sortby.setBounds(new Rectangle(172, 260, 155, 21));
1309     JLabel sortLabel = new JLabel();
1310     sortLabel.setFont(LABEL_FONT);
1311     sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1312     sortLabel.setText(MessageManager.getString("label.sort_by"));
1313     sortAnnBy.setFont(LABEL_FONT);
1314     sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1315     JLabel sortAnnLabel = new JLabel();
1316     sortAnnLabel.setFont(LABEL_FONT);
1317     sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1318     sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1319     sortAutocalc.setFont(LABEL_FONT);
1320     sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1321
1322     JPanel annsettingsPanel = new JPanel();
1323     annsettingsPanel.setBounds(new Rectangle(173, 34, 320, 75));
1324     annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1325     annsettingsPanel.setBorder(new EtchedBorder());
1326     visualTab.add(annsettingsPanel);
1327     Border jb = new EmptyBorder(1, 1, 4, 5);
1328     quality.setBorder(jb);
1329     conservation.setBorder(jb);
1330     identity.setBorder(jb);
1331     showConsensbits.setBorder(jb);
1332     showGroupbits.setBorder(jb);
1333     showGroupConsensus.setBorder(jb);
1334     showGroupConservation.setBorder(jb);
1335     showConsensHistogram.setBorder(jb);
1336     showConsensLogo.setBorder(jb);
1337
1338     JPanel autoAnnotSettings = new JPanel();
1339     autoAnnotSettings.setLayout(new GridLayout(3, 3));
1340     annsettingsPanel.add(autoAnnotSettings);
1341     autoAnnotSettings.add(quality);
1342     autoAnnotSettings.add(conservation);
1343     autoAnnotSettings.add(identity);
1344     autoAnnotSettings.add(showGroupbits);
1345     autoAnnotSettings.add(showGroupConservation);
1346     autoAnnotSettings.add(showGroupConsensus);
1347     autoAnnotSettings.add(showConsensbits);
1348     autoAnnotSettings.add(showConsensHistogram);
1349     autoAnnotSettings.add(showConsensLogo);
1350
1351     JPanel tooltipSettings = new JPanel();
1352     tooltipSettings.setBorder(new TitledBorder(MessageManager
1353             .getString("label.sequence_id_tooltip")));
1354     tooltipSettings.setBounds(173, 140, 220, 62);
1355     tooltipSettings.setLayout(new GridLayout(2, 1));
1356     tooltipSettings.add(showDbRefTooltip);
1357     tooltipSettings.add(showNpTooltip);
1358     visualTab.add(tooltipSettings);
1359
1360     wrap.setFont(LABEL_FONT);
1361     wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1362     wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1363     wrap.setText(MessageManager.getString("label.wrap_alignment"));
1364     rightAlign.setFont(LABEL_FONT);
1365     rightAlign.setForeground(Color.black);
1366     rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1367     rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1368     rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1369     idItalics.setFont(LABEL_FONT_ITALIC);
1370     idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1371     idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1372     idItalics.setText(MessageManager
1373             .getString("label.sequence_name_italics"));
1374     openoverv.setFont(LABEL_FONT);
1375     openoverv.setActionCommand(MessageManager
1376             .getString("label.open_overview"));
1377     openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1378     openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1379     openoverv.setText(MessageManager.getString("label.open_overview"));
1380     JPanel jPanel2 = new JPanel();
1381     jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1382     jPanel2.setLayout(new GridLayout(14, 1));
1383     jPanel2.add(fullScreen);
1384     jPanel2.add(openoverv);
1385     jPanel2.add(seqLimit);
1386     jPanel2.add(rightAlign);
1387     jPanel2.add(fontLabel);
1388     jPanel2.add(showUnconserved);
1389     jPanel2.add(idItalics);
1390     jPanel2.add(smoothFont);
1391     jPanel2.add(scaleProteinToCdna);
1392     jPanel2.add(gapLabel);
1393     jPanel2.add(wrap);
1394     jPanel2.add(sortLabel);
1395     jPanel2.add(sortAnnLabel);
1396     jPanel2.add(startupCheckbox);
1397     visualTab.add(jPanel2);
1398     visualTab.add(annotations);
1399     visualTab.add(startupFileTextfield);
1400     visualTab.add(sortby);
1401     visualTab.add(sortAnnBy);
1402     visualTab.add(sortAutocalc);
1403     visualTab.add(gapSymbolCB);
1404     visualTab.add(fontNameCB);
1405     visualTab.add(fontSizeCB);
1406     visualTab.add(fontStyleCB);
1407     return visualTab;
1408   }
1409
1410   protected void autoIdWidth_actionPerformed()
1411   {
1412     // TODO Auto-generated method stub
1413
1414   }
1415
1416   protected void userIdWidth_actionPerformed()
1417   {
1418     // TODO Auto-generated method stub
1419
1420   }
1421
1422   protected void maxColour_actionPerformed(JPanel panel)
1423   {
1424   }
1425
1426   protected void minColour_actionPerformed(JPanel panel)
1427   {
1428   }
1429
1430   protected void showunconserved_actionPerformed(ActionEvent e)
1431   {
1432     // TODO Auto-generated method stub
1433
1434   }
1435
1436   /**
1437    * DOCUMENT ME!
1438    * 
1439    * @param e
1440    *          DOCUMENT ME!
1441    */
1442   public void ok_actionPerformed(ActionEvent e)
1443   {
1444   }
1445
1446   /**
1447    * DOCUMENT ME!
1448    * 
1449    * @param e
1450    *          DOCUMENT ME!
1451    */
1452   public void cancel_actionPerformed(ActionEvent e)
1453   {
1454   }
1455
1456   /**
1457    * DOCUMENT ME!
1458    * 
1459    * @param e
1460    *          DOCUMENT ME!
1461    */
1462   public void annotations_actionPerformed(ActionEvent e)
1463   {
1464   }
1465
1466   /**
1467    * DOCUMENT ME!
1468    */
1469   public void startupFileTextfield_mouseClicked()
1470   {
1471   }
1472
1473   public void newLink_actionPerformed(ActionEvent e)
1474   {
1475
1476   }
1477
1478   public void editLink_actionPerformed(ActionEvent e)
1479   {
1480
1481   }
1482
1483   public void deleteLink_actionPerformed(ActionEvent e)
1484   {
1485
1486   }
1487
1488   public void defaultBrowser_mouseClicked(MouseEvent e)
1489   {
1490
1491   }
1492
1493   public void linkURLList_keyTyped(KeyEvent e)
1494   {
1495
1496   }
1497
1498   public void useProxy_actionPerformed()
1499   {
1500     boolean enabled = useProxy.isSelected();
1501     portLabel.setEnabled(enabled);
1502     serverLabel.setEnabled(enabled);
1503     proxyServerTB.setEnabled(enabled);
1504     proxyPortTB.setEnabled(enabled);
1505   }
1506
1507   /**
1508    * Customer renderer for JTable: supports column of radio buttons
1509    */
1510   public class RadioButtonRenderer extends JRadioButton implements
1511           TableCellRenderer
1512   {
1513     public RadioButtonRenderer()
1514     {
1515       setHorizontalAlignment(CENTER);
1516       setToolTipText(MessageManager.getString("label.urltooltip"));
1517     }
1518
1519     @Override
1520     public Component getTableCellRendererComponent(JTable table,
1521             Object value, boolean isSelected, boolean hasFocus, int row,
1522             int column)
1523     {
1524       setSelected((boolean) value);
1525
1526       // set colours to match rest of table
1527       if (isSelected)
1528        {
1529          setBackground(table.getSelectionBackground());
1530          setForeground(table.getSelectionForeground());
1531        }
1532        else
1533        {
1534          setBackground(table.getBackground());
1535          setForeground(table.getForeground());
1536       }
1537       return this;
1538     }
1539   }
1540
1541   /**
1542    * Customer cell editor for JTable: supports column of radio buttons in
1543    * conjunction with renderer
1544    */
1545   public class RadioButtonEditor extends AbstractCellEditor implements
1546             TableCellEditor
1547     {
1548       private JRadioButton button = new JRadioButton();
1549
1550       public RadioButtonEditor()
1551       {
1552       button.setHorizontalAlignment(SwingConstants.CENTER);
1553       this.button.addActionListener(new ActionListener()
1554         {
1555           @Override
1556           public void actionPerformed(ActionEvent e)
1557           {
1558             fireEditingStopped();
1559           }
1560         });
1561       }
1562
1563       @Override
1564       public Component getTableCellEditorComponent(JTable table,
1565               Object value, boolean isSelected, int row, int column)
1566       {
1567       button.setSelected((boolean) value);
1568         return button;
1569       }
1570
1571       @Override
1572       public Object getCellEditorValue()
1573       {
1574       return button.isSelected();
1575       }
1576
1577   }
1578 }