Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.jbgui

File GPreferences.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
56% of files have more coverage

Code metrics

114
1,243
110
3
2,907
2,228
187
0.15
11.3
36.67
1.7

Classes

Class Line # Actions
GPreferences 96 1,228 180
0.00%
GPreferences.RadioButtonRenderer 2838 9 3
0.00%
GPreferences.RadioButtonEditor 2873 6 4
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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 java.awt.BorderLayout;
24    import java.awt.Color;
25    import java.awt.Component;
26    import java.awt.Dimension;
27    import java.awt.FlowLayout;
28    import java.awt.Font;
29    import java.awt.GridBagConstraints;
30    import java.awt.GridBagLayout;
31    import java.awt.GridLayout;
32    import java.awt.Insets;
33    import java.awt.Rectangle;
34    import java.awt.event.ActionEvent;
35    import java.awt.event.ActionListener;
36    import java.awt.event.FocusEvent;
37    import java.awt.event.KeyEvent;
38    import java.awt.event.KeyListener;
39    import java.awt.event.MouseAdapter;
40    import java.awt.event.MouseEvent;
41    import java.util.Arrays;
42    import java.util.List;
43   
44    import javax.swing.AbstractCellEditor;
45    import javax.swing.BorderFactory;
46    import javax.swing.ButtonGroup;
47    import javax.swing.DefaultListCellRenderer;
48    import javax.swing.JButton;
49    import javax.swing.JCheckBox;
50    import javax.swing.JComboBox;
51    import javax.swing.JFileChooser;
52    import javax.swing.JLabel;
53    import javax.swing.JPanel;
54    import javax.swing.JRadioButton;
55    import javax.swing.JScrollPane;
56    import javax.swing.JSpinner;
57    import javax.swing.JTabbedPane;
58    import javax.swing.JTable;
59    import javax.swing.JTextArea;
60    import javax.swing.JTextField;
61    import javax.swing.ListSelectionModel;
62    import javax.swing.SpinnerModel;
63    import javax.swing.SpinnerNumberModel;
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    import jalview.bin.Cache;
75    import jalview.fts.core.FTSDataColumnPreferences;
76    import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
77    import jalview.fts.service.pdb.PDBFTSRestClient;
78    import jalview.gui.Desktop;
79    import jalview.gui.JalviewBooleanRadioButtons;
80    import jalview.gui.JvOptionPane;
81    import jalview.gui.JvSwingUtils;
82    import jalview.gui.StructureViewer.ViewerType;
83    import jalview.io.BackupFilenameParts;
84    import jalview.io.BackupFiles;
85    import jalview.io.BackupFilesPresetEntry;
86    import jalview.io.IntKeyStringValueEntry;
87    import jalview.util.MessageManager;
88    import jalview.util.Platform;
89   
90    /**
91    * Base class for the Preferences panel.
92    *
93    * @author $author$
94    * @version $Revision$
95    */
 
96    public class GPreferences extends JPanel
97    {
98    private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
99   
100    private static final Font LABEL_FONT_ITALIC = JvSwingUtils
101    .getLabelFont(false, true);
102   
103    private static final Font LABEL_FONT_BOLD = JvSwingUtils
104    .getLabelFont(true, false);
105   
106    /*
107    * Visual tab components
108    */
109    protected JCheckBox fullScreen = new JCheckBox();
110   
111    protected JCheckBox openoverv = new JCheckBox();
112   
113    protected JCheckBox seqLimit = new JCheckBox();
114   
115    protected JCheckBox rightAlign = new JCheckBox();
116   
117    protected JComboBox<String> fontSizeCB = new JComboBox<>();
118   
119    protected JComboBox<String> fontStyleCB = new JComboBox<>();
120   
121    protected JComboBox<String> fontNameCB = new JComboBox<>();
122   
123    protected JCheckBox showOccupancy = new JCheckBox();
124   
125    protected JCheckBox showUnconserved = new JCheckBox();
126   
127    protected JCheckBox idItalics = new JCheckBox();
128   
129    protected JCheckBox smoothFont = new JCheckBox();
130   
131    protected JCheckBox scaleProteinToCdna = new JCheckBox();
132   
133    protected JComboBox<String> gapSymbolCB = new JComboBox<>();
134   
135    protected JCheckBox wrap = new JCheckBox();
136   
137    protected JComboBox<String> sortby = new JComboBox<>();
138   
139    protected JComboBox<String> sortAnnBy = new JComboBox<>();
140   
141    protected JComboBox<String> sortAutocalc = new JComboBox<>();
142   
143    protected JCheckBox startupCheckbox = new JCheckBox();
144   
145    protected JTextField startupFileTextfield = new JTextField();
146   
147    // below are in the 'second column'
148    protected JCheckBox annotations = new JCheckBox();
149   
150    protected JCheckBox quality = new JCheckBox();
151   
152    protected JCheckBox conservation = new JCheckBox();
153   
154    protected JCheckBox identity = new JCheckBox();
155   
156    protected JCheckBox showGroupConsensus = new JCheckBox();
157   
158    protected JCheckBox showGroupConservation = new JCheckBox();
159   
160    protected JCheckBox showConsensHistogram = new JCheckBox();
161   
162    protected JCheckBox showConsensLogo = new JCheckBox();
163   
164    protected JCheckBox showDbRefTooltip = new JCheckBox();
165   
166    protected JCheckBox showNpTooltip = new JCheckBox();
167   
168    /*
169    * Structure tab and components
170    */
171    protected JPanel structureTab;
172   
173    protected JCheckBox structFromPdb = new JCheckBox();
174   
175    protected JCheckBox useRnaView = new JCheckBox();
176   
177    protected JCheckBox addSecondaryStructure = new JCheckBox();
178   
179    protected JCheckBox addTempFactor = new JCheckBox();
180   
181    protected JComboBox<String> structViewer = new JComboBox<>();
182   
183    protected JLabel structureViewerPathLabel;
184   
185    protected JTextField structureViewerPath = new JTextField();
186   
187    protected ButtonGroup mappingMethod = new ButtonGroup();
188   
189    protected JRadioButton siftsMapping = new JRadioButton();
190   
191    protected JRadioButton nwMapping = new JRadioButton();
192   
193    /*
194    * Colours tab components
195    */
196    protected JPanel minColour = new JPanel();
197   
198    protected JPanel maxColour = new JPanel();
199   
200    protected JComboBox<String> protColour = new JComboBox<>();
201   
202    protected JComboBox<String> nucColour = new JComboBox<>();
203   
204    /*
205    * Overview tab components
206    */
207    protected JPanel gapColour = new JPanel();
208   
209    protected JPanel hiddenColour = new JPanel();
210   
211    protected JCheckBox useLegacyGap;
212   
213    protected JCheckBox showHiddenAtStart;
214   
215    protected JLabel gapLabel;
216   
217    /*
218    * Connections tab components
219    */
220    protected JTable linkUrlTable = new JTable();
221   
222    protected JButton editLink = new JButton();
223   
224    protected JButton deleteLink = new JButton();
225   
226    protected JTextField filterTB = new JTextField();
227   
228    protected JButton doReset = new JButton();
229   
230    protected JButton userOnly = new JButton();
231   
232    protected JLabel portLabel = new JLabel();
233   
234    protected JLabel serverLabel = new JLabel();
235   
236    protected JTextField proxyServerTB = new JTextField();
237   
238    protected JTextField proxyPortTB = new JTextField();
239   
240    protected JTextField defaultBrowser = new JTextField();
241   
242    protected JCheckBox useProxy = new JCheckBox();
243   
244    protected JCheckBox usagestats = new JCheckBox();
245   
246    protected JCheckBox questionnaire = new JCheckBox();
247   
248    protected JCheckBox versioncheck = new JCheckBox();
249   
250    /*
251    * Output tab components
252    */
253    protected JComboBox<Object> epsRendering = new JComboBox<>();
254   
255    protected JComboBox<Object> htmlRendering = new JComboBox<>();
256   
257    protected JComboBox<Object> svgRendering = new JComboBox<>();
258   
259    protected JLabel userIdWidthlabel = new JLabel();
260   
261    protected JCheckBox autoIdWidth = new JCheckBox();
262   
263    protected JTextField userIdWidth = new JTextField();
264   
265    protected JCheckBox blcjv = new JCheckBox();
266   
267    protected JCheckBox pileupjv = new JCheckBox();
268   
269    protected JCheckBox clustaljv = new JCheckBox();
270   
271    protected JCheckBox msfjv = new JCheckBox();
272   
273    protected JCheckBox fastajv = new JCheckBox();
274   
275    protected JCheckBox pfamjv = new JCheckBox();
276   
277    protected JCheckBox pirjv = new JCheckBox();
278   
279    protected JCheckBox modellerOutput = new JCheckBox();
280   
281    protected JCheckBox embbedBioJSON = new JCheckBox();
282   
283    /*
284    * Editing tab components
285    */
286    protected JCheckBox autoCalculateConsCheck = new JCheckBox();
287   
288    protected JCheckBox padGaps = new JCheckBox();
289   
290    protected JCheckBox sortByTree = new JCheckBox();
291   
292    /*
293    * Web Services tab
294    */
295    protected JPanel wsTab = new JPanel();
296   
297    /*
298    * Backups tab components
299    * a lot of these are member variables instead of local variables only so that they
300    * can be enabled/disabled easily in one go
301    */
302   
303    protected JCheckBox enableBackupFiles = new JCheckBox();
304   
305    protected JPanel presetsPanel = new JPanel();
306   
307    protected JLabel presetsComboLabel = new JLabel();
308   
309    protected JCheckBox customiseCheckbox = new JCheckBox();
310   
311    protected JButton revertButton = new JButton();
312   
313    protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
314   
315    private int backupfilesPresetsComboLastSelected = 0;
316   
317    protected JPanel suffixPanel = new JPanel();
318   
319    protected JPanel keepfilesPanel = new JPanel();
320   
321    protected JPanel exampleFilesPanel = new JPanel();
322   
323    protected JTextField suffixTemplate = new JTextField(null, 8);
324   
325    protected JLabel suffixTemplateLabel = new JLabel();
326   
327    protected JLabel suffixDigitsLabel = new JLabel();
328   
329    protected JSpinner suffixDigitsSpinner = new JSpinner();
330   
331    protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
332   
333    protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
334   
335    public JSpinner backupfilesRollMaxSpinner = new JSpinner();
336   
337    protected JLabel oldBackupFilesLabel = new JLabel();
338   
339    protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
340   
341    protected JTextArea backupfilesExampleLabel = new JTextArea();
342   
343    /**
344    * Creates a new GPreferences object.
345    */
 
346  0 toggle public GPreferences()
347    {
348  0 try
349    {
350  0 jbInit();
351    } catch (Exception ex)
352    {
353  0 ex.printStackTrace();
354    }
355    }
356   
357    /**
358    * Construct the panel and its tabbed sub-panels.
359    *
360    * @throws Exception
361    */
 
362  0 toggle private void jbInit() throws Exception
363    {
364  0 final JTabbedPane tabbedPane = new JTabbedPane();
365  0 this.setLayout(new BorderLayout());
366  0 JPanel okCancelPanel = initOkCancelPanel();
367  0 this.add(tabbedPane, BorderLayout.CENTER);
368  0 this.add(okCancelPanel, BorderLayout.SOUTH);
369   
370  0 tabbedPane.add(initVisualTab(),
371    MessageManager.getString("label.visual"));
372   
373  0 tabbedPane.add(initColoursTab(),
374    MessageManager.getString("label.colours"));
375   
376  0 tabbedPane.add(initOverviewTab(),
377    MessageManager.getString("label.overview"));
378   
379  0 tabbedPane.add(initStructureTab(),
380    MessageManager.getString("label.structure"));
381   
382  0 tabbedPane.add(initConnectionsTab(),
383    MessageManager.getString("label.connections"));
384   
385  0 if (!Platform.isJS())
386    {
387  0 tabbedPane.add(initBackupsTab(),
388    MessageManager.getString("label.backups"));
389    }
390   
391  0 tabbedPane.add(initLinksTab(),
392    MessageManager.getString("label.urllinks"));
393   
394  0 tabbedPane.add(initOutputTab(),
395    MessageManager.getString("label.output"));
396   
397  0 tabbedPane.add(initEditingTab(),
398    MessageManager.getString("label.editing"));
399   
400    /*
401    * See WsPreferences for the real work of configuring this tab.
402    */
403  0 if (!Platform.isJS())
404    {
405  0 wsTab.setLayout(new BorderLayout());
406  0 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
407    }
408   
409    /*
410    * Handler to validate a tab before leaving it - currently only for
411    * Structure.
412    */
413  0 tabbedPane.addChangeListener(new ChangeListener()
414    {
415    private Component lastTab;
416   
 
417  0 toggle @Override
418    public void stateChanged(ChangeEvent e)
419    {
420  0 if (lastTab == structureTab
421    && tabbedPane.getSelectedComponent() != structureTab)
422    {
423  0 if (!validateStructure())
424    {
425  0 tabbedPane.setSelectedComponent(structureTab);
426  0 return;
427    }
428    }
429  0 lastTab = tabbedPane.getSelectedComponent();
430    }
431   
432    });
433    }
434   
435    /**
436    * Initialises the Editing tabbed panel.
437    *
438    * @return
439    */
 
440  0 toggle private JPanel initEditingTab()
441    {
442  0 JPanel editingTab = new JPanel();
443  0 editingTab.setLayout(null);
444  0 autoCalculateConsCheck.setFont(LABEL_FONT);
445  0 autoCalculateConsCheck.setText(
446    MessageManager.getString("label.autocalculate_consensus"));
447  0 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
448  0 padGaps.setFont(LABEL_FONT);
449  0 padGaps.setText(
450    MessageManager.getString("label.pad_gaps_when_editing"));
451  0 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
452  0 sortByTree.setFont(LABEL_FONT);
453  0 sortByTree
454    .setText(MessageManager.getString("label.sort_with_new_tree"));
455  0 sortByTree.setToolTipText(MessageManager.getString(
456    "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
457  0 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
458  0 editingTab.add(autoCalculateConsCheck);
459  0 editingTab.add(padGaps);
460  0 editingTab.add(sortByTree);
461  0 return editingTab;
462    }
463   
464    /**
465    * Initialises the Output tab
466    *
467    * @return
468    */
 
469  0 toggle private JPanel initOutputTab()
470    {
471  0 JPanel outputTab = new JPanel();
472  0 outputTab.setLayout(null);
473   
474  0 JLabel epsLabel = new JLabel(
475    MessageManager.formatMessage("label.rendering_style", "EPS"));
476  0 epsLabel.setFont(LABEL_FONT);
477  0 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
478  0 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
479  0 epsRendering.setFont(LABEL_FONT);
480  0 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
481  0 JLabel htmlLabel = new JLabel(
482    MessageManager.formatMessage("label.rendering_style", "HTML"));
483  0 htmlLabel.setFont(LABEL_FONT);
484  0 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
485  0 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
486  0 htmlRendering.setFont(LABEL_FONT);
487  0 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
488  0 JLabel svgLabel = new JLabel(
489    MessageManager.formatMessage("label.rendering_style", "SVG"));
490  0 svgLabel.setFont(LABEL_FONT);
491  0 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
492  0 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
493  0 svgRendering.setFont(LABEL_FONT);
494  0 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
495   
496  0 JLabel jLabel1 = new JLabel();
497  0 jLabel1.setFont(LABEL_FONT);
498  0 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
499  0 jLabel1.setText(MessageManager.getString("label.append_start_end"));
500  0 jLabel1.setFont(LABEL_FONT);
501   
502  0 fastajv.setFont(LABEL_FONT);
503  0 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
504  0 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
505  0 blcjv.setText(MessageManager.getString("label.blc") + " ");
506  0 fastajv.setText(MessageManager.getString("label.fasta") + " ");
507  0 msfjv.setText(MessageManager.getString("label.msf") + " ");
508  0 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
509  0 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
510  0 msfjv.setFont(LABEL_FONT);
511  0 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
512  0 pirjv.setText(MessageManager.getString("label.pir") + " ");
513  0 JPanel jPanel11 = new JPanel();
514  0 jPanel11.setFont(LABEL_FONT);
515  0 TitledBorder titledBorder2 = new TitledBorder(
516    MessageManager.getString("label.file_output"));
517  0 jPanel11.setBorder(titledBorder2);
518  0 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
519  0 GridLayout gridLayout3 = new GridLayout();
520  0 jPanel11.setLayout(gridLayout3);
521  0 gridLayout3.setRows(8);
522  0 blcjv.setFont(LABEL_FONT);
523  0 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
524  0 clustaljv.setFont(LABEL_FONT);
525  0 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
526  0 pfamjv.setFont(LABEL_FONT);
527  0 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
528  0 pileupjv.setFont(LABEL_FONT);
529  0 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
530  0 pirjv.setFont(LABEL_FONT);
531  0 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
532  0 autoIdWidth.setFont(LABEL_FONT);
533  0 autoIdWidth.setText(
534    MessageManager.getString("label.automatically_set_id_width"));
535  0 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
536    .getString("label.adjusts_width_generated_eps_png")));
537  0 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
538  0 autoIdWidth.addActionListener(new ActionListener()
539    {
540   
 
541  0 toggle @Override
542    public void actionPerformed(ActionEvent e)
543    {
544  0 autoIdWidth_actionPerformed();
545    }
546    });
547  0 userIdWidthlabel.setFont(LABEL_FONT);
548  0 userIdWidthlabel.setText(
549    MessageManager.getString("label.figure_id_column_width"));
550  0 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
551    .getString("label.manually_specify_width_left_column")));
552  0 userIdWidthlabel.setToolTipText(
553    JvSwingUtils.wrapTooltip(true, MessageManager.getString(
554    "label.manually_specify_width_left_column")));
555  0 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
556  0 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
557  0 userIdWidth.setText("");
558  0 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
559  0 userIdWidth.addActionListener(new ActionListener()
560    {
561   
 
562  0 toggle @Override
563    public void actionPerformed(ActionEvent e)
564    {
565  0 userIdWidth_actionPerformed();
566    }
567    });
568  0 modellerOutput.setFont(LABEL_FONT);
569  0 modellerOutput
570    .setText(MessageManager.getString("label.use_modeller_output"));
571  0 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
572  0 embbedBioJSON.setFont(LABEL_FONT);
573  0 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
574  0 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
575   
576  0 jPanel11.add(jLabel1);
577  0 jPanel11.add(blcjv);
578  0 jPanel11.add(clustaljv);
579  0 jPanel11.add(fastajv);
580  0 jPanel11.add(msfjv);
581  0 jPanel11.add(pfamjv);
582  0 jPanel11.add(pileupjv);
583  0 jPanel11.add(pirjv);
584  0 outputTab.add(autoIdWidth);
585  0 outputTab.add(userIdWidth);
586  0 outputTab.add(userIdWidthlabel);
587  0 outputTab.add(modellerOutput);
588  0 if (!Platform.isJS())
589    {
590    /*
591    * JalviewJS doesn't support Lineart option or SVG output
592    */
593  0 outputTab.add(embbedBioJSON);
594  0 outputTab.add(epsLabel);
595  0 outputTab.add(epsRendering);
596  0 outputTab.add(htmlLabel);
597  0 outputTab.add(htmlRendering);
598  0 outputTab.add(svgLabel);
599  0 outputTab.add(svgRendering);
600    }
601  0 outputTab.add(jPanel11);
602  0 return outputTab;
603    }
604   
605    /**
606    * Initialises the Connections tabbed panel.
607    *
608    * @return
609    */
 
610  0 toggle private JPanel initConnectionsTab()
611    {
612  0 JPanel connectTab = new JPanel();
613  0 connectTab.setLayout(new GridBagLayout());
614   
615    // Label for browser text box
616  0 JLabel browserLabel = new JLabel();
617  0 browserLabel.setFont(LABEL_FONT);
618  0 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
619  0 browserLabel.setText(
620    MessageManager.getString("label.default_browser_unix"));
621  0 defaultBrowser.setFont(LABEL_FONT);
622  0 defaultBrowser.setText("");
623  0 final String tooltip = JvSwingUtils.wrapTooltip(true,
624    MessageManager.getString("label.double_click_to_browse"));
625  0 defaultBrowser.setToolTipText(tooltip);
626  0 defaultBrowser.addMouseListener(new MouseAdapter()
627    {
 
628  0 toggle @Override
629    public void mouseClicked(MouseEvent e)
630    {
631  0 if (e.getClickCount() > 1)
632    {
633  0 defaultBrowser_mouseClicked(e);
634    }
635    }
636    });
637   
638  0 JPanel proxyPanel = initConnTabProxyPanel();
639  0 initConnTabCheckboxes();
640   
641    // Add default Browser text box
642  0 connectTab.add(browserLabel,
643    new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
644    GridBagConstraints.WEST, GridBagConstraints.NONE,
645    new Insets(10, 0, 5, 5), 5, 1));
646  0 defaultBrowser.setFont(LABEL_FONT);
647  0 defaultBrowser.setText("");
648   
649  0 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
650    0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
651    new Insets(10, 0, 5, 10), 30, 1));
652   
653    // Add proxy server panel
654  0 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
655    GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
656    new Insets(10, 0, 5, 12), 4, 10));
657   
658    // Add usage stats, version check and questionnaire checkboxes
659  0 connectTab.add(usagestats,
660    new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
661    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
662    new Insets(0, 2, 5, 5), 70, 1));
663  0 connectTab.add(questionnaire,
664    new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
665    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
666    new Insets(0, 2, 5, 10), 70, 1));
667  0 connectTab.add(versioncheck,
668    new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
669    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
670    new Insets(0, 2, 5, 5), 70, 1));
671   
672  0 versioncheck.setVisible(false);
673   
674    // Add padding so the panel doesn't look ridiculous
675  0 JPanel spacePanel = new JPanel();
676  0 connectTab.add(spacePanel,
677    new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
678    GridBagConstraints.WEST, GridBagConstraints.BOTH,
679    new Insets(0, 0, 0, 5), 70, 1));
680   
681  0 return connectTab;
682    }
683   
684    /**
685    * Initialises the Links tabbed panel.
686    *
687    * @return
688    */
 
689  0 toggle private JPanel initLinksTab()
690    {
691  0 JPanel linkTab = new JPanel();
692  0 linkTab.setLayout(new GridBagLayout());
693   
694    // Set up table for Url links
695  0 linkUrlTable.getTableHeader().setReorderingAllowed(false);
696  0 linkUrlTable.setFillsViewportHeight(true);
697  0 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
698  0 linkUrlTable.setAutoCreateRowSorter(true);
699  0 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
700   
701    // adjust row height so radio buttons actually fit
702    // don't do this in the renderer, it causes the awt thread to activate
703    // constantly
704  0 JRadioButton temp = new JRadioButton();
705  0 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
706   
707    // Table in scrollpane so that the table is given a scrollbar
708  0 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
709  0 linkScrollPane.setBorder(null);
710   
711    // Panel for links functionality
712  0 JPanel linkPanel = new JPanel(new GridBagLayout());
713  0 linkPanel.setBorder(new TitledBorder(
714    MessageManager.getString("label.url_linkfrom_sequence_id")));
715   
716    // Put the Url links panel together
717   
718    // Buttons go at top right, resizing only resizes the blank space vertically
719  0 JPanel buttonPanel = initLinkTabUrlButtons();
720  0 GridBagConstraints linkConstraints1 = new GridBagConstraints();
721  0 linkConstraints1.insets = new Insets(0, 0, 5, 0);
722  0 linkConstraints1.gridx = 0;
723  0 linkConstraints1.gridy = 0;
724  0 linkConstraints1.weightx = 1.0;
725  0 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
726  0 linkTab.add(buttonPanel, linkConstraints1);
727   
728    // Links table goes at top left, resizing resizes the table
729  0 GridBagConstraints linkConstraints2 = new GridBagConstraints();
730  0 linkConstraints2.insets = new Insets(0, 0, 5, 5);
731  0 linkConstraints2.gridx = 0;
732  0 linkConstraints2.gridy = 1;
733  0 linkConstraints2.weightx = 1.0;
734  0 linkConstraints2.weighty = 1.0;
735  0 linkConstraints2.fill = GridBagConstraints.BOTH;
736  0 linkTab.add(linkScrollPane, linkConstraints2);
737   
738    // Filter box and buttons goes at bottom left, resizing resizes the text box
739  0 JPanel filterPanel = initLinkTabFilterPanel();
740  0 GridBagConstraints linkConstraints3 = new GridBagConstraints();
741  0 linkConstraints3.insets = new Insets(0, 0, 0, 5);
742  0 linkConstraints3.gridx = 0;
743  0 linkConstraints3.gridy = 2;
744  0 linkConstraints3.weightx = 1.0;
745  0 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
746  0 linkTab.add(filterPanel, linkConstraints3);
747   
748  0 return linkTab;
749    }
750   
 
751  0 toggle private JPanel initLinkTabFilterPanel()
752    {
753    // Filter textbox and reset button
754  0 JLabel filterLabel = new JLabel(
755    MessageManager.getString("label.filter"));
756  0 filterLabel.setFont(LABEL_FONT);
757  0 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
758  0 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
759   
760  0 filterTB.setFont(LABEL_FONT);
761  0 filterTB.setText("");
762   
763  0 doReset.setText(MessageManager.getString("action.showall"));
764  0 userOnly.setText(MessageManager.getString("action.customfilter"));
765   
766    // Panel for filter functionality
767  0 JPanel filterPanel = new JPanel(new GridBagLayout());
768  0 filterPanel.setBorder(new TitledBorder("Filter"));
769  0 GridBagConstraints gbc = new GridBagConstraints();
770  0 gbc.gridx = 0;
771  0 gbc.gridy = 0;
772  0 gbc.fill = GridBagConstraints.NONE;
773  0 gbc.anchor = GridBagConstraints.WEST;
774   
775  0 filterPanel.add(filterLabel, gbc);
776   
777  0 GridBagConstraints gbc1 = new GridBagConstraints();
778  0 gbc1.gridx = 1;
779  0 gbc1.gridwidth = 2;
780  0 gbc1.fill = GridBagConstraints.HORIZONTAL;
781  0 gbc1.anchor = GridBagConstraints.WEST;
782  0 gbc1.weightx = 1.0;
783  0 filterPanel.add(filterTB, gbc1);
784   
785  0 GridBagConstraints gbc2 = new GridBagConstraints();
786  0 gbc2.gridx = 3;
787  0 gbc2.fill = GridBagConstraints.NONE;
788  0 gbc2.anchor = GridBagConstraints.WEST;
789  0 filterPanel.add(doReset, gbc2);
790   
791  0 GridBagConstraints gbc3 = new GridBagConstraints();
792  0 gbc3.gridx = 4;
793  0 gbc3.fill = GridBagConstraints.NONE;
794  0 gbc3.anchor = GridBagConstraints.WEST;
795  0 filterPanel.add(userOnly, gbc3);
796   
797  0 return filterPanel;
798    }
799   
 
800  0 toggle private JPanel initLinkTabUrlButtons()
801    {
802    // Buttons for new / edit / delete Url links
803  0 JButton newLink = new JButton();
804  0 newLink.setText(MessageManager.getString("action.new"));
805   
806  0 editLink.setText(MessageManager.getString("action.edit"));
807   
808  0 deleteLink.setText(MessageManager.getString("action.delete"));
809   
810    // no current selection, so initially disable delete/edit buttons
811  0 editLink.setEnabled(false);
812  0 deleteLink.setEnabled(false);
813   
814  0 newLink.addActionListener(new java.awt.event.ActionListener()
815    {
 
816  0 toggle @Override
817    public void actionPerformed(ActionEvent e)
818    {
819  0 newLink_actionPerformed(e);
820    }
821    });
822   
823  0 editLink.setText(MessageManager.getString("action.edit"));
824  0 editLink.addActionListener(new java.awt.event.ActionListener()
825    {
 
826  0 toggle @Override
827    public void actionPerformed(ActionEvent e)
828    {
829  0 editLink_actionPerformed(e);
830    }
831    });
832   
833  0 deleteLink.setText(MessageManager.getString("action.delete"));
834  0 deleteLink.addActionListener(new java.awt.event.ActionListener()
835    {
 
836  0 toggle @Override
837    public void actionPerformed(ActionEvent e)
838    {
839  0 deleteLink_actionPerformed(e);
840    }
841    });
842   
843  0 JPanel buttonPanel = new JPanel(new GridBagLayout());
844  0 buttonPanel.setBorder(new TitledBorder("Edit links"));
845  0 GridBagConstraints gbc = new GridBagConstraints();
846  0 gbc.gridx = 0;
847  0 gbc.gridy = 0;
848  0 gbc.fill = GridBagConstraints.NONE;
849  0 buttonPanel.add(newLink, gbc);
850   
851  0 GridBagConstraints gbc1 = new GridBagConstraints();
852  0 gbc1.gridx = 1;
853  0 gbc1.gridy = 0;
854  0 gbc1.fill = GridBagConstraints.NONE;
855  0 buttonPanel.add(editLink, gbc1);
856   
857  0 GridBagConstraints gbc2 = new GridBagConstraints();
858  0 gbc2.gridx = 2;
859  0 gbc2.gridy = 0;
860  0 gbc2.fill = GridBagConstraints.NONE;
861  0 buttonPanel.add(deleteLink, gbc2);
862   
863  0 GridBagConstraints gbc3 = new GridBagConstraints();
864  0 gbc3.gridx = 3;
865  0 gbc3.gridy = 0;
866  0 gbc3.fill = GridBagConstraints.HORIZONTAL;
867  0 gbc3.weightx = 1.0;
868  0 JPanel spacePanel = new JPanel();
869  0 spacePanel.setBorder(null);
870  0 buttonPanel.add(spacePanel, gbc3);
871   
872  0 return buttonPanel;
873    }
874   
875    /**
876    * Initialises the proxy server panel in the Connections tab
877    *
878    * @return the proxy server panel
879    */
 
880  0 toggle private JPanel initConnTabProxyPanel()
881    {
882    // Label for server text box
883  0 serverLabel.setText(MessageManager.getString("label.address"));
884  0 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
885  0 serverLabel.setFont(LABEL_FONT);
886   
887    // Proxy server and port text boxes
888  0 proxyServerTB.setFont(LABEL_FONT);
889  0 proxyPortTB.setFont(LABEL_FONT);
890   
891    // Label for Port text box
892  0 portLabel.setFont(LABEL_FONT);
893  0 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
894  0 portLabel.setText(MessageManager.getString("label.port"));
895   
896    // Use proxy server checkbox
897  0 useProxy.setFont(LABEL_FONT);
898  0 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
899  0 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
900  0 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
901  0 useProxy.addActionListener(new ActionListener()
902    {
 
903  0 toggle @Override
904    public void actionPerformed(ActionEvent e)
905    {
906  0 useProxy_actionPerformed();
907    }
908    });
909   
910    // Make proxy server panel
911  0 JPanel proxyPanel = new JPanel();
912  0 TitledBorder titledBorder1 = new TitledBorder(
913    MessageManager.getString("label.proxy_server"));
914  0 proxyPanel.setBorder(titledBorder1);
915  0 proxyPanel.setLayout(new GridBagLayout());
916  0 proxyPanel.add(serverLabel,
917    new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
918    GridBagConstraints.WEST, GridBagConstraints.NONE,
919    new Insets(0, 2, 2, 0), 5, 0));
920  0 proxyPanel.add(portLabel,
921    new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
922    GridBagConstraints.WEST, GridBagConstraints.NONE,
923    new Insets(0, 0, 2, 0), 11, 0));
924  0 proxyPanel.add(useProxy,
925    new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
926    GridBagConstraints.WEST, GridBagConstraints.NONE,
927    new Insets(0, 2, 5, 185), 2, -4));
928  0 proxyPanel.add(proxyPortTB,
929    new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
930    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
931    new Insets(0, 2, 2, 2), 54, 1));
932  0 proxyPanel.add(proxyServerTB,
933    new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
934    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
935    new Insets(0, 2, 2, 0), 263, 1));
936   
937  0 return proxyPanel;
938    }
939   
940    /**
941    * Initialises the checkboxes in the Connections tab
942    */
 
943  0 toggle private void initConnTabCheckboxes()
944    {
945    // Usage stats checkbox label
946  0 usagestats.setText(
947    MessageManager.getString("label.send_usage_statistics"));
948  0 usagestats.setFont(LABEL_FONT);
949  0 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
950  0 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
951   
952    // Questionnaire checkbox label
953  0 questionnaire.setText(
954    MessageManager.getString("label.check_for_questionnaires"));
955  0 questionnaire.setFont(LABEL_FONT);
956  0 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
957  0 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
958   
959    // Check for latest version checkbox label
960  0 versioncheck.setText(
961    MessageManager.getString("label.check_for_latest_version"));
962  0 versioncheck.setFont(LABEL_FONT);
963  0 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
964  0 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
965    }
966   
967    /**
968    * Initialises the parent panel which contains the tabbed sections.
969    *
970    * @return
971    */
 
972  0 toggle private JPanel initOkCancelPanel()
973    {
974  0 JButton ok = new JButton();
975  0 ok.setText(MessageManager.getString("action.ok"));
976  0 ok.addActionListener(new ActionListener()
977    {
 
978  0 toggle @Override
979    public void actionPerformed(ActionEvent e)
980    {
981  0 ok_actionPerformed(e);
982    }
983    });
984  0 JButton cancel = new JButton();
985  0 cancel.setText(MessageManager.getString("action.cancel"));
986  0 cancel.addActionListener(new ActionListener()
987    {
 
988  0 toggle @Override
989    public void actionPerformed(ActionEvent e)
990    {
991  0 cancel_actionPerformed(e);
992    }
993    });
994  0 JPanel okCancelPanel = new JPanel();
995  0 okCancelPanel.add(ok);
996  0 okCancelPanel.add(cancel);
997  0 return okCancelPanel;
998    }
999   
1000    /**
1001    * Initialises the Colours tabbed panel.
1002    *
1003    * @return
1004    */
 
1005  0 toggle private JPanel initColoursTab()
1006    {
1007  0 JPanel coloursTab = new JPanel();
1008  0 coloursTab.setBorder(new TitledBorder(
1009    MessageManager.getString("action.open_new_alignment")));
1010  0 coloursTab.setLayout(new FlowLayout());
1011  0 JLabel mincolourLabel = new JLabel();
1012  0 mincolourLabel.setFont(LABEL_FONT);
1013  0 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1014  0 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1015  0 minColour.setFont(LABEL_FONT);
1016  0 minColour.setBorder(BorderFactory.createEtchedBorder());
1017  0 minColour.setPreferredSize(new Dimension(40, 20));
1018  0 minColour.addMouseListener(new MouseAdapter()
1019    {
 
1020  0 toggle @Override
1021    public void mousePressed(MouseEvent e)
1022    {
1023  0 minColour_actionPerformed(minColour);
1024    }
1025    });
1026  0 JLabel maxcolourLabel = new JLabel();
1027  0 maxcolourLabel.setFont(LABEL_FONT);
1028  0 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1029  0 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1030  0 maxColour.setFont(LABEL_FONT);
1031  0 maxColour.setBorder(BorderFactory.createEtchedBorder());
1032  0 maxColour.setPreferredSize(new Dimension(40, 20));
1033  0 maxColour.addMouseListener(new MouseAdapter()
1034    {
 
1035  0 toggle @Override
1036    public void mousePressed(MouseEvent e)
1037    {
1038  0 maxColour_actionPerformed(maxColour);
1039    }
1040    });
1041   
1042  0 protColour.setFont(LABEL_FONT);
1043  0 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1044  0 JLabel protColourLabel = new JLabel();
1045  0 protColourLabel.setFont(LABEL_FONT);
1046  0 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1047  0 protColourLabel.setText(
1048    MessageManager.getString("label.prot_alignment_colour") + " ");
1049  0 JvSwingUtils.addtoLayout(coloursTab,
1050    MessageManager
1051    .getString("label.default_colour_scheme_for_alignment"),
1052    protColourLabel, protColour);
1053   
1054  0 nucColour.setFont(LABEL_FONT);
1055  0 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1056  0 JLabel nucColourLabel = new JLabel();
1057  0 nucColourLabel.setFont(LABEL_FONT);
1058  0 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1059  0 nucColourLabel.setText(
1060    MessageManager.getString("label.nuc_alignment_colour") + " ");
1061  0 JvSwingUtils.addtoLayout(coloursTab,
1062    MessageManager
1063    .getString("label.default_colour_scheme_for_alignment"),
1064    nucColourLabel, nucColour);
1065   
1066  0 JPanel annotationShding = new JPanel();
1067  0 annotationShding.setBorder(new TitledBorder(
1068    MessageManager.getString("label.annotation_shading_default")));
1069  0 annotationShding.setLayout(new GridLayout(1, 2));
1070  0 JvSwingUtils.addtoLayout(annotationShding,
1071    MessageManager.getString(
1072    "label.default_minimum_colour_annotation_shading"),
1073    mincolourLabel, minColour);
1074  0 JvSwingUtils.addtoLayout(annotationShding,
1075    MessageManager.getString(
1076    "label.default_maximum_colour_annotation_shading"),
1077    maxcolourLabel, maxColour);
1078  0 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1079  0 return coloursTab;
1080    }
1081   
1082    /**
1083    * Initialises the Overview tabbed panel.
1084    *
1085    * @return
1086    */
 
1087  0 toggle private JPanel initOverviewTab()
1088    {
1089  0 JPanel overviewPanel = new JPanel();
1090  0 overviewPanel.setBorder(new TitledBorder(
1091    MessageManager.getString("label.overview_settings")));
1092   
1093  0 gapColour.setFont(LABEL_FONT);
1094    // fixing the border colours stops apparent colour bleed from the panel
1095  0 gapColour.setBorder(
1096    BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1097  0 gapColour.setPreferredSize(new Dimension(40, 20));
1098  0 gapColour.addMouseListener(new MouseAdapter()
1099    {
 
1100  0 toggle @Override
1101    public void mousePressed(MouseEvent e)
1102    {
1103  0 gapColour_actionPerformed(gapColour);
1104    }
1105    });
1106   
1107  0 hiddenColour.setFont(LABEL_FONT);
1108    // fixing the border colours stops apparent colour bleed from the panel
1109  0 hiddenColour.setBorder(
1110    BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1111  0 hiddenColour.setPreferredSize(new Dimension(40, 20));
1112  0 hiddenColour.addMouseListener(new MouseAdapter()
1113    {
 
1114  0 toggle @Override
1115    public void mousePressed(MouseEvent e)
1116    {
1117  0 hiddenColour_actionPerformed(hiddenColour);
1118    }
1119    });
1120   
1121  0 useLegacyGap = new JCheckBox(
1122    MessageManager.getString("label.ov_legacy_gap"));
1123  0 useLegacyGap.setFont(LABEL_FONT);
1124  0 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1125  0 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1126  0 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1127  0 gapLabel.setFont(LABEL_FONT);
1128  0 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1129  0 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1130  0 showHiddenAtStart = new JCheckBox(
1131    MessageManager.getString("label.ov_show_hide_default"));
1132  0 showHiddenAtStart.setFont(LABEL_FONT);
1133  0 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1134  0 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1135  0 JLabel hiddenLabel = new JLabel(
1136    MessageManager.getString("label.hidden_colour"));
1137  0 hiddenLabel.setFont(LABEL_FONT);
1138  0 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1139  0 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1140   
1141  0 useLegacyGap.addActionListener(new ActionListener()
1142    {
 
1143  0 toggle @Override
1144    public void actionPerformed(ActionEvent e)
1145    {
1146  0 useLegacyGaps_actionPerformed(e);
1147    }
1148    });
1149   
1150  0 overviewPanel.setLayout(new GridBagLayout());
1151  0 GridBagConstraints c1 = new GridBagConstraints();
1152   
1153  0 c1.fill = GridBagConstraints.HORIZONTAL;
1154  0 c1.gridx = 0;
1155  0 c1.gridy = 0;
1156  0 c1.weightx = 1;
1157  0 c1.ipady = 20;
1158  0 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1159  0 overviewPanel.add(useLegacyGap, c1);
1160   
1161  0 GridBagConstraints c2 = new GridBagConstraints();
1162  0 c2.fill = GridBagConstraints.HORIZONTAL;
1163  0 c2.gridx = 1;
1164  0 c2.gridy = 0;
1165  0 c2.insets = new Insets(0, 15, 0, 10);
1166  0 overviewPanel.add(gapLabel, c2);
1167   
1168  0 GridBagConstraints c3 = new GridBagConstraints();
1169  0 c3.fill = GridBagConstraints.HORIZONTAL;
1170  0 c3.gridx = 2;
1171  0 c3.gridy = 0;
1172  0 c3.insets = new Insets(0, 0, 0, 15);
1173  0 overviewPanel.add(gapColour, c3);
1174   
1175  0 GridBagConstraints c4 = new GridBagConstraints();
1176  0 c4.fill = GridBagConstraints.HORIZONTAL;
1177  0 c4.gridx = 0;
1178  0 c4.gridy = 1;
1179  0 c4.weightx = 1;
1180  0 overviewPanel.add(showHiddenAtStart, c4);
1181   
1182  0 GridBagConstraints c5 = new GridBagConstraints();
1183  0 c5.fill = GridBagConstraints.HORIZONTAL;
1184  0 c5.gridx = 1;
1185  0 c5.gridy = 1;
1186  0 c5.insets = new Insets(0, 15, 0, 10);
1187  0 overviewPanel.add(hiddenLabel, c5);
1188   
1189  0 GridBagConstraints c6 = new GridBagConstraints();
1190  0 c6.fill = GridBagConstraints.HORIZONTAL;
1191  0 c6.gridx = 2;
1192  0 c6.gridy = 1;
1193  0 c6.insets = new Insets(0, 0, 0, 15);
1194  0 overviewPanel.add(hiddenColour, c6);
1195   
1196  0 JButton resetButton = new JButton(
1197    MessageManager.getString("label.reset_to_defaults"));
1198   
1199  0 resetButton.addActionListener(new ActionListener()
1200    {
 
1201  0 toggle @Override
1202    public void actionPerformed(ActionEvent e)
1203    {
1204  0 resetOvDefaults_actionPerformed(e);
1205    }
1206    });
1207   
1208  0 GridBagConstraints c7 = new GridBagConstraints();
1209  0 c7.fill = GridBagConstraints.NONE;
1210  0 c7.gridx = 0;
1211  0 c7.gridy = 2;
1212  0 c7.insets = new Insets(10, 0, 0, 0);
1213  0 c7.anchor = GridBagConstraints.WEST;
1214  0 overviewPanel.add(resetButton, c7);
1215   
1216    // Add padding so the panel doesn't look ridiculous
1217  0 JPanel spacePanel = new JPanel();
1218  0 overviewPanel.add(spacePanel,
1219    new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1220    GridBagConstraints.WEST, GridBagConstraints.BOTH,
1221    new Insets(0, 0, 0, 5), 0, 0));
1222   
1223  0 return overviewPanel;
1224    }
1225   
1226    /**
1227    * Initialises the Structure tabbed panel.
1228    *
1229    * @return
1230    */
 
1231  0 toggle private JPanel initStructureTab()
1232    {
1233  0 structureTab = new JPanel();
1234   
1235  0 structureTab.setBorder(new TitledBorder(
1236    MessageManager.getString("label.structure_options")));
1237  0 structureTab.setLayout(null);
1238  0 final int width = 420;
1239  0 final int height = 22;
1240  0 final int lineSpacing = 25;
1241  0 int ypos = 15;
1242   
1243  0 structFromPdb.setFont(LABEL_FONT);
1244  0 structFromPdb
1245    .setText(MessageManager.getString("label.struct_from_pdb"));
1246  0 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1247  0 structFromPdb.addActionListener(new ActionListener()
1248    {
 
1249  0 toggle @Override
1250    public void actionPerformed(ActionEvent e)
1251    {
1252  0 boolean selected = structFromPdb.isSelected();
1253    // enable other options only when the first is checked
1254  0 useRnaView.setEnabled(selected);
1255  0 addSecondaryStructure.setEnabled(selected);
1256  0 addTempFactor.setEnabled(selected);
1257    }
1258    });
1259  0 structureTab.add(structFromPdb);
1260   
1261    // indent checkboxes that are conditional on the first one
1262  0 ypos += lineSpacing;
1263  0 useRnaView.setFont(LABEL_FONT);
1264  0 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1265  0 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1266  0 structureTab.add(useRnaView);
1267   
1268  0 ypos += lineSpacing;
1269  0 addSecondaryStructure.setFont(LABEL_FONT);
1270  0 addSecondaryStructure
1271    .setText(MessageManager.getString("label.autoadd_secstr"));
1272  0 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1273  0 structureTab.add(addSecondaryStructure);
1274   
1275  0 ypos += lineSpacing;
1276  0 addTempFactor.setFont(LABEL_FONT);
1277  0 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1278  0 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1279  0 structureTab.add(addTempFactor);
1280   
1281  0 ypos += lineSpacing;
1282  0 JLabel viewerLabel = new JLabel();
1283  0 viewerLabel.setFont(LABEL_FONT);
1284  0 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1285  0 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1286  0 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1287  0 structureTab.add(viewerLabel);
1288   
1289    /*
1290    * add all external viewers as options here - check
1291    * when selected whether the program is installed
1292    */
1293  0 structViewer.setFont(LABEL_FONT);
1294  0 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1295  0 structViewer.addItem(ViewerType.JMOL.name());
1296  0 structViewer.addItem(ViewerType.CHIMERA.name());
1297  0 structViewer.addItem(ViewerType.CHIMERAX.name());
1298  0 structViewer.addItem(ViewerType.PYMOL.name());
1299  0 structViewer.addActionListener(new ActionListener()
1300    {
 
1301  0 toggle @Override
1302    public void actionPerformed(ActionEvent e)
1303    {
1304  0 structureViewer_actionPerformed(
1305    (String) structViewer.getSelectedItem());
1306    }
1307    });
1308  0 structureTab.add(structViewer);
1309   
1310  0 ypos += lineSpacing;
1311  0 structureViewerPathLabel = new JLabel();
1312  0 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
1313  0 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1314  0 structureViewerPathLabel.setText(MessageManager
1315    .formatMessage("label.viewer_path", "Chimera(X)"));
1316  0 structureViewerPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
1317  0 structureViewerPathLabel.setEnabled(false);
1318  0 structureTab.add(structureViewerPathLabel);
1319   
1320  0 structureViewerPath.setFont(LABEL_FONT);
1321  0 structureViewerPath.setText("");
1322  0 structureViewerPath.setEnabled(false);
1323  0 final String tooltip = JvSwingUtils.wrapTooltip(true,
1324    MessageManager.getString("label.viewer_path_tip"));
1325  0 structureViewerPath.setToolTipText(tooltip);
1326  0 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1327  0 structureViewerPath.addMouseListener(new MouseAdapter()
1328    {
 
1329  0 toggle @Override
1330    public void mouseClicked(MouseEvent e)
1331    {
1332  0 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1333    {
1334  0 String chosen = openFileChooser();
1335  0 if (chosen != null)
1336    {
1337  0 structureViewerPath.setText(chosen);
1338    }
1339    }
1340    }
1341    });
1342  0 structureTab.add(structureViewerPath);
1343   
1344  0 ypos += lineSpacing;
1345  0 nwMapping.setFont(LABEL_FONT);
1346  0 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1347  0 siftsMapping.setFont(LABEL_FONT);
1348  0 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1349  0 mappingMethod.add(nwMapping);
1350  0 mappingMethod.add(siftsMapping);
1351  0 JPanel mappingPanel = new JPanel();
1352  0 mappingPanel.setFont(LABEL_FONT);
1353  0 TitledBorder mmTitledBorder = new TitledBorder(
1354    MessageManager.getString("label.mapping_method"));
1355  0 mmTitledBorder.setTitleFont(LABEL_FONT);
1356  0 mappingPanel.setBorder(mmTitledBorder);
1357  0 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1358    // GridLayout mappingLayout = new GridLayout();
1359  0 mappingPanel.setLayout(new GridLayout());
1360  0 mappingPanel.add(nwMapping);
1361  0 mappingPanel.add(siftsMapping);
1362  0 structureTab.add(mappingPanel);
1363   
1364  0 ypos += lineSpacing;
1365  0 ypos += lineSpacing;
1366  0 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1367    PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1368  0 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1369  0 structureTab.add(docFieldPref);
1370   
1371    /*
1372    * hide Chimera options in JalviewJS
1373    */
1374  0 if (Platform.isJS())
1375    {
1376  0 structureViewerPathLabel.setVisible(false);
1377  0 structureViewerPath.setVisible(false);
1378  0 viewerLabel.setVisible(false);
1379  0 structViewer.setVisible(false);
1380    }
1381   
1382  0 return structureTab;
1383    }
1384   
1385    /**
1386    * Action on choosing a structure viewer from combobox options.
1387    *
1388    * @param selectedItem
1389    */
 
1390  0 toggle protected void structureViewer_actionPerformed(String selectedItem)
1391    {
1392    }
1393   
1394    /**
1395    * Show a dialog for the user to choose a file. Returns the chosen path, or
1396    * null on Cancel.
1397    *
1398    * @return
1399    */
 
1400  0 toggle protected String openFileChooser()
1401    {
1402  0 String choice = null;
1403  0 JFileChooser chooser = new JFileChooser();
1404   
1405    // chooser.setFileView(new JalviewFileView());
1406  0 chooser.setDialogTitle(
1407    MessageManager.getString("label.open_local_file"));
1408  0 chooser.setToolTipText(MessageManager.getString("action.open"));
1409   
1410  0 int value = chooser.showOpenDialog(this);
1411   
1412  0 if (value == JFileChooser.APPROVE_OPTION)
1413    {
1414  0 choice = chooser.getSelectedFile().getPath();
1415    }
1416  0 return choice;
1417    }
1418   
1419    /**
1420    * Validate the structure tab preferences; if invalid, set focus on this tab.
1421    *
1422    * @param e
1423    */
 
1424  0 toggle protected boolean validateStructure(FocusEvent e)
1425    {
1426  0 if (!validateStructure())
1427    {
1428  0 e.getComponent().requestFocusInWindow();
1429  0 return false;
1430    }
1431  0 return true;
1432    }
1433   
 
1434  0 toggle protected boolean validateStructure()
1435    {
1436  0 return false;
1437    }
1438   
1439    /**
1440    * Initialises the Visual tabbed panel.
1441    *
1442    * @return
1443    */
 
1444  0 toggle private JPanel initVisualTab()
1445    {
1446  0 JPanel visualTab = new JPanel();
1447  0 visualTab.setBorder(new TitledBorder(
1448    MessageManager.getString("action.open_new_alignment")));
1449  0 visualTab.setLayout(null);
1450  0 fullScreen.setFont(LABEL_FONT);
1451  0 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1452  0 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1453  0 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1454  0 quality.setEnabled(false);
1455  0 quality.setFont(LABEL_FONT);
1456  0 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1457  0 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1458  0 quality.setSelected(true);
1459  0 quality.setText(MessageManager.getString("label.quality"));
1460  0 conservation.setEnabled(false);
1461  0 conservation.setFont(LABEL_FONT);
1462  0 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1463  0 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1464  0 conservation.setSelected(true);
1465  0 conservation.setText(MessageManager.getString("label.conservation"));
1466  0 identity.setEnabled(false);
1467  0 identity.setFont(LABEL_FONT);
1468  0 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1469  0 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1470  0 identity.setSelected(true);
1471  0 identity.setText(MessageManager.getString("label.consensus"));
1472  0 showOccupancy.setFont(LABEL_FONT);
1473  0 showOccupancy.setEnabled(false);
1474  0 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1475  0 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1476  0 showOccupancy.setSelected(true);
1477  0 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1478   
1479  0 JLabel showGroupbits = new JLabel();
1480  0 showGroupbits.setFont(LABEL_FONT);
1481  0 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1482  0 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1483  0 showGroupbits
1484    .setText(MessageManager.getString("action.show_group") + ":");
1485  0 JLabel showConsensbits = new JLabel();
1486  0 showConsensbits.setFont(LABEL_FONT);
1487  0 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1488  0 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1489  0 showConsensbits
1490    .setText(MessageManager.getString("label.consensus") + ":");
1491  0 showConsensHistogram.setEnabled(false);
1492  0 showConsensHistogram.setFont(LABEL_FONT);
1493  0 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1494  0 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1495  0 showConsensHistogram.setSelected(true);
1496  0 showConsensHistogram
1497    .setText(MessageManager.getString("label.histogram"));
1498  0 showConsensLogo.setEnabled(false);
1499  0 showConsensLogo.setFont(LABEL_FONT);
1500  0 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1501  0 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1502  0 showConsensLogo.setSelected(true);
1503  0 showConsensLogo.setText(MessageManager.getString("label.logo"));
1504  0 showGroupConsensus.setEnabled(false);
1505  0 showGroupConsensus.setFont(LABEL_FONT);
1506  0 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1507  0 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1508  0 showGroupConsensus.setSelected(true);
1509  0 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1510  0 showGroupConservation.setEnabled(false);
1511  0 showGroupConservation.setFont(LABEL_FONT);
1512  0 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1513  0 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1514  0 showGroupConservation.setSelected(true);
1515  0 showGroupConservation
1516    .setText(MessageManager.getString("label.conservation"));
1517  0 showNpTooltip.setEnabled(true);
1518  0 showNpTooltip.setFont(LABEL_FONT);
1519  0 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1520  0 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1521  0 showNpTooltip.setSelected(true);
1522  0 showNpTooltip.setText(
1523    MessageManager.getString("label.non_positional_features"));
1524  0 showDbRefTooltip.setEnabled(true);
1525  0 showDbRefTooltip.setFont(LABEL_FONT);
1526  0 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1527  0 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1528  0 showDbRefTooltip.setSelected(true);
1529  0 showDbRefTooltip
1530    .setText(MessageManager.getString("label.database_references"));
1531  0 annotations.setFont(LABEL_FONT);
1532  0 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1533  0 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1534  0 annotations.setSelected(true);
1535  0 annotations.setText(MessageManager.getString("label.show_annotations"));
1536    // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1537  0 annotations.addActionListener(new ActionListener()
1538    {
 
1539  0 toggle @Override
1540    public void actionPerformed(ActionEvent e)
1541    {
1542  0 annotations_actionPerformed(e);
1543    }
1544    });
1545  0 identity.addActionListener(new ActionListener()
1546    {
 
1547  0 toggle @Override
1548    public void actionPerformed(ActionEvent e)
1549    {
1550  0 annotations_actionPerformed(e);
1551    }
1552    });
1553  0 showGroupConsensus.addActionListener(new ActionListener()
1554    {
 
1555  0 toggle @Override
1556    public void actionPerformed(ActionEvent e)
1557    {
1558  0 annotations_actionPerformed(e);
1559    }
1560    });
1561  0 showUnconserved.setFont(LABEL_FONT);
1562  0 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1563  0 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1564  0 showUnconserved.setSelected(true);
1565  0 showUnconserved
1566    .setText(MessageManager.getString("action.show_unconserved"));
1567  0 showUnconserved.addActionListener(new ActionListener()
1568    {
 
1569  0 toggle @Override
1570    public void actionPerformed(ActionEvent e)
1571    {
1572  0 showunconserved_actionPerformed(e);
1573    }
1574    });
1575   
1576    // TODO these are not yet added to / action from Preferences
1577    // JCheckBox shareSelections = new JCheckBox();
1578    // shareSelections.setFont(verdana11);
1579    // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1580    // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1581    // shareSelections.setSelected(true);
1582    // shareSelections.setText(MessageManager
1583    // .getString("label.share_selection_across_views"));
1584    // JCheckBox followHighlight = new JCheckBox();
1585    // followHighlight.setFont(verdana11);
1586    // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1587    // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1588    // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1589    // followHighlight.setSelected(true);
1590    // followHighlight.setText(MessageManager
1591    // .getString("label.scroll_highlighted_regions"));
1592   
1593  0 seqLimit.setFont(LABEL_FONT);
1594  0 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1595  0 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1596  0 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1597  0 smoothFont.setFont(LABEL_FONT);
1598  0 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1599  0 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1600  0 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1601  0 scaleProteinToCdna.setFont(LABEL_FONT);
1602  0 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1603  0 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1604  0 scaleProteinToCdna.setText(
1605    MessageManager.getString("label.scale_protein_to_cdna"));
1606  0 scaleProteinToCdna.setToolTipText(
1607    MessageManager.getString("label.scale_protein_to_cdna_tip"));
1608  0 JLabel gapLabel = new JLabel();
1609  0 gapLabel.setFont(LABEL_FONT);
1610  0 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1611  0 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1612  0 JLabel fontLabel = new JLabel();
1613  0 fontLabel.setFont(LABEL_FONT);
1614  0 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1615  0 fontLabel.setText(MessageManager.getString("label.font"));
1616  0 fontSizeCB.setFont(LABEL_FONT);
1617  0 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1618  0 fontStyleCB.setFont(LABEL_FONT);
1619  0 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1620  0 fontNameCB.setFont(LABEL_FONT);
1621  0 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1622  0 gapSymbolCB.setFont(LABEL_FONT);
1623  0 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1624  0 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1625  0 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1626  0 gapSymbolCB.setRenderer(dlcr);
1627   
1628  0 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1629  0 startupCheckbox.setFont(LABEL_FONT);
1630  0 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1631  0 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1632  0 startupCheckbox.setSelected(true);
1633  0 startupFileTextfield.setFont(LABEL_FONT);
1634  0 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1635  0 final String tooltip = JvSwingUtils.wrapTooltip(true,
1636    MessageManager.getString("label.double_click_to_browse"));
1637  0 startupFileTextfield.setToolTipText(tooltip);
1638  0 startupFileTextfield.addMouseListener(new MouseAdapter()
1639    {
 
1640  0 toggle @Override
1641    public void mouseClicked(MouseEvent e)
1642    {
1643  0 if (e.getClickCount() > 1)
1644    {
1645  0 startupFileTextfield_mouseClicked();
1646    }
1647    }
1648    });
1649   
1650  0 sortby.setFont(LABEL_FONT);
1651  0 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1652  0 JLabel sortLabel = new JLabel();
1653  0 sortLabel.setFont(LABEL_FONT);
1654  0 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1655  0 sortLabel.setText(MessageManager.getString("label.sort_by"));
1656  0 sortAnnBy.setFont(LABEL_FONT);
1657  0 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1658  0 JLabel sortAnnLabel = new JLabel();
1659  0 sortAnnLabel.setFont(LABEL_FONT);
1660  0 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1661  0 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1662  0 sortAutocalc.setFont(LABEL_FONT);
1663  0 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1664   
1665  0 JPanel annsettingsPanel = new JPanel();
1666  0 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1667  0 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1668  0 annsettingsPanel.setBorder(new EtchedBorder());
1669  0 visualTab.add(annsettingsPanel);
1670  0 Border jb = new EmptyBorder(1, 1, 4, 5);
1671  0 annotations.setBorder(jb);
1672  0 showOccupancy.setBorder(jb);
1673  0 quality.setBorder(jb);
1674  0 conservation.setBorder(jb);
1675  0 identity.setBorder(jb);
1676  0 showConsensbits.setBorder(jb);
1677  0 showGroupbits.setBorder(jb);
1678  0 showGroupConsensus.setBorder(jb);
1679  0 showGroupConservation.setBorder(jb);
1680  0 showConsensHistogram.setBorder(jb);
1681  0 showConsensLogo.setBorder(jb);
1682   
1683  0 JPanel autoAnnotSettings = new JPanel();
1684  0 annsettingsPanel.add(autoAnnotSettings);
1685  0 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1686  0 autoAnnotSettings.add(annotations);
1687  0 autoAnnotSettings.add(quality);
1688    // second row of autoannotation box
1689  0 autoAnnotSettings = new JPanel();
1690  0 annsettingsPanel.add(autoAnnotSettings);
1691   
1692  0 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1693  0 autoAnnotSettings.add(conservation);
1694  0 autoAnnotSettings.add(identity);
1695  0 autoAnnotSettings.add(showOccupancy);
1696  0 autoAnnotSettings.add(showGroupbits);
1697  0 autoAnnotSettings.add(showGroupConservation);
1698  0 autoAnnotSettings.add(showGroupConsensus);
1699  0 autoAnnotSettings.add(showConsensbits);
1700  0 autoAnnotSettings.add(showConsensHistogram);
1701  0 autoAnnotSettings.add(showConsensLogo);
1702   
1703  0 JPanel tooltipSettings = new JPanel();
1704  0 tooltipSettings.setBorder(new TitledBorder(
1705    MessageManager.getString("label.sequence_id_tooltip")));
1706  0 tooltipSettings.setBounds(173, 140, 220, 62);
1707  0 tooltipSettings.setLayout(new GridLayout(2, 1));
1708  0 tooltipSettings.add(showDbRefTooltip);
1709  0 tooltipSettings.add(showNpTooltip);
1710  0 visualTab.add(tooltipSettings);
1711   
1712  0 wrap.setFont(LABEL_FONT);
1713  0 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1714  0 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1715  0 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1716  0 rightAlign.setFont(LABEL_FONT);
1717  0 rightAlign.setForeground(Color.black);
1718  0 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1719  0 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1720  0 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1721  0 idItalics.setFont(LABEL_FONT_ITALIC);
1722  0 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1723  0 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1724  0 idItalics.setText(
1725    MessageManager.getString("label.sequence_name_italics"));
1726  0 openoverv.setFont(LABEL_FONT);
1727  0 openoverv.setActionCommand(
1728    MessageManager.getString("label.open_overview"));
1729  0 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1730  0 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1731  0 openoverv.setText(MessageManager.getString("label.open_overview"));
1732  0 JPanel jPanel2 = new JPanel();
1733  0 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1734  0 jPanel2.setLayout(new GridLayout(14, 1));
1735  0 jPanel2.add(fullScreen);
1736  0 jPanel2.add(openoverv);
1737  0 jPanel2.add(seqLimit);
1738  0 jPanel2.add(rightAlign);
1739  0 jPanel2.add(fontLabel);
1740  0 jPanel2.add(showUnconserved);
1741  0 jPanel2.add(idItalics);
1742  0 jPanel2.add(smoothFont);
1743  0 jPanel2.add(scaleProteinToCdna);
1744  0 jPanel2.add(gapLabel);
1745  0 jPanel2.add(wrap);
1746  0 jPanel2.add(sortLabel);
1747  0 jPanel2.add(sortAnnLabel);
1748  0 jPanel2.add(startupCheckbox);
1749  0 visualTab.add(jPanel2);
1750  0 visualTab.add(startupFileTextfield);
1751  0 visualTab.add(sortby);
1752  0 visualTab.add(sortAnnBy);
1753  0 visualTab.add(sortAutocalc);
1754  0 visualTab.add(gapSymbolCB);
1755  0 visualTab.add(fontNameCB);
1756  0 visualTab.add(fontSizeCB);
1757  0 visualTab.add(fontStyleCB);
1758   
1759  0 if (Platform.isJS())
1760    {
1761  0 startupCheckbox.setVisible(false);
1762  0 startupFileTextfield.setVisible(false);
1763    }
1764   
1765  0 return visualTab;
1766    }
1767   
1768    /**
1769    * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1770    */
1771   
 
1772  0 toggle protected void loadLastSavedBackupsOptions()
1773    {
1774  0 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1775    .getSavedBackupEntry();
1776  0 enableBackupFiles
1777    .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1778   
1779  0 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1780    .createBackupFilesPresetEntry(Cache
1781    .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1782  0 if (backupfilesCustomEntry == null)
1783    {
1784  0 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1785    .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1786    }
1787  0 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1788    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1789    backupfilesCustomEntry);
1790   
1791  0 setComboIntStringKey(backupfilesPresetsCombo,
1792    Cache.getDefault(BackupFiles.NS + "_PRESET",
1793    BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1794   
1795  0 backupsSetOptions(savedPreset);
1796   
1797  0 backupsOptionsSetEnabled();
1798  0 updateBackupFilesExampleLabel();
1799    }
1800   
 
1801  0 toggle private boolean warnAboutSuffixReverseChange()
1802    {
1803  0 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1804    .getSavedBackupEntry();
1805  0 boolean savedSuffixReverse = bfpe.reverse;
1806  0 int savedSuffixDigits = bfpe.digits;
1807  0 String savedSuffixTemplate = bfpe.suffix;
1808   
1809  0 boolean nowSuffixReverse = suffixReverse.isSelected();
1810  0 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1811  0 String nowSuffixTemplate = suffixTemplate.getText();
1812  0 return nowSuffixReverse != savedSuffixReverse
1813    && nowSuffixDigits == savedSuffixDigits
1814    && nowSuffixTemplate != null
1815    && nowSuffixTemplate.equals(savedSuffixTemplate);
1816    }
1817   
1818    /**
1819    * Initialises the Backups tabbed panel.
1820    *
1821    * @return
1822    */
 
1823  0 toggle private JPanel initBackupsTab()
1824    {
1825  0 JPanel backupsTab = new JPanel();
1826  0 backupsTab.setBorder(new TitledBorder(
1827    MessageManager.getString("label.backup_files")));
1828  0 backupsTab.setLayout(new GridBagLayout());
1829   
1830  0 GridBagConstraints gbc = new GridBagConstraints();
1831  0 gbc.weightx = 0.0;
1832  0 gbc.weighty = 0.0;
1833  0 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1834  0 gbc.fill = GridBagConstraints.NONE;
1835   
1836  0 initBackupsTabPresetsPanel();
1837  0 initBackupsTabSuffixPanel();
1838  0 initBackupsTabKeepFilesPanel();
1839  0 initBackupsTabFilenameExamplesPanel();
1840   
1841  0 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1842  0 enableBackupFiles
1843    .setText(MessageManager.getString("label.enable_backupfiles"));
1844  0 enableBackupFiles.addActionListener(new ActionListener()
1845    {
 
1846  0 toggle @Override
1847    public void actionPerformed(ActionEvent e)
1848    {
1849    // enable other options only when the first is checked
1850  0 backupsOptionsSetEnabled();
1851    }
1852    });
1853   
1854   
1855    // enable checkbox 1 col
1856  0 gbc.gridwidth = 1;
1857  0 gbc.gridheight = 1;
1858  0 gbc.gridx = 0;
1859  0 gbc.gridy = 0; // row 0
1860  0 backupsTab.add(enableBackupFiles, gbc);
1861   
1862    // summary of scheme box (over two rows)
1863  0 gbc.gridx = 1;
1864  0 gbc.weightx = 0.0;
1865  0 gbc.gridheight = 2;
1866  0 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1867  0 gbc.fill = GridBagConstraints.BOTH;
1868  0 backupsTab.add(exampleFilesPanel, gbc);
1869  0 gbc.gridheight = 1;
1870  0 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1871  0 gbc.fill = GridBagConstraints.NONE;
1872   
1873    // fill empty space on right
1874  0 gbc.gridx++;
1875  0 gbc.weightx = 1.0;
1876  0 backupsTab.add(new JPanel(), gbc);
1877   
1878    // schemes box
1879  0 gbc.weightx = 0.0;
1880  0 gbc.gridx = 0;
1881  0 gbc.gridy++; // row 1
1882  0 backupsTab.add(presetsPanel, gbc);
1883   
1884    // now using whole row
1885  0 gbc.gridwidth = 2;
1886  0 gbc.gridheight = 1;
1887    // keep files box
1888  0 gbc.gridx = 0;
1889  0 gbc.gridy++; // row 2
1890  0 backupsTab.add(keepfilesPanel, gbc);
1891   
1892    // filename strategy box
1893  0 gbc.gridy++; // row 3
1894  0 backupsTab.add(suffixPanel, gbc);
1895   
1896    // fill empty space
1897  0 gbc.gridy++; // row 4
1898  0 gbc.weighty = 1.0;
1899  0 backupsTab.add(new JPanel(), gbc);
1900   
1901  0 backupsOptionsSetEnabled();
1902  0 return backupsTab;
1903    }
1904   
 
1905  0 toggle private JPanel initBackupsTabPresetsPanel()
1906    {
1907   
1908  0 String title = MessageManager.getString("label.schemes");
1909   
1910  0 presetsPanel.setLayout(new GridBagLayout());
1911   
1912  0 GridBagConstraints gbc = new GridBagConstraints();
1913  0 gbc.weightx = 0.0;
1914  0 gbc.weighty = 0.0;
1915  0 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1916  0 gbc.fill = GridBagConstraints.NONE;
1917  0 gbc.gridwidth = 1;
1918  0 gbc.gridheight = 1;
1919   
1920    // "Scheme: "
1921  0 gbc.gridx = 0;
1922  0 gbc.gridy = 0;
1923   
1924  0 presetsComboLabel = new JLabel(title + ":");
1925  0 presetsPanel.add(presetsComboLabel, gbc);
1926   
1927  0 List<Object> entries = Arrays
1928    .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
1929  0 List<String> tooltips = Arrays.asList(
1930    BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
1931  0 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
1932    tooltips);
1933    /*
1934    for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1935    {
1936    backupfilesPresetsCombo
1937    .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1938    }
1939    */
1940   
1941  0 backupfilesPresetsCombo.addActionListener(new ActionListener()
1942    {
 
1943  0 toggle @Override
1944    public void actionPerformed(ActionEvent e)
1945    {
1946  0 int key = getComboIntStringKey(backupfilesPresetsCombo);
1947  0 if (!customiseCheckbox.isSelected())
1948    {
1949  0 backupfilesPresetsComboLastSelected = key;
1950    }
1951  0 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1952    {
1953  0 if (customiseCheckbox.isSelected())
1954    {
1955    // got here by clicking on customiseCheckbox so don't change the values
1956  0 backupfilesCustomOptionsSetEnabled();
1957    }
1958    else
1959    {
1960  0 backupsTabUpdatePresets();
1961  0 backupfilesCustomOptionsSetEnabled();
1962    }
1963    }
1964    else
1965    {
1966  0 customiseCheckbox.setSelected(false);
1967  0 backupsTabUpdatePresets();
1968  0 backupfilesCustomOptionsSetEnabled();
1969    }
1970    }
1971    });
1972   
1973    // dropdown list of preset schemes
1974  0 gbc.gridx = 1;
1975  0 presetsPanel.add(backupfilesPresetsCombo, gbc);
1976   
1977  0 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1978  0 revertButton.setToolTipText(
1979    MessageManager.getString("label.cancel_changes_description"));
1980  0 revertButton.addActionListener(new ActionListener()
1981    {
 
1982  0 toggle @Override
1983    public void actionPerformed(ActionEvent e)
1984    {
1985  0 backupsSetOptions(
1986    BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
1987    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
1988  0 backupfilesCustomOptionsSetEnabled();
1989    }
1990   
1991    });
1992  0 revertButton.setFont(LABEL_FONT);
1993   
1994  0 customiseCheckbox.setFont(LABEL_FONT);
1995  0 customiseCheckbox.setText(MessageManager.getString("label.customise"));
1996  0 customiseCheckbox.addActionListener(new ActionListener()
1997    {
 
1998  0 toggle @Override
1999    public void actionPerformed(ActionEvent e)
2000    {
2001  0 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2002  0 if (customiseCheckbox.isSelected())
2003    {
2004  0 backupfilesPresetsComboLastSelected = currently;
2005  0 setComboIntStringKey(backupfilesPresetsCombo,
2006    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2007    }
2008    else
2009    {
2010  0 setComboIntStringKey(backupfilesPresetsCombo,
2011    backupfilesPresetsComboLastSelected);
2012   
2013    }
2014  0 backupfilesCustomOptionsSetEnabled();
2015    }
2016    });
2017  0 customiseCheckbox.setToolTipText(
2018    MessageManager.getString("label.customise_description"));
2019   
2020    // customise checkbox
2021  0 gbc.gridx = 0;
2022  0 gbc.gridy++;
2023  0 presetsPanel.add(customiseCheckbox, gbc);
2024   
2025    // "Cancel changes" button (aligned with combo box above)
2026  0 gbc.gridx = 1;
2027  0 presetsPanel.add(revertButton, gbc);
2028   
2029  0 return presetsPanel;
2030    }
2031   
 
2032  0 toggle private JPanel initBackupsTabFilenameExamplesPanel()
2033    {
2034  0 String title = MessageManager
2035    .getString("label.scheme_examples");
2036  0 TitledBorder tb = new TitledBorder(title);
2037  0 exampleFilesPanel.setBorder(tb);
2038  0 exampleFilesPanel.setLayout(new GridBagLayout());
2039   
2040   
2041  0 backupfilesExampleLabel.setEditable(false);
2042  0 backupfilesExampleLabel
2043    .setBackground(exampleFilesPanel.getBackground());
2044   
2045  0 updateBackupFilesExampleLabel();
2046   
2047  0 GridBagConstraints gbc = new GridBagConstraints();
2048  0 gbc.weightx = 1.0;
2049  0 gbc.weighty = 1.0;
2050  0 gbc.fill = GridBagConstraints.NONE;
2051  0 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2052   
2053  0 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2054  0 return exampleFilesPanel;
2055    }
2056   
 
2057  0 toggle private void backupsTabUpdatePresets()
2058    {
2059  0 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2060    .getSelectedItem();
2061  0 int key = entry.k;
2062  0 String value = entry.v;
2063   
2064  0 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2065    .containsKey(key))
2066    {
2067  0 backupsSetOptions(
2068    BackupFilesPresetEntry.backupfilesPresetEntriesValues
2069    .get(key));
2070    }
2071    else
2072    {
2073  0 Cache.log.error(
2074    "Preset '" + value + "' [key:" + key + "] not implemented");
2075    }
2076   
2077    // Custom options will now be enabled when the customiseCheckbox is checked
2078    // (performed above)
2079    // backupfilesCustomOptionsSetEnabled();
2080  0 updateBackupFilesExampleLabel();
2081    }
2082   
 
2083  0 toggle protected int getComboIntStringKey(
2084    JComboBox<Object> backupfilesPresetsCombo2)
2085    {
2086  0 IntKeyStringValueEntry e;
2087  0 try
2088    {
2089  0 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2090    .getSelectedItem();
2091    } catch (Exception ex)
2092    {
2093  0 Cache.log.error(
2094    "Problem casting Combo entry to IntKeyStringValueEntry.");
2095  0 e = null;
2096    }
2097  0 return e != null ? e.k : 0;
2098    }
2099   
 
2100  0 toggle protected void setComboIntStringKey(
2101    JComboBox<Object> backupfilesPresetsCombo2,
2102    int key)
2103    {
2104  0 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2105    {
2106  0 IntKeyStringValueEntry e;
2107  0 try
2108    {
2109  0 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2110    } catch (Exception ex)
2111    {
2112  0 Cache.log.error(
2113    "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2114  0 continue;
2115    }
2116  0 if (e.k == key)
2117    {
2118  0 backupfilesPresetsCombo2.setSelectedIndex(i);
2119  0 break;
2120    }
2121    }
2122    // backupsTabUpdatePresets();
2123    }
2124   
 
2125  0 toggle private JPanel initBackupsTabSuffixPanel()
2126    {
2127  0 suffixPanel.setBorder(new TitledBorder(
2128    MessageManager.getString("label.backup_filename_strategy")));
2129  0 suffixPanel.setLayout(new GridBagLayout());
2130   
2131  0 suffixTemplateLabel
2132    .setText(MessageManager.getString("label.append_to_filename"));
2133  0 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2134  0 suffixTemplateLabel.setFont(LABEL_FONT);
2135   
2136  0 final String tooltip = JvSwingUtils.wrapTooltip(true,
2137    MessageManager.getString("label.append_to_filename_tooltip"));
2138  0 suffixTemplate.setToolTipText(tooltip);
2139  0 suffixTemplate.addActionListener(new ActionListener()
2140    {
 
2141  0 toggle @Override
2142    public void actionPerformed(ActionEvent e)
2143    {
2144  0 updateBackupFilesExampleLabel();
2145  0 backupfilesCustomOptionsSetEnabled();
2146  0 backupfilesRevertButtonSetEnabled(true);
2147    }
2148   
2149    });
2150  0 suffixTemplate.addKeyListener(new KeyListener()
2151    {
 
2152  0 toggle @Override
2153    public void keyReleased(KeyEvent e)
2154    {
2155  0 updateBackupFilesExampleLabel();
2156  0 backupfilesCustomOptionsSetEnabled();
2157  0 backupfilesRevertButtonSetEnabled(true);
2158    }
2159   
 
2160  0 toggle @Override
2161    public void keyPressed(KeyEvent e)
2162    {
2163    }
2164   
2165    // disable use of ':' or '/' or '\'
 
2166  0 toggle @Override
2167    public void keyTyped(KeyEvent e)
2168    {
2169  0 char c = e.getKeyChar();
2170  0 if (c == ':' || c == '/' || c == '\\')
2171    {
2172    // don't process ':' or '/' or '\'
2173  0 e.consume();
2174    }
2175    }
2176   
2177    });
2178   
2179    // digits spinner
2180  0 suffixDigitsLabel
2181    .setText(MessageManager.getString("label.index_digits"));
2182  0 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2183  0 suffixDigitsLabel.setFont(LABEL_FONT);
2184  0 ChangeListener c = new ChangeListener()
2185    {
 
2186  0 toggle @Override
2187    public void stateChanged(ChangeEvent e)
2188    {
2189  0 backupfilesRevertButtonSetEnabled(true);
2190  0 updateBackupFilesExampleLabel();
2191    }
2192   
2193    };
2194  0 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2195    BackupFilesPresetEntry.DIGITSMAX, 3, c);
2196   
2197  0 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2198    MessageManager.getString("label.increment_index"));
2199  0 suffixReverse.addActionListener(new ActionListener()
2200    {
 
2201  0 toggle @Override
2202    public void actionPerformed(ActionEvent e)
2203    {
2204  0 boolean okay = true;
2205  0 if (warnAboutSuffixReverseChange())
2206    {
2207    // Warning popup
2208  0 okay = confirmSuffixReverseChange();
2209    }
2210  0 if (okay)
2211    {
2212  0 backupfilesRevertButtonSetEnabled(true);
2213  0 updateBackupFilesExampleLabel();
2214    }
2215    else
2216    {
2217  0 boolean savedSuffixReverse = BackupFilesPresetEntry
2218    .getSavedBackupEntry().reverse;
2219  0 suffixReverse.setSelected(savedSuffixReverse);
2220    }
2221    }
2222    });
2223   
2224  0 GridBagConstraints sgbc = new GridBagConstraints();
2225   
2226    // first row (template text box)
2227  0 sgbc.anchor = GridBagConstraints.WEST;
2228  0 sgbc.gridx = 0;
2229  0 sgbc.gridy = 0;
2230  0 sgbc.gridwidth = 1;
2231  0 sgbc.gridheight = 1;
2232  0 sgbc.weightx = 1.0;
2233  0 sgbc.weighty = 0.0;
2234  0 sgbc.fill = GridBagConstraints.NONE;
2235  0 suffixPanel.add(suffixTemplateLabel, sgbc);
2236   
2237  0 sgbc.gridx = 1;
2238  0 sgbc.fill = GridBagConstraints.HORIZONTAL;
2239  0 suffixPanel.add(suffixTemplate, sgbc);
2240   
2241    // second row (number of digits spinner)
2242  0 sgbc.gridy = 1;
2243   
2244  0 sgbc.gridx = 0;
2245  0 sgbc.fill = GridBagConstraints.NONE;
2246  0 suffixPanel.add(suffixDigitsLabel, sgbc);
2247   
2248  0 sgbc.gridx = 1;
2249  0 sgbc.fill = GridBagConstraints.HORIZONTAL;
2250  0 suffixPanel.add(suffixDigitsSpinner, sgbc);
2251   
2252    // third row (forward order radio selection)
2253  0 sgbc.gridx = 0;
2254  0 sgbc.gridy = 2;
2255  0 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2256  0 sgbc.fill = GridBagConstraints.HORIZONTAL;
2257  0 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2258   
2259    // fourth row (reverse order radio selection)
2260  0 sgbc.gridy = 3;
2261  0 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2262  0 return suffixPanel;
2263    }
2264   
 
2265  0 toggle private boolean confirmSuffixReverseChange()
2266    {
2267  0 boolean ret = false;
2268  0 String warningMessage = MessageManager
2269    .getString("label.warning_confirm_change_reverse");
2270  0 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2271    warningMessage,
2272    MessageManager.getString("label.change_increment_decrement"),
2273    JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2274   
2275  0 ret = (confirm == JvOptionPane.YES_OPTION);
2276  0 return ret;
2277    }
2278   
 
2279  0 toggle private JPanel initBackupsTabKeepFilesPanel()
2280    {
2281  0 keepfilesPanel.setBorder(
2282    new TitledBorder(MessageManager.getString("label.keep_files")));
2283  0 keepfilesPanel.setLayout(new GridBagLayout());
2284   
2285  0 backupfilesKeepAll.setLabels(
2286    MessageManager.getString("label.keep_all_backup_files"),
2287    MessageManager.getString(
2288    "label.keep_only_this_number_of_backup_files"));
2289  0 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2290    {
 
2291  0 toggle @Override
2292    public void actionPerformed(ActionEvent e)
2293    {
2294  0 backupfilesRevertButtonSetEnabled(true);
2295  0 updateBackupFilesExampleLabel();
2296    }
2297    });
2298  0 backupfilesKeepAll.addActionListener(new ActionListener()
2299    {
 
2300  0 toggle @Override
2301    public void actionPerformed(ActionEvent e)
2302    {
2303  0 backupfilesRevertButtonSetEnabled(true);
2304  0 keepRollMaxOptionsEnabled();
2305  0 updateBackupFilesExampleLabel();
2306    }
2307    });
2308   
2309  0 ChangeListener c = new ChangeListener()
2310    {
 
2311  0 toggle @Override
2312    public void stateChanged(ChangeEvent e)
2313    {
2314  0 backupfilesRevertButtonSetEnabled(true);
2315  0 updateBackupFilesExampleLabel();
2316    }
2317   
2318    };
2319  0 setIntegerSpinner(backupfilesRollMaxSpinner,
2320    BackupFilesPresetEntry.ROLLMAXMIN,
2321    BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2322   
2323  0 backupfilesConfirmDelete.setLabels(
2324    MessageManager.getString("label.always_ask"),
2325    MessageManager.getString("label.auto_delete"));
2326  0 backupfilesConfirmDelete.addActionListener(new ActionListener()
2327    {
 
2328  0 toggle @Override
2329    public void actionPerformed(ActionEvent e)
2330    {
2331  0 backupfilesRevertButtonSetEnabled(true);
2332    }
2333    });
2334    // update the enabled section
2335  0 keepRollMaxOptionsEnabled();
2336   
2337  0 GridBagConstraints kgbc = new GridBagConstraints();
2338   
2339    // first row (template text box)
2340  0 kgbc.anchor = GridBagConstraints.WEST;
2341  0 kgbc.gridx = 0;
2342  0 kgbc.gridy = 0;
2343  0 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2344  0 kgbc.gridheight = 1;
2345  0 kgbc.weightx = 1.0;
2346  0 kgbc.weighty = 0.0;
2347  0 kgbc.fill = GridBagConstraints.HORIZONTAL;
2348  0 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2349   
2350    // second row
2351  0 kgbc.gridy = 1;
2352   
2353  0 kgbc.gridx = 0;
2354  0 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2355  0 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2356   
2357  0 kgbc.gridx = 1;
2358  0 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2359  0 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2360   
2361    // third row (indented)
2362  0 kgbc.gridy = 2;
2363  0 kgbc.insets = new Insets(0, 20, 0, 0);
2364   
2365  0 kgbc.gridx = 0;
2366  0 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2367  0 kgbc.fill = GridBagConstraints.HORIZONTAL;
2368  0 kgbc.weightx = 1.0;
2369   
2370  0 JPanel jp = new JPanel();
2371  0 jp.setLayout(new FlowLayout());
2372  0 oldBackupFilesLabel
2373    .setText(MessageManager
2374    .getString("label.autodelete_old_backup_files"));
2375  0 oldBackupFilesLabel.setFont(LABEL_FONT);
2376  0 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2377  0 jp.add(oldBackupFilesLabel);
2378  0 jp.add(backupfilesConfirmDelete.getTrueButton());
2379  0 jp.add(backupfilesConfirmDelete.getFalseButton());
2380  0 keepfilesPanel.add(jp, kgbc);
2381   
2382  0 return keepfilesPanel;
2383    }
2384   
 
2385  0 toggle protected void updateBackupFilesExampleLabel()
2386    {
2387  0 int exampleindex = 12;
2388  0 String base = MessageManager.getString("label.filename") + ".fa";
2389  0 if (base == null || base.length() == 0)
2390    {
2391  0 base = "file_name.fa";
2392    }
2393   
2394  0 boolean reverse = suffixReverse.isSelected();
2395  0 boolean keepAll = backupfilesKeepAll.isSelected();
2396  0 int rollMax = 4;
2397  0 String suffix = suffixTemplate.getText();
2398  0 int digits = 3;
2399   
2400  0 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2401  0 if (suffix == null || suffix.length() == 0)
2402    {
2403  0 backupfilesExampleLabel
2404    .setText(MessageManager.getString("label.no_backup_files"));
2405  0 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2406  0 return;
2407    }
2408   
2409  0 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2410  0 rollMax = rollMax < 1 ? 1 : rollMax;
2411   
2412  0 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2413    {
2414  0 rollMax = 1;
2415    }
2416   
2417  0 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2418  0 digits = digits < 1 ? 1 : digits;
2419   
2420  0 int lowersurround = 2;
2421  0 int uppersurround = 0;
2422  0 StringBuilder exampleSB = new StringBuilder();
2423  0 boolean firstLine = true;
2424  0 int lineNumber = 0;
2425  0 if (reverse)
2426    {
2427   
2428  0 int min = 1;
2429  0 int max = keepAll ? exampleindex : rollMax;
2430  0 for (int index = min; index <= max; index++)
2431    {
2432  0 if (index == min + lowersurround && index < max - uppersurround - 1)
2433    {
2434  0 exampleSB.append("\n...");
2435  0 lineNumber++;
2436    }
2437  0 else if (index > min + lowersurround && index < max - uppersurround)
2438    {
2439    // nothing
2440    }
2441    else
2442    {
2443  0 if (firstLine)
2444    {
2445  0 firstLine = false;
2446    }
2447    else
2448    {
2449  0 exampleSB.append("\n");
2450  0 lineNumber++;
2451    }
2452  0 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2453    base, suffix, digits));
2454  0 if (min == max)
2455    {
2456    // no extra text needed
2457    }
2458  0 else if (index == min)
2459    {
2460  0 String newest = MessageManager.getString("label.braced_newest");
2461  0 if (newest != null && newest.length() > 0)
2462    {
2463  0 exampleSB.append(" " + newest);
2464    }
2465    }
2466  0 else if (index == max)
2467    {
2468  0 String oldest = MessageManager.getString("label.braced_oldest");
2469  0 if (oldest != null && oldest.length() > 0)
2470    {
2471  0 exampleSB.append(" " + oldest);
2472    }
2473    }
2474    }
2475    }
2476    }
2477    else
2478    {
2479   
2480  0 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2481    : exampleindex - rollMax + 1;
2482  0 int max = exampleindex;
2483   
2484  0 for (int index = min; index <= max; index++)
2485    {
2486   
2487  0 if (index == min + lowersurround && index < max - uppersurround - 1)
2488    {
2489  0 exampleSB.append("\n...");
2490  0 lineNumber++;
2491    }
2492  0 else if (index > min + lowersurround && index < max - uppersurround)
2493    {
2494    // nothing
2495    }
2496    else
2497    {
2498  0 if (firstLine)
2499    {
2500  0 firstLine = false;
2501    }
2502    else
2503    {
2504  0 exampleSB.append("\n");
2505  0 lineNumber++;
2506    }
2507  0 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2508    base, suffix, digits));
2509  0 if (min == max)
2510    {
2511    // no extra text needed
2512    }
2513  0 else if (index == min)
2514    {
2515  0 String oldest = MessageManager.getString("label.braced_oldest");
2516  0 if (oldest != null && oldest.length() > 0)
2517    {
2518  0 exampleSB.append(" " + oldest);
2519    }
2520    }
2521  0 else if (index == max)
2522    {
2523  0 String newest = MessageManager.getString("label.braced_newest");
2524  0 if (newest != null && newest.length() > 0)
2525    {
2526  0 exampleSB.append(" " + newest);
2527    }
2528    }
2529    }
2530    }
2531   
2532    }
2533   
2534    // add some extra empty lines to pad out the example files box. ugh, please tell
2535    // me how to do this better
2536  0 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2537  0 if (remainingLines > 0)
2538    {
2539  0 for (int i = 0; i < remainingLines; i++)
2540    {
2541  0 exampleSB.append("\n ");
2542  0 lineNumber++;
2543    }
2544    }
2545   
2546  0 backupfilesExampleLabel.setText(exampleSB.toString());
2547    }
2548   
 
2549  0 toggle protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2550    boolean useExistingVal, ChangeListener c)
2551    {
2552  0 int i = def;
2553  0 if (useExistingVal)
2554    {
2555  0 try
2556    {
2557  0 i = ((Integer) s.getValue()).intValue();
2558    } catch (Exception e)
2559    {
2560  0 Cache.log.error(
2561    "Exception casting the initial value of s.getValue()");
2562    }
2563    }
2564   
2565  0 setIntegerSpinner(s, min, max, i, c);
2566    }
2567   
 
2568  0 toggle protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2569    ChangeListener c)
2570    {
2571    // integer spinner for number of digits
2572  0 if (def > max)
2573    {
2574  0 max = def;
2575    }
2576  0 if (def < min)
2577    {
2578  0 def = min;
2579    }
2580  0 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2581  0 s.setModel(sModel);
2582   
2583  0 s.addChangeListener(c);
2584   
2585    }
2586   
 
2587  0 toggle protected static int getSpinnerInt(JSpinner s, int def)
2588    {
2589  0 int i = def;
2590  0 try
2591    {
2592  0 s.commitEdit();
2593  0 i = (Integer) s.getValue();
2594    } catch (Exception e)
2595    {
2596  0 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2597    }
2598  0 return i;
2599    }
2600   
 
2601  0 toggle private void keepRollMaxOptionsEnabled()
2602    {
2603  0 boolean enabled = backupfilesKeepAll.isEnabled()
2604    && !backupfilesKeepAll.isSelected();
2605  0 oldBackupFilesLabel.setEnabled(enabled);
2606  0 backupfilesRollMaxSpinner.setEnabled(enabled);
2607  0 backupfilesConfirmDelete.setEnabled(enabled);
2608    }
2609   
 
2610  0 toggle private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2611    {
2612  0 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2613    && customiseCheckbox.isSelected()
2614    && suffixTemplate.getText()
2615    .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2616  0 keepfilesPanel.setEnabled(enabled);
2617  0 backupfilesKeepAll.setEnabled(enabled);
2618  0 oldBackupFilesLabel.setEnabled(enabled);
2619  0 keepRollMaxOptionsEnabled();
2620    }
2621   
 
2622  0 toggle private void backupfilesSuffixTemplateDigitsSetEnabled()
2623    {
2624  0 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2625    .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2626  0 suffixDigitsLabel.setEnabled(enabled);
2627  0 suffixDigitsSpinner.setEnabled(enabled);
2628  0 suffixReverse.setEnabled(enabled);
2629    }
2630   
 
2631  0 toggle private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2632    {
2633  0 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2634    && customiseCheckbox.isSelected();
2635  0 suffixPanel.setEnabled(enabled);
2636  0 suffixTemplateLabel.setEnabled(enabled);
2637  0 suffixTemplate.setEnabled(enabled);
2638  0 backupfilesSuffixTemplateDigitsSetEnabled();
2639    }
2640   
 
2641  0 toggle private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2642    {
2643  0 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2644    && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2645  0 revertButton.setEnabled(enabled);
2646    }
2647   
 
2648  0 toggle private boolean backupfilesCustomChanged()
2649    {
2650  0 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2651    .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2652  0 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2653  0 return !custom.equals(current);
2654    }
2655   
 
2656  0 toggle protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2657    {
2658  0 String suffix = suffixTemplate.getText();
2659  0 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2660  0 boolean reverse = suffixReverse.isSelected();
2661  0 boolean keepAll = backupfilesKeepAll.isSelected();
2662  0 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2663  0 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2664   
2665  0 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2666    reverse, keepAll, rollMax, confirmDelete);
2667   
2668  0 return bfpe;
2669    }
2670   
 
2671  0 toggle protected void backupfilesCustomOptionsSetEnabled()
2672    {
2673  0 boolean enabled = customiseCheckbox.isSelected();
2674   
2675  0 backupfilesRevertButtonSetEnabled(enabled);
2676  0 backupfilesSuffixTemplateSetEnabled(enabled);
2677  0 backupfilesKeepAllSetEnabled(enabled);
2678    }
2679   
 
2680  0 toggle private void backupfilesSummarySetEnabled()
2681    {
2682  0 boolean enabled = enableBackupFiles.isSelected();
2683  0 backupfilesExampleLabel.setEnabled(enabled);
2684  0 exampleFilesPanel.setEnabled(enabled);
2685    }
2686   
 
2687  0 toggle private void backupfilesPresetsSetEnabled()
2688    {
2689  0 boolean enabled = enableBackupFiles.isSelected();
2690  0 presetsPanel.setEnabled(enabled);
2691  0 presetsComboLabel.setEnabled(enabled);
2692  0 backupfilesPresetsCombo.setEnabled(enabled);
2693  0 customiseCheckbox.setEnabled(enabled);
2694  0 revertButton.setEnabled(enabled);
2695    }
2696   
 
2697  0 toggle protected void backupsOptionsSetEnabled()
2698    {
2699  0 backupfilesPresetsSetEnabled();
2700  0 backupfilesSummarySetEnabled();
2701  0 backupfilesCustomOptionsSetEnabled();
2702    }
2703   
 
2704  0 toggle protected void backupsSetOptions(String suffix, int digits,
2705    boolean reverse, boolean keepAll, int rollMax,
2706    boolean confirmDelete)
2707    {
2708  0 suffixTemplate.setText(suffix);
2709  0 suffixDigitsSpinner.setValue(digits);
2710  0 suffixReverse.setSelected(reverse);
2711  0 backupfilesKeepAll.setSelected(keepAll);
2712  0 backupfilesRollMaxSpinner.setValue(rollMax);
2713  0 backupfilesConfirmDelete.setSelected(confirmDelete);
2714    }
2715   
 
2716  0 toggle protected void backupsSetOptions(BackupFilesPresetEntry p)
2717    {
2718  0 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2719    p.confirmDelete);
2720    }
2721   
 
2722  0 toggle protected void autoIdWidth_actionPerformed()
2723    {
2724    // TODO Auto-generated method stub
2725   
2726    }
2727   
 
2728  0 toggle protected void userIdWidth_actionPerformed()
2729    {
2730    // TODO Auto-generated method stub
2731   
2732    }
2733   
 
2734  0 toggle protected void maxColour_actionPerformed(JPanel panel)
2735    {
2736    }
2737   
 
2738  0 toggle protected void minColour_actionPerformed(JPanel panel)
2739    {
2740    }
2741   
 
2742  0 toggle protected void gapColour_actionPerformed(JPanel panel)
2743    {
2744    }
2745   
 
2746  0 toggle protected void hiddenColour_actionPerformed(JPanel panel)
2747    {
2748    }
2749   
 
2750  0 toggle protected void showunconserved_actionPerformed(ActionEvent e)
2751    {
2752    // TODO Auto-generated method stub
2753   
2754    }
2755   
 
2756  0 toggle protected void useLegacyGaps_actionPerformed(ActionEvent e)
2757    {
2758    }
2759   
 
2760  0 toggle protected void resetOvDefaults_actionPerformed(ActionEvent e)
2761    {
2762    }
2763   
2764    /**
2765    * DOCUMENT ME!
2766    *
2767    * @param e
2768    * DOCUMENT ME!
2769    */
 
2770  0 toggle public void ok_actionPerformed(ActionEvent e)
2771    {
2772    }
2773   
2774    /**
2775    * DOCUMENT ME!
2776    *
2777    * @param e
2778    * DOCUMENT ME!
2779    */
 
2780  0 toggle public void cancel_actionPerformed(ActionEvent e)
2781    {
2782    }
2783   
2784    /**
2785    * DOCUMENT ME!
2786    *
2787    * @param e
2788    * DOCUMENT ME!
2789    */
 
2790  0 toggle public void annotations_actionPerformed(ActionEvent e)
2791    {
2792    }
2793   
2794    /**
2795    * DOCUMENT ME!
2796    */
 
2797  0 toggle public void startupFileTextfield_mouseClicked()
2798    {
2799    }
2800   
 
2801  0 toggle public void newLink_actionPerformed(ActionEvent e)
2802    {
2803   
2804    }
2805   
 
2806  0 toggle public void editLink_actionPerformed(ActionEvent e)
2807    {
2808   
2809    }
2810   
 
2811  0 toggle public void deleteLink_actionPerformed(ActionEvent e)
2812    {
2813   
2814    }
2815   
 
2816  0 toggle public void defaultBrowser_mouseClicked(MouseEvent e)
2817    {
2818   
2819    }
2820   
 
2821  0 toggle public void linkURLList_keyTyped(KeyEvent e)
2822    {
2823   
2824    }
2825   
 
2826  0 toggle public void useProxy_actionPerformed()
2827    {
2828  0 boolean enabled = useProxy.isSelected();
2829  0 portLabel.setEnabled(enabled);
2830  0 serverLabel.setEnabled(enabled);
2831  0 proxyServerTB.setEnabled(enabled);
2832  0 proxyPortTB.setEnabled(enabled);
2833    }
2834   
2835    /**
2836    * Customer renderer for JTable: supports column of radio buttons
2837    */
 
2838    public class RadioButtonRenderer extends JRadioButton
2839    implements TableCellRenderer
2840    {
 
2841  0 toggle public RadioButtonRenderer()
2842    {
2843  0 setHorizontalAlignment(CENTER);
2844  0 setToolTipText(MessageManager.getString("label.urltooltip"));
2845    }
2846   
 
2847  0 toggle @Override
2848    public Component getTableCellRendererComponent(JTable table,
2849    Object value, boolean isSelected, boolean hasFocus, int row,
2850    int column)
2851    {
2852  0 setSelected((boolean) value);
2853   
2854    // set colours to match rest of table
2855  0 if (isSelected)
2856    {
2857  0 setBackground(table.getSelectionBackground());
2858  0 setForeground(table.getSelectionForeground());
2859    }
2860    else
2861    {
2862  0 setBackground(table.getBackground());
2863  0 setForeground(table.getForeground());
2864    }
2865  0 return this;
2866    }
2867    }
2868   
2869    /**
2870    * Customer cell editor for JTable: supports column of radio buttons in
2871    * conjunction with renderer
2872    */
 
2873    public class RadioButtonEditor extends AbstractCellEditor
2874    implements TableCellEditor
2875    {
2876    private JRadioButton button = new JRadioButton();
2877   
 
2878  0 toggle public RadioButtonEditor()
2879    {
2880  0 button.setHorizontalAlignment(SwingConstants.CENTER);
2881  0 this.button.addActionListener(new ActionListener()
2882    {
 
2883  0 toggle @Override
2884    public void actionPerformed(ActionEvent e)
2885    {
2886  0 fireEditingStopped();
2887    }
2888    });
2889    }
2890   
 
2891  0 toggle @Override
2892    public Component getTableCellEditorComponent(JTable table, Object value,
2893    boolean isSelected, int row, int column)
2894    {
2895  0 button.setSelected((boolean) value);
2896  0 return button;
2897    }
2898   
 
2899  0 toggle @Override
2900    public Object getCellEditorValue()
2901    {
2902  0 return button.isSelected();
2903    }
2904   
2905    }
2906    }
2907