1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.jbgui

File GPreferences.java

 

Coverage histogram

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

Code metrics

142
1,597
142
4
3,640
2,800
251
0.16
11.25
35.5
1.77

Classes

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