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