Clover icon

Coverage Report

  1. Project Clover database Wed Dec 3 2025 13:28:34 GMT
  2. Package jalview.jbgui

File GPreferences.java

 

Coverage histogram

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

Code metrics

144
1,598
142
4
3,642
2,803
252
0.16
11.25
35.5
1.77

Classes

Class Line # Actions
GPreferences 105 1,583 245
0.00%
GPreferences.TabRef 546 0 0
-1.0 -
GPreferences.RadioButtonRenderer 3574 9 3
0.00%
GPreferences.RadioButtonEditor 3609 6 4
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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