Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.jbgui

File GPreferences.java

 

Coverage histogram

../../img/srcFileCovDistChart8.png
20% 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  11 toggle public GPreferences()
442    {
443  11 try
444    {
445  11 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  11 toggle private void jbInit() throws Exception
458    {
459    // final JTabbedPane tabbedPane = new JTabbedPane();
460  11 this.setLayout(new BorderLayout());
461   
462    // message label at top
463  11 this.add(messageLabel, BorderLayout.NORTH);
464   
465  11 JPanel okCancelPanel = initOkCancelPanel();
466  11 this.add(tabbedPane, BorderLayout.CENTER);
467  11 this.add(okCancelPanel, BorderLayout.SOUTH);
468   
469  11 tabbedPane.add(initVisualTab(),
470    MessageManager.getString("label.visual"));
471   
472  11 tabbedPane.add(initColoursTab(),
473    MessageManager.getString("label.colours"));
474   
475  11 tabbedPane.add(initOverviewTab(),
476    MessageManager.getString("label.overview"));
477   
478  11 tabbedPane.add(initStructureTab(),
479    MessageManager.getString("label.structure"));
480   
481  11 tabbedPane.add(initConnectionsTab(),
482    MessageManager.getString("label.connections"));
483   
484  11 if (!Platform.isJS())
485    {
486  11 tabbedPane.add(initBackupsTab(),
487    MessageManager.getString("label.backups"));
488    }
489   
490  11 tabbedPane.add(initLinksTab(),
491    MessageManager.getString("label.urllinks"));
492   
493  11 tabbedPane.add(initOutputTab(),
494    MessageManager.getString("label.output"));
495   
496  11 tabbedPane.add(initEditingTab(),
497    MessageManager.getString("label.editing"));
498   
499    /*
500    * See WsPreferences for the real work of configuring this tab.
501    */
502  11 if (!Platform.isJS())
503    {
504  11 tabbedPane.add(initHMMERTab(), MessageManager.getString("label.hmmer"));
505  11 tabbedPane.add(initStartupTab(),
506    MessageManager.getString("label.startup"));
507  11 wsTab.setLayout(new BorderLayout());
508  11 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
509    }
510   
511  11 slivkaTab.setLayout(new BorderLayout());
512  11 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  11 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  11 toggle private JPanel initEditingTab()
599    {
600  11 JPanel editingTab = new JPanel();
601  11 editingTab.setLayout(null);
602  11 autoCalculateConsCheck.setFont(LABEL_FONT);
603  11 autoCalculateConsCheck.setText(
604    MessageManager.getString("label.autocalculate_consensus"));
605  11 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
606  11 padGaps.setFont(LABEL_FONT);
607  11 padGaps.setText(
608    MessageManager.getString("label.pad_gaps_when_editing"));
609  11 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
610  11 sortByTree.setFont(LABEL_FONT);
611  11 sortByTree
612    .setText(MessageManager.getString("label.sort_with_new_tree"));
613  11 sortByTree.setToolTipText(MessageManager.getString(
614    "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
615  11 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
616  11 editingTab.add(autoCalculateConsCheck);
617  11 editingTab.add(padGaps);
618  11 editingTab.add(sortByTree);
619  11 return editingTab;
620    }
621   
622    /**
623    * Initialises the hmmer tabbed panel
624    *
625    * @return
626    */
 
627  11 toggle private JPanel initHMMERTab()
628    {
629  11 hmmerTab = new JPanel();
630  11 hmmerTab.setLayout(new BoxLayout(hmmerTab, BoxLayout.Y_AXIS));
631  11 hmmerTab.setLayout(new MigLayout("flowy"));
632   
633    /*
634    * path to hmmer binaries folder
635    */
636  11 JPanel installationPanel = new JPanel(new MigLayout("flowy"));
637    // new FlowLayout(FlowLayout.LEFT));
638  11 JvSwingUtils.createTitledBorder(installationPanel,
639    MessageManager.getString("label.installation"), true);
640  11 hmmerTab.add(installationPanel);
641  11 JLabel hmmerLocation = new JLabel(
642    MessageManager.getString("label.hmmer_location"));
643  11 hmmerLocation.setFont(LABEL_FONT);
644  11 final int pathFieldLength = 40;
645  11 hmmerPath = new JTextField(pathFieldLength);
646  11 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  11 installationPanel.add(hmmerLocation);
663  11 installationPanel.add(hmmerPath);
664   
665    /*
666    * path to Cygwin binaries folder (for Windows)
667    */
668  11 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  11 JPanel alignOptionsPanel = new JPanel(new MigLayout());
698    // new FlowLayout(FlowLayout.LEFT));
699  11 JvSwingUtils.createTitledBorder(alignOptionsPanel,
700    MessageManager.getString("label.hmmalign_options"), true);
701  11 hmmerTab.add(alignOptionsPanel);
702  11 hmmrTrimTermini = new JCheckBox();
703  11 hmmrTrimTermini.setFont(LABEL_FONT);
704  11 hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
705  11 alignOptionsPanel.add(hmmrTrimTermini);
706   
707    /*
708    * preferences for hmmsearch
709    */
710  11 JPanel searchOptions = new JPanel(new MigLayout());
711    // FlowLayout(FlowLayout.LEFT));
712  11 JvSwingUtils.createTitledBorder(searchOptions,
713    MessageManager.getString("label.hmmsearch_options"), true);
714  11 hmmerTab.add(searchOptions);
715  11 JLabel sequencesToKeep = new JLabel(
716    MessageManager.getString("label.no_of_sequences"));
717  11 sequencesToKeep.setFont(LABEL_FONT);
718  11 searchOptions.add(sequencesToKeep);
719  11 hmmerSequenceCount = new JTextField(5);
720  11 searchOptions.add(hmmerSequenceCount);
721   
722    /*
723    * preferences for Information Content annotation
724    */
725    // JPanel dummy = new JPanel(new FlowLayout(FlowLayout.LEFT));
726  11 JPanel annotationOptions = new JPanel(new MigLayout("left"));
727  11 JvSwingUtils.createTitledBorder(annotationOptions,
728    MessageManager.getString("label.information_annotation"), true);
729    // dummy.add(annotationOptions);
730  11 hmmerTab.add(annotationOptions);
731  11 ButtonGroup backgroundOptions = new ButtonGroup();
732  11 hmmerBackgroundUniprot = new JRadioButton(
733    MessageManager.getString("label.freq_uniprot"));
734  11 hmmerBackgroundUniprot.setFont(LABEL_FONT);
735  11 hmmerBackgroundAlignment = new JRadioButton(
736    MessageManager.getString("label.freq_alignment"));
737  11 hmmerBackgroundAlignment.setFont(LABEL_FONT);
738  11 backgroundOptions.add(hmmerBackgroundUniprot);
739  11 backgroundOptions.add(hmmerBackgroundAlignment);
740  11 backgroundOptions.setSelected(hmmerBackgroundUniprot.getModel(), true);
741    // disable buttons for now as annotation only uses Uniprot background
742  11 hmmerBackgroundAlignment.setEnabled(false);
743  11 hmmerBackgroundUniprot.setEnabled(false);
744  11 annotationOptions.add(hmmerBackgroundUniprot, "wrap");
745  11 annotationOptions.add(hmmerBackgroundAlignment);
746   
747  11 return hmmerTab;
748    }
749   
750    /**
751    * Initialises the Output tabbed panel.
752    *
753    * @return
754    */
 
755  11 toggle private JPanel initOutputTab()
756    {
757  11 JPanel outputTab = new JPanel();
758  11 outputTab.setLayout(null);
759   
760  11 JLabel epsLabel = new JLabel(
761    MessageManager.formatMessage("label.rendering_style", "EPS"));
762  11 epsLabel.setFont(LABEL_FONT);
763  11 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
764  11 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
765  11 epsRendering.setFont(LABEL_FONT);
766  11 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
767  11 JLabel htmlLabel = new JLabel(
768    MessageManager.formatMessage("label.rendering_style", "HTML"));
769  11 htmlLabel.setFont(LABEL_FONT);
770  11 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
771  11 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
772  11 htmlRendering.setFont(LABEL_FONT);
773  11 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
774  11 JLabel svgLabel = new JLabel(
775    MessageManager.formatMessage("label.rendering_style", "SVG"));
776  11 svgLabel.setFont(LABEL_FONT);
777  11 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
778  11 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
779  11 svgRendering.setFont(LABEL_FONT);
780  11 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
781   
782  11 JLabel jLabel1 = new JLabel();
783  11 jLabel1.setFont(LABEL_FONT);
784  11 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
785  11 jLabel1.setText(MessageManager.getString("label.append_start_end"));
786  11 jLabel1.setFont(LABEL_FONT);
787   
788  11 fastajv.setFont(LABEL_FONT);
789  11 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
790  11 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
791  11 blcjv.setText(MessageManager.getString("label.blc") + " ");
792  11 fastajv.setText(MessageManager.getString("label.fasta") + " ");
793  11 msfjv.setText(MessageManager.getString("label.msf") + " ");
794  11 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
795  11 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
796  11 msfjv.setFont(LABEL_FONT);
797  11 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
798  11 pirjv.setText(MessageManager.getString("label.pir") + " ");
799  11 JPanel jPanel11 = new JPanel();
800  11 jPanel11.setFont(LABEL_FONT);
801  11 TitledBorder titledBorder2 = new TitledBorder(
802    MessageManager.getString("label.file_output"));
803  11 jPanel11.setBorder(titledBorder2);
804  11 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
805  11 GridLayout gridLayout3 = new GridLayout();
806  11 jPanel11.setLayout(gridLayout3);
807  11 gridLayout3.setRows(8);
808  11 blcjv.setFont(LABEL_FONT);
809  11 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
810  11 clustaljv.setFont(LABEL_FONT);
811  11 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
812  11 pfamjv.setFont(LABEL_FONT);
813  11 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
814  11 pileupjv.setFont(LABEL_FONT);
815  11 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
816  11 pirjv.setFont(LABEL_FONT);
817  11 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
818  11 autoIdWidth.setFont(LABEL_FONT);
819  11 autoIdWidth.setText(
820    MessageManager.getString("label.automatically_set_id_width"));
821  11 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
822    .getString("label.adjusts_width_generated_eps_png")));
823  11 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
824  11 autoIdWidth.addActionListener(new ActionListener()
825    {
826   
 
827  0 toggle @Override
828    public void actionPerformed(ActionEvent e)
829    {
830  0 autoIdWidth_actionPerformed();
831    }
832    });
833  11 userIdWidthlabel.setFont(LABEL_FONT);
834  11 userIdWidthlabel.setText(
835    MessageManager.getString("label.figure_id_column_width"));
836  11 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
837    .getString("label.manually_specify_width_left_column")));
838  11 userIdWidthlabel.setToolTipText(
839    JvSwingUtils.wrapTooltip(true, MessageManager.getString(
840    "label.manually_specify_width_left_column")));
841  11 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
842  11 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
843  11 userIdWidth.setText("");
844  11 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
845  11 userIdWidth.addActionListener(new ActionListener()
846    {
847   
 
848  0 toggle @Override
849    public void actionPerformed(ActionEvent e)
850    {
851  0 userIdWidth_actionPerformed();
852    }
853    });
854  11 modellerOutput.setFont(LABEL_FONT);
855  11 modellerOutput
856    .setText(MessageManager.getString("label.use_modeller_output"));
857  11 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
858  11 embbedBioJSON.setFont(LABEL_FONT);
859  11 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
860  11 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
861   
862  11 jPanel11.add(jLabel1);
863  11 jPanel11.add(blcjv);
864  11 jPanel11.add(clustaljv);
865  11 jPanel11.add(fastajv);
866  11 jPanel11.add(msfjv);
867  11 jPanel11.add(pfamjv);
868  11 jPanel11.add(pileupjv);
869  11 jPanel11.add(pirjv);
870  11 outputTab.add(autoIdWidth);
871  11 outputTab.add(userIdWidth);
872  11 outputTab.add(userIdWidthlabel);
873  11 outputTab.add(modellerOutput);
874  11 if (!Platform.isJS())
875    {
876    /*
877    * JalviewJS doesn't support Lineart option or SVG output
878    */
879  11 outputTab.add(embbedBioJSON);
880  11 outputTab.add(epsLabel);
881  11 outputTab.add(epsRendering);
882  11 outputTab.add(htmlLabel);
883  11 outputTab.add(htmlRendering);
884  11 outputTab.add(svgLabel);
885  11 outputTab.add(svgRendering);
886    }
887  11 outputTab.add(jPanel11);
888  11 return outputTab;
889    }
890   
891    /**
892    * Initialises the Connections tabbed panel.
893    *
894    * @return
895    */
 
896  11 toggle private JPanel initConnectionsTab()
897    {
898  11 connectTab = new JPanel();
899  11 connectTab.setLayout(new GridBagLayout());
900   
901   
902  11 JPanel proxyPanel = initConnTabProxyPanel();
903  11 initConnTabCheckboxes();
904   
905    // Add proxy server panel
906  11 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  11 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  11 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  11 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  11 versioncheck.setVisible(false);
925   
926    // Add padding so the panel doesn't look ridiculous
927  11 JPanel spacePanel = new JPanel();
928  11 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  11 return connectTab;
934    }
935   
936    /**
937    * Initialises the Links tabbed panel.
938    *
939    * @return
940    */
 
941  11 toggle private JPanel initLinksTab()
942    {
943  11 JPanel linkTab = new JPanel();
944  11 linkTab.setLayout(new GridBagLayout());
945   
946    // Set up table for Url links
947  11 linkUrlTable.getTableHeader().setReorderingAllowed(false);
948  11 linkUrlTable.setFillsViewportHeight(true);
949  11 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
950  11 linkUrlTable.setAutoCreateRowSorter(true);
951  11 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  11 JRadioButton temp = new JRadioButton();
957  11 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
958   
959    // Table in scrollpane so that the table is given a scrollbar
960  11 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
961  11 linkScrollPane.setBorder(null);
962   
963    // Panel for links functionality
964  11 JPanel linkPanel = new JPanel(new GridBagLayout());
965  11 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  11 JPanel buttonPanel = initLinkTabUrlButtons();
972  11 GridBagConstraints linkConstraints1 = new GridBagConstraints();
973  11 linkConstraints1.insets = new Insets(0, 0, 5, 0);
974  11 linkConstraints1.gridx = 0;
975  11 linkConstraints1.gridy = 0;
976  11 linkConstraints1.weightx = 1.0;
977  11 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
978  11 linkTab.add(buttonPanel, linkConstraints1);
979   
980    // Links table goes at top left, resizing resizes the table
981  11 GridBagConstraints linkConstraints2 = new GridBagConstraints();
982  11 linkConstraints2.insets = new Insets(0, 0, 5, 5);
983  11 linkConstraints2.gridx = 0;
984  11 linkConstraints2.gridy = 1;
985  11 linkConstraints2.weightx = 1.0;
986  11 linkConstraints2.weighty = 1.0;
987  11 linkConstraints2.fill = GridBagConstraints.BOTH;
988  11 linkTab.add(linkScrollPane, linkConstraints2);
989   
990    // Filter box and buttons goes at bottom left, resizing resizes the text box
991  11 JPanel filterPanel = initLinkTabFilterPanel();
992  11 GridBagConstraints linkConstraints3 = new GridBagConstraints();
993  11 linkConstraints3.insets = new Insets(0, 0, 0, 5);
994  11 linkConstraints3.gridx = 0;
995  11 linkConstraints3.gridy = 2;
996  11 linkConstraints3.weightx = 1.0;
997  11 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
998  11 linkTab.add(filterPanel, linkConstraints3);
999   
1000  11 return linkTab;
1001    }
1002   
 
1003  11 toggle private JPanel initLinkTabFilterPanel()
1004    {
1005    // Filter textbox and reset button
1006  11 JLabel filterLabel = new JLabel(
1007    MessageManager.getString("label.filter"));
1008  11 filterLabel.setFont(LABEL_FONT);
1009  11 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1010  11 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
1011   
1012  11 filterTB.setFont(LABEL_FONT);
1013  11 filterTB.setText("");
1014   
1015  11 doReset.setText(MessageManager.getString("action.showall"));
1016  11 userOnly.setText(MessageManager.getString("action.customfilter"));
1017   
1018    // Panel for filter functionality
1019  11 JPanel filterPanel = new JPanel(new GridBagLayout());
1020  11 filterPanel.setBorder(new TitledBorder("Filter"));
1021  11 GridBagConstraints gbc = new GridBagConstraints();
1022  11 gbc.gridx = 0;
1023  11 gbc.gridy = 0;
1024  11 gbc.fill = GridBagConstraints.NONE;
1025  11 gbc.anchor = GridBagConstraints.WEST;
1026   
1027  11 filterPanel.add(filterLabel, gbc);
1028   
1029  11 GridBagConstraints gbc1 = new GridBagConstraints();
1030  11 gbc1.gridx = 1;
1031  11 gbc1.gridwidth = 2;
1032  11 gbc1.fill = GridBagConstraints.HORIZONTAL;
1033  11 gbc1.anchor = GridBagConstraints.WEST;
1034  11 gbc1.weightx = 1.0;
1035  11 filterPanel.add(filterTB, gbc1);
1036   
1037  11 GridBagConstraints gbc2 = new GridBagConstraints();
1038  11 gbc2.gridx = 3;
1039  11 gbc2.fill = GridBagConstraints.NONE;
1040  11 gbc2.anchor = GridBagConstraints.WEST;
1041  11 filterPanel.add(doReset, gbc2);
1042   
1043  11 GridBagConstraints gbc3 = new GridBagConstraints();
1044  11 gbc3.gridx = 4;
1045  11 gbc3.fill = GridBagConstraints.NONE;
1046  11 gbc3.anchor = GridBagConstraints.WEST;
1047  11 filterPanel.add(userOnly, gbc3);
1048   
1049  11 return filterPanel;
1050    }
1051   
 
1052  11 toggle private JPanel initLinkTabUrlButtons()
1053    {
1054    // Buttons for new / edit / delete Url links
1055  11 JButton newLink = new JButton();
1056  11 newLink.setText(MessageManager.getString("action.new"));
1057   
1058  11 editLink.setText(MessageManager.getString("action.edit"));
1059   
1060  11 deleteLink.setText(MessageManager.getString("action.delete"));
1061   
1062    // no current selection, so initially disable delete/edit buttons
1063  11 editLink.setEnabled(false);
1064  11 deleteLink.setEnabled(false);
1065   
1066  11 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  11 editLink.setText(MessageManager.getString("action.edit"));
1076  11 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  11 deleteLink.setText(MessageManager.getString("action.delete"));
1086  11 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  11 JPanel buttonPanel = new JPanel(new GridBagLayout());
1096  11 buttonPanel.setBorder(new TitledBorder("Edit links"));
1097  11 GridBagConstraints gbc = new GridBagConstraints();
1098  11 gbc.gridx = 0;
1099  11 gbc.gridy = 0;
1100  11 gbc.fill = GridBagConstraints.NONE;
1101  11 buttonPanel.add(newLink, gbc);
1102   
1103  11 GridBagConstraints gbc1 = new GridBagConstraints();
1104  11 gbc1.gridx = 1;
1105  11 gbc1.gridy = 0;
1106  11 gbc1.fill = GridBagConstraints.NONE;
1107  11 buttonPanel.add(editLink, gbc1);
1108   
1109  11 GridBagConstraints gbc2 = new GridBagConstraints();
1110  11 gbc2.gridx = 2;
1111  11 gbc2.gridy = 0;
1112  11 gbc2.fill = GridBagConstraints.NONE;
1113  11 buttonPanel.add(deleteLink, gbc2);
1114   
1115  11 GridBagConstraints gbc3 = new GridBagConstraints();
1116  11 gbc3.gridx = 3;
1117  11 gbc3.gridy = 0;
1118  11 gbc3.fill = GridBagConstraints.HORIZONTAL;
1119  11 gbc3.weightx = 1.0;
1120  11 JPanel spacePanel = new JPanel();
1121  11 spacePanel.setBorder(null);
1122  11 buttonPanel.add(spacePanel, gbc3);
1123   
1124  11 return buttonPanel;
1125    }
1126   
1127    /**
1128    * Initialises the proxy server panel in the Connections tab
1129    *
1130    * @return the proxy server panel
1131    */
 
1132  11 toggle private JPanel initConnTabProxyPanel()
1133    {
1134    // Label for server text box
1135  11 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1136  11 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1137  11 serverLabel.setFont(LABEL_FONT);
1138  11 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1139  11 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1140  11 serverLabel2.setFont(LABEL_FONT);
1141   
1142    // Proxy server and port text boxes
1143  11 proxyServerHttpTB.setFont(LABEL_FONT);
1144  11 proxyServerHttpTB.setColumns(40);
1145  11 proxyPortHttpTB.setFont(LABEL_FONT);
1146  11 proxyPortHttpTB.setColumns(4);
1147  11 proxyServerHttpsTB.setFont(LABEL_FONT);
1148  11 proxyServerHttpsTB.setColumns(40);
1149  11 proxyPortHttpsTB.setFont(LABEL_FONT);
1150  11 proxyPortHttpsTB.setColumns(4);
1151  11 proxyAuthUsernameTB.setFont(LABEL_FONT);
1152  11 proxyAuthUsernameTB.setColumns(30);
1153   
1154    // check for any change to enable applyProxyButton
1155  11 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  11 proxyServerHttpTB.getDocument().addDocumentListener(d);
1176  11 proxyPortHttpTB.getDocument().addDocumentListener(d);
1177  11 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1178  11 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1179  11 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1180  11 proxyAuthPasswordPB.setFont(LABEL_FONT);
1181  11 proxyAuthPasswordPB.setColumns(30);
1182  11 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  11 portLabel.setFont(LABEL_FONT);
1210  11 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1211  11 portLabel.setText(MessageManager.getString("label.port") + ": ");
1212  11 portLabel2.setFont(LABEL_FONT);
1213  11 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1214  11 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1215   
1216  11 httpLabel.setText("HTTP");
1217  11 httpLabel.setFont(LABEL_FONT_BOLD);
1218  11 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1219  11 httpsLabel.setText("HTTPS");
1220  11 httpsLabel.setFont(LABEL_FONT_BOLD);
1221  11 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1222   
1223  11 proxyAuthUsernameLabel
1224    .setText(MessageManager.getString("label.username") + ": ");
1225  11 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1226  11 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1227  11 proxyAuthPasswordLabel
1228    .setText(MessageManager.getString("label.password") + ": ");
1229  11 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1230  11 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1231  11 passwordNotStoredLabel.setText(
1232    "(" + MessageManager.getString("label.not_stored") + ")");
1233  11 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1234  11 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1235   
1236    // Proxy type radio buttons
1237  11 noProxy.setFont(LABEL_FONT);
1238  11 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1239  11 noProxy.setText(MessageManager.getString("label.no_proxy"));
1240  11 systemProxy.setFont(LABEL_FONT);
1241  11 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1242  11 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  11 customProxy.setFont(LABEL_FONT);
1250  11 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1251  11 customProxy.setText(
1252    MessageManager.getString("label.use_proxy_server") + ":");
1253  11 ActionListener al = new ActionListener()
1254    {
 
1255  0 toggle @Override
1256    public void actionPerformed(ActionEvent e)
1257    {
1258  0 proxyType_actionPerformed();
1259    }
1260    };
1261  11 noProxy.addActionListener(al);
1262  11 systemProxy.addActionListener(al);
1263  11 customProxy.addActionListener(al);
1264  11 proxyType.add(noProxy);
1265  11 proxyType.add(systemProxy);
1266  11 proxyType.add(customProxy);
1267   
1268  11 proxyAuth.setFont(LABEL_FONT);
1269  11 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1270  11 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1271  11 proxyAuth.addActionListener(new ActionListener()
1272    {
 
1273  0 toggle @Override
1274    public void actionPerformed(ActionEvent e)
1275    {
1276  0 proxyAuth_actionPerformed();
1277    }
1278    });
1279   
1280  11 setCustomProxyEnabled();
1281   
1282    // Make proxy server panel
1283  11 JPanel proxyPanel = new JPanel();
1284  11 TitledBorder titledBorder1 = new TitledBorder(
1285    MessageManager.getString("label.proxy_servers"));
1286  11 proxyPanel.setBorder(titledBorder1);
1287  11 proxyPanel.setLayout(new GridBagLayout());
1288  11 GridBagConstraints gbc = new GridBagConstraints();
1289  11 gbc.fill = GridBagConstraints.HORIZONTAL;
1290  11 gbc.weightx = 1.0;
1291   
1292  11 GridBagConstraints c = new GridBagConstraints();
1293    // Proxy type radio buttons (3)
1294  11 JPanel ptPanel = new JPanel();
1295  11 ptPanel.setLayout(new GridBagLayout());
1296  11 c.weightx = 1.0;
1297  11 c.gridy = 0;
1298  11 c.gridx = 0;
1299  11 c.gridwidth = 1;
1300  11 c.fill = GridBagConstraints.HORIZONTAL;
1301  11 ptPanel.add(noProxy, c);
1302  11 c.gridy++;
1303  11 ptPanel.add(systemProxy, c);
1304  11 c.gridy++;
1305  11 ptPanel.add(customProxy, c);
1306   
1307  11 gbc.gridy = 0;
1308  11 proxyPanel.add(ptPanel, gbc);
1309   
1310    // host and port text boxes
1311  11 JPanel hpPanel = new JPanel();
1312  11 hpPanel.setLayout(new GridBagLayout());
1313    // HTTP host port row
1314  11 c.gridy = 0;
1315  11 c.gridx = 0;
1316   
1317  11 c.weightx = 0.1;
1318  11 c.anchor = GridBagConstraints.LINE_START;
1319  11 hpPanel.add(httpLabel, c);
1320   
1321  11 c.gridx++;
1322  11 c.weightx = 0.1;
1323  11 c.anchor = GridBagConstraints.LINE_END;
1324  11 hpPanel.add(serverLabel, c);
1325   
1326  11 c.gridx++;
1327  11 c.weightx = 1.0;
1328  11 c.anchor = GridBagConstraints.LINE_START;
1329  11 hpPanel.add(proxyServerHttpTB, c);
1330   
1331  11 c.gridx++;
1332  11 c.weightx = 0.1;
1333  11 c.anchor = GridBagConstraints.LINE_END;
1334  11 hpPanel.add(portLabel, c);
1335   
1336  11 c.gridx++;
1337  11 c.weightx = 0.2;
1338  11 c.anchor = GridBagConstraints.LINE_START;
1339  11 hpPanel.add(proxyPortHttpTB, c);
1340   
1341    // HTTPS host port row
1342  11 c.gridy++;
1343  11 c.gridx = 0;
1344  11 c.gridwidth = 1;
1345   
1346  11 c.anchor = GridBagConstraints.LINE_START;
1347  11 hpPanel.add(httpsLabel, c);
1348   
1349  11 c.gridx++;
1350  11 c.anchor = GridBagConstraints.LINE_END;
1351  11 hpPanel.add(serverLabel2, c);
1352   
1353  11 c.gridx++;
1354  11 c.anchor = GridBagConstraints.LINE_START;
1355  11 hpPanel.add(proxyServerHttpsTB, c);
1356   
1357  11 c.gridx++;
1358  11 c.anchor = GridBagConstraints.LINE_END;
1359  11 hpPanel.add(portLabel2, c);
1360   
1361  11 c.gridx++;
1362  11 c.anchor = GridBagConstraints.LINE_START;
1363  11 hpPanel.add(proxyPortHttpsTB, c);
1364   
1365  11 gbc.gridy++;
1366  11 proxyPanel.add(hpPanel, gbc);
1367   
1368  11 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  11 gbc.gridy++;
1379  11 proxyPanel.add(proxyAuth, gbc);
1380   
1381    // username and password
1382  11 JPanel upPanel = new JPanel();
1383  11 upPanel.setLayout(new GridBagLayout());
1384    // username row
1385  11 c.gridy = 0;
1386  11 c.gridx = 0;
1387  11 c.gridwidth = 1;
1388  11 c.weightx = 0.4;
1389  11 c.anchor = GridBagConstraints.LINE_END;
1390  11 upPanel.add(proxyAuthUsernameLabel, c);
1391   
1392  11 c.gridx++;
1393  11 c.weightx = 1.0;
1394  11 c.anchor = GridBagConstraints.LINE_START;
1395  11 upPanel.add(proxyAuthUsernameTB, c);
1396   
1397    // password row
1398  11 c.gridy++;
1399  11 c.gridx = 0;
1400  11 c.weightx = 0.4;
1401  11 c.anchor = GridBagConstraints.LINE_END;
1402  11 upPanel.add(proxyAuthPasswordLabel, c);
1403   
1404  11 c.gridx++;
1405  11 c.weightx = 1.0;
1406  11 c.anchor = GridBagConstraints.LINE_START;
1407  11 upPanel.add(proxyAuthPasswordPB, c);
1408   
1409  11 c.gridx++;
1410  11 c.weightx = 0.4;
1411  11 c.anchor = GridBagConstraints.LINE_START;
1412  11 upPanel.add(passwordNotStoredLabel, c);
1413   
1414  11 gbc.gridy++;
1415  11 proxyPanel.add(upPanel, gbc);
1416   
1417    } // end j2sIgnore
1418   
1419  11 applyProxyButton.setText(MessageManager.getString("action.apply"));
1420  11 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  11 gbc.gridy++;
1430  11 gbc.fill = GridBagConstraints.NONE;
1431  11 gbc.anchor = GridBagConstraints.LINE_END;
1432  11 proxyPanel.add(applyProxyButton, gbc);
1433   
1434  11 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  11 toggle public void applyProxyButtonEnabled(boolean enabled)
1461    {
1462  11 applyProxyButton.setEnabled(enabled);
1463    }
1464   
 
1465  0 toggle public void saveProxySettings()
1466    {
1467    // overridden in Preferences
1468    }
1469   
 
1470  22 toggle private String displayUserHostPort(String user, String host, String port)
1471    {
1472  22 boolean hostBlank = (host == null || host.isEmpty());
1473  22 boolean portBlank = (port == null || port.isEmpty());
1474  22 if (hostBlank && portBlank)
1475    {
1476  22 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  11 toggle private void initConnTabCheckboxes()
1499    {
1500    // Usage stats checkbox label
1501  11 usagestats.setText(
1502    MessageManager.getString("label.send_usage_statistics"));
1503  11 usagestats.setFont(LABEL_FONT);
1504  11 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1505  11 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1506   
1507    // Questionnaire checkbox label
1508  11 questionnaire.setText(
1509    MessageManager.getString("label.check_for_questionnaires"));
1510  11 questionnaire.setFont(LABEL_FONT);
1511  11 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1512  11 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1513   
1514    // Check for latest version checkbox label
1515  11 versioncheck.setText(
1516    MessageManager.getString("label.check_for_latest_version"));
1517  11 versioncheck.setFont(LABEL_FONT);
1518  11 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1519  11 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1520    }
1521   
1522    /**
1523    * Initialises the parent panel which contains the tabbed sections.
1524    *
1525    * @return
1526    */
 
1527  11 toggle private JPanel initOkCancelPanel()
1528    {
1529  11 JButton ok = new JButton();
1530  11 ok.setText(MessageManager.getString("action.ok"));
1531  11 ok.addActionListener(new ActionListener()
1532    {
 
1533  0 toggle @Override
1534    public void actionPerformed(ActionEvent e)
1535    {
1536  0 ok_actionPerformed(e);
1537    }
1538    });
1539  11 JButton cancel = new JButton();
1540  11 cancel.setText(MessageManager.getString("action.cancel"));
1541  11 cancel.addActionListener(new ActionListener()
1542    {
 
1543  0 toggle @Override
1544    public void actionPerformed(ActionEvent e)
1545    {
1546  0 cancel_actionPerformed(e);
1547    }
1548    });
1549  11 JPanel okCancelPanel = new JPanel();
1550  11 okCancelPanel.add(ok);
1551  11 okCancelPanel.add(cancel);
1552  11 return okCancelPanel;
1553    }
1554   
1555    /**
1556    * Initialises the Colours tabbed panel.
1557    *
1558    * @return
1559    */
 
1560  11 toggle private JPanel initColoursTab()
1561    {
1562  11 JPanel coloursTab = new JPanel();
1563  11 coloursTab.setBorder(new TitledBorder(
1564    MessageManager.getString("action.open_new_alignment")));
1565  11 coloursTab.setLayout(new FlowLayout());
1566  11 JLabel mincolourLabel = new JLabel();
1567  11 mincolourLabel.setFont(LABEL_FONT);
1568  11 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1569  11 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1570  11 minColour.setFont(LABEL_FONT);
1571  11 minColour.setBorder(BorderFactory.createEtchedBorder());
1572  11 minColour.setPreferredSize(new Dimension(40, 20));
1573  11 minColour.addMouseListener(new MouseAdapter()
1574    {
 
1575  0 toggle @Override
1576    public void mousePressed(MouseEvent e)
1577    {
1578  0 minColour_actionPerformed(minColour);
1579    }
1580    });
1581  11 JLabel maxcolourLabel = new JLabel();
1582  11 maxcolourLabel.setFont(LABEL_FONT);
1583  11 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1584  11 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1585  11 maxColour.setFont(LABEL_FONT);
1586  11 maxColour.setBorder(BorderFactory.createEtchedBorder());
1587  11 maxColour.setPreferredSize(new Dimension(40, 20));
1588  11 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  11 protColour.setFont(LABEL_FONT);
1598  11 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1599  11 JLabel protColourLabel = new JLabel();
1600  11 protColourLabel.setFont(LABEL_FONT);
1601  11 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1602  11 protColourLabel.setText(
1603    MessageManager.getString("label.prot_alignment_colour") + " ");
1604  11 GPreferences.addtoLayout(coloursTab,
1605    MessageManager
1606    .getString("label.default_colour_scheme_for_alignment"),
1607    protColourLabel, protColour);
1608   
1609  11 nucColour.setFont(LABEL_FONT);
1610  11 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1611  11 JLabel nucColourLabel = new JLabel();
1612  11 nucColourLabel.setFont(LABEL_FONT);
1613  11 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1614  11 nucColourLabel.setText(
1615    MessageManager.getString("label.nuc_alignment_colour") + " ");
1616  11 GPreferences.addtoLayout(coloursTab,
1617    MessageManager
1618    .getString("label.default_colour_scheme_for_alignment"),
1619    nucColourLabel, nucColour);
1620   
1621  11 JPanel annotationShding = new JPanel();
1622  11 annotationShding.setBorder(new TitledBorder(
1623    MessageManager.getString("label.annotation_shading_default")));
1624  11 annotationShding.setLayout(new GridLayout(1, 2));
1625  11 GPreferences.addtoLayout(annotationShding,
1626    MessageManager.getString(
1627    "label.default_minimum_colour_annotation_shading"),
1628    mincolourLabel, minColour);
1629  11 GPreferences.addtoLayout(annotationShding,
1630    MessageManager.getString(
1631    "label.default_maximum_colour_annotation_shading"),
1632    maxcolourLabel, maxColour);
1633  11 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1634  11 return coloursTab;
1635    }
1636   
1637    /**
1638    * Initialises the Overview tabbed panel.
1639    *
1640    * @return
1641    */
 
1642  11 toggle private JPanel initOverviewTab()
1643    {
1644  11 JPanel overviewPanel = new JPanel();
1645  11 overviewPanel.setBorder(new TitledBorder(
1646    MessageManager.getString("label.overview_settings")));
1647   
1648  11 gapColour.setFont(LABEL_FONT);
1649    // fixing the border colours stops apparent colour bleed from the panel
1650  11 gapColour.setBorder(
1651    BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1652  11 gapColour.setPreferredSize(new Dimension(40, 20));
1653  11 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  11 hiddenColour.setFont(LABEL_FONT);
1663    // fixing the border colours stops apparent colour bleed from the panel
1664  11 hiddenColour.setBorder(
1665    BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1666  11 hiddenColour.setPreferredSize(new Dimension(40, 20));
1667  11 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  11 useLegacyGap = new JCheckBox(
1677    MessageManager.getString("label.ov_legacy_gap"));
1678  11 useLegacyGap.setFont(LABEL_FONT);
1679  11 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1680  11 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1681  11 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1682  11 gapLabel.setFont(LABEL_FONT);
1683  11 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1684  11 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1685  11 showHiddenAtStart = new JCheckBox(
1686    MessageManager.getString("label.ov_show_hide_default"));
1687  11 showHiddenAtStart.setFont(LABEL_FONT);
1688  11 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1689  11 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1690  11 JLabel hiddenLabel = new JLabel(
1691    MessageManager.getString("label.hidden_colour"));
1692  11 hiddenLabel.setFont(LABEL_FONT);
1693  11 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1694  11 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1695   
1696  11 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  11 overviewPanel.setLayout(new GridBagLayout());
1706  11 GridBagConstraints c1 = new GridBagConstraints();
1707   
1708  11 c1.fill = GridBagConstraints.HORIZONTAL;
1709  11 c1.gridx = 0;
1710  11 c1.gridy = 0;
1711  11 c1.weightx = 1;
1712  11 c1.ipady = 20;
1713  11 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1714  11 overviewPanel.add(useLegacyGap, c1);
1715   
1716  11 GridBagConstraints c2 = new GridBagConstraints();
1717  11 c2.fill = GridBagConstraints.HORIZONTAL;
1718  11 c2.gridx = 1;
1719  11 c2.gridy = 0;
1720  11 c2.insets = new Insets(0, 15, 0, 10);
1721  11 overviewPanel.add(gapLabel, c2);
1722   
1723  11 GridBagConstraints c3 = new GridBagConstraints();
1724  11 c3.fill = GridBagConstraints.HORIZONTAL;
1725  11 c3.gridx = 2;
1726  11 c3.gridy = 0;
1727  11 c3.insets = new Insets(0, 0, 0, 15);
1728  11 overviewPanel.add(gapColour, c3);
1729   
1730  11 GridBagConstraints c4 = new GridBagConstraints();
1731  11 c4.fill = GridBagConstraints.HORIZONTAL;
1732  11 c4.gridx = 0;
1733  11 c4.gridy = 1;
1734  11 c4.weightx = 1;
1735  11 overviewPanel.add(showHiddenAtStart, c4);
1736   
1737  11 GridBagConstraints c5 = new GridBagConstraints();
1738  11 c5.fill = GridBagConstraints.HORIZONTAL;
1739  11 c5.gridx = 1;
1740  11 c5.gridy = 1;
1741  11 c5.insets = new Insets(0, 15, 0, 10);
1742  11 overviewPanel.add(hiddenLabel, c5);
1743   
1744  11 GridBagConstraints c6 = new GridBagConstraints();
1745  11 c6.fill = GridBagConstraints.HORIZONTAL;
1746  11 c6.gridx = 2;
1747  11 c6.gridy = 1;
1748  11 c6.insets = new Insets(0, 0, 0, 15);
1749  11 overviewPanel.add(hiddenColour, c6);
1750   
1751  11 JButton resetButton = new JButton(
1752    MessageManager.getString("label.reset_to_defaults"));
1753   
1754  11 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  11 GridBagConstraints c7 = new GridBagConstraints();
1764  11 c7.fill = GridBagConstraints.NONE;
1765  11 c7.gridx = 0;
1766  11 c7.gridy = 2;
1767  11 c7.insets = new Insets(10, 0, 0, 0);
1768  11 c7.anchor = GridBagConstraints.WEST;
1769  11 overviewPanel.add(resetButton, c7);
1770   
1771    // Add padding so the panel doesn't look ridiculous
1772  11 JPanel spacePanel = new JPanel();
1773  11 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  11 return overviewPanel;
1779    }
1780   
1781    /**
1782    * Initialises the Structure tabbed panel.
1783    *
1784    * @return
1785    */
 
1786  11 toggle private JPanel initStructureTab()
1787    {
1788  11 structureTab = new JPanel();
1789   
1790  11 structureTab.setBorder(new TitledBorder(
1791    MessageManager.getString("label.structure_options")));
1792  11 structureTab.setLayout(null);
1793  11 final int width = 420;
1794  11 final int height = 22;
1795  11 final int lineSpacing = 25;
1796  11 int ypos = 15;
1797   
1798  11 structFromPdb.setFont(LABEL_FONT);
1799  11 structFromPdb
1800    .setText(MessageManager.getString("label.struct_from_pdb"));
1801  11 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1802  11 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  11 structureTab.add(structFromPdb);
1814   
1815    // indent checkboxes that are conditional on the first one
1816  11 ypos += lineSpacing;
1817  11 addSecondaryStructure.setFont(LABEL_FONT);
1818  11 addSecondaryStructure
1819    .setText(MessageManager.getString("label.autoadd_secstr"));
1820  11 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1821  11 structureTab.add(addSecondaryStructure);
1822   
1823  11 ypos += lineSpacing;
1824  11 addTempFactor.setFont(LABEL_FONT);
1825  11 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1826  11 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1827  11 structureTab.add(addTempFactor);
1828   
1829  11 ypos += lineSpacing;
1830  11 JLabel viewerLabel = new JLabel();
1831  11 viewerLabel.setFont(LABEL_FONT);
1832  11 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1833  11 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1834  11 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1835  11 structureTab.add(viewerLabel);
1836   
1837    /*
1838    * add all external viewers as options here - check
1839    * when selected whether the program is installed
1840    */
1841  11 structViewer.setFont(LABEL_FONT);
1842  11 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1843  11 for (ViewerType v : EnumSet.allOf(ViewerType.class))
1844    {
1845  44 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  11 structViewer.addActionListener(new ActionListener()
1854    {
 
1855  11 toggle @Override
1856    public void actionPerformed(ActionEvent e)
1857    {
1858  11 structureViewer_actionPerformed(
1859    (String) structViewer.getSelectedItem());
1860    }
1861    });
1862  11 structureTab.add(structViewer);
1863   
1864  11 ypos += lineSpacing;
1865  11 structureViewerPathLabel = new JLabel();
1866  11 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1867    // 11));
1868  11 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1869  11 structureViewerPathLabel.setText(MessageManager
1870    .formatMessage("label.viewer_path", "Chimera(X)"));
1871  11 structureViewerPathLabel
1872    .setBounds(new Rectangle(10, ypos, 170, height));
1873  11 structureViewerPathLabel.setEnabled(false);
1874  11 structureTab.add(structureViewerPathLabel);
1875   
1876  11 structureViewerPath.setFont(LABEL_FONT);
1877  11 structureViewerPath.setText("");
1878  11 structureViewerPath.setEnabled(false);
1879  11 final String tooltip = JvSwingUtils.wrapTooltip(true,
1880    MessageManager.getString("label.viewer_path_tip"));
1881  11 structureViewerPath.setToolTipText(tooltip);
1882  11 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1883  11 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  11 structureTab.add(structureViewerPath);
1899   
1900  11 ypos += lineSpacing;
1901  11 nwMapping.setFont(LABEL_FONT);
1902  11 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1903  11 siftsMapping.setFont(LABEL_FONT);
1904  11 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1905  11 mappingMethod.add(nwMapping);
1906  11 mappingMethod.add(siftsMapping);
1907  11 JPanel mappingPanel = new JPanel();
1908  11 mappingPanel.setFont(LABEL_FONT);
1909  11 TitledBorder mmTitledBorder = new TitledBorder(
1910    MessageManager.getString("label.mapping_method"));
1911  11 mmTitledBorder.setTitleFont(LABEL_FONT);
1912  11 mappingPanel.setBorder(mmTitledBorder);
1913  11 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1914    // GridLayout mappingLayout = new GridLayout();
1915  11 mappingPanel.setLayout(new GridLayout());
1916  11 mappingPanel.add(nwMapping);
1917  11 mappingPanel.add(siftsMapping);
1918  11 structureTab.add(mappingPanel);
1919   
1920  11 ypos += lineSpacing;
1921  11 ypos += lineSpacing;
1922  11 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1923    PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1924  11 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1925  11 structureTab.add(docFieldPref);
1926   
1927    /*
1928    * hide Chimera options in JalviewJS
1929    */
1930  11 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  11 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  11 toggle private JPanel initVisualTab()
2013    {
2014  11 JPanel visualTab = new JPanel();
2015  11 visualTab.setBorder(new TitledBorder(
2016    MessageManager.getString("action.open_new_alignment")));
2017  11 visualTab.setLayout(null);
2018  11 fullScreen.setFont(LABEL_FONT);
2019  11 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
2020  11 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
2021  11 fullScreen.setText(MessageManager.getString("label.maximize_window"));
2022  11 quality.setEnabled(false);
2023  11 quality.setFont(LABEL_FONT);
2024  11 quality.setHorizontalAlignment(SwingConstants.RIGHT);
2025  11 quality.setHorizontalTextPosition(SwingConstants.LEFT);
2026  11 quality.setSelected(true);
2027  11 quality.setText(MessageManager.getString("label.quality"));
2028  11 conservation.setEnabled(false);
2029  11 conservation.setFont(LABEL_FONT);
2030  11 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
2031  11 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
2032  11 conservation.setSelected(true);
2033  11 conservation.setText(MessageManager.getString("label.conservation"));
2034  11 identity.setEnabled(false);
2035  11 identity.setFont(LABEL_FONT);
2036  11 identity.setHorizontalAlignment(SwingConstants.RIGHT);
2037  11 identity.setHorizontalTextPosition(SwingConstants.LEFT);
2038  11 identity.setSelected(true);
2039  11 identity.setText(MessageManager.getString("label.consensus"));
2040  11 ssConsensus.setEnabled(false);
2041  11 ssConsensus.setFont(LABEL_FONT);
2042  11 ssConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2043  11 ssConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2044  11 ssConsensus.setSelected(false);
2045  11 ssConsensus.setText(MessageManager.getString("label.ssConsensus"));
2046  11 showOccupancy.setFont(LABEL_FONT);
2047  11 showOccupancy.setEnabled(false);
2048  11 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
2049  11 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
2050  11 showOccupancy.setSelected(true);
2051  11 showOccupancy.setText(MessageManager.getString("label.occupancy"));
2052   
2053  11 JLabel showGroupbits = new JLabel();
2054  11 showGroupbits.setFont(LABEL_FONT);
2055  11 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
2056  11 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
2057  11 showGroupbits
2058    .setText(MessageManager.getString("action.show_group") + ":");
2059  11 JLabel showConsensbits = new JLabel();
2060  11 showConsensbits.setFont(LABEL_FONT);
2061  11 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
2062  11 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
2063  11 showConsensbits
2064    .setText(MessageManager.getString("label.consensus") + ":");
2065  11 showConsensHistogram.setEnabled(false);
2066  11 showConsensHistogram.setFont(LABEL_FONT);
2067  11 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
2068  11 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
2069  11 showConsensHistogram.setSelected(true);
2070  11 showConsensHistogram
2071    .setText(MessageManager.getString("label.histogram"));
2072  11 showConsensLogo.setEnabled(false);
2073  11 showConsensLogo.setFont(LABEL_FONT);
2074  11 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
2075  11 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
2076  11 showConsensLogo.setSelected(true);
2077  11 showConsensLogo.setText(MessageManager.getString("label.logo"));
2078  11 showGroupConsensus.setEnabled(false);
2079  11 showGroupConsensus.setFont(LABEL_FONT);
2080  11 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2081  11 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2082  11 showGroupConsensus.setSelected(true);
2083  11 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
2084  11 showGroupConservation.setEnabled(false);
2085  11 showGroupConservation.setFont(LABEL_FONT);
2086  11 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
2087  11 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
2088  11 showGroupConservation.setSelected(true);
2089  11 showGroupConservation
2090    .setText(MessageManager.getString("label.conservation"));
2091  11 showNpTooltip.setEnabled(true);
2092  11 showNpTooltip.setFont(LABEL_FONT);
2093  11 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2094  11 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2095  11 showNpTooltip.setSelected(true);
2096  11 showNpTooltip.setText(
2097    MessageManager.getString("label.non_positional_features"));
2098  11 showDbRefTooltip.setEnabled(true);
2099  11 showDbRefTooltip.setFont(LABEL_FONT);
2100  11 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2101  11 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2102  11 showDbRefTooltip.setSelected(true);
2103  11 showDbRefTooltip
2104    .setText(MessageManager.getString("label.database_references"));
2105  11 annotations.setFont(LABEL_FONT);
2106  11 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
2107  11 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
2108  11 annotations.setSelected(true);
2109  11 annotations.setText(MessageManager.getString("label.show_annotations"));
2110    // annotations.setBounds(new Rectangle(169, 12, 200, 23));
2111  11 annotations.addActionListener(new ActionListener()
2112    {
 
2113  0 toggle @Override
2114    public void actionPerformed(ActionEvent e)
2115    {
2116  0 annotations_actionPerformed(e);
2117    }
2118    });
2119  11 identity.addActionListener(new ActionListener()
2120    {
 
2121  0 toggle @Override
2122    public void actionPerformed(ActionEvent e)
2123    {
2124  0 annotations_actionPerformed(e);
2125    }
2126    });
2127  11 showGroupConsensus.addActionListener(new ActionListener()
2128    {
 
2129  0 toggle @Override
2130    public void actionPerformed(ActionEvent e)
2131    {
2132  0 annotations_actionPerformed(e);
2133    }
2134    });
2135  11 showUnconserved.setFont(LABEL_FONT);
2136  11 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2137  11 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2138  11 showUnconserved.setSelected(true);
2139  11 showUnconserved
2140    .setText(MessageManager.getString("action.show_unconserved"));
2141  11 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  11 seqLimit.setFont(LABEL_FONT);
2168  11 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2169  11 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2170  11 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2171  11 smoothFont.setFont(LABEL_FONT);
2172  11 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2173  11 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2174  11 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2175  11 scaleProteinToCdna.setFont(LABEL_FONT);
2176  11 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2177  11 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2178  11 scaleProteinToCdna.setText(
2179    MessageManager.getString("label.scale_protein_to_cdna"));
2180  11 scaleProteinToCdna.setToolTipText(
2181    MessageManager.getString("label.scale_protein_to_cdna_tip"));
2182  11 JLabel gapLabel = new JLabel();
2183  11 gapLabel.setFont(LABEL_FONT);
2184  11 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2185  11 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2186  11 JLabel fontLabel = new JLabel();
2187  11 fontLabel.setFont(LABEL_FONT);
2188  11 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2189  11 fontLabel.setText(MessageManager.getString("label.font"));
2190  11 fontSizeCB.setFont(LABEL_FONT);
2191  11 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2192  11 fontStyleCB.setFont(LABEL_FONT);
2193  11 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2194  11 fontNameCB.setFont(LABEL_FONT);
2195  11 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2196  11 gapSymbolCB.setFont(LABEL_FONT);
2197  11 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2198  11 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2199  11 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2200  11 gapSymbolCB.setRenderer(dlcr);
2201   
2202  11 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2203  11 startupCheckbox.setFont(LABEL_FONT);
2204  11 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2205  11 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2206  11 startupCheckbox.setSelected(true);
2207  11 startupFileTextfield.setFont(LABEL_FONT);
2208  11 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2209  11 final String tooltip = JvSwingUtils.wrapTooltip(true,
2210    MessageManager.getString("label.double_click_to_browse"));
2211  11 startupFileTextfield.setToolTipText(tooltip);
2212  11 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  11 sortby.setFont(LABEL_FONT);
2225  11 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2226  11 JLabel sortLabel = new JLabel();
2227  11 sortLabel.setFont(LABEL_FONT);
2228  11 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2229  11 sortLabel.setText(MessageManager.getString("label.sort_by"));
2230  11 sortAnnBy.setFont(LABEL_FONT);
2231  11 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2232  11 JLabel sortAnnLabel = new JLabel();
2233  11 sortAnnLabel.setFont(LABEL_FONT);
2234  11 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2235  11 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2236  11 sortAutocalc.setFont(LABEL_FONT);
2237  11 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2238   
2239  11 JPanel annsettingsPanel = new JPanel();
2240  11 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 101));
2241  11 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2242  11 annsettingsPanel.setBorder(new EtchedBorder());
2243  11 visualTab.add(annsettingsPanel);
2244  11 Border jb = new EmptyBorder(1, 1, 4, 5);
2245  11 annotations.setBorder(jb);
2246  11 showOccupancy.setBorder(jb);
2247  11 quality.setBorder(jb);
2248  11 conservation.setBorder(jb);
2249  11 identity.setBorder(jb);
2250  11 ssConsensus.setBorder(jb);
2251  11 showConsensbits.setBorder(jb);
2252  11 showGroupbits.setBorder(jb);
2253  11 showGroupConsensus.setBorder(jb);
2254  11 showGroupConservation.setBorder(jb);
2255  11 showConsensHistogram.setBorder(jb);
2256  11 showConsensLogo.setBorder(jb);
2257   
2258  11 JPanel autoAnnotSettings = new JPanel();
2259  11 annsettingsPanel.add(autoAnnotSettings);
2260  11 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2261  11 autoAnnotSettings.add(annotations);
2262  11 autoAnnotSettings.add(quality);
2263    // second row of autoannotation box
2264  11 autoAnnotSettings = new JPanel();
2265  11 annsettingsPanel.add(autoAnnotSettings);
2266  11 autoAnnotSettings.setLayout(new GridLayout(0, 1));
2267  11 autoAnnotSettings.add(ssConsensus);
2268   
2269    // third row of autoannotation box
2270  11 autoAnnotSettings = new JPanel();
2271  11 annsettingsPanel.add(autoAnnotSettings);
2272   
2273  11 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2274  11 autoAnnotSettings.add(conservation);
2275  11 autoAnnotSettings.add(identity);
2276  11 autoAnnotSettings.add(showOccupancy);
2277  11 autoAnnotSettings.add(showGroupbits);
2278  11 autoAnnotSettings.add(showGroupConservation);
2279  11 autoAnnotSettings.add(showGroupConsensus);
2280  11 autoAnnotSettings.add(showConsensbits);
2281  11 autoAnnotSettings.add(showConsensHistogram);
2282  11 autoAnnotSettings.add(showConsensLogo);
2283   
2284  11 JPanel tooltipSettings = new JPanel();
2285  11 tooltipSettings.setBorder(new TitledBorder(
2286    MessageManager.getString("label.sequence_id_tooltip")));
2287  11 tooltipSettings.setBounds(173, 140, 220, 62);
2288  11 tooltipSettings.setLayout(new GridLayout(2, 1));
2289  11 tooltipSettings.add(showDbRefTooltip);
2290  11 tooltipSettings.add(showNpTooltip);
2291  11 visualTab.add(tooltipSettings);
2292   
2293  11 wrap.setFont(LABEL_FONT);
2294  11 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2295  11 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2296  11 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2297  11 rightAlign.setFont(LABEL_FONT);
2298  11 rightAlign.setForeground(Color.black);
2299  11 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2300  11 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2301  11 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2302  11 idItalics.setFont(LABEL_FONT_ITALIC);
2303  11 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2304  11 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2305  11 idItalics.setText(
2306    MessageManager.getString("label.sequence_name_italics"));
2307  11 openoverv.setFont(LABEL_FONT);
2308  11 openoverv.setActionCommand(
2309    MessageManager.getString("label.open_overview"));
2310  11 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2311  11 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2312  11 openoverv.setText(MessageManager.getString("label.open_overview"));
2313  11 JPanel jPanel2 = new JPanel();
2314  11 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2315  11 jPanel2.setLayout(new GridLayout(14, 1));
2316  11 jPanel2.add(fullScreen);
2317  11 jPanel2.add(openoverv);
2318  11 jPanel2.add(seqLimit);
2319  11 jPanel2.add(rightAlign);
2320  11 jPanel2.add(fontLabel);
2321  11 jPanel2.add(showUnconserved);
2322  11 jPanel2.add(idItalics);
2323  11 jPanel2.add(smoothFont);
2324  11 jPanel2.add(scaleProteinToCdna);
2325  11 jPanel2.add(gapLabel);
2326  11 jPanel2.add(wrap);
2327  11 jPanel2.add(sortLabel);
2328  11 jPanel2.add(sortAnnLabel);
2329  11 jPanel2.add(startupCheckbox);
2330  11 visualTab.add(jPanel2);
2331  11 visualTab.add(startupFileTextfield);
2332  11 visualTab.add(sortby);
2333  11 visualTab.add(sortAnnBy);
2334  11 visualTab.add(sortAutocalc);
2335  11 visualTab.add(gapSymbolCB);
2336  11 visualTab.add(fontNameCB);
2337  11 visualTab.add(fontSizeCB);
2338  11 visualTab.add(fontStyleCB);
2339   
2340   
2341  11 if (Platform.isJS())
2342    {
2343  0 startupCheckbox.setVisible(false);
2344  0 startupFileTextfield.setVisible(false);
2345    }
2346   
2347   
2348  11 return visualTab;
2349    }
2350   
2351    /**
2352    * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2353    */
2354   
 
2355  11 toggle protected void loadLastSavedBackupsOptions()
2356    {
2357  11 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2358    .getSavedBackupEntry();
2359  11 enableBackupFiles
2360    .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2361   
2362  11 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2363    .createBackupFilesPresetEntry(Cache
2364    .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2365  11 if (backupfilesCustomEntry == null)
2366    {
2367  7 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2368    .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2369    }
2370  11 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2371    BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2372    backupfilesCustomEntry);
2373   
2374  11 setComboIntStringKey(backupfilesPresetsCombo,
2375    Cache.getDefault(BackupFiles.NS + "_PRESET",
2376    BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2377   
2378  11 backupsSetOptions(savedPreset);
2379   
2380  11 backupsOptionsSetEnabled();
2381  11 updateBackupFilesExampleLabel();
2382    }
2383   
2384    /*
2385    * Load the saved Memory settings
2386    */
 
2387  11 toggle protected void loadLastSavedMemorySettings()
2388    {
2389  11 customiseMemorySetting.setSelected(
2390    Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2391  11 jvmMemoryPercentSlider
2392    .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2393  11 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  11 toggle private JPanel initStartupTab()
2419    {
2420  11 JPanel startupTab = new JPanel();
2421  11 startupTab.setBorder(
2422    new TitledBorder(MessageManager.getString("label.memory")));
2423  11 startupTab.setLayout(new GridBagLayout());
2424   
2425  11 GridBagConstraints gbc = new GridBagConstraints();
2426  11 gbc.weightx = 0.0;
2427  11 gbc.weighty = 0.0;
2428  11 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2429  11 gbc.fill = GridBagConstraints.NONE;
2430   
2431  11 initMemoryPanel();
2432   
2433  11 gbc.gridheight = 1;
2434  11 gbc.gridwidth = 3;
2435   
2436  11 gbc.gridy = 0; // row 1
2437  11 gbc.gridx = 0;
2438  11 JLabel memoryText = new JLabel();
2439  11 memoryText.setFont(LABEL_FONT_ITALIC);
2440  11 memoryText
2441    .setText(MessageManager.getString("label.memory_setting_text"));
2442  11 startupTab.add(memoryText, gbc);
2443   
2444  11 gbc.gridy++; // row 2
2445  11 gbc.gridx = 0;
2446  11 JPanel exampleMemoryPanel = new JPanel();
2447  11 exampleMemoryPanel
2448    .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2449  11 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2450    MessageManager.getString("label.memory_example_tooltip")));
2451  11 JLabel exampleTextLabel = new JLabel();
2452  11 exampleTextLabel
2453    .setText(MessageManager.getString("label.memory_example_text"));
2454  11 exampleTextLabel.setForeground(Color.GRAY);
2455  11 exampleTextLabel.setFont(LABEL_FONT);
2456  11 exampleMemoryPanel.add(exampleTextLabel);
2457  11 exampleMemoryPanel.add(exampleMemoryLabel);
2458  11 exampleMemoryPanel.setBackground(Color.WHITE);
2459  11 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2460  11 startupTab.add(exampleMemoryPanel, gbc);
2461   
2462  11 gbc.gridy++; // row 3
2463  11 gbc.gridx = 0;
2464  11 startupTab.add(customiseMemorySetting, gbc);
2465   
2466  11 gbc.gridy += 2; // row 4 with a gap
2467  11 gbc.gridx = 0;
2468  11 startupTab.add(maxMemoryLabel, gbc);
2469   
2470  11 gbc.gridy += 2; // row 5
2471  11 gbc.gridx = 0;
2472  11 gbc.gridwidth = 1;
2473  11 startupTab.add(jvmMemoryPercentLabel, gbc);
2474  11 gbc.gridx++;
2475  11 startupTab.add(jvmMemoryPercentSlider, gbc);
2476  11 gbc.gridx++;
2477    // gbc.weightx = 0.1;
2478  11 startupTab.add(jvmMemoryPercentDisplay, gbc);
2479    // gbc.weightx = 1.0;
2480  11 gbc.gridwidth = 3;
2481   
2482  11 gbc.gridy++; // row 6
2483  11 gbc.gridx = 0;
2484  11 startupTab.add(jvmMemoryMaxLabel, gbc);
2485  11 gbc.gridx++;
2486  11 startupTab.add(jvmMemoryMaxTextField, gbc);
2487   
2488  11 gbc.gridy++; // row 7
2489  11 gbc.gridx = 0;
2490  11 gbc.gridwidth = 4;
2491  11 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2492  11 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2493  11 sp.setBorder(BorderFactory.createEmptyBorder());
2494  11 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2495  11 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2496  11 startupTab.add(sp, gbc);
2497   
2498    // fill empty space to push widget to top left
2499  11 gbc.gridy++;
2500  11 gbc.weighty = 1.0;
2501  11 gbc.gridx = 100;
2502  11 gbc.gridwidth = 1;
2503  11 gbc.weightx = 1.0;
2504  11 startupTab.add(new JPanel(), gbc);
2505   
2506  11 setMemoryPercentDisplay();
2507  11 memoryOptionsSetEnabled();
2508  11 return startupTab;
2509    }
2510   
 
2511  11 toggle private void initMemoryPanel()
2512    {
2513    // Enable memory settings checkbox
2514  11 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2515  11 customiseMemorySetting.setText(
2516    MessageManager.getString("label.customise_memory_settings"));
2517  11 customiseMemorySetting.addActionListener(new ActionListener()
2518    {
 
2519  0 toggle @Override
2520    public void actionPerformed(ActionEvent e)
2521    {
2522  0 memoryOptionsSetEnabled();
2523    }
2524    });
2525   
2526  11 loadLastSavedMemorySettings();
2527   
2528  11 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2529  11 exampleMemoryLabel.setBackground(Color.WHITE);
2530   
2531  11 maxMemoryLabel = new JLabel(
2532    MessageManager.getString("label.maximum_memory_used"));
2533  11 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2534   
2535    // Maximum memory percentage slider
2536  11 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2537  11 jvmMemoryPercentLabel.setText(
2538    MessageManager.getString("label.percent_of_physical_memory"));
2539  11 jvmMemoryPercentSlider.setPaintLabels(true);
2540  11 jvmMemoryPercentSlider.setPaintTicks(true);
2541  11 jvmMemoryPercentSlider.setPaintTrack(true);
2542  11 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2543  11 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2544  11 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2545    {
 
2546  0 toggle @Override
2547    public void stateChanged(ChangeEvent e)
2548    {
2549  0 setMemoryPercentDisplay();
2550    }
2551    });
2552  11 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2553  11 setMemoryPercentDisplay();
2554   
2555    // Maximum memory cap textbox
2556  11 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2557  11 jvmMemoryMaxLabel
2558    .setText(MessageManager.getString("label.maximum_memory"));
2559  11 initMemoryMaxTextField();
2560   
2561  11 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2562  11 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2563  11 exampleMemoryMessageTextArea.setEditable(false);
2564  11 exampleMemoryMessageTextArea.setLineWrap(true);
2565  11 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2566  11 exampleMemoryMessageTextArea.setText(" ");
2567  11 exampleMemoryMessageTextArea.setRows(2);
2568  11 exampleMemoryMessageTextArea.setColumns(40);
2569   
2570  11 setExampleMemoryLabel();
2571    }
2572   
 
2573  11 toggle private void initMemoryMaxTextField()
2574    {
2575  11 jvmMemoryMaxTextField.setToolTipText(
2576    MessageManager.getString("label.maximum_memory_tooltip"));
2577  11 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  11 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  22 toggle private void setMemoryPercentDisplay()
2645    {
2646  22 jvmMemoryPercentDisplay
2647    .setText(jvmMemoryPercentSlider.getValue() + "%");
2648  22 setExampleMemoryLabel();
2649    }
2650   
 
2651  44 toggle private void setExampleMemoryLabel()
2652    {
2653  44 boolean selected = customiseMemorySetting.isSelected();
2654  44 int jvmmempc = jvmMemoryPercentSlider.getValue();
2655  44 String jvmmemmax = jvmMemoryMaxTextField.getText();
2656   
2657  44 long mem;
2658  44 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  44 mem = MemorySetting.getMemorySetting(null, null, false, true);
2667    }
2668  44 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2669  44 String message = MemorySetting.getAdjustmentMessage();
2670  44 exampleMemoryMessageTextArea.setText(
2671    MessageManager.getString("label.adjustments_for_this_computer")
2672    + ": "
2673  44 + (message == null
2674    ? MessageManager.getString("label.none")
2675    : message));
2676    }
2677   
 
2678  11 toggle private void memoryOptionsSetEnabled()
2679    {
2680  11 boolean enabled = customiseMemorySetting.isSelected();
2681    // leave exampleMemoryLabel enabled always
2682  11 maxMemoryLabel.setEnabled(enabled);
2683  11 jvmMemoryPercentLabel.setEnabled(enabled);
2684  11 jvmMemoryPercentSlider.setEnabled(enabled);
2685  11 jvmMemoryPercentDisplay.setEnabled(enabled);
2686  11 jvmMemoryMaxLabel.setEnabled(enabled);
2687  11 jvmMemoryMaxTextField.setEnabled(enabled);
2688  11 exampleMemoryMessageTextArea.setEnabled(enabled);
2689  11 setExampleMemoryLabel();
2690    }
2691   
2692    /**
2693    * Initialises the Backups tabbed panel.
2694    *
2695    * @return
2696    */
 
2697  11 toggle private JPanel initBackupsTab()
2698    {
2699  11 JPanel backupsTab = new JPanel();
2700  11 backupsTab.setBorder(new TitledBorder(
2701    MessageManager.getString("label.backup_files")));
2702  11 backupsTab.setLayout(new GridBagLayout());
2703   
2704  11 GridBagConstraints gbc = new GridBagConstraints();
2705  11 gbc.weightx = 0.0;
2706  11 gbc.weighty = 0.0;
2707  11 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2708  11 gbc.fill = GridBagConstraints.NONE;
2709   
2710  11 initBackupsTabPresetsPanel();
2711  11 initBackupsTabSuffixPanel();
2712  11 initBackupsTabKeepFilesPanel();
2713  11 initBackupsTabFilenameExamplesPanel();
2714   
2715  11 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2716  11 enableBackupFiles
2717    .setText(MessageManager.getString("label.enable_backupfiles"));
2718  11 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  11 gbc.gridwidth = 1;
2730  11 gbc.gridheight = 1;
2731  11 gbc.gridx = 0;
2732  11 gbc.gridy = 0; // row 0
2733  11 backupsTab.add(enableBackupFiles, gbc);
2734   
2735    // summary of scheme box (over two rows)
2736  11 gbc.gridx = 1;
2737  11 gbc.weightx = 0.0;
2738  11 gbc.gridheight = 2;
2739  11 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2740  11 gbc.fill = GridBagConstraints.BOTH;
2741  11 backupsTab.add(exampleFilesPanel, gbc);
2742  11 gbc.gridheight = 1;
2743  11 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2744  11 gbc.fill = GridBagConstraints.NONE;
2745   
2746    // fill empty space on right
2747  11 gbc.gridx++;
2748  11 gbc.weightx = 1.0;
2749  11 backupsTab.add(new JPanel(), gbc);
2750   
2751    // schemes box
2752  11 gbc.weightx = 0.0;
2753  11 gbc.gridx = 0;
2754  11 gbc.gridy++; // row 1
2755  11 backupsTab.add(presetsPanel, gbc);
2756   
2757    // now using whole row
2758  11 gbc.gridwidth = 2;
2759  11 gbc.gridheight = 1;
2760    // keep files box
2761  11 gbc.gridx = 0;
2762  11 gbc.gridy++; // row 2
2763  11 backupsTab.add(keepfilesPanel, gbc);
2764   
2765    // filename strategy box
2766  11 gbc.gridy++; // row 3
2767  11 backupsTab.add(suffixPanel, gbc);
2768   
2769    // fill empty space
2770  11 gbc.gridy++; // row 4
2771  11 gbc.weighty = 1.0;
2772  11 backupsTab.add(new JPanel(), gbc);
2773   
2774  11 backupsOptionsSetEnabled();
2775  11 return backupsTab;
2776    }
2777   
 
2778  11 toggle private JPanel initBackupsTabPresetsPanel()
2779    {
2780   
2781  11 String title = MessageManager.getString("label.schemes");
2782   
2783  11 presetsPanel.setLayout(new GridBagLayout());
2784   
2785  11 GridBagConstraints gbc = new GridBagConstraints();
2786  11 gbc.weightx = 0.0;
2787  11 gbc.weighty = 0.0;
2788  11 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2789  11 gbc.fill = GridBagConstraints.NONE;
2790  11 gbc.gridwidth = 1;
2791  11 gbc.gridheight = 1;
2792   
2793    // "Scheme: "
2794  11 gbc.gridx = 0;
2795  11 gbc.gridy = 0;
2796   
2797  11 presetsComboLabel = new JLabel(title + ":");
2798  11 presetsPanel.add(presetsComboLabel, gbc);
2799   
2800  11 List<Object> entries = Arrays
2801    .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2802  11 List<String> tooltips = Arrays.asList(
2803    BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2804  11 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  11 backupfilesPresetsCombo.addActionListener(new ActionListener()
2815    {
 
2816  11 toggle @Override
2817    public void actionPerformed(ActionEvent e)
2818    {
2819  11 int key = getComboIntStringKey(backupfilesPresetsCombo);
2820  11 if (!customiseCheckbox.isSelected())
2821    {
2822  11 backupfilesPresetsComboLastSelected = key;
2823    }
2824  11 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2825    {
2826  4 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  4 backupsTabUpdatePresets();
2834  4 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  11 gbc.gridx = 1;
2848  11 presetsPanel.add(backupfilesPresetsCombo, gbc);
2849   
2850  11 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2851  11 revertButton.setToolTipText(
2852    MessageManager.getString("label.cancel_changes_description"));
2853  11 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  11 revertButton.setFont(LABEL_FONT);
2866   
2867  11 customiseCheckbox.setFont(LABEL_FONT);
2868  11 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2869  11 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  11 customiseCheckbox.setToolTipText(
2891    MessageManager.getString("label.customise_description"));
2892   
2893    // customise checkbox
2894  11 gbc.gridx = 0;
2895  11 gbc.gridy++;
2896  11 presetsPanel.add(customiseCheckbox, gbc);
2897   
2898    // "Cancel changes" button (aligned with combo box above)
2899  11 gbc.gridx = 1;
2900  11 presetsPanel.add(revertButton, gbc);
2901   
2902  11 return presetsPanel;
2903    }
2904   
 
2905  11 toggle private JPanel initBackupsTabFilenameExamplesPanel()
2906    {
2907  11 String title = MessageManager
2908    .getString("label.scheme_examples");
2909  11 TitledBorder tb = new TitledBorder(title);
2910  11 exampleFilesPanel.setBorder(tb);
2911  11 exampleFilesPanel.setLayout(new GridBagLayout());
2912   
2913  11 backupfilesExampleLabel.setEditable(false);
2914  11 backupfilesExampleLabel
2915    .setBackground(exampleFilesPanel.getBackground());
2916   
2917  11 updateBackupFilesExampleLabel();
2918   
2919  11 GridBagConstraints gbc = new GridBagConstraints();
2920  11 gbc.weightx = 1.0;
2921  11 gbc.weighty = 1.0;
2922  11 gbc.fill = GridBagConstraints.NONE;
2923  11 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2924   
2925  11 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2926  11 return exampleFilesPanel;
2927    }
2928   
 
2929  11 toggle private void backupsTabUpdatePresets()
2930    {
2931  11 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2932    .getSelectedItem();
2933  11 int key = entry.k;
2934  11 String value = entry.v;
2935   
2936  11 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2937    .containsKey(key))
2938    {
2939  11 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  11 updateBackupFilesExampleLabel();
2953    }
2954   
 
2955  11 toggle protected int getComboIntStringKey(
2956    JComboBox<Object> backupfilesPresetsCombo2)
2957    {
2958  11 IntKeyStringValueEntry e;
2959  11 try
2960    {
2961  11 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  11 return e != null ? e.k : 0;
2970    }
2971   
 
2972  11 toggle protected void setComboIntStringKey(
2973    JComboBox<Object> backupfilesPresetsCombo2,
2974    int key)
2975    {
2976  27 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2977    {
2978  27 IntKeyStringValueEntry e;
2979  27 try
2980    {
2981  27 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  27 if (e.k == key)
2989    {
2990  11 backupfilesPresetsCombo2.setSelectedIndex(i);
2991  11 break;
2992    }
2993    }
2994    // backupsTabUpdatePresets();
2995    }
2996   
 
2997  11 toggle private JPanel initBackupsTabSuffixPanel()
2998    {
2999  11 suffixPanel.setBorder(new TitledBorder(
3000    MessageManager.getString("label.backup_filename_strategy")));
3001  11 suffixPanel.setLayout(new GridBagLayout());
3002   
3003  11 suffixTemplateLabel
3004    .setText(MessageManager.getString("label.append_to_filename"));
3005  11 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
3006  11 suffixTemplateLabel.setFont(LABEL_FONT);
3007   
3008  11 final String tooltip = JvSwingUtils.wrapTooltip(true,
3009    MessageManager.getString("label.append_to_filename_tooltip"));
3010  11 suffixTemplate.setToolTipText(tooltip);
3011  11 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  11 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  11 suffixDigitsLabel
3053    .setText(MessageManager.getString("label.index_digits"));
3054  11 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
3055  11 suffixDigitsLabel.setFont(LABEL_FONT);
3056  11 ChangeListener c = new ChangeListener()
3057    {
 
3058  4 toggle @Override
3059    public void stateChanged(ChangeEvent e)
3060    {
3061  4 backupfilesRevertButtonSetEnabled(true);
3062  4 updateBackupFilesExampleLabel();
3063    }
3064   
3065    };
3066  11 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
3067    BackupFilesPresetEntry.DIGITSMAX, 3, c);
3068   
3069  11 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
3070    MessageManager.getString("label.increment_index"));
3071  11 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  11 GridBagConstraints sgbc = new GridBagConstraints();
3097   
3098    // first row (template text box)
3099  11 sgbc.anchor = GridBagConstraints.WEST;
3100  11 sgbc.gridx = 0;
3101  11 sgbc.gridy = 0;
3102  11 sgbc.gridwidth = 1;
3103  11 sgbc.gridheight = 1;
3104  11 sgbc.weightx = 1.0;
3105  11 sgbc.weighty = 0.0;
3106  11 sgbc.fill = GridBagConstraints.NONE;
3107  11 suffixPanel.add(suffixTemplateLabel, sgbc);
3108   
3109  11 sgbc.gridx = 1;
3110  11 sgbc.fill = GridBagConstraints.HORIZONTAL;
3111  11 suffixPanel.add(suffixTemplate, sgbc);
3112   
3113    // second row (number of digits spinner)
3114  11 sgbc.gridy = 1;
3115   
3116  11 sgbc.gridx = 0;
3117  11 sgbc.fill = GridBagConstraints.NONE;
3118  11 suffixPanel.add(suffixDigitsLabel, sgbc);
3119   
3120  11 sgbc.gridx = 1;
3121  11 sgbc.fill = GridBagConstraints.HORIZONTAL;
3122  11 suffixPanel.add(suffixDigitsSpinner, sgbc);
3123   
3124    // third row (forward order radio selection)
3125  11 sgbc.gridx = 0;
3126  11 sgbc.gridy = 2;
3127  11 sgbc.gridwidth = GridBagConstraints.REMAINDER;
3128  11 sgbc.fill = GridBagConstraints.HORIZONTAL;
3129  11 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
3130   
3131    // fourth row (reverse order radio selection)
3132  11 sgbc.gridy = 3;
3133  11 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
3134  11 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  11 toggle private JPanel initBackupsTabKeepFilesPanel()
3152    {
3153  11 keepfilesPanel.setBorder(
3154    new TitledBorder(MessageManager.getString("label.keep_files")));
3155  11 keepfilesPanel.setLayout(new GridBagLayout());
3156   
3157  11 backupfilesKeepAll.setLabels(
3158    MessageManager.getString("label.keep_all_backup_files"),
3159    MessageManager.getString(
3160    "label.keep_only_this_number_of_backup_files"));
3161  11 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  11 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  11 ChangeListener c = new ChangeListener()
3182    {
 
3183  11 toggle @Override
3184    public void stateChanged(ChangeEvent e)
3185    {
3186  11 backupfilesRevertButtonSetEnabled(true);
3187  11 updateBackupFilesExampleLabel();
3188    }
3189   
3190    };
3191  11 setIntegerSpinner(backupfilesRollMaxSpinner,
3192    BackupFilesPresetEntry.ROLLMAXMIN,
3193    BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3194   
3195  11 backupfilesConfirmDelete.setLabels(
3196    MessageManager.getString("label.always_ask"),
3197    MessageManager.getString("label.auto_delete"));
3198  11 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  11 keepRollMaxOptionsEnabled();
3208   
3209  11 GridBagConstraints kgbc = new GridBagConstraints();
3210   
3211    // first row (template text box)
3212  11 kgbc.anchor = GridBagConstraints.WEST;
3213  11 kgbc.gridx = 0;
3214  11 kgbc.gridy = 0;
3215  11 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3216  11 kgbc.gridheight = 1;
3217  11 kgbc.weightx = 1.0;
3218  11 kgbc.weighty = 0.0;
3219  11 kgbc.fill = GridBagConstraints.HORIZONTAL;
3220  11 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3221   
3222    // second row
3223  11 kgbc.gridy = 1;
3224   
3225  11 kgbc.gridx = 0;
3226  11 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3227  11 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3228   
3229  11 kgbc.gridx = 1;
3230  11 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3231  11 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3232   
3233    // third row (indented)
3234  11 kgbc.gridy = 2;
3235  11 kgbc.insets = new Insets(0, 20, 0, 0);
3236   
3237  11 kgbc.gridx = 0;
3238  11 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3239  11 kgbc.fill = GridBagConstraints.HORIZONTAL;
3240  11 kgbc.weightx = 1.0;
3241   
3242  11 JPanel jp = new JPanel();
3243  11 jp.setLayout(new FlowLayout());
3244  11 oldBackupFilesLabel
3245    .setText(MessageManager
3246    .getString("label.autodelete_old_backup_files"));
3247  11 oldBackupFilesLabel.setFont(LABEL_FONT);
3248  11 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3249  11 jp.add(oldBackupFilesLabel);
3250  11 jp.add(backupfilesConfirmDelete.getTrueButton());
3251  11 jp.add(backupfilesConfirmDelete.getFalseButton());
3252  11 keepfilesPanel.add(jp, kgbc);
3253   
3254  11 return keepfilesPanel;
3255    }
3256   
 
3257  48 toggle protected void updateBackupFilesExampleLabel()
3258    {
3259  48 int exampleindex = 12;
3260  48 String base = MessageManager.getString("label.filename") + ".fa";
3261  48 if (base == null || base.length() == 0)
3262    {
3263  0 base = "file_name.fa";
3264    }
3265   
3266  48 boolean reverse = suffixReverse.isSelected();
3267  48 boolean keepAll = backupfilesKeepAll.isSelected();
3268  48 int rollMax = 4;
3269  48 String suffix = suffixTemplate.getText();
3270  48 int digits = 3;
3271   
3272  48 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3273  48 if (suffix == null || suffix.length() == 0)
3274    {
3275  11 backupfilesExampleLabel
3276    .setText(MessageManager.getString("label.no_backup_files"));
3277  11 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3278  11 return;
3279    }
3280   
3281  37 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3282  37 rollMax = rollMax < 1 ? 1 : rollMax;
3283   
3284  37 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3285    {
3286  0 rollMax = 1;
3287    }
3288   
3289  37 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3290  37 digits = digits < 1 ? 1 : digits;
3291   
3292  37 int lowersurround = 2;
3293  37 int uppersurround = 0;
3294  37 StringBuilder exampleSB = new StringBuilder();
3295  37 boolean firstLine = true;
3296  37 int lineNumber = 0;
3297  37 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  37 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3353    : exampleindex - rollMax + 1;
3354  37 int max = exampleindex;
3355   
3356  128 for (int index = min; index <= max; index++)
3357    {
3358   
3359  91 if (index == min + lowersurround && index < max - uppersurround - 1)
3360    {
3361  0 exampleSB.append("\n...");
3362  0 lineNumber++;
3363    }
3364  91 else if (index > min + lowersurround && index < max - uppersurround)
3365    {
3366    // nothing
3367    }
3368    else
3369    {
3370  91 if (firstLine)
3371    {
3372  37 firstLine = false;
3373    }
3374    else
3375    {
3376  54 exampleSB.append("\n");
3377  54 lineNumber++;
3378    }
3379  91 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3380    base, suffix, digits));
3381  91 if (min == max)
3382    {
3383    // no extra text needed
3384    }
3385  87 else if (index == min)
3386    {
3387  33 String oldest = MessageManager.getString("label.braced_oldest");
3388  33 if (oldest != null && oldest.length() > 0)
3389    {
3390  33 exampleSB.append(" " + oldest);
3391    }
3392    }
3393  54 else if (index == max)
3394    {
3395  33 String newest = MessageManager.getString("label.braced_newest");
3396  33 if (newest != null && newest.length() > 0)
3397    {
3398  33 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  37 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3409  37 if (remainingLines > 0)
3410    {
3411  94 for (int i = 0; i < remainingLines; i++)
3412    {
3413  57 exampleSB.append("\n ");
3414  57 lineNumber++;
3415    }
3416    }
3417   
3418  37 backupfilesExampleLabel.setText(exampleSB.toString());
3419    }
3420   
 
3421  11 toggle protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3422    boolean useExistingVal, ChangeListener c)
3423    {
3424  11 int i = def;
3425  11 if (useExistingVal)
3426    {
3427  11 try
3428    {
3429  11 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  11 setIntegerSpinner(s, min, max, i, c);
3438    }
3439   
 
3440  22 toggle protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3441    ChangeListener c)
3442    {
3443    // integer spinner for number of digits
3444  22 if (def > max)
3445    {
3446  0 max = def;
3447    }
3448  22 if (def < min)
3449    {
3450  11 def = min;
3451    }
3452  22 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3453  22 s.setModel(sModel);
3454   
3455  22 s.addChangeListener(c);
3456   
3457    }
3458   
 
3459  74 toggle protected static int getSpinnerInt(JSpinner s, int def)
3460    {
3461  74 int i = def;
3462  74 try
3463    {
3464  74 s.commitEdit();
3465  74 i = (Integer) s.getValue();
3466    } catch (Exception e)
3467    {
3468  0 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3469    }
3470  74 return i;
3471    }
3472   
 
3473  44 toggle private void keepRollMaxOptionsEnabled()
3474    {
3475  44 boolean enabled = backupfilesKeepAll.isEnabled()
3476    && !backupfilesKeepAll.isSelected();
3477  44 oldBackupFilesLabel.setEnabled(enabled);
3478  44 backupfilesRollMaxSpinner.setEnabled(enabled);
3479  44 backupfilesConfirmDelete.setEnabled(enabled);
3480    }
3481   
 
3482  33 toggle private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3483    {
3484  33 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3485    && customiseCheckbox.isSelected()
3486    && suffixTemplate.getText()
3487    .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3488  33 keepfilesPanel.setEnabled(enabled);
3489  33 backupfilesKeepAll.setEnabled(enabled);
3490  33 oldBackupFilesLabel.setEnabled(enabled);
3491  33 keepRollMaxOptionsEnabled();
3492    }
3493   
 
3494  33 toggle private void backupfilesSuffixTemplateDigitsSetEnabled()
3495    {
3496  33 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3497    .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3498  33 suffixDigitsLabel.setEnabled(enabled);
3499  33 suffixDigitsSpinner.setEnabled(enabled);
3500  33 suffixReverse.setEnabled(enabled);
3501    }
3502   
 
3503  33 toggle private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3504    {
3505  33 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3506    && customiseCheckbox.isSelected();
3507  33 suffixPanel.setEnabled(enabled);
3508  33 suffixTemplateLabel.setEnabled(enabled);
3509  33 suffixTemplate.setEnabled(enabled);
3510  33 backupfilesSuffixTemplateDigitsSetEnabled();
3511    }
3512   
 
3513  48 toggle private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3514    {
3515  48 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3516    && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3517  48 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  33 toggle protected void backupfilesCustomOptionsSetEnabled()
3544    {
3545  33 boolean enabled = customiseCheckbox.isSelected();
3546   
3547  33 backupfilesRevertButtonSetEnabled(enabled);
3548  33 backupfilesSuffixTemplateSetEnabled(enabled);
3549  33 backupfilesKeepAllSetEnabled(enabled);
3550    }
3551   
 
3552  22 toggle private void backupfilesSummarySetEnabled()
3553    {
3554  22 boolean enabled = enableBackupFiles.isSelected();
3555  22 backupfilesExampleLabel.setEnabled(enabled);
3556  22 exampleFilesPanel.setEnabled(enabled);
3557    }
3558   
 
3559  22 toggle private void backupfilesPresetsSetEnabled()
3560    {
3561  22 boolean enabled = enableBackupFiles.isSelected();
3562  22 presetsPanel.setEnabled(enabled);
3563  22 presetsComboLabel.setEnabled(enabled);
3564  22 backupfilesPresetsCombo.setEnabled(enabled);
3565  22 customiseCheckbox.setEnabled(enabled);
3566  22 revertButton.setEnabled(enabled);
3567    }
3568   
 
3569  22 toggle protected void backupsOptionsSetEnabled()
3570    {
3571  22 backupfilesPresetsSetEnabled();
3572  22 backupfilesSummarySetEnabled();
3573  22 backupfilesCustomOptionsSetEnabled();
3574    }
3575   
 
3576  22 toggle protected void backupsSetOptions(String suffix, int digits,
3577    boolean reverse, boolean keepAll, int rollMax,
3578    boolean confirmDelete)
3579    {
3580  22 suffixTemplate.setText(suffix);
3581  22 suffixDigitsSpinner.setValue(digits);
3582  22 suffixReverse.setSelected(reverse);
3583  22 backupfilesKeepAll.setSelected(keepAll);
3584  22 backupfilesRollMaxSpinner.setValue(rollMax);
3585  22 backupfilesConfirmDelete.setSelected(confirmDelete);
3586    }
3587   
 
3588  22 toggle protected void backupsSetOptions(BackupFilesPresetEntry p)
3589    {
3590  22 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  22 toggle public void setProxyAuthEnabled()
3699    {
3700  22 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3701  22 proxyAuthUsernameLabel.setEnabled(enabled);
3702  22 proxyAuthPasswordLabel.setEnabled(enabled);
3703  22 passwordNotStoredLabel.setEnabled(enabled);
3704  22 proxyAuthUsernameTB.setEnabled(enabled);
3705  22 proxyAuthPasswordPB.setEnabled(enabled);
3706    }
3707   
 
3708  22 toggle public void setCustomProxyEnabled()
3709    {
3710  22 boolean enabled = customProxy.isSelected();
3711  22 portLabel.setEnabled(enabled);
3712  22 serverLabel.setEnabled(enabled);
3713  22 portLabel2.setEnabled(enabled);
3714  22 serverLabel2.setEnabled(enabled);
3715  22 httpLabel.setEnabled(enabled);
3716  22 httpsLabel.setEnabled(enabled);
3717  22 proxyServerHttpTB.setEnabled(enabled);
3718  22 proxyPortHttpTB.setEnabled(enabled);
3719  22 proxyServerHttpsTB.setEnabled(enabled);
3720  22 proxyPortHttpsTB.setEnabled(enabled);
3721  22 proxyAuth.setEnabled(enabled);
3722  22 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  11 toggle public RadioButtonRenderer()
3746    {
3747  11 setHorizontalAlignment(CENTER);
3748  11 setToolTipText(MessageManager.getString("label.urltooltip"));
3749    }
3750   
 
3751  11 toggle @Override
3752    public Component getTableCellRendererComponent(JTable table,
3753    Object value, boolean isSelected, boolean hasFocus, int row,
3754    int column)
3755    {
3756  11 setSelected((boolean) value);
3757   
3758    // set colours to match rest of table
3759  11 if (isSelected)
3760    {
3761  0 setBackground(table.getSelectionBackground());
3762  0 setForeground(table.getSelectionForeground());
3763    }
3764    else
3765    {
3766  11 setBackground(table.getBackground());
3767  11 setForeground(table.getForeground());
3768    }
3769  11 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  11 toggle public RadioButtonEditor()
3783    {
3784  11 button.setHorizontalAlignment(SwingConstants.CENTER);
3785  11 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  44 toggle protected static void addtoLayout(JPanel panel, String tooltip,
3829    JComponent label, JComponent valBox)
3830    {
3831  44 JPanel laypanel = new JPanel(new GridLayout(1, 2));
3832  44 JPanel labPanel = new JPanel(new BorderLayout());
3833  44 JPanel valPanel = new JPanel();
3834  44 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
3835  44 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
3836  44 labPanel.add(label, BorderLayout.WEST);
3837  44 valPanel.add(valBox);
3838  44 laypanel.add(labPanel);
3839  44 laypanel.add(valPanel);
3840  44 valPanel.setToolTipText(tooltip);
3841  44 labPanel.setToolTipText(tooltip);
3842  44 valBox.setToolTipText(tooltip);
3843  44 panel.add(laypanel);
3844  44 panel.validate();
3845    }
3846    }