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