Clover icon

Coverage Report

  1. Project Clover database Thu Jun 4 2026 15:31:54 BST
  2. Package jalview.jbgui

File GPreferences.java

 

Coverage histogram

../../img/srcFileCovDistChart8.png
21% of files have more coverage

Code metrics

154
1,677
149
4
3,846
2,947
264
0.16
11.26
37.25
1.77

Classes

Class Line # Actions
GPreferences 109 1,662 257
0.7828308378.3%
GPreferences.TabRef 573 0 0
-1.0 -
GPreferences.RadioButtonRenderer 3742 9 3
0.769230876.9%
GPreferences.RadioButtonEditor 3777 6 4
0.330%
 

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 jalview.bin.Cache;
24    import jalview.bin.Console;
25    import jalview.bin.MemorySetting;
26    import jalview.fts.core.FTSDataColumnPreferences;
27    import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
28    import jalview.fts.service.pdb.PDBFTSRestClient;
29    import jalview.gui.Desktop;
30    import jalview.gui.JalviewBooleanRadioButtons;
31    import jalview.gui.JvOptionPane;
32    import jalview.gui.JvSwingUtils;
33    import jalview.gui.StructureViewer.ViewerType;
34    import jalview.io.BackupFilenameParts;
35    import jalview.io.BackupFiles;
36    import jalview.io.BackupFilesPresetEntry;
37    import jalview.io.IntKeyStringValueEntry;
38    import jalview.util.MessageManager;
39    import jalview.util.Platform;
40    import jalview.util.StringUtils;
41   
42    import java.awt.BorderLayout;
43    import java.awt.Color;
44    import java.awt.Component;
45    import java.awt.Dimension;
46    import java.awt.FlowLayout;
47    import java.awt.Font;
48    import java.awt.GridBagConstraints;
49    import java.awt.GridBagLayout;
50    import java.awt.GridLayout;
51    import java.awt.Insets;
52    import java.awt.Rectangle;
53    import java.awt.event.ActionEvent;
54    import java.awt.event.ActionListener;
55    import java.awt.event.FocusEvent;
56    import java.awt.event.KeyEvent;
57    import java.awt.event.KeyListener;
58    import java.awt.event.MouseAdapter;
59    import java.awt.event.MouseEvent;
60    import java.util.Arrays;
61    import java.util.EnumSet;
62    import java.util.List;
63   
64    import javax.swing.AbstractButton;
65    import javax.swing.AbstractCellEditor;
66    import javax.swing.BorderFactory;
67    import javax.swing.BoxLayout;
68    import javax.swing.ButtonGroup;
69    import javax.swing.DefaultListCellRenderer;
70    import javax.swing.JButton;
71    import javax.swing.JCheckBox;
72    import javax.swing.JComboBox;
73    import javax.swing.JComponent;
74    import javax.swing.JFileChooser;
75    import javax.swing.JLabel;
76    import javax.swing.JPanel;
77    import javax.swing.JPasswordField;
78    import javax.swing.JRadioButton;
79    import javax.swing.JScrollPane;
80    import javax.swing.JSlider;
81    import javax.swing.JSpinner;
82    import javax.swing.JTabbedPane;
83    import javax.swing.JTable;
84    import javax.swing.JTextArea;
85    import javax.swing.JTextField;
86    import javax.swing.ListSelectionModel;
87    import javax.swing.SpinnerModel;
88    import javax.swing.SpinnerNumberModel;
89    import javax.swing.SwingConstants;
90    import javax.swing.border.Border;
91    import javax.swing.border.EmptyBorder;
92    import javax.swing.border.EtchedBorder;
93    import javax.swing.border.TitledBorder;
94    import javax.swing.event.ChangeEvent;
95    import javax.swing.event.ChangeListener;
96    import javax.swing.event.DocumentEvent;
97    import javax.swing.event.DocumentListener;
98    import javax.swing.table.TableCellEditor;
99    import javax.swing.table.TableCellRenderer;
100   
101    import net.miginfocom.swing.MigLayout;
102   
103    /**
104    * Base class for the Preferences panel.
105    *
106    * @author $author$
107    * @version $Revision$
108    */
 
109    public class GPreferences extends JPanel
110    {
111    private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
112   
113    private static final Font LABEL_FONT_ITALIC = JvSwingUtils
114    .getLabelFont(false, true);
115   
116    private static final Font LABEL_FONT_BOLD = JvSwingUtils
117    .getLabelFont(true, false);
118   
119    /*
120    * Visual tab components
121    */
122    protected JCheckBox fullScreen = new JCheckBox();
123   
124    protected JCheckBox openoverv = new JCheckBox();
125   
126    protected JCheckBox seqLimit = new JCheckBox();
127   
128    protected JCheckBox rightAlign = new JCheckBox();
129   
130    protected JComboBox<String> fontSizeCB = new JComboBox<>();
131   
132    protected JComboBox<String> fontStyleCB = new JComboBox<>();
133   
134    protected JComboBox<String> fontNameCB = new JComboBox<>();
135   
136    protected JCheckBox showOccupancy = new JCheckBox();
137   
138    protected JCheckBox showUnconserved = new JCheckBox();
139   
140    protected JCheckBox idItalics = new JCheckBox();
141   
142    protected JCheckBox smoothFont = new JCheckBox();
143   
144    protected JCheckBox scaleProteinToCdna = new JCheckBox();
145   
146    protected JComboBox<String> gapSymbolCB = new JComboBox<>();
147   
148    protected JCheckBox wrap = new JCheckBox();
149   
150    protected JComboBox<String> sortby = new JComboBox<>();
151   
152    protected JComboBox<String> sortAnnBy = new JComboBox<>();
153   
154    protected JComboBox<String> sortAutocalc = new JComboBox<>();
155   
156    protected JCheckBox startupCheckbox = new JCheckBox();
157   
158    protected JTextField startupFileTextfield = new JTextField();
159   
160    // below are in the 'second column'
161    protected JCheckBox annotations = new JCheckBox();
162   
163    protected JCheckBox quality = new JCheckBox();
164   
165    protected JCheckBox conservation = new JCheckBox();
166   
167    protected JCheckBox identity = new JCheckBox();
168   
169    protected JCheckBox ssConsensus = new JCheckBox();
170   
171    protected JCheckBox showGroupConsensus = new JCheckBox();
172   
173    protected JCheckBox showGroupConservation = new JCheckBox();
174   
175    protected JCheckBox showConsensHistogram = new JCheckBox();
176   
177    protected JCheckBox showConsensLogo = new JCheckBox();
178   
179    protected JCheckBox showInformationHistogram = new JCheckBox();
180   
181    protected JCheckBox showHMMLogo = new JCheckBox();
182    protected JCheckBox showDbRefTooltip = new JCheckBox();
183   
184    protected JCheckBox showNpTooltip = new JCheckBox();
185   
186    /*
187    * Structure tab and components
188    */
189    protected JPanel structureTab;
190   
191    protected JCheckBox structFromPdb = new JCheckBox();
192   
193    protected JCheckBox addSecondaryStructure = new JCheckBox();
194   
195    protected JCheckBox addTempFactor = new JCheckBox();
196   
197    protected JComboBox<String> structViewer = new JComboBox<>();
198   
199    protected JLabel structureViewerPathLabel;
200   
201    protected JTextField structureViewerPath = new JTextField();
202   
203    protected ButtonGroup mappingMethod = new ButtonGroup();
204   
205    protected JRadioButton siftsMapping = new JRadioButton();
206   
207    protected JRadioButton nwMapping = new JRadioButton();
208   
209    /*
210    * Colours tab components
211    */
212    protected JPanel minColour = new JPanel();
213   
214    protected JPanel maxColour = new JPanel();
215   
216    protected JComboBox<String> protColour = new JComboBox<>();
217   
218    protected JComboBox<String> nucColour = new JComboBox<>();
219   
220    /*
221    * Overview tab components
222    */
223    protected JPanel gapColour = new JPanel();
224   
225    protected JPanel hiddenColour = new JPanel();
226   
227    protected JCheckBox useLegacyGap;
228   
229    protected JCheckBox showHiddenAtStart;
230   
231    protected JLabel gapLabel;
232   
233    /*
234    * Connections tab components
235    */
236    protected JPanel connectTab;
237   
238    protected JTable linkUrlTable = new JTable();
239   
240    protected JButton editLink = new JButton();
241   
242    protected JButton deleteLink = new JButton();
243   
244    protected JTextField filterTB = new JTextField();
245   
246    protected JButton doReset = new JButton();
247   
248    protected JButton userOnly = new JButton();
249   
250    protected JLabel httpLabel = new JLabel();
251   
252    protected JLabel httpsLabel = new JLabel();
253   
254    protected JLabel portLabel = new JLabel();
255   
256    protected JLabel serverLabel = new JLabel();
257   
258    protected JLabel portLabel2 = new JLabel();
259   
260    protected JLabel serverLabel2 = new JLabel();
261   
262    protected JLabel proxyAuthUsernameLabel = new JLabel();
263   
264    protected JLabel proxyAuthPasswordLabel = new JLabel();
265   
266    protected JLabel passwordNotStoredLabel = new JLabel();
267   
268    protected JTextField proxyServerHttpTB = new JTextField();
269   
270    protected JTextField proxyPortHttpTB = new JTextField();
271   
272    protected JTextField proxyServerHttpsTB = new JTextField();
273   
274    protected JTextField proxyPortHttpsTB = new JTextField();
275   
276    protected JCheckBox proxyAuth = new JCheckBox();
277   
278    protected JTextField proxyAuthUsernameTB = new JTextField();
279   
280    protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
281   
282    protected JTextField defaultBrowser = new JTextField();
283   
284    protected ButtonGroup proxyType = new ButtonGroup();
285   
286    protected JRadioButton noProxy = new JRadioButton();
287   
288    protected JRadioButton systemProxy = new JRadioButton();
289   
290    protected JRadioButton customProxy = new JRadioButton();
291   
292    protected JButton applyProxyButton = new JButton();
293   
294    protected JCheckBox usagestats = new JCheckBox();
295   
296    protected JCheckBox questionnaire = new JCheckBox();
297   
298    protected JCheckBox versioncheck = new JCheckBox();
299   
300    /*
301    * Output tab components
302    */
303    protected JComboBox<Object> epsRendering = new JComboBox<>();
304   
305    protected JComboBox<Object> htmlRendering = new JComboBox<>();
306   
307    protected JComboBox<Object> svgRendering = new JComboBox<>();
308   
309    protected JLabel userIdWidthlabel = new JLabel();
310   
311    protected JCheckBox autoIdWidth = new JCheckBox();
312   
313    protected JTextField userIdWidth = new JTextField();
314   
315    protected JCheckBox blcjv = new JCheckBox();
316   
317    protected JCheckBox pileupjv = new JCheckBox();
318   
319    protected JCheckBox clustaljv = new JCheckBox();
320   
321    protected JCheckBox msfjv = new JCheckBox();
322   
323    protected JCheckBox fastajv = new JCheckBox();
324   
325    protected JCheckBox pfamjv = new JCheckBox();
326   
327    protected JCheckBox pirjv = new JCheckBox();
328   
329    protected JCheckBox modellerOutput = new JCheckBox();
330   
331    protected JCheckBox embbedBioJSON = new JCheckBox();
332   
333    /*
334    * Editing tab components
335    */
336    protected JCheckBox autoCalculateConsCheck = new JCheckBox();
337   
338    protected JCheckBox padGaps = new JCheckBox();
339   
340    protected JCheckBox sortByTree = new JCheckBox();
341   
342    /*
343    * hmmer tab and components
344    */
345    protected JPanel hmmerTab;
346   
347    protected JCheckBox hmmrTrimTermini;
348   
349    protected AbstractButton hmmerBackgroundUniprot;
350   
351    protected AbstractButton hmmerBackgroundAlignment;
352   
353    protected JTextField hmmerSequenceCount;
354   
355    protected JTextField hmmerPath;
356   
357    protected JTextField cygwinPath;
358   
359    /*
360    * Web Services tab
361    */
362    protected JPanel wsTab = new JPanel();
363   
364    protected JPanel slivkaTab = new JPanel();
365    /*
366    * Backups tab components
367    * a lot of these are member variables instead of local variables only so that they
368    * can be enabled/disabled easily in one go
369    */
370   
371    protected JCheckBox enableBackupFiles = new JCheckBox();
372   
373    protected JPanel presetsPanel = new JPanel();
374   
375    protected JLabel presetsComboLabel = new JLabel();
376   
377    protected JCheckBox customiseCheckbox = new JCheckBox();
378   
379    protected JButton revertButton = new JButton();
380   
381    protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
382   
383    private int backupfilesPresetsComboLastSelected = 0;
384   
385    protected JPanel suffixPanel = new JPanel();
386   
387    protected JPanel keepfilesPanel = new JPanel();
388   
389    protected JPanel exampleFilesPanel = new JPanel();
390   
391    protected JTextField suffixTemplate = new JTextField(null, 8);
392   
393    protected JLabel suffixTemplateLabel = new JLabel();
394   
395    protected JLabel suffixDigitsLabel = new JLabel();
396   
397    protected JSpinner suffixDigitsSpinner = new JSpinner();
398   
399    protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
400   
401    protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
402   
403    public JSpinner backupfilesRollMaxSpinner = new JSpinner();
404   
405    protected JLabel oldBackupFilesLabel = new JLabel();
406   
407    protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
408   
409    protected JTextArea backupfilesExampleLabel = new JTextArea();
410   
411    private final JTabbedPane tabbedPane = new JTabbedPane();
412   
413    private JLabel messageLabel = new JLabel("", JLabel.CENTER);
414   
415    /*
416    * Startup tab components
417    */
418   
419    protected JCheckBox customiseMemorySetting = new JCheckBox();
420   
421    protected JLabel exampleMemoryLabel = new JLabel();
422   
423    protected JTextArea exampleMemoryMessageTextArea = new JTextArea();
424   
425    protected JLabel maxMemoryLabel = new JLabel();
426   
427    protected JLabel jvmMemoryPercentLabel = new JLabel();
428   
429    protected JSlider jvmMemoryPercentSlider = new JSlider();
430   
431    protected JLabel jvmMemoryPercentDisplay = new JLabel();
432   
433    protected JLabel jvmMemoryMaxLabel = new JLabel();
434   
435    protected JTextField jvmMemoryMaxTextField = new JTextField(null, 8);
436   
437    protected JComboBox<Object> lafCombo = new JComboBox<>();
438    /**
439    * Creates a new GPreferences object.
440    */
 
441  13 toggle public GPreferences()
442    {
443  13 try
444    {
445  13 jbInit();
446    } catch (Exception ex)
447    {
448  0 ex.printStackTrace();
449    }
450    }
451   
452    /**
453    * Construct the panel and its tabbed sub-panels.
454    *
455    * @throws Exception
456    */
 
457  13 toggle private void jbInit() throws Exception
458    {
459    // final JTabbedPane tabbedPane = new JTabbedPane();
460  13 this.setLayout(new BorderLayout());
461   
462    // message label at top
463  13 this.add(messageLabel, BorderLayout.NORTH);
464   
465  13 JPanel okCancelPanel = initOkCancelPanel();
466  13 this.add(tabbedPane, BorderLayout.CENTER);
467  13 this.add(okCancelPanel, BorderLayout.SOUTH);
468   
469  13 tabbedPane.add(initVisualTab(),
470    MessageManager.getString("label.visual"));
471   
472  13 tabbedPane.add(initColoursTab(),
473    MessageManager.getString("label.colours"));
474   
475  13 tabbedPane.add(initOverviewTab(),
476    MessageManager.getString("label.overview"));
477   
478  13 tabbedPane.add(initStructureTab(),
479    MessageManager.getString("label.structure"));
480   
481  13 tabbedPane.add(initConnectionsTab(),
482    MessageManager.getString("label.connections"));
483   
484  13 if (!Platform.isJS())
485    {
486  13 tabbedPane.add(initBackupsTab(),
487    MessageManager.getString("label.backups"));
488    }
489   
490  13 tabbedPane.add(initLinksTab(),
491    MessageManager.getString("label.urllinks"));
492   
493  13 tabbedPane.add(initOutputTab(),
494    MessageManager.getString("label.output"));
495   
496  13 tabbedPane.add(initEditingTab(),
497    MessageManager.getString("label.editing"));
498   
499    /*
500    * See WsPreferences for the real work of configuring this tab.
501    */
502  13 if (!Platform.isJS())
503    {
504  13 tabbedPane.add(initHMMERTab(), MessageManager.getString("label.hmmer"));
505  13 tabbedPane.add(initStartupTab(),
506    MessageManager.getString("label.startup"));
507  13 wsTab.setLayout(new BorderLayout());
508  13 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
509    }
510   
511  13 slivkaTab.setLayout(new BorderLayout());
512  13 tabbedPane.add(slivkaTab, "Slivka Services");
513   
514    /*
515    * Handler to validate a tab before leaving it - currently only for
516    * Structure.
517    * Adding a clearMessage() so messages are cleared when changing tabs.
518    */
519  13 tabbedPane.addChangeListener(new ChangeListener()
520    {
521    private Component lastTab;
522   
 
523  0 toggle @Override
524    public void stateChanged(ChangeEvent e)
525    {
526  0 if (lastTab == structureTab
527    && tabbedPane.getSelectedComponent() != structureTab)
528    {
529  0 if (!validateStructure())
530    {
531  0 tabbedPane.setSelectedComponent(structureTab);
532  0 return;
533    }
534    }
535  0 lastTab = tabbedPane.getSelectedComponent();
536   
537  0 clearMessage();
538    }
539   
540    });
541    }
542   
 
543  0 toggle public void setMessage(String message)
544    {
545  0 if (message != null)
546    {
547  0 messageLabel.setText(message);
548  0 messageLabel.setFont(LABEL_FONT_BOLD);
549  0 messageLabel.setForeground(Color.RED.darker());
550  0 messageLabel.revalidate();
551  0 messageLabel.repaint();
552    }
553    // note message not cleared if message is null. call clearMessage()
554    // directly.
555  0 this.revalidate();
556  0 this.repaint();
557    }
558   
 
559  0 toggle public void clearMessage()
560    {
561    // only repaint if message exists
562  0 if (messageLabel.getText() != null
563    && messageLabel.getText().length() > 0)
564    {
565  0 messageLabel.setText("");
566  0 messageLabel.revalidate();
567  0 messageLabel.repaint();
568  0 this.revalidate();
569  0 this.repaint();
570    }
571    }
572   
 
573    public static enum TabRef
574    {
575    CONNECTIONS_TAB, STRUCTURE_TAB
576    };
577   
 
578  0 toggle public void selectTab(TabRef selectTab)
579    {
580    // select a given tab - currently only for Connections
581  0 switch (selectTab)
582    {
583  0 case CONNECTIONS_TAB:
584  0 tabbedPane.setSelectedComponent(connectTab);
585  0 break;
586  0 case STRUCTURE_TAB:
587  0 tabbedPane.setSelectedComponent(structureTab);
588  0 break;
589  0 default:
590    }
591    }
592   
593    /**
594    * Initialises the Editing tabbed panel.
595    *
596    * @return
597    */
 
598  13 toggle private JPanel initEditingTab()
599    {
600  13 JPanel editingTab = new JPanel();
601  13 editingTab.setLayout(null);
602  13 autoCalculateConsCheck.setFont(LABEL_FONT);
603  13 autoCalculateConsCheck.setText(
604    MessageManager.getString("label.autocalculate_consensus"));
605  13 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
606  13 padGaps.setFont(LABEL_FONT);
607  13 padGaps.setText(
608    MessageManager.getString("label.pad_gaps_when_editing"));
609  13 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
610  13 sortByTree.setFont(LABEL_FONT);
611  13 sortByTree
612    .setText(MessageManager.getString("label.sort_with_new_tree"));
613  13 sortByTree.setToolTipText(MessageManager.getString(
614    "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
615  13 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
616  13 editingTab.add(autoCalculateConsCheck);
617  13 editingTab.add(padGaps);
618  13 editingTab.add(sortByTree);
619  13 return editingTab;
620    }
621   
622    /**
623    * Initialises the hmmer tabbed panel
624    *
625    * @return
626    */
 
627  13 toggle private JPanel initHMMERTab()
628    {
629  13 hmmerTab = new JPanel();
630  13 hmmerTab.setLayout(new BoxLayout(hmmerTab, BoxLayout.Y_AXIS));
631  13 hmmerTab.setLayout(new MigLayout("flowy"));
632   
633    /*
634    * path to hmmer binaries folder
635    */
636  13 JPanel installationPanel = new JPanel(new MigLayout("flowy"));
637    // new FlowLayout(FlowLayout.LEFT));
638  13 JvSwingUtils.createTitledBorder(installationPanel,
639    MessageManager.getString("label.installation"), true);
640  13 hmmerTab.add(installationPanel);
641  13 JLabel hmmerLocation = new JLabel(
642    MessageManager.getString("label.hmmer_location"));
643  13 hmmerLocation.setFont(LABEL_FONT);
644  13 final int pathFieldLength = 40;
645  13 hmmerPath = new JTextField(pathFieldLength);
646  13 hmmerPath.addMouseListener(new MouseAdapter()
647    {
 
648  0 toggle @Override
649    public void mouseClicked(MouseEvent e)
650    {
651  0 if (e.getClickCount() == 2)
652    {
653  0 String chosen = openFileChooser(true);
654  0 if (chosen != null)
655    {
656  0 hmmerPath.setText(chosen);
657  0 validateHmmerPath();
658    }
659    }
660    }
661    });
662  13 installationPanel.add(hmmerLocation);
663  13 installationPanel.add(hmmerPath);
664   
665    /*
666    * path to Cygwin binaries folder (for Windows)
667    */
668  13 if (Platform.isWindowsAndNotJS())
669    {
670  0 JLabel cygwinLocation = new JLabel(
671    MessageManager.getString("label.cygwin_location"));
672  0 cygwinLocation.setFont(LABEL_FONT);
673  0 cygwinPath = new JTextField(pathFieldLength);
674  0 cygwinPath.addMouseListener(new MouseAdapter()
675    {
 
676  0 toggle @Override
677    public void mouseClicked(MouseEvent e)
678    {
679  0 if (e.getClickCount() == 2)
680    {
681  0 String chosen = openFileChooser(true);
682  0 if (chosen != null)
683    {
684  0 cygwinPath.setText(chosen);
685  0 validateCygwinPath();
686    }
687    }
688    }
689    });
690  0 installationPanel.add(cygwinLocation);
691  0 installationPanel.add(cygwinPath);
692    }
693   
694    /*
695    * preferences for hmmalign
696    */
697  13 JPanel alignOptionsPanel = new JPanel(new MigLayout());
698    // new FlowLayout(FlowLayout.LEFT));
699  13 JvSwingUtils.createTitledBorder(alignOptionsPanel,
700    MessageManager.getString("label.hmmalign_options"), true);
701  13 hmmerTab.add(alignOptionsPanel);
702  13 hmmrTrimTermini = new JCheckBox();
703  13 hmmrTrimTermini.setFont(LABEL_FONT);
704  13 hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
705  13 alignOptionsPanel.add(hmmrTrimTermini);
706   
707    /*
708    * preferences for hmmsearch
709    */
710  13 JPanel searchOptions = new JPanel(new MigLayout());
711    // FlowLayout(FlowLayout.LEFT));
712  13 JvSwingUtils.createTitledBorder(searchOptions,
713    MessageManager.getString("label.hmmsearch_options"), true);
714  13 hmmerTab.add(searchOptions);
715  13 JLabel sequencesToKeep = new JLabel(
716    MessageManager.getString("label.no_of_sequences"));
717  13 sequencesToKeep.setFont(LABEL_FONT);
718  13 searchOptions.add(sequencesToKeep);
719  13 hmmerSequenceCount = new JTextField(5);
720  13 searchOptions.add(hmmerSequenceCount);
721   
722    /*
723    * preferences for Information Content annotation
724    */
725    // JPanel dummy = new JPanel(new FlowLayout(FlowLayout.LEFT));
726  13 JPanel annotationOptions = new JPanel(new MigLayout("left"));
727  13 JvSwingUtils.createTitledBorder(annotationOptions,
728    MessageManager.getString("label.information_annotation"), true);
729    // dummy.add(annotationOptions);
730  13 hmmerTab.add(annotationOptions);
731  13 ButtonGroup backgroundOptions = new ButtonGroup();
732  13 hmmerBackgroundUniprot = new JRadioButton(
733    MessageManager.getString("label.freq_uniprot"));
734  13 hmmerBackgroundUniprot.setFont(LABEL_FONT);
735  13 hmmerBackgroundAlignment = new JRadioButton(
736    MessageManager.getString("label.freq_alignment"));
737  13 hmmerBackgroundAlignment.setFont(LABEL_FONT);
738  13 backgroundOptions.add(hmmerBackgroundUniprot);
739  13 backgroundOptions.add(hmmerBackgroundAlignment);
740  13 backgroundOptions.setSelected(hmmerBackgroundUniprot.getModel(), true);
741    // disable buttons for now as annotation only uses Uniprot background
742  13 hmmerBackgroundAlignment.setEnabled(false);
743  13 hmmerBackgroundUniprot.setEnabled(false);
744  13 annotationOptions.add(hmmerBackgroundUniprot, "wrap");
745  13 annotationOptions.add(hmmerBackgroundAlignment);
746   
747  13 return hmmerTab;
748    }
749   
750    /**
751    * Initialises the Output tabbed panel.
752    *
753    * @return
754    */
 
755  13 toggle private JPanel initOutputTab()
756    {
757  13 JPanel outputTab = new JPanel();
758  13 outputTab.setLayout(null);
759   
760  13 JLabel epsLabel = new JLabel(
761    MessageManager.formatMessage("label.rendering_style", "EPS"));
762  13 epsLabel.setFont(LABEL_FONT);
763  13 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
764  13 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
765  13 epsRendering.setFont(LABEL_FONT);
766  13 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
767  13 JLabel htmlLabel = new JLabel(
768    MessageManager.formatMessage("label.rendering_style", "HTML"));
769  13 htmlLabel.setFont(LABEL_FONT);
770  13 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
771  13 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
772  13 htmlRendering.setFont(LABEL_FONT);
773  13 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
774  13 JLabel svgLabel = new JLabel(
775    MessageManager.formatMessage("label.rendering_style", "SVG"));
776  13 svgLabel.setFont(LABEL_FONT);
777  13 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
778  13 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
779  13 svgRendering.setFont(LABEL_FONT);
780  13 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
781   
782  13 JLabel jLabel1 = new JLabel();
783  13 jLabel1.setFont(LABEL_FONT);
784  13 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
785  13 jLabel1.setText(MessageManager.getString("label.append_start_end"));
786  13 jLabel1.setFont(LABEL_FONT);
787   
788  13 fastajv.setFont(LABEL_FONT);
789  13 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
790  13 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
791  13 blcjv.setText(MessageManager.getString("label.blc") + " ");
792  13 fastajv.setText(MessageManager.getString("label.fasta") + " ");
793  13 msfjv.setText(MessageManager.getString("label.msf") + " ");
794  13 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
795  13 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
796  13 msfjv.setFont(LABEL_FONT);
797  13 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
798  13 pirjv.setText(MessageManager.getString("label.pir") + " ");
799  13 JPanel jPanel11 = new JPanel();
800  13 jPanel11.setFont(LABEL_FONT);
801  13 TitledBorder titledBorder2 = new TitledBorder(
802    MessageManager.getString("label.file_output"));
803  13 jPanel11.setBorder(titledBorder2);
804  13 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
805  13 GridLayout gridLayout3 = new GridLayout();
806  13 jPanel11.setLayout(gridLayout3);
807  13 gridLayout3.setRows(8);
808  13 blcjv.setFont(LABEL_FONT);
809  13 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
810  13 clustaljv.setFont(LABEL_FONT);
811  13 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
812  13 pfamjv.setFont(LABEL_FONT);
813  13 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
814  13 pileupjv.setFont(LABEL_FONT);
815  13 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
816  13 pirjv.setFont(LABEL_FONT);
817  13 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
818  13 autoIdWidth.setFont(LABEL_FONT);
819  13 autoIdWidth.setText(
820    MessageManager.getString("label.automatically_set_id_width"));
821  13 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
822    .getString("label.adjusts_width_generated_eps_png")));
823  13 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
824  13 autoIdWidth.addActionListener(new ActionListener()
825    {
826   
 
827  0 toggle @Override
828    public void actionPerformed(ActionEvent e)
829    {
830  0 autoIdWidth_actionPerformed();
831    }
832    });
833  13 userIdWidthlabel.setFont(LABEL_FONT);
834  13 userIdWidthlabel.setText(
835    MessageManager.getString("label.figure_id_column_width"));
836  13 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
837    .getString("label.manually_specify_width_left_column")));
838  13 userIdWidthlabel.setToolTipText(
839    JvSwingUtils.wrapTooltip(true, MessageManager.getString(
840    "label.manually_specify_width_left_column")));
841  13 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
842  13 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
843  13 userIdWidth.setText("");
844  13 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
845  13 userIdWidth.addActionListener(new ActionListener()
846    {
847   
 
848  0 toggle @Override
849    public void actionPerformed(ActionEvent e)
850    {
851  0 userIdWidth_actionPerformed();
852    }
853    });
854  13 modellerOutput.setFont(LABEL_FONT);
855  13 modellerOutput
856    .setText(MessageManager.getString("label.use_modeller_output"));
857  13 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
858  13 embbedBioJSON.setFont(LABEL_FONT);
859  13 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
860  13 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
861   
862  13 jPanel11.add(jLabel1);
863  13 jPanel11.add(blcjv);
864  13 jPanel11.add(clustaljv);
865  13 jPanel11.add(fastajv);
866  13 jPanel11.add(msfjv);
867  13 jPanel11.add(pfamjv);
868  13 jPanel11.add(pileupjv);
869  13 jPanel11.add(pirjv);
870  13 outputTab.add(autoIdWidth);
871  13 outputTab.add(userIdWidth);
872  13 outputTab.add(userIdWidthlabel);
873  13 outputTab.add(modellerOutput);
874  13 if (!Platform.isJS())
875    {
876    /*
877    * JalviewJS doesn't support Lineart option or SVG output
878    */
879  13 outputTab.add(embbedBioJSON);
880  13 outputTab.add(epsLabel);
881  13 outputTab.add(epsRendering);
882  13 outputTab.add(htmlLabel);
883  13 outputTab.add(htmlRendering);
884  13 outputTab.add(svgLabel);
885  13 outputTab.add(svgRendering);
886    }
887  13 outputTab.add(jPanel11);
888  13 return outputTab;
889    }
890   
891    /**
892    * Initialises the Connections tabbed panel.
893    *
894    * @return
895    */
 
896  13 toggle private JPanel initConnectionsTab()
897    {
898  13 connectTab = new JPanel();
899  13 connectTab.setLayout(new GridBagLayout());
900   
901   
902  13 JPanel proxyPanel = initConnTabProxyPanel();
903  13 initConnTabCheckboxes();
904   
905    // Add proxy server panel
906  13 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
907    GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
908    new Insets(10, 0, 5, 12), 4, 10));
909   
910    // Add usage stats, version check and questionnaire checkboxes
911  13 connectTab.add(usagestats,
912    new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
913    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
914    new Insets(0, 2, 5, 5), 70, 1));
915  13 connectTab.add(questionnaire,
916    new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
917    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
918    new Insets(0, 2, 5, 10), 70, 1));
919  13 connectTab.add(versioncheck,
920    new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
921    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
922    new Insets(0, 2, 5, 5), 70, 1));
923   
924  13 versioncheck.setVisible(false);
925   
926    // Add padding so the panel doesn't look ridiculous
927  13 JPanel spacePanel = new JPanel();
928  13 connectTab.add(spacePanel,
929    new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
930    GridBagConstraints.WEST, GridBagConstraints.BOTH,
931    new Insets(0, 0, 0, 5), 70, 1));
932   
933  13 return connectTab;
934    }
935   
936    /**
937    * Initialises the Links tabbed panel.
938    *
939    * @return
940    */
 
941  13 toggle private JPanel initLinksTab()
942    {
943  13 JPanel linkTab = new JPanel();
944  13 linkTab.setLayout(new GridBagLayout());
945   
946    // Set up table for Url links
947  13 linkUrlTable.getTableHeader().setReorderingAllowed(false);
948  13 linkUrlTable.setFillsViewportHeight(true);
949  13 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
950  13 linkUrlTable.setAutoCreateRowSorter(true);
951  13 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
952   
953    // adjust row height so radio buttons actually fit
954    // don't do this in the renderer, it causes the awt thread to activate
955    // constantly
956  13 JRadioButton temp = new JRadioButton();
957  13 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
958   
959    // Table in scrollpane so that the table is given a scrollbar
960  13 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
961  13 linkScrollPane.setBorder(null);
962   
963    // Panel for links functionality
964  13 JPanel linkPanel = new JPanel(new GridBagLayout());
965  13 linkPanel.setBorder(new TitledBorder(
966    MessageManager.getString("label.url_linkfrom_sequence_id")));
967   
968    // Put the Url links panel together
969   
970    // Buttons go at top right, resizing only resizes the blank space vertically
971  13 JPanel buttonPanel = initLinkTabUrlButtons();
972  13 GridBagConstraints linkConstraints1 = new GridBagConstraints();
973  13 linkConstraints1.insets = new Insets(0, 0, 5, 0);
974  13 linkConstraints1.gridx = 0;
975  13 linkConstraints1.gridy = 0;
976  13 linkConstraints1.weightx = 1.0;
977  13 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
978  13 linkTab.add(buttonPanel, linkConstraints1);
979   
980    // Links table goes at top left, resizing resizes the table
981  13 GridBagConstraints linkConstraints2 = new GridBagConstraints();
982  13 linkConstraints2.insets = new Insets(0, 0, 5, 5);
983  13 linkConstraints2.gridx = 0;
984  13 linkConstraints2.gridy = 1;
985  13 linkConstraints2.weightx = 1.0;
986  13 linkConstraints2.weighty = 1.0;
987  13 linkConstraints2.fill = GridBagConstraints.BOTH;
988  13 linkTab.add(linkScrollPane, linkConstraints2);
989   
990    // Filter box and buttons goes at bottom left, resizing resizes the text box
991  13 JPanel filterPanel = initLinkTabFilterPanel();
992  13 GridBagConstraints linkConstraints3 = new GridBagConstraints();
993  13 linkConstraints3.insets = new Insets(0, 0, 0, 5);
994  13 linkConstraints3.gridx = 0;
995  13 linkConstraints3.gridy = 2;
996  13 linkConstraints3.weightx = 1.0;
997  13 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
998  13 linkTab.add(filterPanel, linkConstraints3);
999   
1000  13 return linkTab;
1001    }
1002   
 
1003  13 toggle private JPanel initLinkTabFilterPanel()
1004    {
1005    // Filter textbox and reset button
1006  13 JLabel filterLabel = new JLabel(
1007    MessageManager.getString("label.filter"));
1008  13 filterLabel.setFont(LABEL_FONT);
1009  13 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1010  13 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
1011   
1012  13 filterTB.setFont(LABEL_FONT);
1013  13 filterTB.setText("");
1014   
1015  13 doReset.setText(MessageManager.getString("action.showall"));
1016  13 userOnly.setText(MessageManager.getString("action.customfilter"));
1017   
1018    // Panel for filter functionality
1019  13 JPanel filterPanel = new JPanel(new GridBagLayout());
1020  13 filterPanel.setBorder(new TitledBorder("Filter"));
1021  13 GridBagConstraints gbc = new GridBagConstraints();
1022  13 gbc.gridx = 0;
1023  13 gbc.gridy = 0;
1024  13 gbc.fill = GridBagConstraints.NONE;
1025  13 gbc.anchor = GridBagConstraints.WEST;
1026   
1027  13 filterPanel.add(filterLabel, gbc);
1028   
1029  13 GridBagConstraints gbc1 = new GridBagConstraints();
1030  13 gbc1.gridx = 1;
1031  13 gbc1.gridwidth = 2;
1032  13 gbc1.fill = GridBagConstraints.HORIZONTAL;
1033  13 gbc1.anchor = GridBagConstraints.WEST;
1034  13 gbc1.weightx = 1.0;
1035  13 filterPanel.add(filterTB, gbc1);
1036   
1037  13 GridBagConstraints gbc2 = new GridBagConstraints();
1038  13 gbc2.gridx = 3;
1039  13 gbc2.fill = GridBagConstraints.NONE;
1040  13 gbc2.anchor = GridBagConstraints.WEST;
1041  13 filterPanel.add(doReset, gbc2);
1042   
1043  13 GridBagConstraints gbc3 = new GridBagConstraints();
1044  13 gbc3.gridx = 4;
1045  13 gbc3.fill = GridBagConstraints.NONE;
1046  13 gbc3.anchor = GridBagConstraints.WEST;
1047  13 filterPanel.add(userOnly, gbc3);
1048   
1049  13 return filterPanel;
1050    }
1051   
 
1052  13 toggle private JPanel initLinkTabUrlButtons()
1053    {
1054    // Buttons for new / edit / delete Url links
1055  13 JButton newLink = new JButton();
1056  13 newLink.setText(MessageManager.getString("action.new"));
1057   
1058  13 editLink.setText(MessageManager.getString("action.edit"));
1059   
1060  13 deleteLink.setText(MessageManager.getString("action.delete"));
1061   
1062    // no current selection, so initially disable delete/edit buttons
1063  13 editLink.setEnabled(false);
1064  13 deleteLink.setEnabled(false);
1065   
1066  13 newLink.addActionListener(new java.awt.event.ActionListener()
1067    {
 
1068  0 toggle @Override
1069    public void actionPerformed(ActionEvent e)
1070    {
1071  0 newLink_actionPerformed(e);
1072    }
1073    });
1074   
1075  13 editLink.setText(MessageManager.getString("action.edit"));
1076  13 editLink.addActionListener(new java.awt.event.ActionListener()
1077    {
 
1078  0 toggle @Override
1079    public void actionPerformed(ActionEvent e)
1080    {
1081  0 editLink_actionPerformed(e);
1082    }
1083    });
1084   
1085  13 deleteLink.setText(MessageManager.getString("action.delete"));
1086  13 deleteLink.addActionListener(new java.awt.event.ActionListener()
1087    {
 
1088  0 toggle @Override
1089    public void actionPerformed(ActionEvent e)
1090    {
1091  0 deleteLink_actionPerformed(e);
1092    }
1093    });
1094   
1095  13 JPanel buttonPanel = new JPanel(new GridBagLayout());
1096  13 buttonPanel.setBorder(new TitledBorder("Edit links"));
1097  13 GridBagConstraints gbc = new GridBagConstraints();
1098  13 gbc.gridx = 0;
1099  13 gbc.gridy = 0;
1100  13 gbc.fill = GridBagConstraints.NONE;
1101  13 buttonPanel.add(newLink, gbc);
1102   
1103  13 GridBagConstraints gbc1 = new GridBagConstraints();
1104  13 gbc1.gridx = 1;
1105  13 gbc1.gridy = 0;
1106  13 gbc1.fill = GridBagConstraints.NONE;
1107  13 buttonPanel.add(editLink, gbc1);
1108   
1109  13 GridBagConstraints gbc2 = new GridBagConstraints();
1110  13 gbc2.gridx = 2;
1111  13 gbc2.gridy = 0;
1112  13 gbc2.fill = GridBagConstraints.NONE;
1113  13 buttonPanel.add(deleteLink, gbc2);
1114   
1115  13 GridBagConstraints gbc3 = new GridBagConstraints();
1116  13 gbc3.gridx = 3;
1117  13 gbc3.gridy = 0;
1118  13 gbc3.fill = GridBagConstraints.HORIZONTAL;
1119  13 gbc3.weightx = 1.0;
1120  13 JPanel spacePanel = new JPanel();
1121  13 spacePanel.setBorder(null);
1122  13 buttonPanel.add(spacePanel, gbc3);
1123   
1124  13 return buttonPanel;
1125    }
1126   
1127    /**
1128    * Initialises the proxy server panel in the Connections tab
1129    *
1130    * @return the proxy server panel
1131    */
 
1132  13 toggle private JPanel initConnTabProxyPanel()
1133    {
1134    // Label for server text box
1135  13 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1136  13 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1137  13 serverLabel.setFont(LABEL_FONT);
1138  13 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1139  13 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1140  13 serverLabel2.setFont(LABEL_FONT);
1141   
1142    // Proxy server and port text boxes
1143  13 proxyServerHttpTB.setFont(LABEL_FONT);
1144  13 proxyServerHttpTB.setColumns(40);
1145  13 proxyPortHttpTB.setFont(LABEL_FONT);
1146  13 proxyPortHttpTB.setColumns(4);
1147  13 proxyServerHttpsTB.setFont(LABEL_FONT);
1148  13 proxyServerHttpsTB.setColumns(40);
1149  13 proxyPortHttpsTB.setFont(LABEL_FONT);
1150  13 proxyPortHttpsTB.setColumns(4);
1151  13 proxyAuthUsernameTB.setFont(LABEL_FONT);
1152  13 proxyAuthUsernameTB.setColumns(30);
1153   
1154    // check for any change to enable applyProxyButton
1155  13 DocumentListener d = new DocumentListener()
1156    {
 
1157  0 toggle @Override
1158    public void changedUpdate(DocumentEvent e)
1159    {
1160  0 applyProxyButtonEnabled(true);
1161    }
1162   
 
1163  0 toggle @Override
1164    public void insertUpdate(DocumentEvent e)
1165    {
1166  0 applyProxyButtonEnabled(true);
1167    }
1168   
 
1169  0 toggle @Override
1170    public void removeUpdate(DocumentEvent e)
1171    {
1172  0 applyProxyButtonEnabled(true);
1173    }
1174    };
1175  13 proxyServerHttpTB.getDocument().addDocumentListener(d);
1176  13 proxyPortHttpTB.getDocument().addDocumentListener(d);
1177  13 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1178  13 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1179  13 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1180  13 proxyAuthPasswordPB.setFont(LABEL_FONT);
1181  13 proxyAuthPasswordPB.setColumns(30);
1182  13 proxyAuthPasswordPB.getDocument()
1183    .addDocumentListener(new DocumentListener()
1184    {
 
1185  0 toggle @Override
1186    public void changedUpdate(DocumentEvent e)
1187    {
1188  0 proxyAuthPasswordCheckHighlight(true);
1189  0 applyProxyButtonEnabled(true);
1190    }
1191   
 
1192  0 toggle @Override
1193    public void insertUpdate(DocumentEvent e)
1194    {
1195  0 proxyAuthPasswordCheckHighlight(true);
1196  0 applyProxyButtonEnabled(true);
1197    }
1198   
 
1199  0 toggle @Override
1200    public void removeUpdate(DocumentEvent e)
1201    {
1202  0 proxyAuthPasswordCheckHighlight(true);
1203  0 applyProxyButtonEnabled(true);
1204    }
1205   
1206    });
1207   
1208    // Label for Port text box
1209  13 portLabel.setFont(LABEL_FONT);
1210  13 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1211  13 portLabel.setText(MessageManager.getString("label.port") + ": ");
1212  13 portLabel2.setFont(LABEL_FONT);
1213  13 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1214  13 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1215   
1216  13 httpLabel.setText("HTTP");
1217  13 httpLabel.setFont(LABEL_FONT_BOLD);
1218  13 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1219  13 httpsLabel.setText("HTTPS");
1220  13 httpsLabel.setFont(LABEL_FONT_BOLD);
1221  13 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1222   
1223  13 proxyAuthUsernameLabel
1224    .setText(MessageManager.getString("label.username") + ": ");
1225  13 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1226  13 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1227  13 proxyAuthPasswordLabel
1228    .setText(MessageManager.getString("label.password") + ": ");
1229  13 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1230  13 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1231  13 passwordNotStoredLabel.setText(
1232    "(" + MessageManager.getString("label.not_stored") + ")");
1233  13 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1234  13 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1235   
1236    // Proxy type radio buttons
1237  13 noProxy.setFont(LABEL_FONT);
1238  13 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1239  13 noProxy.setText(MessageManager.getString("label.no_proxy"));
1240  13 systemProxy.setFont(LABEL_FONT);
1241  13 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1242  13 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1243    displayUserHostPort(Cache.startupProxyProperties[4],
1244    Cache.startupProxyProperties[0],
1245    Cache.startupProxyProperties[1]),
1246    displayUserHostPort(Cache.startupProxyProperties[6],
1247    Cache.startupProxyProperties[2],
1248    Cache.startupProxyProperties[3])));
1249  13 customProxy.setFont(LABEL_FONT);
1250  13 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1251  13 customProxy.setText(
1252    MessageManager.getString("label.use_proxy_server") + ":");
1253  13 ActionListener al = new ActionListener()
1254    {
 
1255  0 toggle @Override
1256    public void actionPerformed(ActionEvent e)
1257    {
1258  0 proxyType_actionPerformed();
1259    }
1260    };
1261  13 noProxy.addActionListener(al);
1262  13 systemProxy.addActionListener(al);
1263  13 customProxy.addActionListener(al);
1264  13 proxyType.add(noProxy);
1265  13 proxyType.add(systemProxy);
1266  13 proxyType.add(customProxy);
1267   
1268  13 proxyAuth.setFont(LABEL_FONT);
1269  13 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1270  13 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1271  13 proxyAuth.addActionListener(new ActionListener()
1272    {
 
1273  0 toggle @Override
1274    public void actionPerformed(ActionEvent e)
1275    {
1276  0 proxyAuth_actionPerformed();
1277    }
1278    });
1279   
1280  13 setCustomProxyEnabled();
1281   
1282    // Make proxy server panel
1283  13 JPanel proxyPanel = new JPanel();
1284  13 TitledBorder titledBorder1 = new TitledBorder(
1285    MessageManager.getString("label.proxy_servers"));
1286  13 proxyPanel.setBorder(titledBorder1);
1287  13 proxyPanel.setLayout(new GridBagLayout());
1288  13 GridBagConstraints gbc = new GridBagConstraints();
1289  13 gbc.fill = GridBagConstraints.HORIZONTAL;
1290  13 gbc.weightx = 1.0;
1291   
1292  13 GridBagConstraints c = new GridBagConstraints();
1293    // Proxy type radio buttons (3)
1294  13 JPanel ptPanel = new JPanel();
1295  13 ptPanel.setLayout(new GridBagLayout());
1296  13 c.weightx = 1.0;
1297  13 c.gridy = 0;
1298  13 c.gridx = 0;
1299  13 c.gridwidth = 1;
1300  13 c.fill = GridBagConstraints.HORIZONTAL;
1301  13 ptPanel.add(noProxy, c);
1302  13 c.gridy++;
1303  13 ptPanel.add(systemProxy, c);
1304  13 c.gridy++;
1305  13 ptPanel.add(customProxy, c);
1306   
1307  13 gbc.gridy = 0;
1308  13 proxyPanel.add(ptPanel, gbc);
1309   
1310    // host and port text boxes
1311  13 JPanel hpPanel = new JPanel();
1312  13 hpPanel.setLayout(new GridBagLayout());
1313    // HTTP host port row
1314  13 c.gridy = 0;
1315  13 c.gridx = 0;
1316   
1317  13 c.weightx = 0.1;
1318  13 c.anchor = GridBagConstraints.LINE_START;
1319  13 hpPanel.add(httpLabel, c);
1320   
1321  13 c.gridx++;
1322  13 c.weightx = 0.1;
1323  13 c.anchor = GridBagConstraints.LINE_END;
1324  13 hpPanel.add(serverLabel, c);
1325   
1326  13 c.gridx++;
1327  13 c.weightx = 1.0;
1328  13 c.anchor = GridBagConstraints.LINE_START;
1329  13 hpPanel.add(proxyServerHttpTB, c);
1330   
1331  13 c.gridx++;
1332  13 c.weightx = 0.1;
1333  13 c.anchor = GridBagConstraints.LINE_END;
1334  13 hpPanel.add(portLabel, c);
1335   
1336  13 c.gridx++;
1337  13 c.weightx = 0.2;
1338  13 c.anchor = GridBagConstraints.LINE_START;
1339  13 hpPanel.add(proxyPortHttpTB, c);
1340   
1341    // HTTPS host port row
1342  13 c.gridy++;
1343  13 c.gridx = 0;
1344  13 c.gridwidth = 1;
1345   
1346  13 c.anchor = GridBagConstraints.LINE_START;
1347  13 hpPanel.add(httpsLabel, c);
1348   
1349  13 c.gridx++;
1350  13 c.anchor = GridBagConstraints.LINE_END;
1351  13 hpPanel.add(serverLabel2, c);
1352   
1353  13 c.gridx++;
1354  13 c.anchor = GridBagConstraints.LINE_START;
1355  13 hpPanel.add(proxyServerHttpsTB, c);
1356   
1357  13 c.gridx++;
1358  13 c.anchor = GridBagConstraints.LINE_END;
1359  13 hpPanel.add(portLabel2, c);
1360   
1361  13 c.gridx++;
1362  13 c.anchor = GridBagConstraints.LINE_START;
1363  13 hpPanel.add(proxyPortHttpsTB, c);
1364   
1365  13 gbc.gridy++;
1366  13 proxyPanel.add(hpPanel, gbc);
1367   
1368  13 if (!Platform.isJS())
1369    /**
1370    * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1371    * Authentication options in Preferences.
1372    *
1373    * @j2sIgnore
1374    *
1375    */
1376    {
1377    // Require authentication checkbox
1378  13 gbc.gridy++;
1379  13 proxyPanel.add(proxyAuth, gbc);
1380   
1381    // username and password
1382  13 JPanel upPanel = new JPanel();
1383  13 upPanel.setLayout(new GridBagLayout());
1384    // username row
1385  13 c.gridy = 0;
1386  13 c.gridx = 0;
1387  13 c.gridwidth = 1;
1388  13 c.weightx = 0.4;
1389  13 c.anchor = GridBagConstraints.LINE_END;
1390  13 upPanel.add(proxyAuthUsernameLabel, c);
1391   
1392  13 c.gridx++;
1393  13 c.weightx = 1.0;
1394  13 c.anchor = GridBagConstraints.LINE_START;
1395  13 upPanel.add(proxyAuthUsernameTB, c);
1396   
1397    // password row
1398  13 c.gridy++;
1399  13 c.gridx = 0;
1400  13 c.weightx = 0.4;
1401  13 c.anchor = GridBagConstraints.LINE_END;
1402  13 upPanel.add(proxyAuthPasswordLabel, c);
1403   
1404  13 c.gridx++;
1405  13 c.weightx = 1.0;
1406  13 c.anchor = GridBagConstraints.LINE_START;
1407  13 upPanel.add(proxyAuthPasswordPB, c);
1408   
1409  13 c.gridx++;
1410  13 c.weightx = 0.4;
1411  13 c.anchor = GridBagConstraints.LINE_START;
1412  13 upPanel.add(passwordNotStoredLabel, c);
1413   
1414  13 gbc.gridy++;
1415  13 proxyPanel.add(upPanel, gbc);
1416   
1417    } // end j2sIgnore
1418   
1419  13 applyProxyButton.setText(MessageManager.getString("action.apply"));
1420  13 applyProxyButton.addActionListener(new ActionListener()
1421    {
 
1422  0 toggle @Override
1423    public void actionPerformed(ActionEvent e)
1424    {
1425  0 saveProxySettings();
1426  0 applyProxyButton.setEnabled(false);
1427    }
1428    });
1429  13 gbc.gridy++;
1430  13 gbc.fill = GridBagConstraints.NONE;
1431  13 gbc.anchor = GridBagConstraints.LINE_END;
1432  13 proxyPanel.add(applyProxyButton, gbc);
1433   
1434  13 return proxyPanel;
1435    }
1436   
 
1437  0 toggle public void proxyAuthPasswordCheckHighlight(boolean enabled)
1438    {
1439  0 proxyAuthPasswordCheckHighlight(enabled, false);
1440    }
1441   
 
1442  0 toggle public void proxyAuthPasswordCheckHighlight(boolean enabled,
1443    boolean grabFocus)
1444    {
1445  0 if (enabled && proxyType.isSelected(customProxy.getModel())
1446    && proxyAuth.isSelected()
1447    && !proxyAuthUsernameTB.getText().isEmpty()
1448    && proxyAuthPasswordPB.getDocument().getLength() == 0)
1449    {
1450  0 if (grabFocus)
1451  0 proxyAuthPasswordPB.grabFocus();
1452  0 proxyAuthPasswordPB.setBackground(Color.PINK);
1453    }
1454    else
1455    {
1456  0 proxyAuthPasswordPB.setBackground(Color.WHITE);
1457    }
1458    }
1459   
 
1460  12 toggle public void applyProxyButtonEnabled(boolean enabled)
1461    {
1462  12 applyProxyButton.setEnabled(enabled);
1463    }
1464   
 
1465  0 toggle public void saveProxySettings()
1466    {
1467    // overridden in Preferences
1468    }
1469   
 
1470  26 toggle private String displayUserHostPort(String user, String host, String port)
1471    {
1472  26 boolean hostBlank = (host == null || host.isEmpty());
1473  26 boolean portBlank = (port == null || port.isEmpty());
1474  26 if (hostBlank && portBlank)
1475    {
1476  26 return MessageManager.getString("label.none");
1477    }
1478   
1479  0 StringBuilder sb = new StringBuilder();
1480  0 if (user != null)
1481    {
1482  0 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1483    : user);
1484  0 sb.append("@");
1485    }
1486  0 sb.append(hostBlank ? "" : host);
1487  0 if (!portBlank)
1488    {
1489  0 sb.append(":");
1490  0 sb.append(port);
1491    }
1492  0 return sb.toString();
1493    }
1494   
1495    /**
1496    * Initialises the checkboxes in the Connections tab
1497    */
 
1498  13 toggle private void initConnTabCheckboxes()
1499    {
1500    // Usage stats checkbox label
1501  13 usagestats.setText(
1502    MessageManager.getString("label.send_usage_statistics"));
1503  13 usagestats.setFont(LABEL_FONT);
1504  13 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1505  13 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1506   
1507    // Questionnaire checkbox label
1508  13 questionnaire.setText(
1509    MessageManager.getString("label.check_for_questionnaires"));
1510  13 questionnaire.setFont(LABEL_FONT);
1511  13 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1512  13 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1513   
1514    // Check for latest version checkbox label
1515  13 versioncheck.setText(
1516    MessageManager.getString("label.check_for_latest_version"));
1517  13 versioncheck.setFont(LABEL_FONT);
1518  13 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1519  13 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1520    }
1521   
1522    /**
1523    * Initialises the parent panel which contains the tabbed sections.
1524    *
1525    * @return
1526    */
 
1527  13 toggle private JPanel initOkCancelPanel()
1528    {
1529  13 JButton ok = new JButton();
1530  13 ok.setText(MessageManager.getString("action.ok"));
1531  13 ok.addActionListener(new ActionListener()
1532    {
 
1533  0 toggle @Override
1534    public void actionPerformed(ActionEvent e)
1535    {
1536  0 ok_actionPerformed(e);
1537    }
1538    });
1539  13 JButton cancel = new JButton();
1540  13 cancel.setText(MessageManager.getString("action.cancel"));
1541  13 cancel.addActionListener(new ActionListener()
1542    {
 
1543  0 toggle @Override
1544    public void actionPerformed(ActionEvent e)
1545    {
1546  0 cancel_actionPerformed(e);
1547    }
1548    });
1549  13 JPanel okCancelPanel = new JPanel();
1550  13 okCancelPanel.add(ok);
1551  13 okCancelPanel.add(cancel);
1552  13 return okCancelPanel;
1553    }
1554   
1555    /**
1556    * Initialises the Colours tabbed panel.
1557    *
1558    * @return
1559    */
 
1560  13 toggle private JPanel initColoursTab()
1561    {
1562  13 JPanel coloursTab = new JPanel();
1563  13 coloursTab.setBorder(new TitledBorder(
1564    MessageManager.getString("action.open_new_alignment")));
1565  13 coloursTab.setLayout(new FlowLayout());
1566  13 JLabel mincolourLabel = new JLabel();
1567  13 mincolourLabel.setFont(LABEL_FONT);
1568  13 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1569  13 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1570  13 minColour.setFont(LABEL_FONT);
1571  13 minColour.setBorder(BorderFactory.createEtchedBorder());
1572  13 minColour.setPreferredSize(new Dimension(40, 20));
1573  13 minColour.addMouseListener(new MouseAdapter()
1574    {
 
1575  0 toggle @Override
1576    public void mousePressed(MouseEvent e)
1577    {
1578  0 minColour_actionPerformed(minColour);
1579    }
1580    });
1581  13 JLabel maxcolourLabel = new JLabel();
1582  13 maxcolourLabel.setFont(LABEL_FONT);
1583  13 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1584  13 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1585  13 maxColour.setFont(LABEL_FONT);
1586  13 maxColour.setBorder(BorderFactory.createEtchedBorder());
1587  13 maxColour.setPreferredSize(new Dimension(40, 20));
1588  13 maxColour.addMouseListener(new MouseAdapter()
1589    {
 
1590  0 toggle @Override
1591    public void mousePressed(MouseEvent e)
1592    {
1593  0 maxColour_actionPerformed(maxColour);
1594    }
1595    });
1596   
1597  13 protColour.setFont(LABEL_FONT);
1598  13 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1599  13 JLabel protColourLabel = new JLabel();
1600  13 protColourLabel.setFont(LABEL_FONT);
1601  13 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1602  13 protColourLabel.setText(
1603    MessageManager.getString("label.prot_alignment_colour") + " ");
1604  13 GPreferences.addtoLayout(coloursTab,
1605    MessageManager
1606    .getString("label.default_colour_scheme_for_alignment"),
1607    protColourLabel, protColour);
1608   
1609  13 nucColour.setFont(LABEL_FONT);
1610  13 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1611  13 JLabel nucColourLabel = new JLabel();
1612  13 nucColourLabel.setFont(LABEL_FONT);
1613  13 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1614  13 nucColourLabel.setText(
1615    MessageManager.getString("label.nuc_alignment_colour") + " ");
1616  13 GPreferences.addtoLayout(coloursTab,
1617    MessageManager
1618    .getString("label.default_colour_scheme_for_alignment"),
1619    nucColourLabel, nucColour);
1620   
1621  13 JPanel annotationShding = new JPanel();
1622  13 annotationShding.setBorder(new TitledBorder(
1623    MessageManager.getString("label.annotation_shading_default")));
1624  13 annotationShding.setLayout(new GridLayout(1, 2));
1625  13 GPreferences.addtoLayout(annotationShding,
1626    MessageManager.getString(
1627    "label.default_minimum_colour_annotation_shading"),
1628    mincolourLabel, minColour);
1629  13 GPreferences.addtoLayout(annotationShding,
1630    MessageManager.getString(
1631    "label.default_maximum_colour_annotation_shading"),
1632    maxcolourLabel, maxColour);
1633  13 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1634  13 return coloursTab;
1635    }
1636   
1637    /**
1638    * Initialises the Overview tabbed panel.
1639    *
1640    * @return
1641    */
 
1642  13 toggle private JPanel initOverviewTab()
1643    {
1644  13 JPanel overviewPanel = new JPanel();
1645  13 overviewPanel.setBorder(new TitledBorder(
1646    MessageManager.getString("label.overview_settings")));
1647   
1648  13 gapColour.setFont(LABEL_FONT);
1649    // fixing the border colours stops apparent colour bleed from the panel
1650  13 gapColour.setBorder(
1651    BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1652  13 gapColour.setPreferredSize(new Dimension(40, 20));
1653  13 gapColour.addMouseListener(new MouseAdapter()
1654    {
 
1655  0 toggle @Override
1656    public void mousePressed(MouseEvent e)
1657    {
1658  0 gapColour_actionPerformed(gapColour);
1659    }
1660    });
1661   
1662  13 hiddenColour.setFont(LABEL_FONT);
1663    // fixing the border colours stops apparent colour bleed from the panel
1664  13 hiddenColour.setBorder(
1665    BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1666  13 hiddenColour.setPreferredSize(new Dimension(40, 20));
1667  13 hiddenColour.addMouseListener(new MouseAdapter()
1668    {
 
1669  0 toggle @Override
1670    public void mousePressed(MouseEvent e)
1671    {
1672  0 hiddenColour_actionPerformed(hiddenColour);
1673    }
1674    });
1675   
1676  13 useLegacyGap = new JCheckBox(
1677    MessageManager.getString("label.ov_legacy_gap"));
1678  13 useLegacyGap.setFont(LABEL_FONT);
1679  13 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1680  13 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1681  13 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1682  13 gapLabel.setFont(LABEL_FONT);
1683  13 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1684  13 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1685  13 showHiddenAtStart = new JCheckBox(
1686    MessageManager.getString("label.ov_show_hide_default"));
1687  13 showHiddenAtStart.setFont(LABEL_FONT);
1688  13 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1689  13 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1690  13 JLabel hiddenLabel = new JLabel(
1691    MessageManager.getString("label.hidden_colour"));
1692  13 hiddenLabel.setFont(LABEL_FONT);
1693  13 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1694  13 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1695   
1696  13 useLegacyGap.addActionListener(new ActionListener()
1697    {
 
1698  0 toggle @Override
1699    public void actionPerformed(ActionEvent e)
1700    {
1701  0 useLegacyGaps_actionPerformed(e);
1702    }
1703    });
1704   
1705  13 overviewPanel.setLayout(new GridBagLayout());
1706  13 GridBagConstraints c1 = new GridBagConstraints();
1707   
1708  13 c1.fill = GridBagConstraints.HORIZONTAL;
1709  13 c1.gridx = 0;
1710  13 c1.gridy = 0;
1711  13 c1.weightx = 1;
1712  13 c1.ipady = 20;
1713  13 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1714  13 overviewPanel.add(useLegacyGap, c1);
1715   
1716  13 GridBagConstraints c2 = new GridBagConstraints();
1717  13 c2.fill = GridBagConstraints.HORIZONTAL;
1718  13 c2.gridx = 1;
1719  13 c2.gridy = 0;
1720  13 c2.insets = new Insets(0, 15, 0, 10);
1721  13 overviewPanel.add(gapLabel, c2);
1722   
1723  13 GridBagConstraints c3 = new GridBagConstraints();
1724  13 c3.fill = GridBagConstraints.HORIZONTAL;
1725  13 c3.gridx = 2;
1726  13 c3.gridy = 0;
1727  13 c3.insets = new Insets(0, 0, 0, 15);
1728  13 overviewPanel.add(gapColour, c3);
1729   
1730  13 GridBagConstraints c4 = new GridBagConstraints();
1731  13 c4.fill = GridBagConstraints.HORIZONTAL;
1732  13 c4.gridx = 0;
1733  13 c4.gridy = 1;
1734  13 c4.weightx = 1;
1735  13 overviewPanel.add(showHiddenAtStart, c4);
1736   
1737  13 GridBagConstraints c5 = new GridBagConstraints();
1738  13 c5.fill = GridBagConstraints.HORIZONTAL;
1739  13 c5.gridx = 1;
1740  13 c5.gridy = 1;
1741  13 c5.insets = new Insets(0, 15, 0, 10);
1742  13 overviewPanel.add(hiddenLabel, c5);
1743   
1744  13 GridBagConstraints c6 = new GridBagConstraints();
1745  13 c6.fill = GridBagConstraints.HORIZONTAL;
1746  13 c6.gridx = 2;
1747  13 c6.gridy = 1;
1748  13 c6.insets = new Insets(0, 0, 0, 15);
1749  13 overviewPanel.add(hiddenColour, c6);
1750   
1751  13 JButton resetButton = new JButton(
1752    MessageManager.getString("label.reset_to_defaults"));
1753   
1754  13 resetButton.addActionListener(new ActionListener()
1755    {
 
1756  0 toggle @Override
1757    public void actionPerformed(ActionEvent e)
1758    {
1759  0 resetOvDefaults_actionPerformed(e);
1760    }
1761    });
1762   
1763  13 GridBagConstraints c7 = new GridBagConstraints();
1764  13 c7.fill = GridBagConstraints.NONE;
1765  13 c7.gridx = 0;
1766  13 c7.gridy = 2;
1767  13 c7.insets = new Insets(10, 0, 0, 0);
1768  13 c7.anchor = GridBagConstraints.WEST;
1769  13 overviewPanel.add(resetButton, c7);
1770   
1771    // Add padding so the panel doesn't look ridiculous
1772  13 JPanel spacePanel = new JPanel();
1773  13 overviewPanel.add(spacePanel,
1774    new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1775    GridBagConstraints.WEST, GridBagConstraints.BOTH,
1776    new Insets(0, 0, 0, 5), 0, 0));
1777   
1778  13 return overviewPanel;
1779    }
1780   
1781    /**
1782    * Initialises the Structure tabbed panel.
1783    *
1784    * @return
1785    */
 
1786  13 toggle private JPanel initStructureTab()
1787    {
1788  13 structureTab = new JPanel();
1789   
1790  13 structureTab.setBorder(new TitledBorder(
1791    MessageManager.getString("label.structure_options")));
1792  13 structureTab.setLayout(null);
1793  13 final int width = 420;
1794  13 final int height = 22;
1795  13 final int lineSpacing = 25;
1796  13 int ypos = 15;
1797   
1798  13 structFromPdb.setFont(LABEL_FONT);
1799  13 structFromPdb
1800    .setText(MessageManager.getString("label.struct_from_pdb"));
1801  13 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1802  13 structFromPdb.addActionListener(new ActionListener()
1803    {
 
1804  0 toggle @Override
1805    public void actionPerformed(ActionEvent e)
1806    {
1807  0 boolean selected = structFromPdb.isSelected();
1808    // enable other options only when the first is checked
1809  0 addSecondaryStructure.setEnabled(selected);
1810  0 addTempFactor.setEnabled(selected);
1811    }
1812    });
1813  13 structureTab.add(structFromPdb);
1814   
1815    // indent checkboxes that are conditional on the first one
1816  13 ypos += lineSpacing;
1817  13 addSecondaryStructure.setFont(LABEL_FONT);
1818  13 addSecondaryStructure
1819    .setText(MessageManager.getString("label.autoadd_secstr"));
1820  13 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1821  13 structureTab.add(addSecondaryStructure);
1822   
1823  13 ypos += lineSpacing;
1824  13 addTempFactor.setFont(LABEL_FONT);
1825  13 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1826  13 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1827  13 structureTab.add(addTempFactor);
1828   
1829  13 ypos += lineSpacing;
1830  13 JLabel viewerLabel = new JLabel();
1831  13 viewerLabel.setFont(LABEL_FONT);
1832  13 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1833  13 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1834  13 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1835  13 structureTab.add(viewerLabel);
1836   
1837    /*
1838    * add all external viewers as options here - check
1839    * when selected whether the program is installed
1840    */
1841  13 structViewer.setFont(LABEL_FONT);
1842  13 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1843  13 for (ViewerType v : EnumSet.allOf(ViewerType.class))
1844    {
1845  52 structViewer.addItem(v.name());
1846    }
1847    /*
1848    structViewer.addItem(ViewerType.JMOL.name());
1849    structViewer.addItem(ViewerType.CHIMERA.name());
1850    structViewer.addItem(ViewerType.CHIMERAX.name());
1851    structViewer.addItem(ViewerType.PYMOL.name());
1852    */
1853  13 structViewer.addActionListener(new ActionListener()
1854    {
 
1855  12 toggle @Override
1856    public void actionPerformed(ActionEvent e)
1857    {
1858  12 structureViewer_actionPerformed(
1859    (String) structViewer.getSelectedItem());
1860    }
1861    });
1862  13 structureTab.add(structViewer);
1863   
1864  13 ypos += lineSpacing;
1865  13 structureViewerPathLabel = new JLabel();
1866  13 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1867    // 11));
1868  13 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1869  13 structureViewerPathLabel.setText(MessageManager
1870    .formatMessage("label.viewer_path", "Chimera(X)"));
1871  13 structureViewerPathLabel
1872    .setBounds(new Rectangle(10, ypos, 170, height));
1873  13 structureViewerPathLabel.setEnabled(false);
1874  13 structureTab.add(structureViewerPathLabel);
1875   
1876  13 structureViewerPath.setFont(LABEL_FONT);
1877  13 structureViewerPath.setText("");
1878  13 structureViewerPath.setEnabled(false);
1879  13 final String tooltip = JvSwingUtils.wrapTooltip(true,
1880    MessageManager.getString("label.viewer_path_tip"));
1881  13 structureViewerPath.setToolTipText(tooltip);
1882  13 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1883  13 structureViewerPath.addMouseListener(new MouseAdapter()
1884    {
 
1885  0 toggle @Override
1886    public void mouseClicked(MouseEvent e)
1887    {
1888  0 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1889    {
1890  0 String chosen = openFileChooser(false);
1891  0 if (chosen != null)
1892    {
1893  0 structureViewerPath.setText(chosen);
1894    }
1895    }
1896    }
1897    });
1898  13 structureTab.add(structureViewerPath);
1899   
1900  13 ypos += lineSpacing;
1901  13 nwMapping.setFont(LABEL_FONT);
1902  13 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1903  13 siftsMapping.setFont(LABEL_FONT);
1904  13 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1905  13 mappingMethod.add(nwMapping);
1906  13 mappingMethod.add(siftsMapping);
1907  13 JPanel mappingPanel = new JPanel();
1908  13 mappingPanel.setFont(LABEL_FONT);
1909  13 TitledBorder mmTitledBorder = new TitledBorder(
1910    MessageManager.getString("label.mapping_method"));
1911  13 mmTitledBorder.setTitleFont(LABEL_FONT);
1912  13 mappingPanel.setBorder(mmTitledBorder);
1913  13 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1914    // GridLayout mappingLayout = new GridLayout();
1915  13 mappingPanel.setLayout(new GridLayout());
1916  13 mappingPanel.add(nwMapping);
1917  13 mappingPanel.add(siftsMapping);
1918  13 structureTab.add(mappingPanel);
1919   
1920  13 ypos += lineSpacing;
1921  13 ypos += lineSpacing;
1922  13 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1923    PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1924  13 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1925  13 structureTab.add(docFieldPref);
1926   
1927    /*
1928    * hide Chimera options in JalviewJS
1929    */
1930  13 if (Platform.isJS())
1931    {
1932  0 structureViewerPathLabel.setVisible(false);
1933  0 structureViewerPath.setVisible(false);
1934  0 viewerLabel.setVisible(false);
1935  0 structViewer.setVisible(false);
1936    }
1937   
1938  13 return structureTab;
1939    }
1940   
1941    /**
1942    * Action on choosing a structure viewer from combobox options.
1943    *
1944    * @param selectedItem
1945    */
 
1946  0 toggle protected void structureViewer_actionPerformed(String selectedItem)
1947    {
1948    }
1949   
1950    /**
1951    * Show a dialog for the user to choose a file. Returns the chosen path, or null
1952    * on Cancel.
1953    *
1954    * @return
1955    */
 
1956  0 toggle protected String openFileChooser(boolean forFolder)
1957    {
1958  0 String choice = null;
1959  0 JFileChooser chooser = new JFileChooser();
1960   
1961    // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1962    // hidden executables within .app dirs
1963  0 if (Platform.isMac())
1964    {
1965  0 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1966    true);
1967    }
1968   
1969  0 if (forFolder)
1970    {
1971  0 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1972    }
1973    // chooser.setFileView(new JalviewFileView());
1974  0 chooser.setDialogTitle(
1975    MessageManager.getString("label.open_local_file"));
1976  0 chooser.setToolTipText(MessageManager.getString("action.open"));
1977   
1978  0 int value = chooser.showOpenDialog(this);
1979   
1980  0 if (value == JFileChooser.APPROVE_OPTION)
1981    {
1982  0 choice = chooser.getSelectedFile().getPath();
1983    }
1984  0 return choice;
1985    }
1986   
1987    /**
1988    * Validate the structure tab preferences; if invalid, set focus on this tab.
1989    *
1990    * @param e
1991    */
 
1992  0 toggle protected boolean validateStructure(FocusEvent e)
1993    {
1994  0 if (!validateStructure())
1995    {
1996  0 e.getComponent().requestFocusInWindow();
1997  0 return false;
1998    }
1999  0 return true;
2000    }
2001   
 
2002  0 toggle protected boolean validateStructure()
2003    {
2004  0 return false;
2005    }
2006   
2007    /**
2008    * Initialises the Visual tabbed panel.
2009    *
2010    * @return
2011    */
 
2012  13 toggle private JPanel initVisualTab()
2013    {
2014  13 JPanel visualTab = new JPanel();
2015  13 visualTab.setBorder(new TitledBorder(
2016    MessageManager.getString("action.open_new_alignment")));
2017  13 visualTab.setLayout(null);
2018  13 fullScreen.setFont(LABEL_FONT);
2019  13 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
2020  13 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
2021  13 fullScreen.setText(MessageManager.getString("label.maximize_window"));
2022  13 quality.setEnabled(false);
2023  13 quality.setFont(LABEL_FONT);
2024  13 quality.setHorizontalAlignment(SwingConstants.RIGHT);
2025  13 quality.setHorizontalTextPosition(SwingConstants.LEFT);
2026  13 quality.setSelected(true);
2027  13 quality.setText(MessageManager.getString("label.quality"));
2028  13 conservation.setEnabled(false);
2029  13 conservation.setFont(LABEL_FONT);
2030  13 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
2031  13 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
2032  13 conservation.setSelected(true);
2033  13 conservation.setText(MessageManager.getString("label.conservation"));
2034  13 identity.setEnabled(false);
2035  13 identity.setFont(LABEL_FONT);
2036  13 identity.setHorizontalAlignment(SwingConstants.RIGHT);
2037  13 identity.setHorizontalTextPosition(SwingConstants.LEFT);
2038  13 identity.setSelected(true);
2039  13 identity.setText(MessageManager.getString("label.consensus"));
2040  13 ssConsensus.setEnabled(false);
2041  13 ssConsensus.setFont(LABEL_FONT);
2042  13 ssConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2043  13 ssConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2044  13 ssConsensus.setSelected(false);
2045  13 ssConsensus.setText(MessageManager.getString("label.ssConsensus"));
2046  13 showOccupancy.setFont(LABEL_FONT);
2047  13 showOccupancy.setEnabled(false);
2048  13 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
2049  13 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
2050  13 showOccupancy.setSelected(true);
2051  13 showOccupancy.setText(MessageManager.getString("label.occupancy"));
2052   
2053  13 JLabel showGroupbits = new JLabel();
2054  13 showGroupbits.setFont(LABEL_FONT);
2055  13 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
2056  13 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
2057  13 showGroupbits
2058    .setText(MessageManager.getString("action.show_group") + ":");
2059  13 JLabel showConsensbits = new JLabel();
2060  13 showConsensbits.setFont(LABEL_FONT);
2061  13 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
2062  13 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
2063  13 showConsensbits
2064    .setText(MessageManager.getString("label.consensus") + ":");
2065  13 showConsensHistogram.setEnabled(false);
2066  13 showConsensHistogram.setFont(LABEL_FONT);
2067  13 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
2068  13 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
2069  13 showConsensHistogram.setSelected(true);
2070  13 showConsensHistogram
2071    .setText(MessageManager.getString("label.histogram"));
2072  13 showConsensLogo.setEnabled(false);
2073  13 showConsensLogo.setFont(LABEL_FONT);
2074  13 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
2075  13 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
2076  13 showConsensLogo.setSelected(true);
2077  13 showConsensLogo.setText(MessageManager.getString("label.logo"));
2078  13 showGroupConsensus.setEnabled(false);
2079  13 showGroupConsensus.setFont(LABEL_FONT);
2080  13 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2081  13 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2082  13 showGroupConsensus.setSelected(true);
2083  13 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
2084  13 showGroupConservation.setEnabled(false);
2085  13 showGroupConservation.setFont(LABEL_FONT);
2086  13 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
2087  13 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
2088  13 showGroupConservation.setSelected(true);
2089  13 showGroupConservation
2090    .setText(MessageManager.getString("label.conservation"));
2091  13 showNpTooltip.setEnabled(true);
2092  13 showNpTooltip.setFont(LABEL_FONT);
2093  13 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2094  13 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2095  13 showNpTooltip.setSelected(true);
2096  13 showNpTooltip.setText(
2097    MessageManager.getString("label.non_positional_features"));
2098  13 showDbRefTooltip.setEnabled(true);
2099  13 showDbRefTooltip.setFont(LABEL_FONT);
2100  13 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2101  13 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2102  13 showDbRefTooltip.setSelected(true);
2103  13 showDbRefTooltip
2104    .setText(MessageManager.getString("label.database_references"));
2105  13 annotations.setFont(LABEL_FONT);
2106  13 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
2107  13 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
2108  13 annotations.setSelected(true);
2109  13 annotations.setText(MessageManager.getString("label.show_annotations"));
2110    // annotations.setBounds(new Rectangle(169, 12, 200, 23));
2111  13 annotations.addActionListener(new ActionListener()
2112    {
 
2113  0 toggle @Override
2114    public void actionPerformed(ActionEvent e)
2115    {
2116  0 annotations_actionPerformed(e);
2117    }
2118    });
2119  13 identity.addActionListener(new ActionListener()
2120    {
 
2121  0 toggle @Override
2122    public void actionPerformed(ActionEvent e)
2123    {
2124  0 annotations_actionPerformed(e);
2125    }
2126    });
2127  13 showGroupConsensus.addActionListener(new ActionListener()
2128    {
 
2129  0 toggle @Override
2130    public void actionPerformed(ActionEvent e)
2131    {
2132  0 annotations_actionPerformed(e);
2133    }
2134    });
2135  13 showUnconserved.setFont(LABEL_FONT);
2136  13 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2137  13 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2138  13 showUnconserved.setSelected(true);
2139  13 showUnconserved
2140    .setText(MessageManager.getString("action.show_unconserved"));
2141  13 showUnconserved.addActionListener(new ActionListener()
2142    {
 
2143  0 toggle @Override
2144    public void actionPerformed(ActionEvent e)
2145    {
2146  0 showunconserved_actionPerformed(e);
2147    }
2148    });
2149   
2150    // TODO these are not yet added to / action from Preferences
2151    // JCheckBox shareSelections = new JCheckBox();
2152    // shareSelections.setFont(verdana11);
2153    // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2154    // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2155    // shareSelections.setSelected(true);
2156    // shareSelections.setText(MessageManager
2157    // .getString("label.share_selection_across_views"));
2158    // JCheckBox followHighlight = new JCheckBox();
2159    // followHighlight.setFont(verdana11);
2160    // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2161    // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2162    // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2163    // followHighlight.setSelected(true);
2164    // followHighlight.setText(MessageManager
2165    // .getString("label.scroll_highlighted_regions"));
2166   
2167  13 seqLimit.setFont(LABEL_FONT);
2168  13 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2169  13 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2170  13 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2171  13 smoothFont.setFont(LABEL_FONT);
2172  13 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2173  13 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2174  13 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2175  13 scaleProteinToCdna.setFont(LABEL_FONT);
2176  13 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2177  13 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2178  13 scaleProteinToCdna.setText(
2179    MessageManager.getString("label.scale_protein_to_cdna"));
2180  13 scaleProteinToCdna.setToolTipText(
2181    MessageManager.getString("label.scale_protein_to_cdna_tip"));
2182  13 JLabel gapLabel = new JLabel();
2183  13 gapLabel.setFont(LABEL_FONT);
2184  13 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2185  13 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2186  13 JLabel fontLabel = new JLabel();
2187  13 fontLabel.setFont(LABEL_FONT);
2188  13 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2189  13 fontLabel.setText(MessageManager.getString("label.font"));
2190  13 fontSizeCB.setFont(LABEL_FONT);
2191  13 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2192  13 fontStyleCB.setFont(LABEL_FONT);
2193  13 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2194  13 fontNameCB.setFont(LABEL_FONT);
2195  13 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2196  13 gapSymbolCB.setFont(LABEL_FONT);
2197  13 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2198  13 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2199  13 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2200  13 gapSymbolCB.setRenderer(dlcr);
2201   
2202  13 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2203  13 startupCheckbox.setFont(LABEL_FONT);
2204  13 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2205  13 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2206  13 startupCheckbox.setSelected(true);
2207  13 startupFileTextfield.setFont(LABEL_FONT);
2208  13 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2209  13 final String tooltip = JvSwingUtils.wrapTooltip(true,
2210    MessageManager.getString("label.double_click_to_browse"));
2211  13 startupFileTextfield.setToolTipText(tooltip);
2212  13 startupFileTextfield.addMouseListener(new MouseAdapter()
2213    {
 
2214  0 toggle @Override
2215    public void mouseClicked(MouseEvent e)
2216    {
2217  0 if (e.getClickCount() > 1)
2218    {
2219  0 startupFileTextfield_mouseClicked();
2220    }
2221    }
2222    });
2223   
2224  13 sortby.setFont(LABEL_FONT);
2225  13 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2226  13 JLabel sortLabel = new JLabel();
2227  13 sortLabel.setFont(LABEL_FONT);
2228  13 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2229  13 sortLabel.setText(MessageManager.getString("label.sort_by"));
2230  13 sortAnnBy.setFont(LABEL_FONT);
2231  13 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2232  13 JLabel sortAnnLabel = new JLabel();
2233  13 sortAnnLabel.setFont(LABEL_FONT);
2234  13 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2235  13 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2236  13 sortAutocalc.setFont(LABEL_FONT);
2237  13 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2238   
2239  13 JPanel annsettingsPanel = new JPanel();
2240  13 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 101));
2241  13 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2242  13 annsettingsPanel.setBorder(new EtchedBorder());
2243  13 visualTab.add(annsettingsPanel);
2244  13 Border jb = new EmptyBorder(1, 1, 4, 5);
2245  13 annotations.setBorder(jb);
2246  13 showOccupancy.setBorder(jb);
2247  13 quality.setBorder(jb);
2248  13 conservation.setBorder(jb);
2249  13 identity.setBorder(jb);
2250  13 ssConsensus.setBorder(jb);
2251  13 showConsensbits.setBorder(jb);
2252  13 showGroupbits.setBorder(jb);
2253  13 showGroupConsensus.setBorder(jb);
2254  13 showGroupConservation.setBorder(jb);
2255  13 showConsensHistogram.setBorder(jb);
2256  13 showConsensLogo.setBorder(jb);
2257   
2258  13 JPanel autoAnnotSettings = new JPanel();
2259  13 annsettingsPanel.add(autoAnnotSettings);
2260  13 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2261  13 autoAnnotSettings.add(annotations);
2262  13 autoAnnotSettings.add(quality);
2263    // second row of autoannotation box
2264  13 autoAnnotSettings = new JPanel();
2265  13 annsettingsPanel.add(autoAnnotSettings);
2266  13 autoAnnotSettings.setLayout(new GridLayout(0, 1));
2267  13 autoAnnotSettings.add(ssConsensus);
2268   
2269    // third row of autoannotation box
2270  13 autoAnnotSettings = new JPanel();
2271  13 annsettingsPanel.add(autoAnnotSettings);
2272   
2273  13 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2274  13 autoAnnotSettings.add(conservation);
2275  13 autoAnnotSettings.add(identity);
2276  13 autoAnnotSettings.add(showOccupancy);
2277  13 autoAnnotSettings.add(showGroupbits);
2278  13 autoAnnotSettings.add(showGroupConservation);
2279  13 autoAnnotSettings.add(showGroupConsensus);
2280  13 autoAnnotSettings.add(showConsensbits);
2281  13 autoAnnotSettings.add(showConsensHistogram);
2282  13 autoAnnotSettings.add(showConsensLogo);
2283   
2284  13 JPanel tooltipSettings = new JPanel();
2285  13 tooltipSettings.setBorder(new TitledBorder(
2286    MessageManager.getString("label.sequence_id_tooltip")));
2287  13 tooltipSettings.setBounds(173, 140, 220, 62);
2288  13 tooltipSettings.setLayout(new GridLayout(2, 1));
2289  13 tooltipSettings.add(showDbRefTooltip);
2290  13 tooltipSettings.add(showNpTooltip);
2291  13 visualTab.add(tooltipSettings);
2292   
2293  13 wrap.setFont(LABEL_FONT);
2294  13 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2295  13 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2296  13 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2297  13 rightAlign.setFont(LABEL_FONT);
2298  13 rightAlign.setForeground(Color.black);
2299  13 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2300  13 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2301  13 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2302  13 idItalics.setFont(LABEL_FONT_ITALIC);
2303  13 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2304  13 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2305  13 idItalics.setText(
2306    MessageManager.getString("label.sequence_name_italics"));
2307  13 openoverv.setFont(LABEL_FONT);
2308  13 openoverv.setActionCommand(
2309    MessageManager.getString("label.open_overview"));
2310  13 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2311  13 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2312  13 openoverv.setText(MessageManager.getString("label.open_overview"));
2313  13 JPanel jPanel2 = new JPanel();
2314  13 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2315  13 jPanel2.setLayout(new GridLayout(14, 1));
2316  13 jPanel2.add(fullScreen);
2317  13 jPanel2.add(openoverv);
2318  13 jPanel2.add(seqLimit);
2319  13 jPanel2.add(rightAlign);
2320  13 jPanel2.add(fontLabel);
2321  13 jPanel2.add(showUnconserved);
2322  13 jPanel2.add(idItalics);
2323  13 jPanel2.add(smoothFont);
2324  13 jPanel2.add(scaleProteinToCdna);
2325  13 jPanel2.add(gapLabel);
2326  13 jPanel2.add(wrap);
2327  13 jPanel2.add(sortLabel);
2328  13 jPanel2.add(sortAnnLabel);
2329  13 jPanel2.add(startupCheckbox);
2330  13 visualTab.add(jPanel2);
2331  13 visualTab.add(startupFileTextfield);
2332  13 visualTab.add(sortby);
2333  13 visualTab.add(sortAnnBy);
2334  13 visualTab.add(sortAutocalc);
2335  13 visualTab.add(gapSymbolCB);
2336  13 visualTab.add(fontNameCB);
2337  13 visualTab.add(fontSizeCB);
2338  13 visualTab.add(fontStyleCB);
2339   
2340   
2341  13 if (Platform.isJS())
2342    {
2343  0 startupCheckbox.setVisible(false);
2344  0 startupFileTextfield.setVisible(false);
2345    }
2346   
2347   
2348  13 return visualTab;
2349    }
2350   
2351    /**
2352    * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2353    */
2354   
 
2355  12 toggle protected void loadLastSavedBackupsOptions()
2356    {
2357  12 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2358    .getSavedBackupEntry();
2359  12 enableBackupFiles
2360    .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2361   
2362  12 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2363    .createBackupFilesPresetEntry(Cache
2364    .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2365  12 if (backupfilesCustomEntry == null)
2366    {
2367  7 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2368    .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2369    }
2370  12 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2371    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2372    backupfilesCustomEntry);
2373   
2374  12 setComboIntStringKey(backupfilesPresetsCombo,
2375    Cache.getDefault(BackupFiles.NS + "_PRESET",
2376    BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2377   
2378  12 backupsSetOptions(savedPreset);
2379   
2380  12 backupsOptionsSetEnabled();
2381  12 updateBackupFilesExampleLabel();
2382    }
2383   
2384    /*
2385    * Load the saved Memory settings
2386    */
 
2387  13 toggle protected void loadLastSavedMemorySettings()
2388    {
2389  13 customiseMemorySetting.setSelected(
2390    Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2391  13 jvmMemoryPercentSlider
2392    .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2393  13 jvmMemoryMaxTextField.setText(
2394    Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2395    }
 
2396  0 toggle private boolean warnAboutSuffixReverseChange()
2397    {
2398  0 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2399    .getSavedBackupEntry();
2400  0 boolean savedSuffixReverse = bfpe.reverse;
2401  0 int savedSuffixDigits = bfpe.digits;
2402  0 String savedSuffixTemplate = bfpe.suffix;
2403   
2404  0 boolean nowSuffixReverse = suffixReverse.isSelected();
2405  0 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2406  0 String nowSuffixTemplate = suffixTemplate.getText();
2407  0 return nowSuffixReverse != savedSuffixReverse
2408    && nowSuffixDigits == savedSuffixDigits
2409    && nowSuffixTemplate != null
2410    && nowSuffixTemplate.equals(savedSuffixTemplate);
2411    }
2412   
2413    /* Initialises the Startup tabbed panel.
2414    *
2415    * @return
2416    * */
2417   
 
2418  13 toggle private JPanel initStartupTab()
2419    {
2420  13 JPanel startupTab = new JPanel();
2421  13 startupTab.setBorder(
2422    new TitledBorder(MessageManager.getString("label.memory")));
2423  13 startupTab.setLayout(new GridBagLayout());
2424   
2425  13 GridBagConstraints gbc = new GridBagConstraints();
2426  13 gbc.weightx = 0.0;
2427  13 gbc.weighty = 0.0;
2428  13 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2429  13 gbc.fill = GridBagConstraints.NONE;
2430   
2431  13 initMemoryPanel();
2432   
2433  13 gbc.gridheight = 1;
2434  13 gbc.gridwidth = 3;
2435   
2436  13 gbc.gridy = 0; // row 1
2437  13 gbc.gridx = 0;
2438  13 JLabel memoryText = new JLabel();
2439  13 memoryText.setFont(LABEL_FONT_ITALIC);
2440  13 memoryText
2441    .setText(MessageManager.getString("label.memory_setting_text"));
2442  13 startupTab.add(memoryText, gbc);
2443   
2444  13 gbc.gridy++; // row 2
2445  13 gbc.gridx = 0;
2446  13 JPanel exampleMemoryPanel = new JPanel();
2447  13 exampleMemoryPanel
2448    .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2449  13 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2450    MessageManager.getString("label.memory_example_tooltip")));
2451  13 JLabel exampleTextLabel = new JLabel();
2452  13 exampleTextLabel
2453    .setText(MessageManager.getString("label.memory_example_text"));
2454  13 exampleTextLabel.setForeground(Color.GRAY);
2455  13 exampleTextLabel.setFont(LABEL_FONT);
2456  13 exampleMemoryPanel.add(exampleTextLabel);
2457  13 exampleMemoryPanel.add(exampleMemoryLabel);
2458  13 exampleMemoryPanel.setBackground(Color.WHITE);
2459  13 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2460  13 startupTab.add(exampleMemoryPanel, gbc);
2461   
2462  13 gbc.gridy++; // row 3
2463  13 gbc.gridx = 0;
2464  13 startupTab.add(customiseMemorySetting, gbc);
2465   
2466  13 gbc.gridy += 2; // row 4 with a gap
2467  13 gbc.gridx = 0;
2468  13 startupTab.add(maxMemoryLabel, gbc);
2469   
2470  13 gbc.gridy += 2; // row 5
2471  13 gbc.gridx = 0;
2472  13 gbc.gridwidth = 1;
2473  13 startupTab.add(jvmMemoryPercentLabel, gbc);
2474  13 gbc.gridx++;
2475  13 startupTab.add(jvmMemoryPercentSlider, gbc);
2476  13 gbc.gridx++;
2477    // gbc.weightx = 0.1;
2478  13 startupTab.add(jvmMemoryPercentDisplay, gbc);
2479    // gbc.weightx = 1.0;
2480  13 gbc.gridwidth = 3;
2481   
2482  13 gbc.gridy++; // row 6
2483  13 gbc.gridx = 0;
2484  13 startupTab.add(jvmMemoryMaxLabel, gbc);
2485  13 gbc.gridx++;
2486  13 startupTab.add(jvmMemoryMaxTextField, gbc);
2487   
2488  13 gbc.gridy++; // row 7
2489  13 gbc.gridx = 0;
2490  13 gbc.gridwidth = 4;
2491  13 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2492  13 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2493  13 sp.setBorder(BorderFactory.createEmptyBorder());
2494  13 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2495  13 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2496  13 startupTab.add(sp, gbc);
2497   
2498    // fill empty space to push widget to top left
2499  13 gbc.gridy++;
2500  13 gbc.weighty = 1.0;
2501  13 gbc.gridx = 100;
2502  13 gbc.gridwidth = 1;
2503  13 gbc.weightx = 1.0;
2504  13 startupTab.add(new JPanel(), gbc);
2505   
2506  13 setMemoryPercentDisplay();
2507  13 memoryOptionsSetEnabled();
2508  13 return startupTab;
2509    }
2510   
 
2511  13 toggle private void initMemoryPanel()
2512    {
2513    // Enable memory settings checkbox
2514  13 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2515  13 customiseMemorySetting.setText(
2516    MessageManager.getString("label.customise_memory_settings"));
2517  13 customiseMemorySetting.addActionListener(new ActionListener()
2518    {
 
2519  0 toggle @Override
2520    public void actionPerformed(ActionEvent e)
2521    {
2522  0 memoryOptionsSetEnabled();
2523    }
2524    });
2525   
2526  13 loadLastSavedMemorySettings();
2527   
2528  13 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2529  13 exampleMemoryLabel.setBackground(Color.WHITE);
2530   
2531  13 maxMemoryLabel = new JLabel(
2532    MessageManager.getString("label.maximum_memory_used"));
2533  13 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2534   
2535    // Maximum memory percentage slider
2536  13 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2537  13 jvmMemoryPercentLabel.setText(
2538    MessageManager.getString("label.percent_of_physical_memory"));
2539  13 jvmMemoryPercentSlider.setPaintLabels(true);
2540  13 jvmMemoryPercentSlider.setPaintTicks(true);
2541  13 jvmMemoryPercentSlider.setPaintTrack(true);
2542  13 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2543  13 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2544  13 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2545    {
 
2546  0 toggle @Override
2547    public void stateChanged(ChangeEvent e)
2548    {
2549  0 setMemoryPercentDisplay();
2550    }
2551    });
2552  13 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2553  13 setMemoryPercentDisplay();
2554   
2555    // Maximum memory cap textbox
2556  13 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2557  13 jvmMemoryMaxLabel
2558    .setText(MessageManager.getString("label.maximum_memory"));
2559  13 initMemoryMaxTextField();
2560   
2561  13 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2562  13 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2563  13 exampleMemoryMessageTextArea.setEditable(false);
2564  13 exampleMemoryMessageTextArea.setLineWrap(true);
2565  13 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2566  13 exampleMemoryMessageTextArea.setText(" ");
2567  13 exampleMemoryMessageTextArea.setRows(2);
2568  13 exampleMemoryMessageTextArea.setColumns(40);
2569   
2570  13 setExampleMemoryLabel();
2571    }
2572   
 
2573  13 toggle private void initMemoryMaxTextField()
2574    {
2575  13 jvmMemoryMaxTextField.setToolTipText(
2576    MessageManager.getString("label.maximum_memory_tooltip"));
2577  13 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2578    {
 
2579  0 toggle @Override
2580    public void actionPerformed(ActionEvent arg0)
2581    {
2582  0 validateMemoryMaxTextField();
2583  0 setExampleMemoryLabel();
2584    }
2585    });
2586   
2587  13 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2588    {
 
2589  0 toggle @Override
2590    public void keyReleased(KeyEvent e)
2591    {
2592  0 validateMemoryMaxTextField();
2593  0 setExampleMemoryLabel();
2594    }
2595   
 
2596  0 toggle @Override
2597    public void keyPressed(KeyEvent e)
2598    {
2599    }
2600   
2601    // try and stop invalid typing
 
2602  0 toggle @Override
2603    public void keyTyped(KeyEvent e)
2604    {
2605  0 char c = Character.toLowerCase(e.getKeyChar());
2606  0 String text = jvmMemoryMaxTextField.getText();
2607  0 String suffixes = "tgmkb";
2608  0 int pos = jvmMemoryMaxTextField.getCaretPosition();
2609  0 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2610  0 if (!((('0' <= c && c <= '9')
2611    && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2612    // before suffix
2613    || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2614    // suffix
2615    && pos == text.length() // at end of text and
2616    && suffixPos == -1) // there isn't already one
2617    ))
2618    {
2619    // don't process
2620  0 e.consume();
2621    }
2622    }
2623    });
2624    }
2625   
 
2626  0 toggle private boolean isMemoryMaxTextFieldValid()
2627    {
2628  0 return MemorySetting
2629    .isValidMemoryString(jvmMemoryMaxTextField.getText());
2630    }
2631   
 
2632  0 toggle private void validateMemoryMaxTextField()
2633    {
2634  0 if (isMemoryMaxTextFieldValid())
2635    {
2636  0 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2637    }
2638    else
2639    {
2640  0 jvmMemoryMaxTextField.setBackground(Color.PINK);
2641    }
2642    }
2643   
 
2644  26 toggle private void setMemoryPercentDisplay()
2645    {
2646  26 jvmMemoryPercentDisplay
2647    .setText(jvmMemoryPercentSlider.getValue() + "%");
2648  26 setExampleMemoryLabel();
2649    }
2650   
 
2651  52 toggle private void setExampleMemoryLabel()
2652    {
2653  52 boolean selected = customiseMemorySetting.isSelected();
2654  52 int jvmmempc = jvmMemoryPercentSlider.getValue();
2655  52 String jvmmemmax = jvmMemoryMaxTextField.getText();
2656   
2657  52 long mem;
2658  52 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2659    && MemorySetting.isValidMemoryString(jvmmemmax))
2660    {
2661  0 mem = MemorySetting.getMemorySetting(jvmmemmax,
2662    String.valueOf(jvmmempc), false, true);
2663    }
2664    else
2665    {
2666  52 mem = MemorySetting.getMemorySetting(null, null, false, true);
2667    }
2668  52 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2669  52 String message = MemorySetting.getAdjustmentMessage();
2670  52 exampleMemoryMessageTextArea.setText(
2671    MessageManager.getString("label.adjustments_for_this_computer")
2672    + ": "
2673  52 + (message == null
2674    ? MessageManager.getString("label.none")
2675    : message));
2676    }
2677   
 
2678  13 toggle private void memoryOptionsSetEnabled()
2679    {
2680  13 boolean enabled = customiseMemorySetting.isSelected();
2681    // leave exampleMemoryLabel enabled always
2682  13 maxMemoryLabel.setEnabled(enabled);
2683  13 jvmMemoryPercentLabel.setEnabled(enabled);
2684  13 jvmMemoryPercentSlider.setEnabled(enabled);
2685  13 jvmMemoryPercentDisplay.setEnabled(enabled);
2686  13 jvmMemoryMaxLabel.setEnabled(enabled);
2687  13 jvmMemoryMaxTextField.setEnabled(enabled);
2688  13 exampleMemoryMessageTextArea.setEnabled(enabled);
2689  13 setExampleMemoryLabel();
2690    }
2691   
2692    /**
2693    * Initialises the Backups tabbed panel.
2694    *
2695    * @return
2696    */
 
2697  13 toggle private JPanel initBackupsTab()
2698    {
2699  13 JPanel backupsTab = new JPanel();
2700  13 backupsTab.setBorder(new TitledBorder(
2701    MessageManager.getString("label.backup_files")));
2702  13 backupsTab.setLayout(new GridBagLayout());
2703   
2704  13 GridBagConstraints gbc = new GridBagConstraints();
2705  13 gbc.weightx = 0.0;
2706  13 gbc.weighty = 0.0;
2707  13 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2708  13 gbc.fill = GridBagConstraints.NONE;
2709   
2710  13 initBackupsTabPresetsPanel();
2711  13 initBackupsTabSuffixPanel();
2712  13 initBackupsTabKeepFilesPanel();
2713  13 initBackupsTabFilenameExamplesPanel();
2714   
2715  13 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2716  13 enableBackupFiles
2717    .setText(MessageManager.getString("label.enable_backupfiles"));
2718  13 enableBackupFiles.addActionListener(new ActionListener()
2719    {
 
2720  0 toggle @Override
2721    public void actionPerformed(ActionEvent e)
2722    {
2723    // enable other options only when the first is checked
2724  0 backupsOptionsSetEnabled();
2725    }
2726    });
2727   
2728    // enable checkbox 1 col
2729  13 gbc.gridwidth = 1;
2730  13 gbc.gridheight = 1;
2731  13 gbc.gridx = 0;
2732  13 gbc.gridy = 0; // row 0
2733  13 backupsTab.add(enableBackupFiles, gbc);
2734   
2735    // summary of scheme box (over two rows)
2736  13 gbc.gridx = 1;
2737  13 gbc.weightx = 0.0;
2738  13 gbc.gridheight = 2;
2739  13 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2740  13 gbc.fill = GridBagConstraints.BOTH;
2741  13 backupsTab.add(exampleFilesPanel, gbc);
2742  13 gbc.gridheight = 1;
2743  13 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2744  13 gbc.fill = GridBagConstraints.NONE;
2745   
2746    // fill empty space on right
2747  13 gbc.gridx++;
2748  13 gbc.weightx = 1.0;
2749  13 backupsTab.add(new JPanel(), gbc);
2750   
2751    // schemes box
2752  13 gbc.weightx = 0.0;
2753  13 gbc.gridx = 0;
2754  13 gbc.gridy++; // row 1
2755  13 backupsTab.add(presetsPanel, gbc);
2756   
2757    // now using whole row
2758  13 gbc.gridwidth = 2;
2759  13 gbc.gridheight = 1;
2760    // keep files box
2761  13 gbc.gridx = 0;
2762  13 gbc.gridy++; // row 2
2763  13 backupsTab.add(keepfilesPanel, gbc);
2764   
2765    // filename strategy box
2766  13 gbc.gridy++; // row 3
2767  13 backupsTab.add(suffixPanel, gbc);
2768   
2769    // fill empty space
2770  13 gbc.gridy++; // row 4
2771  13 gbc.weighty = 1.0;
2772  13 backupsTab.add(new JPanel(), gbc);
2773   
2774  13 backupsOptionsSetEnabled();
2775  13 return backupsTab;
2776    }
2777   
 
2778  13 toggle private JPanel initBackupsTabPresetsPanel()
2779    {
2780   
2781  13 String title = MessageManager.getString("label.schemes");
2782   
2783  13 presetsPanel.setLayout(new GridBagLayout());
2784   
2785  13 GridBagConstraints gbc = new GridBagConstraints();
2786  13 gbc.weightx = 0.0;
2787  13 gbc.weighty = 0.0;
2788  13 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2789  13 gbc.fill = GridBagConstraints.NONE;
2790  13 gbc.gridwidth = 1;
2791  13 gbc.gridheight = 1;
2792   
2793    // "Scheme: "
2794  13 gbc.gridx = 0;
2795  13 gbc.gridy = 0;
2796   
2797  13 presetsComboLabel = new JLabel(title + ":");
2798  13 presetsPanel.add(presetsComboLabel, gbc);
2799   
2800  13 List<Object> entries = Arrays
2801    .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2802  13 List<String> tooltips = Arrays.asList(
2803    BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2804  13 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2805    tooltips);
2806    /*
2807    for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2808    {
2809    backupfilesPresetsCombo
2810    .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2811    }
2812    */
2813   
2814  13 backupfilesPresetsCombo.addActionListener(new ActionListener()
2815    {
 
2816  12 toggle @Override
2817    public void actionPerformed(ActionEvent e)
2818    {
2819  12 int key = getComboIntStringKey(backupfilesPresetsCombo);
2820  12 if (!customiseCheckbox.isSelected())
2821    {
2822  12 backupfilesPresetsComboLastSelected = key;
2823    }
2824  12 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2825    {
2826  5 if (customiseCheckbox.isSelected())
2827    {
2828    // got here by clicking on customiseCheckbox so don't change the values
2829  0 backupfilesCustomOptionsSetEnabled();
2830    }
2831    else
2832    {
2833  5 backupsTabUpdatePresets();
2834  5 backupfilesCustomOptionsSetEnabled();
2835    }
2836    }
2837    else
2838    {
2839  7 customiseCheckbox.setSelected(false);
2840  7 backupsTabUpdatePresets();
2841  7 backupfilesCustomOptionsSetEnabled();
2842    }
2843    }
2844    });
2845   
2846    // dropdown list of preset schemes
2847  13 gbc.gridx = 1;
2848  13 presetsPanel.add(backupfilesPresetsCombo, gbc);
2849   
2850  13 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2851  13 revertButton.setToolTipText(
2852    MessageManager.getString("label.cancel_changes_description"));
2853  13 revertButton.addActionListener(new ActionListener()
2854    {
 
2855  0 toggle @Override
2856    public void actionPerformed(ActionEvent e)
2857    {
2858  0 backupsSetOptions(
2859    BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2860    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2861  0 backupfilesCustomOptionsSetEnabled();
2862    }
2863   
2864    });
2865  13 revertButton.setFont(LABEL_FONT);
2866   
2867  13 customiseCheckbox.setFont(LABEL_FONT);
2868  13 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2869  13 customiseCheckbox.addActionListener(new ActionListener()
2870    {
 
2871  0 toggle @Override
2872    public void actionPerformed(ActionEvent e)
2873    {
2874  0 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2875  0 if (customiseCheckbox.isSelected())
2876    {
2877  0 backupfilesPresetsComboLastSelected = currently;
2878  0 setComboIntStringKey(backupfilesPresetsCombo,
2879    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2880    }
2881    else
2882    {
2883  0 setComboIntStringKey(backupfilesPresetsCombo,
2884    backupfilesPresetsComboLastSelected);
2885   
2886    }
2887  0 backupfilesCustomOptionsSetEnabled();
2888    }
2889    });
2890  13 customiseCheckbox.setToolTipText(
2891    MessageManager.getString("label.customise_description"));
2892   
2893    // customise checkbox
2894  13 gbc.gridx = 0;
2895  13 gbc.gridy++;
2896  13 presetsPanel.add(customiseCheckbox, gbc);
2897   
2898    // "Cancel changes" button (aligned with combo box above)
2899  13 gbc.gridx = 1;
2900  13 presetsPanel.add(revertButton, gbc);
2901   
2902  13 return presetsPanel;
2903    }
2904   
 
2905  13 toggle private JPanel initBackupsTabFilenameExamplesPanel()
2906    {
2907  13 String title = MessageManager
2908    .getString("label.scheme_examples");
2909  13 TitledBorder tb = new TitledBorder(title);
2910  13 exampleFilesPanel.setBorder(tb);
2911  13 exampleFilesPanel.setLayout(new GridBagLayout());
2912   
2913  13 backupfilesExampleLabel.setEditable(false);
2914  13 backupfilesExampleLabel
2915    .setBackground(exampleFilesPanel.getBackground());
2916   
2917  13 updateBackupFilesExampleLabel();
2918   
2919  13 GridBagConstraints gbc = new GridBagConstraints();
2920  13 gbc.weightx = 1.0;
2921  13 gbc.weighty = 1.0;
2922  13 gbc.fill = GridBagConstraints.NONE;
2923  13 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2924   
2925  13 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2926  13 return exampleFilesPanel;
2927    }
2928   
 
2929  12 toggle private void backupsTabUpdatePresets()
2930    {
2931  12 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2932    .getSelectedItem();
2933  12 int key = entry.k;
2934  12 String value = entry.v;
2935   
2936  12 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2937    .containsKey(key))
2938    {
2939  12 backupsSetOptions(
2940    BackupFilesPresetEntry.backupfilesPresetEntriesValues
2941    .get(key));
2942    }
2943    else
2944    {
2945  0 Console.error(
2946    "Preset '" + value + "' [key:" + key + "] not implemented");
2947    }
2948   
2949    // Custom options will now be enabled when the customiseCheckbox is checked
2950    // (performed above)
2951    // backupfilesCustomOptionsSetEnabled();
2952  12 updateBackupFilesExampleLabel();
2953    }
2954   
 
2955  12 toggle protected int getComboIntStringKey(
2956    JComboBox<Object> backupfilesPresetsCombo2)
2957    {
2958  12 IntKeyStringValueEntry e;
2959  12 try
2960    {
2961  12 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2962    .getSelectedItem();
2963    } catch (Exception ex)
2964    {
2965  0 Console.error(
2966    "Problem casting Combo entry to IntKeyStringValueEntry.");
2967  0 e = null;
2968    }
2969  12 return e != null ? e.k : 0;
2970    }
2971   
 
2972  12 toggle protected void setComboIntStringKey(
2973    JComboBox<Object> backupfilesPresetsCombo2,
2974    int key)
2975    {
2976  32 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2977    {
2978  32 IntKeyStringValueEntry e;
2979  32 try
2980    {
2981  32 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2982    } catch (Exception ex)
2983    {
2984  0 Console.error(
2985    "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2986  0 continue;
2987    }
2988  32 if (e.k == key)
2989    {
2990  12 backupfilesPresetsCombo2.setSelectedIndex(i);
2991  12 break;
2992    }
2993    }
2994    // backupsTabUpdatePresets();
2995    }
2996   
 
2997  13 toggle private JPanel initBackupsTabSuffixPanel()
2998    {
2999  13 suffixPanel.setBorder(new TitledBorder(
3000    MessageManager.getString("label.backup_filename_strategy")));
3001  13 suffixPanel.setLayout(new GridBagLayout());
3002   
3003  13 suffixTemplateLabel
3004    .setText(MessageManager.getString("label.append_to_filename"));
3005  13 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
3006  13 suffixTemplateLabel.setFont(LABEL_FONT);
3007   
3008  13 final String tooltip = JvSwingUtils.wrapTooltip(true,
3009    MessageManager.getString("label.append_to_filename_tooltip"));
3010  13 suffixTemplate.setToolTipText(tooltip);
3011  13 suffixTemplate.addActionListener(new ActionListener()
3012    {
 
3013  0 toggle @Override
3014    public void actionPerformed(ActionEvent e)
3015    {
3016  0 updateBackupFilesExampleLabel();
3017  0 backupfilesCustomOptionsSetEnabled();
3018  0 backupfilesRevertButtonSetEnabled(true);
3019    }
3020   
3021    });
3022  13 suffixTemplate.addKeyListener(new KeyListener()
3023    {
 
3024  0 toggle @Override
3025    public void keyReleased(KeyEvent e)
3026    {
3027  0 updateBackupFilesExampleLabel();
3028  0 backupfilesCustomOptionsSetEnabled();
3029  0 backupfilesRevertButtonSetEnabled(true);
3030    }
3031   
 
3032  0 toggle @Override
3033    public void keyPressed(KeyEvent e)
3034    {
3035    }
3036   
3037    // disable use of ':' or '/' or '\'
 
3038  0 toggle @Override
3039    public void keyTyped(KeyEvent e)
3040    {
3041  0 char c = e.getKeyChar();
3042  0 if (c == ':' || c == '/' || c == '\\')
3043    {
3044    // don't process ':' or '/' or '\'
3045  0 e.consume();
3046    }
3047    }
3048   
3049    });
3050   
3051    // digits spinner
3052  13 suffixDigitsLabel
3053    .setText(MessageManager.getString("label.index_digits"));
3054  13 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
3055  13 suffixDigitsLabel.setFont(LABEL_FONT);
3056  13 ChangeListener c = new ChangeListener()
3057    {
 
3058  5 toggle @Override
3059    public void stateChanged(ChangeEvent e)
3060    {
3061  5 backupfilesRevertButtonSetEnabled(true);
3062  5 updateBackupFilesExampleLabel();
3063    }
3064   
3065    };
3066  13 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
3067    BackupFilesPresetEntry.DIGITSMAX, 3, c);
3068   
3069  13 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
3070    MessageManager.getString("label.increment_index"));
3071  13 suffixReverse.addActionListener(new ActionListener()
3072    {
 
3073  0 toggle @Override
3074    public void actionPerformed(ActionEvent e)
3075    {
3076  0 boolean okay = true;
3077  0 if (warnAboutSuffixReverseChange())
3078    {
3079    // Warning popup
3080  0 okay = confirmSuffixReverseChange();
3081    }
3082  0 if (okay)
3083    {
3084  0 backupfilesRevertButtonSetEnabled(true);
3085  0 updateBackupFilesExampleLabel();
3086    }
3087    else
3088    {
3089  0 boolean savedSuffixReverse = BackupFilesPresetEntry
3090    .getSavedBackupEntry().reverse;
3091  0 suffixReverse.setSelected(savedSuffixReverse);
3092    }
3093    }
3094    });
3095   
3096  13 GridBagConstraints sgbc = new GridBagConstraints();
3097   
3098    // first row (template text box)
3099  13 sgbc.anchor = GridBagConstraints.WEST;
3100  13 sgbc.gridx = 0;
3101  13 sgbc.gridy = 0;
3102  13 sgbc.gridwidth = 1;
3103  13 sgbc.gridheight = 1;
3104  13 sgbc.weightx = 1.0;
3105  13 sgbc.weighty = 0.0;
3106  13 sgbc.fill = GridBagConstraints.NONE;
3107  13 suffixPanel.add(suffixTemplateLabel, sgbc);
3108   
3109  13 sgbc.gridx = 1;
3110  13 sgbc.fill = GridBagConstraints.HORIZONTAL;
3111  13 suffixPanel.add(suffixTemplate, sgbc);
3112   
3113    // second row (number of digits spinner)
3114  13 sgbc.gridy = 1;
3115   
3116  13 sgbc.gridx = 0;
3117  13 sgbc.fill = GridBagConstraints.NONE;
3118  13 suffixPanel.add(suffixDigitsLabel, sgbc);
3119   
3120  13 sgbc.gridx = 1;
3121  13 sgbc.fill = GridBagConstraints.HORIZONTAL;
3122  13 suffixPanel.add(suffixDigitsSpinner, sgbc);
3123   
3124    // third row (forward order radio selection)
3125  13 sgbc.gridx = 0;
3126  13 sgbc.gridy = 2;
3127  13 sgbc.gridwidth = GridBagConstraints.REMAINDER;
3128  13 sgbc.fill = GridBagConstraints.HORIZONTAL;
3129  13 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
3130   
3131    // fourth row (reverse order radio selection)
3132  13 sgbc.gridy = 3;
3133  13 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
3134  13 return suffixPanel;
3135    }
3136   
 
3137  0 toggle private boolean confirmSuffixReverseChange()
3138    {
3139  0 boolean ret = false;
3140  0 String warningMessage = MessageManager
3141    .getString("label.warning_confirm_change_reverse");
3142  0 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
3143    warningMessage,
3144    MessageManager.getString("label.change_increment_decrement"),
3145    JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
3146   
3147  0 ret = (confirm == JvOptionPane.YES_OPTION);
3148  0 return ret;
3149    }
3150   
 
3151  13 toggle private JPanel initBackupsTabKeepFilesPanel()
3152    {
3153  13 keepfilesPanel.setBorder(
3154    new TitledBorder(MessageManager.getString("label.keep_files")));
3155  13 keepfilesPanel.setLayout(new GridBagLayout());
3156   
3157  13 backupfilesKeepAll.setLabels(
3158    MessageManager.getString("label.keep_all_backup_files"),
3159    MessageManager.getString(
3160    "label.keep_only_this_number_of_backup_files"));
3161  13 backupfilesKeepAll.addTrueActionListener(new ActionListener()
3162    {
 
3163  0 toggle @Override
3164    public void actionPerformed(ActionEvent e)
3165    {
3166  0 backupfilesRevertButtonSetEnabled(true);
3167  0 updateBackupFilesExampleLabel();
3168    }
3169    });
3170  13 backupfilesKeepAll.addActionListener(new ActionListener()
3171    {
 
3172  0 toggle @Override
3173    public void actionPerformed(ActionEvent e)
3174    {
3175  0 backupfilesRevertButtonSetEnabled(true);
3176  0 keepRollMaxOptionsEnabled();
3177  0 updateBackupFilesExampleLabel();
3178    }
3179    });
3180   
3181  13 ChangeListener c = new ChangeListener()
3182    {
 
3183  12 toggle @Override
3184    public void stateChanged(ChangeEvent e)
3185    {
3186  12 backupfilesRevertButtonSetEnabled(true);
3187  12 updateBackupFilesExampleLabel();
3188    }
3189   
3190    };
3191  13 setIntegerSpinner(backupfilesRollMaxSpinner,
3192    BackupFilesPresetEntry.ROLLMAXMIN,
3193    BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3194   
3195  13 backupfilesConfirmDelete.setLabels(
3196    MessageManager.getString("label.always_ask"),
3197    MessageManager.getString("label.auto_delete"));
3198  13 backupfilesConfirmDelete.addActionListener(new ActionListener()
3199    {
 
3200  0 toggle @Override
3201    public void actionPerformed(ActionEvent e)
3202    {
3203  0 backupfilesRevertButtonSetEnabled(true);
3204    }
3205    });
3206    // update the enabled section
3207  13 keepRollMaxOptionsEnabled();
3208   
3209  13 GridBagConstraints kgbc = new GridBagConstraints();
3210   
3211    // first row (template text box)
3212  13 kgbc.anchor = GridBagConstraints.WEST;
3213  13 kgbc.gridx = 0;
3214  13 kgbc.gridy = 0;
3215  13 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3216  13 kgbc.gridheight = 1;
3217  13 kgbc.weightx = 1.0;
3218  13 kgbc.weighty = 0.0;
3219  13 kgbc.fill = GridBagConstraints.HORIZONTAL;
3220  13 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3221   
3222    // second row
3223  13 kgbc.gridy = 1;
3224   
3225  13 kgbc.gridx = 0;
3226  13 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3227  13 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3228   
3229  13 kgbc.gridx = 1;
3230  13 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3231  13 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3232   
3233    // third row (indented)
3234  13 kgbc.gridy = 2;
3235  13 kgbc.insets = new Insets(0, 20, 0, 0);
3236   
3237  13 kgbc.gridx = 0;
3238  13 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3239  13 kgbc.fill = GridBagConstraints.HORIZONTAL;
3240  13 kgbc.weightx = 1.0;
3241   
3242  13 JPanel jp = new JPanel();
3243  13 jp.setLayout(new FlowLayout());
3244  13 oldBackupFilesLabel
3245    .setText(MessageManager
3246    .getString("label.autodelete_old_backup_files"));
3247  13 oldBackupFilesLabel.setFont(LABEL_FONT);
3248  13 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3249  13 jp.add(oldBackupFilesLabel);
3250  13 jp.add(backupfilesConfirmDelete.getTrueButton());
3251  13 jp.add(backupfilesConfirmDelete.getFalseButton());
3252  13 keepfilesPanel.add(jp, kgbc);
3253   
3254  13 return keepfilesPanel;
3255    }
3256   
 
3257  54 toggle protected void updateBackupFilesExampleLabel()
3258    {
3259  54 int exampleindex = 12;
3260  54 String base = MessageManager.getString("label.filename") + ".fa";
3261  54 if (base == null || base.length() == 0)
3262    {
3263  0 base = "file_name.fa";
3264    }
3265   
3266  54 boolean reverse = suffixReverse.isSelected();
3267  54 boolean keepAll = backupfilesKeepAll.isSelected();
3268  54 int rollMax = 4;
3269  54 String suffix = suffixTemplate.getText();
3270  54 int digits = 3;
3271   
3272  54 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3273  54 if (suffix == null || suffix.length() == 0)
3274    {
3275  13 backupfilesExampleLabel
3276    .setText(MessageManager.getString("label.no_backup_files"));
3277  13 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3278  13 return;
3279    }
3280   
3281  41 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3282  41 rollMax = rollMax < 1 ? 1 : rollMax;
3283   
3284  41 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3285    {
3286  0 rollMax = 1;
3287    }
3288   
3289  41 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3290  41 digits = digits < 1 ? 1 : digits;
3291   
3292  41 int lowersurround = 2;
3293  41 int uppersurround = 0;
3294  41 StringBuilder exampleSB = new StringBuilder();
3295  41 boolean firstLine = true;
3296  41 int lineNumber = 0;
3297  41 if (reverse)
3298    {
3299   
3300  0 int min = 1;
3301  0 int max = keepAll ? exampleindex : rollMax;
3302  0 for (int index = min; index <= max; index++)
3303    {
3304  0 if (index == min + lowersurround && index < max - uppersurround - 1)
3305    {
3306  0 exampleSB.append("\n...");
3307  0 lineNumber++;
3308    }
3309  0 else if (index > min + lowersurround && index < max - uppersurround)
3310    {
3311    // nothing
3312    }
3313    else
3314    {
3315  0 if (firstLine)
3316    {
3317  0 firstLine = false;
3318    }
3319    else
3320    {
3321  0 exampleSB.append("\n");
3322  0 lineNumber++;
3323    }
3324  0 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3325    base, suffix, digits));
3326  0 if (min == max)
3327    {
3328    // no extra text needed
3329    }
3330  0 else if (index == min)
3331    {
3332  0 String newest = MessageManager.getString("label.braced_newest");
3333  0 if (newest != null && newest.length() > 0)
3334    {
3335  0 exampleSB.append(" " + newest);
3336    }
3337    }
3338  0 else if (index == max)
3339    {
3340  0 String oldest = MessageManager.getString("label.braced_oldest");
3341  0 if (oldest != null && oldest.length() > 0)
3342    {
3343  0 exampleSB.append(" " + oldest);
3344    }
3345    }
3346    }
3347    }
3348    }
3349    else
3350    {
3351   
3352  41 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3353    : exampleindex - rollMax + 1;
3354  41 int max = exampleindex;
3355   
3356  139 for (int index = min; index <= max; index++)
3357    {
3358   
3359  98 if (index == min + lowersurround && index < max - uppersurround - 1)
3360    {
3361  0 exampleSB.append("\n...");
3362  0 lineNumber++;
3363    }
3364  98 else if (index > min + lowersurround && index < max - uppersurround)
3365    {
3366    // nothing
3367    }
3368    else
3369    {
3370  98 if (firstLine)
3371    {
3372  41 firstLine = false;
3373    }
3374    else
3375    {
3376  57 exampleSB.append("\n");
3377  57 lineNumber++;
3378    }
3379  98 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3380    base, suffix, digits));
3381  98 if (min == max)
3382    {
3383    // no extra text needed
3384    }
3385  93 else if (index == min)
3386    {
3387  36 String oldest = MessageManager.getString("label.braced_oldest");
3388  36 if (oldest != null && oldest.length() > 0)
3389    {
3390  36 exampleSB.append(" " + oldest);
3391    }
3392    }
3393  57 else if (index == max)
3394    {
3395  36 String newest = MessageManager.getString("label.braced_newest");
3396  36 if (newest != null && newest.length() > 0)
3397    {
3398  36 exampleSB.append(" " + newest);
3399    }
3400    }
3401    }
3402    }
3403   
3404    }
3405   
3406    // add some extra empty lines to pad out the example files box. ugh, please tell
3407    // me how to do this better
3408  41 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3409  41 if (remainingLines > 0)
3410    {
3411  107 for (int i = 0; i < remainingLines; i++)
3412    {
3413  66 exampleSB.append("\n ");
3414  66 lineNumber++;
3415    }
3416    }
3417   
3418  41 backupfilesExampleLabel.setText(exampleSB.toString());
3419    }
3420   
 
3421  13 toggle protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3422    boolean useExistingVal, ChangeListener c)
3423    {
3424  13 int i = def;
3425  13 if (useExistingVal)
3426    {
3427  13 try
3428    {
3429  13 i = ((Integer) s.getValue()).intValue();
3430    } catch (Exception e)
3431    {
3432  0 Console.error(
3433    "Exception casting the initial value of s.getValue()");
3434    }
3435    }
3436   
3437  13 setIntegerSpinner(s, min, max, i, c);
3438    }
3439   
 
3440  26 toggle protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3441    ChangeListener c)
3442    {
3443    // integer spinner for number of digits
3444  26 if (def > max)
3445    {
3446  0 max = def;
3447    }
3448  26 if (def < min)
3449    {
3450  13 def = min;
3451    }
3452  26 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3453  26 s.setModel(sModel);
3454   
3455  26 s.addChangeListener(c);
3456   
3457    }
3458   
 
3459  82 toggle protected static int getSpinnerInt(JSpinner s, int def)
3460    {
3461  82 int i = def;
3462  82 try
3463    {
3464  82 s.commitEdit();
3465  82 i = (Integer) s.getValue();
3466    } catch (Exception e)
3467    {
3468  0 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3469    }
3470  82 return i;
3471    }
3472   
 
3473  50 toggle private void keepRollMaxOptionsEnabled()
3474    {
3475  50 boolean enabled = backupfilesKeepAll.isEnabled()
3476    && !backupfilesKeepAll.isSelected();
3477  50 oldBackupFilesLabel.setEnabled(enabled);
3478  50 backupfilesRollMaxSpinner.setEnabled(enabled);
3479  50 backupfilesConfirmDelete.setEnabled(enabled);
3480    }
3481   
 
3482  37 toggle private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3483    {
3484  37 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3485    && customiseCheckbox.isSelected()
3486    && suffixTemplate.getText()
3487    .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3488  37 keepfilesPanel.setEnabled(enabled);
3489  37 backupfilesKeepAll.setEnabled(enabled);
3490  37 oldBackupFilesLabel.setEnabled(enabled);
3491  37 keepRollMaxOptionsEnabled();
3492    }
3493   
 
3494  37 toggle private void backupfilesSuffixTemplateDigitsSetEnabled()
3495    {
3496  37 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3497    .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3498  37 suffixDigitsLabel.setEnabled(enabled);
3499  37 suffixDigitsSpinner.setEnabled(enabled);
3500  37 suffixReverse.setEnabled(enabled);
3501    }
3502   
 
3503  37 toggle private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3504    {
3505  37 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3506    && customiseCheckbox.isSelected();
3507  37 suffixPanel.setEnabled(enabled);
3508  37 suffixTemplateLabel.setEnabled(enabled);
3509  37 suffixTemplate.setEnabled(enabled);
3510  37 backupfilesSuffixTemplateDigitsSetEnabled();
3511    }
3512   
 
3513  54 toggle private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3514    {
3515  54 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3516    && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3517  54 revertButton.setEnabled(enabled);
3518    }
3519   
 
3520  0 toggle private boolean backupfilesCustomChanged()
3521    {
3522  0 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3523    .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3524  0 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3525  0 return !custom.equals(current);
3526    }
3527   
 
3528  0 toggle protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3529    {
3530  0 String suffix = suffixTemplate.getText();
3531  0 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3532  0 boolean reverse = suffixReverse.isSelected();
3533  0 boolean keepAll = backupfilesKeepAll.isSelected();
3534  0 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3535  0 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3536   
3537  0 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3538    reverse, keepAll, rollMax, confirmDelete);
3539   
3540  0 return bfpe;
3541    }
3542   
 
3543  37 toggle protected void backupfilesCustomOptionsSetEnabled()
3544    {
3545  37 boolean enabled = customiseCheckbox.isSelected();
3546   
3547  37 backupfilesRevertButtonSetEnabled(enabled);
3548  37 backupfilesSuffixTemplateSetEnabled(enabled);
3549  37 backupfilesKeepAllSetEnabled(enabled);
3550    }
3551   
 
3552  25 toggle private void backupfilesSummarySetEnabled()
3553    {
3554  25 boolean enabled = enableBackupFiles.isSelected();
3555  25 backupfilesExampleLabel.setEnabled(enabled);
3556  25 exampleFilesPanel.setEnabled(enabled);
3557    }
3558   
 
3559  25 toggle private void backupfilesPresetsSetEnabled()
3560    {
3561  25 boolean enabled = enableBackupFiles.isSelected();
3562  25 presetsPanel.setEnabled(enabled);
3563  25 presetsComboLabel.setEnabled(enabled);
3564  25 backupfilesPresetsCombo.setEnabled(enabled);
3565  25 customiseCheckbox.setEnabled(enabled);
3566  25 revertButton.setEnabled(enabled);
3567    }
3568   
 
3569  25 toggle protected void backupsOptionsSetEnabled()
3570    {
3571  25 backupfilesPresetsSetEnabled();
3572  25 backupfilesSummarySetEnabled();
3573  25 backupfilesCustomOptionsSetEnabled();
3574    }
3575   
 
3576  24 toggle protected void backupsSetOptions(String suffix, int digits,
3577    boolean reverse, boolean keepAll, int rollMax,
3578    boolean confirmDelete)
3579    {
3580  24 suffixTemplate.setText(suffix);
3581  24 suffixDigitsSpinner.setValue(digits);
3582  24 suffixReverse.setSelected(reverse);
3583  24 backupfilesKeepAll.setSelected(keepAll);
3584  24 backupfilesRollMaxSpinner.setValue(rollMax);
3585  24 backupfilesConfirmDelete.setSelected(confirmDelete);
3586    }
3587   
 
3588  24 toggle protected void backupsSetOptions(BackupFilesPresetEntry p)
3589    {
3590  24 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3591    p.confirmDelete);
3592    }
3593   
 
3594  0 toggle protected void autoIdWidth_actionPerformed()
3595    {
3596    // TODO Auto-generated method stub
3597   
3598    }
3599   
 
3600  0 toggle protected void userIdWidth_actionPerformed()
3601    {
3602    // TODO Auto-generated method stub
3603   
3604    }
3605   
 
3606  0 toggle protected void maxColour_actionPerformed(JPanel panel)
3607    {
3608    }
3609   
 
3610  0 toggle protected void minColour_actionPerformed(JPanel panel)
3611    {
3612    }
3613   
 
3614  0 toggle protected void gapColour_actionPerformed(JPanel panel)
3615    {
3616    }
3617   
 
3618  0 toggle protected void hiddenColour_actionPerformed(JPanel panel)
3619    {
3620    }
3621   
 
3622  0 toggle protected void showunconserved_actionPerformed(ActionEvent e)
3623    {
3624    // TODO Auto-generated method stub
3625   
3626    }
3627   
 
3628  0 toggle protected void useLegacyGaps_actionPerformed(ActionEvent e)
3629    {
3630    }
3631   
 
3632  0 toggle protected void resetOvDefaults_actionPerformed(ActionEvent e)
3633    {
3634    }
3635   
3636    /**
3637    * DOCUMENT ME!
3638    *
3639    * @param e
3640    * DOCUMENT ME!
3641    */
 
3642  0 toggle public void ok_actionPerformed(ActionEvent e)
3643    {
3644    }
3645   
3646    /**
3647    * DOCUMENT ME!
3648    *
3649    * @param e
3650    * DOCUMENT ME!
3651    */
 
3652  0 toggle public void cancel_actionPerformed(ActionEvent e)
3653    {
3654    }
3655   
3656    /**
3657    * DOCUMENT ME!
3658    *
3659    * @param e
3660    * DOCUMENT ME!
3661    */
 
3662  0 toggle public void annotations_actionPerformed(ActionEvent e)
3663    {
3664    }
3665   
3666    /**
3667    * DOCUMENT ME!
3668    */
 
3669  0 toggle public void startupFileTextfield_mouseClicked()
3670    {
3671    }
3672   
 
3673  0 toggle public void newLink_actionPerformed(ActionEvent e)
3674    {
3675   
3676    }
3677   
 
3678  0 toggle public void editLink_actionPerformed(ActionEvent e)
3679    {
3680   
3681    }
3682   
 
3683  0 toggle public void deleteLink_actionPerformed(ActionEvent e)
3684    {
3685   
3686    }
3687   
 
3688  0 toggle public void defaultBrowser_mouseClicked(MouseEvent e)
3689    {
3690   
3691    }
3692   
 
3693  0 toggle public void linkURLList_keyTyped(KeyEvent e)
3694    {
3695   
3696    }
3697   
 
3698  25 toggle public void setProxyAuthEnabled()
3699    {
3700  25 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3701  25 proxyAuthUsernameLabel.setEnabled(enabled);
3702  25 proxyAuthPasswordLabel.setEnabled(enabled);
3703  25 passwordNotStoredLabel.setEnabled(enabled);
3704  25 proxyAuthUsernameTB.setEnabled(enabled);
3705  25 proxyAuthPasswordPB.setEnabled(enabled);
3706    }
3707   
 
3708  25 toggle public void setCustomProxyEnabled()
3709    {
3710  25 boolean enabled = customProxy.isSelected();
3711  25 portLabel.setEnabled(enabled);
3712  25 serverLabel.setEnabled(enabled);
3713  25 portLabel2.setEnabled(enabled);
3714  25 serverLabel2.setEnabled(enabled);
3715  25 httpLabel.setEnabled(enabled);
3716  25 httpsLabel.setEnabled(enabled);
3717  25 proxyServerHttpTB.setEnabled(enabled);
3718  25 proxyPortHttpTB.setEnabled(enabled);
3719  25 proxyServerHttpsTB.setEnabled(enabled);
3720  25 proxyPortHttpsTB.setEnabled(enabled);
3721  25 proxyAuth.setEnabled(enabled);
3722  25 setProxyAuthEnabled();
3723    }
3724   
 
3725  0 toggle public void proxyType_actionPerformed()
3726    {
3727  0 setCustomProxyEnabled();
3728  0 proxyAuthPasswordCheckHighlight(true);
3729  0 applyProxyButtonEnabled(true);
3730    }
3731   
 
3732  0 toggle public void proxyAuth_actionPerformed()
3733    {
3734  0 setProxyAuthEnabled();
3735  0 proxyAuthPasswordCheckHighlight(true);
3736  0 applyProxyButtonEnabled(true);
3737    }
3738   
3739    /**
3740    * Customer renderer for JTable: supports column of radio buttons
3741    */
 
3742    public class RadioButtonRenderer extends JRadioButton
3743    implements TableCellRenderer
3744    {
 
3745  12 toggle public RadioButtonRenderer()
3746    {
3747  12 setHorizontalAlignment(CENTER);
3748  12 setToolTipText(MessageManager.getString("label.urltooltip"));
3749    }
3750   
 
3751  12 toggle @Override
3752    public Component getTableCellRendererComponent(JTable table,
3753    Object value, boolean isSelected, boolean hasFocus, int row,
3754    int column)
3755    {
3756  12 setSelected((boolean) value);
3757   
3758    // set colours to match rest of table
3759  12 if (isSelected)
3760    {
3761  0 setBackground(table.getSelectionBackground());
3762  0 setForeground(table.getSelectionForeground());
3763    }
3764    else
3765    {
3766  12 setBackground(table.getBackground());
3767  12 setForeground(table.getForeground());
3768    }
3769  12 return this;
3770    }
3771    }
3772   
3773    /**
3774    * Customer cell editor for JTable: supports column of radio buttons in
3775    * conjunction with renderer
3776    */
 
3777    public class RadioButtonEditor extends AbstractCellEditor
3778    implements TableCellEditor
3779    {
3780    private JRadioButton button = new JRadioButton();
3781   
 
3782  12 toggle public RadioButtonEditor()
3783    {
3784  12 button.setHorizontalAlignment(SwingConstants.CENTER);
3785  12 this.button.addActionListener(new ActionListener()
3786    {
 
3787  0 toggle @Override
3788    public void actionPerformed(ActionEvent e)
3789    {
3790  0 fireEditingStopped();
3791    }
3792    });
3793    }
3794   
 
3795  0 toggle @Override
3796    public Component getTableCellEditorComponent(JTable table, Object value,
3797    boolean isSelected, int row, int column)
3798    {
3799  0 button.setSelected((boolean) value);
3800  0 return button;
3801    }
3802   
 
3803  0 toggle @Override
3804    public Object getCellEditorValue()
3805    {
3806  0 return button.isSelected();
3807    }
3808   
3809    }
3810   
 
3811  0 toggle protected void validateHmmerPath()
3812    {
3813    }
3814   
 
3815  0 toggle protected void validateCygwinPath()
3816    {
3817    }
3818   
3819    /**
3820    * A helper method to add a panel containing a label and a component to a
3821    * panel
3822    *
3823    * @param panel
3824    * @param tooltip
3825    * @param label
3826    * @param valBox
3827    */
 
3828  52 toggle protected static void addtoLayout(JPanel panel, String tooltip,
3829    JComponent label, JComponent valBox)
3830    {
3831  52 JPanel laypanel = new JPanel(new GridLayout(1, 2));
3832  52 JPanel labPanel = new JPanel(new BorderLayout());
3833  52 JPanel valPanel = new JPanel();
3834  52 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
3835  52 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
3836  52 labPanel.add(label, BorderLayout.WEST);
3837  52 valPanel.add(valBox);
3838  52 laypanel.add(labPanel);
3839  52 laypanel.add(valPanel);
3840  52 valPanel.setToolTipText(tooltip);
3841  52 labPanel.setToolTipText(tooltip);
3842  52 valBox.setToolTipText(tooltip);
3843  52 panel.add(laypanel);
3844  52 panel.validate();
3845    }
3846    }