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