2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
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;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.util.Arrays;
42 import java.util.List;
44 import javax.swing.AbstractCellEditor;
45 import javax.swing.BorderFactory;
46 import javax.swing.BoxLayout;
47 import javax.swing.ButtonGroup;
48 import javax.swing.DefaultListCellRenderer;
49 import javax.swing.JButton;
50 import javax.swing.JCheckBox;
51 import javax.swing.JComboBox;
52 import javax.swing.JFileChooser;
53 import javax.swing.JLabel;
54 import javax.swing.JPanel;
55 import javax.swing.JPasswordField;
56 import javax.swing.JRadioButton;
57 import javax.swing.JScrollPane;
58 import javax.swing.JSlider;
59 import javax.swing.JSpinner;
60 import javax.swing.JTabbedPane;
61 import javax.swing.JTable;
62 import javax.swing.JTextArea;
63 import javax.swing.JTextField;
64 import javax.swing.ListSelectionModel;
65 import javax.swing.SpinnerModel;
66 import javax.swing.SpinnerNumberModel;
67 import javax.swing.SwingConstants;
68 import javax.swing.border.Border;
69 import javax.swing.border.EmptyBorder;
70 import javax.swing.border.EtchedBorder;
71 import javax.swing.border.TitledBorder;
72 import javax.swing.event.ChangeEvent;
73 import javax.swing.event.ChangeListener;
74 import javax.swing.event.DocumentEvent;
75 import javax.swing.event.DocumentListener;
76 import javax.swing.table.TableCellEditor;
77 import javax.swing.table.TableCellRenderer;
79 import jalview.bin.Cache;
80 import jalview.bin.Console;
81 import jalview.bin.MemorySetting;
82 import jalview.fts.core.FTSDataColumnPreferences;
83 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
84 import jalview.fts.service.pdb.PDBFTSRestClient;
85 import jalview.gui.Desktop;
86 import jalview.gui.JalviewBooleanRadioButtons;
87 import jalview.gui.JvOptionPane;
88 import jalview.gui.JvSwingUtils;
89 import jalview.gui.StructureViewer.ViewerType;
90 import jalview.io.BackupFilenameParts;
91 import jalview.io.BackupFiles;
92 import jalview.io.BackupFilesPresetEntry;
93 import jalview.io.IntKeyStringValueEntry;
94 import jalview.util.MessageManager;
95 import jalview.util.Platform;
96 import jalview.util.StringUtils;
99 * Base class for the Preferences panel.
102 * @version $Revision$
104 public class GPreferences extends JPanel
106 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
108 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
109 .getLabelFont(false, true);
111 private static final Font LABEL_FONT_BOLD = JvSwingUtils
112 .getLabelFont(true, false);
115 * Visual tab components
117 protected JCheckBox fullScreen = new JCheckBox();
119 protected JCheckBox openoverv = new JCheckBox();
121 protected JCheckBox seqLimit = new JCheckBox();
123 protected JCheckBox rightAlign = new JCheckBox();
125 protected JComboBox<String> fontSizeCB = new JComboBox<>();
127 protected JComboBox<String> fontStyleCB = new JComboBox<>();
129 protected JComboBox<String> fontNameCB = new JComboBox<>();
131 protected JCheckBox showOccupancy = new JCheckBox();
133 protected JCheckBox showUnconserved = new JCheckBox();
135 protected JCheckBox idItalics = new JCheckBox();
137 protected JCheckBox smoothFont = new JCheckBox();
139 protected JCheckBox scaleProteinToCdna = new JCheckBox();
141 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
143 protected JCheckBox wrap = new JCheckBox();
145 protected JComboBox<String> sortby = new JComboBox<>();
147 protected JComboBox<String> sortAnnBy = new JComboBox<>();
149 protected JComboBox<String> sortAutocalc = new JComboBox<>();
151 protected JCheckBox startupCheckbox = new JCheckBox();
153 protected JTextField startupFileTextfield = new JTextField();
155 // below are in the 'second column'
156 protected JCheckBox annotations = new JCheckBox();
158 protected JCheckBox quality = new JCheckBox();
160 protected JCheckBox conservation = new JCheckBox();
162 protected JCheckBox identity = new JCheckBox();
164 protected JCheckBox showGroupConsensus = new JCheckBox();
166 protected JCheckBox showGroupConservation = new JCheckBox();
168 protected JCheckBox showConsensHistogram = new JCheckBox();
170 protected JCheckBox showConsensLogo = new JCheckBox();
172 protected JCheckBox showDbRefTooltip = new JCheckBox();
174 protected JCheckBox showNpTooltip = new JCheckBox();
177 * Structure tab and components
179 protected JPanel structureTab;
181 protected JCheckBox structFromPdb = new JCheckBox();
183 protected JCheckBox addSecondaryStructure = new JCheckBox();
185 protected JCheckBox addTempFactor = new JCheckBox();
187 protected JComboBox<String> structViewer = new JComboBox<>();
189 protected JLabel structureViewerPathLabel;
191 protected JTextField structureViewerPath = new JTextField();
193 protected ButtonGroup mappingMethod = new ButtonGroup();
195 protected JRadioButton siftsMapping = new JRadioButton();
197 protected JRadioButton nwMapping = new JRadioButton();
200 * Colours tab components
202 protected JPanel minColour = new JPanel();
204 protected JPanel maxColour = new JPanel();
206 protected JComboBox<String> protColour = new JComboBox<>();
208 protected JComboBox<String> nucColour = new JComboBox<>();
211 * Overview tab components
213 protected JPanel gapColour = new JPanel();
215 protected JPanel hiddenColour = new JPanel();
217 protected JCheckBox useLegacyGap;
219 protected JCheckBox showHiddenAtStart;
221 protected JLabel gapLabel;
224 * Connections tab components
226 protected JPanel connectTab;
228 protected JTable linkUrlTable = new JTable();
230 protected JButton editLink = new JButton();
232 protected JButton deleteLink = new JButton();
234 protected JTextField filterTB = new JTextField();
236 protected JButton doReset = new JButton();
238 protected JButton userOnly = new JButton();
240 protected JLabel httpLabel = new JLabel();
242 protected JLabel httpsLabel = new JLabel();
244 protected JLabel portLabel = new JLabel();
246 protected JLabel serverLabel = new JLabel();
248 protected JLabel portLabel2 = new JLabel();
250 protected JLabel serverLabel2 = new JLabel();
252 protected JLabel proxyAuthUsernameLabel = new JLabel();
254 protected JLabel proxyAuthPasswordLabel = new JLabel();
256 protected JLabel passwordNotStoredLabel = new JLabel();
258 protected JTextField proxyServerHttpTB = new JTextField();
260 protected JTextField proxyPortHttpTB = new JTextField();
262 protected JTextField proxyServerHttpsTB = new JTextField();
264 protected JTextField proxyPortHttpsTB = new JTextField();
266 protected JCheckBox proxyAuth = new JCheckBox();
268 protected JTextField proxyAuthUsernameTB = new JTextField();
270 protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
272 protected ButtonGroup proxyType = new ButtonGroup();
274 protected JRadioButton noProxy = new JRadioButton();
276 protected JRadioButton systemProxy = new JRadioButton();
278 protected JRadioButton customProxy = new JRadioButton();
280 protected JButton applyProxyButton = new JButton();
282 protected JCheckBox usagestats = new JCheckBox();
284 protected JCheckBox questionnaire = new JCheckBox();
286 protected JCheckBox versioncheck = new JCheckBox();
289 * Output tab components
291 protected JComboBox<Object> epsRendering = new JComboBox<>();
293 protected JComboBox<Object> htmlRendering = new JComboBox<>();
295 protected JComboBox<Object> svgRendering = new JComboBox<>();
297 protected JLabel userIdWidthlabel = new JLabel();
299 protected JCheckBox autoIdWidth = new JCheckBox();
301 protected JTextField userIdWidth = new JTextField();
303 protected JCheckBox blcjv = new JCheckBox();
305 protected JCheckBox pileupjv = new JCheckBox();
307 protected JCheckBox clustaljv = new JCheckBox();
309 protected JCheckBox msfjv = new JCheckBox();
311 protected JCheckBox fastajv = new JCheckBox();
313 protected JCheckBox pfamjv = new JCheckBox();
315 protected JCheckBox pirjv = new JCheckBox();
317 protected JCheckBox modellerOutput = new JCheckBox();
319 protected JCheckBox embbedBioJSON = new JCheckBox();
322 * Editing tab components
324 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
326 protected JCheckBox padGaps = new JCheckBox();
328 protected JCheckBox sortByTree = new JCheckBox();
333 protected JPanel wsTab = new JPanel();
336 * Backups tab components
337 * a lot of these are member variables instead of local variables only so that they
338 * can be enabled/disabled easily in one go
341 protected JCheckBox enableBackupFiles = new JCheckBox();
343 protected JPanel presetsPanel = new JPanel();
345 protected JLabel presetsComboLabel = new JLabel();
347 protected JCheckBox customiseCheckbox = new JCheckBox();
349 protected JButton revertButton = new JButton();
351 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
353 private int backupfilesPresetsComboLastSelected = 0;
355 protected JPanel suffixPanel = new JPanel();
357 protected JPanel keepfilesPanel = new JPanel();
359 protected JPanel exampleFilesPanel = new JPanel();
361 protected JTextField suffixTemplate = new JTextField(null, 8);
363 protected JLabel suffixTemplateLabel = new JLabel();
365 protected JLabel suffixDigitsLabel = new JLabel();
367 protected JSpinner suffixDigitsSpinner = new JSpinner();
369 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
371 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
373 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
375 protected JLabel oldBackupFilesLabel = new JLabel();
377 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
379 protected JTextArea backupfilesExampleLabel = new JTextArea();
381 private final JTabbedPane tabbedPane = new JTabbedPane();
383 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
386 * Startup tab components
389 protected JCheckBox customiseMemorySetting = new JCheckBox();
391 protected JLabel exampleMemoryLabel = new JLabel();
393 protected JTextArea exampleMemoryMessageTextArea = new JTextArea();
395 protected JLabel maxMemoryLabel = new JLabel();
397 protected JLabel jvmMemoryPercentLabel = new JLabel();
399 protected JSlider jvmMemoryPercentSlider = new JSlider();
401 protected JLabel jvmMemoryPercentDisplay = new JLabel();
403 protected JLabel jvmMemoryMaxLabel = new JLabel();
405 protected JTextField jvmMemoryMaxTextField = new JTextField(null, 8);
407 protected JComboBox<Object> lafCombo = new JComboBox<>();
410 * Creates a new GPreferences object.
412 public GPreferences()
417 } catch (Exception ex)
419 ex.printStackTrace();
424 * Construct the panel and its tabbed sub-panels.
428 private void jbInit() throws Exception
430 // final JTabbedPane tabbedPane = new JTabbedPane();
431 this.setLayout(new BorderLayout());
433 // message label at top
434 this.add(messageLabel, BorderLayout.NORTH);
436 JPanel okCancelPanel = initOkCancelPanel();
437 this.add(tabbedPane, BorderLayout.CENTER);
438 this.add(okCancelPanel, BorderLayout.SOUTH);
440 tabbedPane.add(initVisualTab(),
441 MessageManager.getString("label.visual"));
443 tabbedPane.add(initColoursTab(),
444 MessageManager.getString("label.colours"));
446 tabbedPane.add(initOverviewTab(),
447 MessageManager.getString("label.overview"));
449 tabbedPane.add(initStructureTab(),
450 MessageManager.getString("label.structure"));
452 tabbedPane.add(initConnectionsTab(),
453 MessageManager.getString("label.connections"));
455 if (!Platform.isJS())
457 tabbedPane.add(initBackupsTab(),
458 MessageManager.getString("label.backups"));
461 tabbedPane.add(initLinksTab(),
462 MessageManager.getString("label.urllinks"));
464 tabbedPane.add(initOutputTab(),
465 MessageManager.getString("label.output"));
467 tabbedPane.add(initEditingTab(),
468 MessageManager.getString("label.editing"));
470 tabbedPane.add(initStartupTab(),
471 MessageManager.getString("label.startup"));
474 * See WsPreferences for the real work of configuring this tab.
476 if (!Platform.isJS())
478 wsTab.setLayout(new BorderLayout());
479 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
483 * Handler to validate a tab before leaving it - currently only for
485 * Adding a clearMessage() so messages are cleared when changing tabs.
487 tabbedPane.addChangeListener(new ChangeListener()
489 private Component lastTab;
492 public void stateChanged(ChangeEvent e)
494 if (lastTab == structureTab
495 && tabbedPane.getSelectedComponent() != structureTab)
497 if (!validateStructure())
499 tabbedPane.setSelectedComponent(structureTab);
503 lastTab = tabbedPane.getSelectedComponent();
511 public void setMessage(String message)
515 messageLabel.setText(message);
516 messageLabel.setFont(LABEL_FONT_BOLD);
517 messageLabel.setForeground(Color.RED.darker());
518 messageLabel.revalidate();
519 messageLabel.repaint();
521 // note message not cleared if message is null. call clearMessage()
527 public void clearMessage()
529 // only repaint if message exists
530 if (messageLabel.getText() != null
531 && messageLabel.getText().length() > 0)
533 messageLabel.setText("");
534 messageLabel.revalidate();
535 messageLabel.repaint();
541 public static enum TabRef
543 CONNECTIONS_TAB, STRUCTURE_TAB
546 public void selectTab(TabRef selectTab)
548 // select a given tab - currently only for Connections
551 case CONNECTIONS_TAB:
552 tabbedPane.setSelectedComponent(connectTab);
555 tabbedPane.setSelectedComponent(structureTab);
562 * Initialises the Editing tabbed panel.
566 private JPanel initEditingTab()
568 JPanel editingTab = new JPanel();
569 editingTab.setLayout(null);
570 autoCalculateConsCheck.setFont(LABEL_FONT);
571 autoCalculateConsCheck.setText(
572 MessageManager.getString("label.autocalculate_consensus"));
573 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
574 padGaps.setFont(LABEL_FONT);
576 MessageManager.getString("label.pad_gaps_when_editing"));
577 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
578 sortByTree.setFont(LABEL_FONT);
580 .setText(MessageManager.getString("label.sort_with_new_tree"));
581 sortByTree.setToolTipText(MessageManager.getString(
582 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
583 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
584 editingTab.add(autoCalculateConsCheck);
585 editingTab.add(padGaps);
586 editingTab.add(sortByTree);
591 * Initialises the Output tab
595 private JPanel initOutputTab()
597 JPanel outputTab = new JPanel();
598 outputTab.setLayout(null);
600 JLabel epsLabel = new JLabel(
601 MessageManager.formatMessage("label.rendering_style", "EPS"));
602 epsLabel.setFont(LABEL_FONT);
603 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
604 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
605 epsRendering.setFont(LABEL_FONT);
606 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
607 JLabel htmlLabel = new JLabel(
608 MessageManager.formatMessage("label.rendering_style", "HTML"));
609 htmlLabel.setFont(LABEL_FONT);
610 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
611 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
612 htmlRendering.setFont(LABEL_FONT);
613 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
614 JLabel svgLabel = new JLabel(
615 MessageManager.formatMessage("label.rendering_style", "SVG"));
616 svgLabel.setFont(LABEL_FONT);
617 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
618 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
619 svgRendering.setFont(LABEL_FONT);
620 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
622 JLabel jLabel1 = new JLabel();
623 jLabel1.setFont(LABEL_FONT);
624 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
625 jLabel1.setText(MessageManager.getString("label.append_start_end"));
626 jLabel1.setFont(LABEL_FONT);
628 fastajv.setFont(LABEL_FONT);
629 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
630 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
631 blcjv.setText(MessageManager.getString("label.blc") + " ");
632 fastajv.setText(MessageManager.getString("label.fasta") + " ");
633 msfjv.setText(MessageManager.getString("label.msf") + " ");
634 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
635 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
636 msfjv.setFont(LABEL_FONT);
637 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
638 pirjv.setText(MessageManager.getString("label.pir") + " ");
639 JPanel jPanel11 = new JPanel();
640 jPanel11.setFont(LABEL_FONT);
641 TitledBorder titledBorder2 = new TitledBorder(
642 MessageManager.getString("label.file_output"));
643 jPanel11.setBorder(titledBorder2);
644 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
645 GridLayout gridLayout3 = new GridLayout();
646 jPanel11.setLayout(gridLayout3);
647 gridLayout3.setRows(8);
648 blcjv.setFont(LABEL_FONT);
649 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
650 clustaljv.setFont(LABEL_FONT);
651 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
652 pfamjv.setFont(LABEL_FONT);
653 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
654 pileupjv.setFont(LABEL_FONT);
655 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
656 pirjv.setFont(LABEL_FONT);
657 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
658 autoIdWidth.setFont(LABEL_FONT);
660 MessageManager.getString("label.automatically_set_id_width"));
661 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
662 .getString("label.adjusts_width_generated_eps_png")));
663 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
664 autoIdWidth.addActionListener(new ActionListener()
668 public void actionPerformed(ActionEvent e)
670 autoIdWidth_actionPerformed();
673 userIdWidthlabel.setFont(LABEL_FONT);
674 userIdWidthlabel.setText(
675 MessageManager.getString("label.figure_id_column_width"));
676 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
677 .getString("label.manually_specify_width_left_column")));
678 userIdWidthlabel.setToolTipText(
679 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
680 "label.manually_specify_width_left_column")));
681 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
682 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
683 userIdWidth.setText("");
684 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
685 userIdWidth.addActionListener(new ActionListener()
689 public void actionPerformed(ActionEvent e)
691 userIdWidth_actionPerformed();
694 modellerOutput.setFont(LABEL_FONT);
696 .setText(MessageManager.getString("label.use_modeller_output"));
697 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
698 embbedBioJSON.setFont(LABEL_FONT);
699 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
700 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
702 jPanel11.add(jLabel1);
704 jPanel11.add(clustaljv);
705 jPanel11.add(fastajv);
707 jPanel11.add(pfamjv);
708 jPanel11.add(pileupjv);
710 outputTab.add(autoIdWidth);
711 outputTab.add(userIdWidth);
712 outputTab.add(userIdWidthlabel);
713 outputTab.add(modellerOutput);
714 if (!Platform.isJS())
717 * JalviewJS doesn't support Lineart option or SVG output
719 outputTab.add(embbedBioJSON);
720 outputTab.add(epsLabel);
721 outputTab.add(epsRendering);
722 outputTab.add(htmlLabel);
723 outputTab.add(htmlRendering);
724 outputTab.add(svgLabel);
725 outputTab.add(svgRendering);
727 outputTab.add(jPanel11);
732 * Initialises the Connections tabbed panel.
736 private JPanel initConnectionsTab()
738 connectTab = new JPanel();
739 connectTab.setLayout(new GridBagLayout());
741 JPanel proxyPanel = initConnTabProxyPanel();
742 initConnTabCheckboxes();
744 // Add proxy server panel
745 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
746 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
747 new Insets(10, 0, 5, 12), 4, 10));
749 // Add usage stats, version check and questionnaire checkboxes
750 connectTab.add(usagestats,
751 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
752 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
753 new Insets(0, 2, 5, 5), 70, 1));
754 connectTab.add(questionnaire,
755 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
756 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
757 new Insets(0, 2, 5, 10), 70, 1));
758 connectTab.add(versioncheck,
759 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
760 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
761 new Insets(0, 2, 5, 5), 70, 1));
763 versioncheck.setVisible(false);
765 // Add padding so the panel doesn't look ridiculous
766 JPanel spacePanel = new JPanel();
767 connectTab.add(spacePanel,
768 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
769 GridBagConstraints.WEST, GridBagConstraints.BOTH,
770 new Insets(0, 0, 0, 5), 70, 1));
776 * Initialises the Links tabbed panel.
780 private JPanel initLinksTab()
782 JPanel linkTab = new JPanel();
783 linkTab.setLayout(new GridBagLayout());
785 // Set up table for Url links
786 linkUrlTable.getTableHeader().setReorderingAllowed(false);
787 linkUrlTable.setFillsViewportHeight(true);
788 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
789 linkUrlTable.setAutoCreateRowSorter(true);
790 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
792 // adjust row height so radio buttons actually fit
793 // don't do this in the renderer, it causes the awt thread to activate
795 JRadioButton temp = new JRadioButton();
796 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
798 // Table in scrollpane so that the table is given a scrollbar
799 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
800 linkScrollPane.setBorder(null);
802 // Panel for links functionality
803 JPanel linkPanel = new JPanel(new GridBagLayout());
804 linkPanel.setBorder(new TitledBorder(
805 MessageManager.getString("label.url_linkfrom_sequence_id")));
807 // Put the Url links panel together
809 // Buttons go at top right, resizing only resizes the blank space vertically
810 JPanel buttonPanel = initLinkTabUrlButtons();
811 GridBagConstraints linkConstraints1 = new GridBagConstraints();
812 linkConstraints1.insets = new Insets(0, 0, 5, 0);
813 linkConstraints1.gridx = 0;
814 linkConstraints1.gridy = 0;
815 linkConstraints1.weightx = 1.0;
816 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
817 linkTab.add(buttonPanel, linkConstraints1);
819 // Links table goes at top left, resizing resizes the table
820 GridBagConstraints linkConstraints2 = new GridBagConstraints();
821 linkConstraints2.insets = new Insets(0, 0, 5, 5);
822 linkConstraints2.gridx = 0;
823 linkConstraints2.gridy = 1;
824 linkConstraints2.weightx = 1.0;
825 linkConstraints2.weighty = 1.0;
826 linkConstraints2.fill = GridBagConstraints.BOTH;
827 linkTab.add(linkScrollPane, linkConstraints2);
829 // Filter box and buttons goes at bottom left, resizing resizes the text box
830 JPanel filterPanel = initLinkTabFilterPanel();
831 GridBagConstraints linkConstraints3 = new GridBagConstraints();
832 linkConstraints3.insets = new Insets(0, 0, 0, 5);
833 linkConstraints3.gridx = 0;
834 linkConstraints3.gridy = 2;
835 linkConstraints3.weightx = 1.0;
836 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
837 linkTab.add(filterPanel, linkConstraints3);
842 private JPanel initLinkTabFilterPanel()
844 // Filter textbox and reset button
845 JLabel filterLabel = new JLabel(
846 MessageManager.getString("label.filter"));
847 filterLabel.setFont(LABEL_FONT);
848 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
849 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
851 filterTB.setFont(LABEL_FONT);
852 filterTB.setText("");
854 doReset.setText(MessageManager.getString("action.showall"));
855 userOnly.setText(MessageManager.getString("action.customfilter"));
857 // Panel for filter functionality
858 JPanel filterPanel = new JPanel(new GridBagLayout());
859 filterPanel.setBorder(new TitledBorder("Filter"));
860 GridBagConstraints gbc = new GridBagConstraints();
863 gbc.fill = GridBagConstraints.NONE;
864 gbc.anchor = GridBagConstraints.WEST;
866 filterPanel.add(filterLabel, gbc);
868 GridBagConstraints gbc1 = new GridBagConstraints();
871 gbc1.fill = GridBagConstraints.HORIZONTAL;
872 gbc1.anchor = GridBagConstraints.WEST;
874 filterPanel.add(filterTB, gbc1);
876 GridBagConstraints gbc2 = new GridBagConstraints();
878 gbc2.fill = GridBagConstraints.NONE;
879 gbc2.anchor = GridBagConstraints.WEST;
880 filterPanel.add(doReset, gbc2);
882 GridBagConstraints gbc3 = new GridBagConstraints();
884 gbc3.fill = GridBagConstraints.NONE;
885 gbc3.anchor = GridBagConstraints.WEST;
886 filterPanel.add(userOnly, gbc3);
891 private JPanel initLinkTabUrlButtons()
893 // Buttons for new / edit / delete Url links
894 JButton newLink = new JButton();
895 newLink.setText(MessageManager.getString("action.new"));
897 editLink.setText(MessageManager.getString("action.edit"));
899 deleteLink.setText(MessageManager.getString("action.delete"));
901 // no current selection, so initially disable delete/edit buttons
902 editLink.setEnabled(false);
903 deleteLink.setEnabled(false);
905 newLink.addActionListener(new java.awt.event.ActionListener()
908 public void actionPerformed(ActionEvent e)
910 newLink_actionPerformed(e);
914 editLink.setText(MessageManager.getString("action.edit"));
915 editLink.addActionListener(new java.awt.event.ActionListener()
918 public void actionPerformed(ActionEvent e)
920 editLink_actionPerformed(e);
924 deleteLink.setText(MessageManager.getString("action.delete"));
925 deleteLink.addActionListener(new java.awt.event.ActionListener()
928 public void actionPerformed(ActionEvent e)
930 deleteLink_actionPerformed(e);
934 JPanel buttonPanel = new JPanel(new GridBagLayout());
935 buttonPanel.setBorder(new TitledBorder("Edit links"));
936 GridBagConstraints gbc = new GridBagConstraints();
939 gbc.fill = GridBagConstraints.NONE;
940 buttonPanel.add(newLink, gbc);
942 GridBagConstraints gbc1 = new GridBagConstraints();
945 gbc1.fill = GridBagConstraints.NONE;
946 buttonPanel.add(editLink, gbc1);
948 GridBagConstraints gbc2 = new GridBagConstraints();
951 gbc2.fill = GridBagConstraints.NONE;
952 buttonPanel.add(deleteLink, gbc2);
954 GridBagConstraints gbc3 = new GridBagConstraints();
957 gbc3.fill = GridBagConstraints.HORIZONTAL;
959 JPanel spacePanel = new JPanel();
960 spacePanel.setBorder(null);
961 buttonPanel.add(spacePanel, gbc3);
967 * Initialises the proxy server panel in the Connections tab
969 * @return the proxy server panel
971 private JPanel initConnTabProxyPanel()
973 // Label for server text box
974 serverLabel.setText(MessageManager.getString("label.host") + ": ");
975 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
976 serverLabel.setFont(LABEL_FONT);
977 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
978 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
979 serverLabel2.setFont(LABEL_FONT);
981 // Proxy server and port text boxes
982 proxyServerHttpTB.setFont(LABEL_FONT);
983 proxyServerHttpTB.setColumns(40);
984 proxyPortHttpTB.setFont(LABEL_FONT);
985 proxyPortHttpTB.setColumns(4);
986 proxyServerHttpsTB.setFont(LABEL_FONT);
987 proxyServerHttpsTB.setColumns(40);
988 proxyPortHttpsTB.setFont(LABEL_FONT);
989 proxyPortHttpsTB.setColumns(4);
990 proxyAuthUsernameTB.setFont(LABEL_FONT);
991 proxyAuthUsernameTB.setColumns(30);
993 // check for any change to enable applyProxyButton
994 DocumentListener d = new DocumentListener()
997 public void changedUpdate(DocumentEvent e)
999 applyProxyButtonEnabled(true);
1003 public void insertUpdate(DocumentEvent e)
1005 applyProxyButtonEnabled(true);
1009 public void removeUpdate(DocumentEvent e)
1011 applyProxyButtonEnabled(true);
1014 proxyServerHttpTB.getDocument().addDocumentListener(d);
1015 proxyPortHttpTB.getDocument().addDocumentListener(d);
1016 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1017 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1018 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1019 proxyAuthPasswordPB.setFont(LABEL_FONT);
1020 proxyAuthPasswordPB.setColumns(30);
1021 proxyAuthPasswordPB.getDocument()
1022 .addDocumentListener(new DocumentListener()
1025 public void changedUpdate(DocumentEvent e)
1027 proxyAuthPasswordCheckHighlight(true);
1028 applyProxyButtonEnabled(true);
1032 public void insertUpdate(DocumentEvent e)
1034 proxyAuthPasswordCheckHighlight(true);
1035 applyProxyButtonEnabled(true);
1039 public void removeUpdate(DocumentEvent e)
1041 proxyAuthPasswordCheckHighlight(true);
1042 applyProxyButtonEnabled(true);
1047 // Label for Port text box
1048 portLabel.setFont(LABEL_FONT);
1049 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1050 portLabel.setText(MessageManager.getString("label.port") + ": ");
1051 portLabel2.setFont(LABEL_FONT);
1052 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1053 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1055 httpLabel.setText("HTTP");
1056 httpLabel.setFont(LABEL_FONT_BOLD);
1057 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1058 httpsLabel.setText("HTTPS");
1059 httpsLabel.setFont(LABEL_FONT_BOLD);
1060 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1062 proxyAuthUsernameLabel
1063 .setText(MessageManager.getString("label.username") + ": ");
1064 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1065 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1066 proxyAuthPasswordLabel
1067 .setText(MessageManager.getString("label.password") + ": ");
1068 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1069 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1070 passwordNotStoredLabel.setText(
1071 "(" + MessageManager.getString("label.not_stored") + ")");
1072 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1073 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1075 // Proxy type radio buttons
1076 noProxy.setFont(LABEL_FONT);
1077 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1078 noProxy.setText(MessageManager.getString("label.no_proxy"));
1079 systemProxy.setFont(LABEL_FONT);
1080 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1081 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1082 displayUserHostPort(Cache.startupProxyProperties[4],
1083 Cache.startupProxyProperties[0],
1084 Cache.startupProxyProperties[1]),
1085 displayUserHostPort(Cache.startupProxyProperties[6],
1086 Cache.startupProxyProperties[2],
1087 Cache.startupProxyProperties[3])));
1088 customProxy.setFont(LABEL_FONT);
1089 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1090 customProxy.setText(
1091 MessageManager.getString("label.use_proxy_server") + ":");
1092 ActionListener al = new ActionListener()
1095 public void actionPerformed(ActionEvent e)
1097 proxyType_actionPerformed();
1100 noProxy.addActionListener(al);
1101 systemProxy.addActionListener(al);
1102 customProxy.addActionListener(al);
1103 proxyType.add(noProxy);
1104 proxyType.add(systemProxy);
1105 proxyType.add(customProxy);
1107 proxyAuth.setFont(LABEL_FONT);
1108 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1109 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1110 proxyAuth.addActionListener(new ActionListener()
1113 public void actionPerformed(ActionEvent e)
1115 proxyAuth_actionPerformed();
1119 setCustomProxyEnabled();
1121 // Make proxy server panel
1122 JPanel proxyPanel = new JPanel();
1123 TitledBorder titledBorder1 = new TitledBorder(
1124 MessageManager.getString("label.proxy_servers"));
1125 proxyPanel.setBorder(titledBorder1);
1126 proxyPanel.setLayout(new GridBagLayout());
1127 GridBagConstraints gbc = new GridBagConstraints();
1128 gbc.fill = GridBagConstraints.HORIZONTAL;
1131 GridBagConstraints c = new GridBagConstraints();
1132 // Proxy type radio buttons (3)
1133 JPanel ptPanel = new JPanel();
1134 ptPanel.setLayout(new GridBagLayout());
1139 c.fill = GridBagConstraints.HORIZONTAL;
1140 ptPanel.add(noProxy, c);
1142 ptPanel.add(systemProxy, c);
1144 ptPanel.add(customProxy, c);
1147 proxyPanel.add(ptPanel, gbc);
1149 // host and port text boxes
1150 JPanel hpPanel = new JPanel();
1151 hpPanel.setLayout(new GridBagLayout());
1152 // HTTP host port row
1157 c.anchor = GridBagConstraints.LINE_START;
1158 hpPanel.add(httpLabel, c);
1162 c.anchor = GridBagConstraints.LINE_END;
1163 hpPanel.add(serverLabel, c);
1167 c.anchor = GridBagConstraints.LINE_START;
1168 hpPanel.add(proxyServerHttpTB, c);
1172 c.anchor = GridBagConstraints.LINE_END;
1173 hpPanel.add(portLabel, c);
1177 c.anchor = GridBagConstraints.LINE_START;
1178 hpPanel.add(proxyPortHttpTB, c);
1180 // HTTPS host port row
1185 c.anchor = GridBagConstraints.LINE_START;
1186 hpPanel.add(httpsLabel, c);
1189 c.anchor = GridBagConstraints.LINE_END;
1190 hpPanel.add(serverLabel2, c);
1193 c.anchor = GridBagConstraints.LINE_START;
1194 hpPanel.add(proxyServerHttpsTB, c);
1197 c.anchor = GridBagConstraints.LINE_END;
1198 hpPanel.add(portLabel2, c);
1201 c.anchor = GridBagConstraints.LINE_START;
1202 hpPanel.add(proxyPortHttpsTB, c);
1205 proxyPanel.add(hpPanel, gbc);
1207 if (!Platform.isJS())
1209 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1210 * Authentication options in Preferences.
1216 // Require authentication checkbox
1218 proxyPanel.add(proxyAuth, gbc);
1220 // username and password
1221 JPanel upPanel = new JPanel();
1222 upPanel.setLayout(new GridBagLayout());
1228 c.anchor = GridBagConstraints.LINE_END;
1229 upPanel.add(proxyAuthUsernameLabel, c);
1233 c.anchor = GridBagConstraints.LINE_START;
1234 upPanel.add(proxyAuthUsernameTB, c);
1240 c.anchor = GridBagConstraints.LINE_END;
1241 upPanel.add(proxyAuthPasswordLabel, c);
1245 c.anchor = GridBagConstraints.LINE_START;
1246 upPanel.add(proxyAuthPasswordPB, c);
1250 c.anchor = GridBagConstraints.LINE_START;
1251 upPanel.add(passwordNotStoredLabel, c);
1254 proxyPanel.add(upPanel, gbc);
1258 applyProxyButton.setText(MessageManager.getString("action.apply"));
1259 applyProxyButton.addActionListener(new ActionListener()
1262 public void actionPerformed(ActionEvent e)
1264 saveProxySettings();
1265 applyProxyButton.setEnabled(false);
1269 gbc.fill = GridBagConstraints.NONE;
1270 gbc.anchor = GridBagConstraints.LINE_END;
1271 proxyPanel.add(applyProxyButton, gbc);
1276 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1278 proxyAuthPasswordCheckHighlight(enabled, false);
1281 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1284 if (enabled && proxyType.isSelected(customProxy.getModel())
1285 && proxyAuth.isSelected()
1286 && !proxyAuthUsernameTB.getText().isEmpty()
1287 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1290 proxyAuthPasswordPB.grabFocus();
1291 proxyAuthPasswordPB.setBackground(Color.PINK);
1295 proxyAuthPasswordPB.setBackground(Color.WHITE);
1299 public void applyProxyButtonEnabled(boolean enabled)
1301 applyProxyButton.setEnabled(enabled);
1304 public void saveProxySettings()
1306 // overridden in Preferences
1309 private String displayUserHostPort(String user, String host, String port)
1311 boolean hostBlank = (host == null || host.isEmpty());
1312 boolean portBlank = (port == null || port.isEmpty());
1313 if (hostBlank && portBlank)
1315 return MessageManager.getString("label.none");
1318 StringBuilder sb = new StringBuilder();
1321 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1325 sb.append(hostBlank ? "" : host);
1331 return sb.toString();
1335 * Initialises the checkboxes in the Connections tab
1337 private void initConnTabCheckboxes()
1339 // Usage stats checkbox label
1341 MessageManager.getString("label.send_usage_statistics"));
1342 usagestats.setFont(LABEL_FONT);
1343 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1344 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1346 // Questionnaire checkbox label
1347 questionnaire.setText(
1348 MessageManager.getString("label.check_for_questionnaires"));
1349 questionnaire.setFont(LABEL_FONT);
1350 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1351 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1353 // Check for latest version checkbox label
1354 versioncheck.setText(
1355 MessageManager.getString("label.check_for_latest_version"));
1356 versioncheck.setFont(LABEL_FONT);
1357 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1358 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1362 * Initialises the parent panel which contains the tabbed sections.
1366 private JPanel initOkCancelPanel()
1368 JButton ok = new JButton();
1369 ok.setText(MessageManager.getString("action.ok"));
1370 ok.addActionListener(new ActionListener()
1373 public void actionPerformed(ActionEvent e)
1375 ok_actionPerformed(e);
1378 JButton cancel = new JButton();
1379 cancel.setText(MessageManager.getString("action.cancel"));
1380 cancel.addActionListener(new ActionListener()
1383 public void actionPerformed(ActionEvent e)
1385 cancel_actionPerformed(e);
1388 JPanel okCancelPanel = new JPanel();
1389 okCancelPanel.add(ok);
1390 okCancelPanel.add(cancel);
1391 return okCancelPanel;
1395 * Initialises the Colours tabbed panel.
1399 private JPanel initColoursTab()
1401 JPanel coloursTab = new JPanel();
1402 coloursTab.setBorder(new TitledBorder(
1403 MessageManager.getString("action.open_new_alignment")));
1404 coloursTab.setLayout(new FlowLayout());
1405 JLabel mincolourLabel = new JLabel();
1406 mincolourLabel.setFont(LABEL_FONT);
1407 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1408 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1409 minColour.setFont(LABEL_FONT);
1410 minColour.setBorder(BorderFactory.createEtchedBorder());
1411 minColour.setPreferredSize(new Dimension(40, 20));
1412 minColour.addMouseListener(new MouseAdapter()
1415 public void mousePressed(MouseEvent e)
1417 minColour_actionPerformed(minColour);
1420 JLabel maxcolourLabel = new JLabel();
1421 maxcolourLabel.setFont(LABEL_FONT);
1422 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1423 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1424 maxColour.setFont(LABEL_FONT);
1425 maxColour.setBorder(BorderFactory.createEtchedBorder());
1426 maxColour.setPreferredSize(new Dimension(40, 20));
1427 maxColour.addMouseListener(new MouseAdapter()
1430 public void mousePressed(MouseEvent e)
1432 maxColour_actionPerformed(maxColour);
1436 protColour.setFont(LABEL_FONT);
1437 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1438 JLabel protColourLabel = new JLabel();
1439 protColourLabel.setFont(LABEL_FONT);
1440 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1441 protColourLabel.setText(
1442 MessageManager.getString("label.prot_alignment_colour") + " ");
1443 JvSwingUtils.addtoLayout(coloursTab,
1445 .getString("label.default_colour_scheme_for_alignment"),
1446 protColourLabel, protColour);
1448 nucColour.setFont(LABEL_FONT);
1449 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1450 JLabel nucColourLabel = new JLabel();
1451 nucColourLabel.setFont(LABEL_FONT);
1452 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1453 nucColourLabel.setText(
1454 MessageManager.getString("label.nuc_alignment_colour") + " ");
1455 JvSwingUtils.addtoLayout(coloursTab,
1457 .getString("label.default_colour_scheme_for_alignment"),
1458 nucColourLabel, nucColour);
1460 JPanel annotationShding = new JPanel();
1461 annotationShding.setBorder(new TitledBorder(
1462 MessageManager.getString("label.annotation_shading_default")));
1463 annotationShding.setLayout(new GridLayout(1, 2));
1464 JvSwingUtils.addtoLayout(annotationShding,
1465 MessageManager.getString(
1466 "label.default_minimum_colour_annotation_shading"),
1467 mincolourLabel, minColour);
1468 JvSwingUtils.addtoLayout(annotationShding,
1469 MessageManager.getString(
1470 "label.default_maximum_colour_annotation_shading"),
1471 maxcolourLabel, maxColour);
1472 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1477 * Initialises the Overview tabbed panel.
1481 private JPanel initOverviewTab()
1483 JPanel overviewPanel = new JPanel();
1484 overviewPanel.setBorder(new TitledBorder(
1485 MessageManager.getString("label.overview_settings")));
1487 gapColour.setFont(LABEL_FONT);
1488 // fixing the border colours stops apparent colour bleed from the panel
1489 gapColour.setBorder(
1490 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1491 gapColour.setPreferredSize(new Dimension(40, 20));
1492 gapColour.addMouseListener(new MouseAdapter()
1495 public void mousePressed(MouseEvent e)
1497 gapColour_actionPerformed(gapColour);
1501 hiddenColour.setFont(LABEL_FONT);
1502 // fixing the border colours stops apparent colour bleed from the panel
1503 hiddenColour.setBorder(
1504 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1505 hiddenColour.setPreferredSize(new Dimension(40, 20));
1506 hiddenColour.addMouseListener(new MouseAdapter()
1509 public void mousePressed(MouseEvent e)
1511 hiddenColour_actionPerformed(hiddenColour);
1515 useLegacyGap = new JCheckBox(
1516 MessageManager.getString("label.ov_legacy_gap"));
1517 useLegacyGap.setFont(LABEL_FONT);
1518 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1519 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1520 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1521 gapLabel.setFont(LABEL_FONT);
1522 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1523 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1524 showHiddenAtStart = new JCheckBox(
1525 MessageManager.getString("label.ov_show_hide_default"));
1526 showHiddenAtStart.setFont(LABEL_FONT);
1527 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1528 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1529 JLabel hiddenLabel = new JLabel(
1530 MessageManager.getString("label.hidden_colour"));
1531 hiddenLabel.setFont(LABEL_FONT);
1532 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1533 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1535 useLegacyGap.addActionListener(new ActionListener()
1538 public void actionPerformed(ActionEvent e)
1540 useLegacyGaps_actionPerformed(e);
1544 overviewPanel.setLayout(new GridBagLayout());
1545 GridBagConstraints c1 = new GridBagConstraints();
1547 c1.fill = GridBagConstraints.HORIZONTAL;
1552 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1553 overviewPanel.add(useLegacyGap, c1);
1555 GridBagConstraints c2 = new GridBagConstraints();
1556 c2.fill = GridBagConstraints.HORIZONTAL;
1559 c2.insets = new Insets(0, 15, 0, 10);
1560 overviewPanel.add(gapLabel, c2);
1562 GridBagConstraints c3 = new GridBagConstraints();
1563 c3.fill = GridBagConstraints.HORIZONTAL;
1566 c3.insets = new Insets(0, 0, 0, 15);
1567 overviewPanel.add(gapColour, c3);
1569 GridBagConstraints c4 = new GridBagConstraints();
1570 c4.fill = GridBagConstraints.HORIZONTAL;
1574 overviewPanel.add(showHiddenAtStart, c4);
1576 GridBagConstraints c5 = new GridBagConstraints();
1577 c5.fill = GridBagConstraints.HORIZONTAL;
1580 c5.insets = new Insets(0, 15, 0, 10);
1581 overviewPanel.add(hiddenLabel, c5);
1583 GridBagConstraints c6 = new GridBagConstraints();
1584 c6.fill = GridBagConstraints.HORIZONTAL;
1587 c6.insets = new Insets(0, 0, 0, 15);
1588 overviewPanel.add(hiddenColour, c6);
1590 JButton resetButton = new JButton(
1591 MessageManager.getString("label.reset_to_defaults"));
1593 resetButton.addActionListener(new ActionListener()
1596 public void actionPerformed(ActionEvent e)
1598 resetOvDefaults_actionPerformed(e);
1602 GridBagConstraints c7 = new GridBagConstraints();
1603 c7.fill = GridBagConstraints.NONE;
1606 c7.insets = new Insets(10, 0, 0, 0);
1607 c7.anchor = GridBagConstraints.WEST;
1608 overviewPanel.add(resetButton, c7);
1610 // Add padding so the panel doesn't look ridiculous
1611 JPanel spacePanel = new JPanel();
1612 overviewPanel.add(spacePanel,
1613 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1614 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1615 new Insets(0, 0, 0, 5), 0, 0));
1617 return overviewPanel;
1621 * Initialises the Structure tabbed panel.
1625 private JPanel initStructureTab()
1627 structureTab = new JPanel();
1629 structureTab.setBorder(new TitledBorder(
1630 MessageManager.getString("label.structure_options")));
1631 structureTab.setLayout(null);
1632 final int width = 420;
1633 final int height = 22;
1634 final int lineSpacing = 25;
1637 structFromPdb.setFont(LABEL_FONT);
1639 .setText(MessageManager.getString("label.struct_from_pdb"));
1640 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1641 structFromPdb.addActionListener(new ActionListener()
1644 public void actionPerformed(ActionEvent e)
1646 boolean selected = structFromPdb.isSelected();
1647 // enable other options only when the first is checked
1648 addSecondaryStructure.setEnabled(selected);
1649 addTempFactor.setEnabled(selected);
1652 structureTab.add(structFromPdb);
1654 // indent checkboxes that are conditional on the first one
1655 ypos += lineSpacing;
1656 addSecondaryStructure.setFont(LABEL_FONT);
1657 addSecondaryStructure
1658 .setText(MessageManager.getString("label.autoadd_secstr"));
1659 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1660 structureTab.add(addSecondaryStructure);
1662 ypos += lineSpacing;
1663 addTempFactor.setFont(LABEL_FONT);
1664 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1665 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1666 structureTab.add(addTempFactor);
1668 ypos += lineSpacing;
1669 JLabel viewerLabel = new JLabel();
1670 viewerLabel.setFont(LABEL_FONT);
1671 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1672 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1673 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1674 structureTab.add(viewerLabel);
1677 * add all external viewers as options here - check
1678 * when selected whether the program is installed
1680 structViewer.setFont(LABEL_FONT);
1681 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1682 structViewer.addItem(ViewerType.JMOL.name());
1683 structViewer.addItem(ViewerType.CHIMERA.name());
1684 structViewer.addItem(ViewerType.CHIMERAX.name());
1685 structViewer.addItem(ViewerType.PYMOL.name());
1686 structViewer.addActionListener(new ActionListener()
1689 public void actionPerformed(ActionEvent e)
1691 structureViewer_actionPerformed(
1692 (String) structViewer.getSelectedItem());
1695 structureTab.add(structViewer);
1697 ypos += lineSpacing;
1698 structureViewerPathLabel = new JLabel();
1699 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1701 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1702 structureViewerPathLabel.setText(MessageManager
1703 .formatMessage("label.viewer_path", "Chimera(X)"));
1704 structureViewerPathLabel
1705 .setBounds(new Rectangle(10, ypos, 170, height));
1706 structureViewerPathLabel.setEnabled(false);
1707 structureTab.add(structureViewerPathLabel);
1709 structureViewerPath.setFont(LABEL_FONT);
1710 structureViewerPath.setText("");
1711 structureViewerPath.setEnabled(false);
1712 final String tooltip = JvSwingUtils.wrapTooltip(true,
1713 MessageManager.getString("label.viewer_path_tip"));
1714 structureViewerPath.setToolTipText(tooltip);
1715 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1716 structureViewerPath.addMouseListener(new MouseAdapter()
1719 public void mouseClicked(MouseEvent e)
1721 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1723 String chosen = openFileChooser();
1726 structureViewerPath.setText(chosen);
1731 structureTab.add(structureViewerPath);
1733 ypos += lineSpacing;
1734 nwMapping.setFont(LABEL_FONT);
1735 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1736 siftsMapping.setFont(LABEL_FONT);
1737 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1738 mappingMethod.add(nwMapping);
1739 mappingMethod.add(siftsMapping);
1740 JPanel mappingPanel = new JPanel();
1741 mappingPanel.setFont(LABEL_FONT);
1742 TitledBorder mmTitledBorder = new TitledBorder(
1743 MessageManager.getString("label.mapping_method"));
1744 mmTitledBorder.setTitleFont(LABEL_FONT);
1745 mappingPanel.setBorder(mmTitledBorder);
1746 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1747 // GridLayout mappingLayout = new GridLayout();
1748 mappingPanel.setLayout(new GridLayout());
1749 mappingPanel.add(nwMapping);
1750 mappingPanel.add(siftsMapping);
1751 structureTab.add(mappingPanel);
1753 ypos += lineSpacing;
1754 ypos += lineSpacing;
1755 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1756 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1757 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1758 structureTab.add(docFieldPref);
1761 * hide Chimera options in JalviewJS
1763 if (Platform.isJS())
1765 structureViewerPathLabel.setVisible(false);
1766 structureViewerPath.setVisible(false);
1767 viewerLabel.setVisible(false);
1768 structViewer.setVisible(false);
1771 return structureTab;
1775 * Action on choosing a structure viewer from combobox options.
1777 * @param selectedItem
1779 protected void structureViewer_actionPerformed(String selectedItem)
1784 * Show a dialog for the user to choose a file. Returns the chosen path, or
1789 protected String openFileChooser()
1791 String choice = null;
1792 JFileChooser chooser = new JFileChooser();
1794 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1795 // hidden executables within .app dirs
1796 if (Platform.isMac())
1798 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1802 // chooser.setFileView(new JalviewFileView());
1803 chooser.setDialogTitle(
1804 MessageManager.getString("label.open_local_file"));
1805 chooser.setToolTipText(MessageManager.getString("action.open"));
1807 int value = chooser.showOpenDialog(this);
1809 if (value == JFileChooser.APPROVE_OPTION)
1811 choice = chooser.getSelectedFile().getPath();
1817 * Validate the structure tab preferences; if invalid, set focus on this tab.
1821 protected boolean validateStructure(FocusEvent e)
1823 if (!validateStructure())
1825 e.getComponent().requestFocusInWindow();
1831 protected boolean validateStructure()
1837 * Initialises the Visual tabbed panel.
1841 private JPanel initVisualTab()
1843 JPanel visualTab = new JPanel();
1844 visualTab.setBorder(new TitledBorder(
1845 MessageManager.getString("action.open_new_alignment")));
1846 visualTab.setLayout(null);
1847 fullScreen.setFont(LABEL_FONT);
1848 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1849 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1850 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1851 quality.setEnabled(false);
1852 quality.setFont(LABEL_FONT);
1853 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1854 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1855 quality.setSelected(true);
1856 quality.setText(MessageManager.getString("label.quality"));
1857 conservation.setEnabled(false);
1858 conservation.setFont(LABEL_FONT);
1859 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1860 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1861 conservation.setSelected(true);
1862 conservation.setText(MessageManager.getString("label.conservation"));
1863 identity.setEnabled(false);
1864 identity.setFont(LABEL_FONT);
1865 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1866 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1867 identity.setSelected(true);
1868 identity.setText(MessageManager.getString("label.consensus"));
1869 showOccupancy.setFont(LABEL_FONT);
1870 showOccupancy.setEnabled(false);
1871 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1872 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1873 showOccupancy.setSelected(true);
1874 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1876 JLabel showGroupbits = new JLabel();
1877 showGroupbits.setFont(LABEL_FONT);
1878 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1879 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1881 .setText(MessageManager.getString("action.show_group") + ":");
1882 JLabel showConsensbits = new JLabel();
1883 showConsensbits.setFont(LABEL_FONT);
1884 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1885 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1887 .setText(MessageManager.getString("label.consensus") + ":");
1888 showConsensHistogram.setEnabled(false);
1889 showConsensHistogram.setFont(LABEL_FONT);
1890 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1891 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1892 showConsensHistogram.setSelected(true);
1893 showConsensHistogram
1894 .setText(MessageManager.getString("label.histogram"));
1895 showConsensLogo.setEnabled(false);
1896 showConsensLogo.setFont(LABEL_FONT);
1897 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1898 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1899 showConsensLogo.setSelected(true);
1900 showConsensLogo.setText(MessageManager.getString("label.logo"));
1901 showGroupConsensus.setEnabled(false);
1902 showGroupConsensus.setFont(LABEL_FONT);
1903 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1904 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1905 showGroupConsensus.setSelected(true);
1906 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1907 showGroupConservation.setEnabled(false);
1908 showGroupConservation.setFont(LABEL_FONT);
1909 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1910 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1911 showGroupConservation.setSelected(true);
1912 showGroupConservation
1913 .setText(MessageManager.getString("label.conservation"));
1914 showNpTooltip.setEnabled(true);
1915 showNpTooltip.setFont(LABEL_FONT);
1916 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1917 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1918 showNpTooltip.setSelected(true);
1919 showNpTooltip.setText(
1920 MessageManager.getString("label.non_positional_features"));
1921 showDbRefTooltip.setEnabled(true);
1922 showDbRefTooltip.setFont(LABEL_FONT);
1923 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1924 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1925 showDbRefTooltip.setSelected(true);
1927 .setText(MessageManager.getString("label.database_references"));
1928 annotations.setFont(LABEL_FONT);
1929 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1930 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1931 annotations.setSelected(true);
1932 annotations.setText(MessageManager.getString("label.show_annotations"));
1933 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1934 annotations.addActionListener(new ActionListener()
1937 public void actionPerformed(ActionEvent e)
1939 annotations_actionPerformed(e);
1942 identity.addActionListener(new ActionListener()
1945 public void actionPerformed(ActionEvent e)
1947 annotations_actionPerformed(e);
1950 showGroupConsensus.addActionListener(new ActionListener()
1953 public void actionPerformed(ActionEvent e)
1955 annotations_actionPerformed(e);
1958 showUnconserved.setFont(LABEL_FONT);
1959 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1960 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1961 showUnconserved.setSelected(true);
1963 .setText(MessageManager.getString("action.show_unconserved"));
1964 showUnconserved.addActionListener(new ActionListener()
1967 public void actionPerformed(ActionEvent e)
1969 showunconserved_actionPerformed(e);
1973 // TODO these are not yet added to / action from Preferences
1974 // JCheckBox shareSelections = new JCheckBox();
1975 // shareSelections.setFont(verdana11);
1976 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1977 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1978 // shareSelections.setSelected(true);
1979 // shareSelections.setText(MessageManager
1980 // .getString("label.share_selection_across_views"));
1981 // JCheckBox followHighlight = new JCheckBox();
1982 // followHighlight.setFont(verdana11);
1983 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1984 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1985 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1986 // followHighlight.setSelected(true);
1987 // followHighlight.setText(MessageManager
1988 // .getString("label.scroll_highlighted_regions"));
1990 seqLimit.setFont(LABEL_FONT);
1991 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1992 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1993 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1994 smoothFont.setFont(LABEL_FONT);
1995 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1996 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1997 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1998 scaleProteinToCdna.setFont(LABEL_FONT);
1999 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2000 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2001 scaleProteinToCdna.setText(
2002 MessageManager.getString("label.scale_protein_to_cdna"));
2003 scaleProteinToCdna.setToolTipText(
2004 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2005 JLabel gapLabel = new JLabel();
2006 gapLabel.setFont(LABEL_FONT);
2007 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2008 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2009 JLabel fontLabel = new JLabel();
2010 fontLabel.setFont(LABEL_FONT);
2011 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2012 fontLabel.setText(MessageManager.getString("label.font"));
2013 fontSizeCB.setFont(LABEL_FONT);
2014 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2015 fontStyleCB.setFont(LABEL_FONT);
2016 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2017 fontNameCB.setFont(LABEL_FONT);
2018 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2019 gapSymbolCB.setFont(LABEL_FONT);
2020 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2021 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2022 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2023 gapSymbolCB.setRenderer(dlcr);
2025 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2026 startupCheckbox.setFont(LABEL_FONT);
2027 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2028 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2029 startupCheckbox.setSelected(true);
2030 startupFileTextfield.setFont(LABEL_FONT);
2031 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2032 final String tooltip = JvSwingUtils.wrapTooltip(true,
2033 MessageManager.getString("label.double_click_to_browse"));
2034 startupFileTextfield.setToolTipText(tooltip);
2035 startupFileTextfield.addMouseListener(new MouseAdapter()
2038 public void mouseClicked(MouseEvent e)
2040 if (e.getClickCount() > 1)
2042 startupFileTextfield_mouseClicked();
2047 sortby.setFont(LABEL_FONT);
2048 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2049 JLabel sortLabel = new JLabel();
2050 sortLabel.setFont(LABEL_FONT);
2051 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2052 sortLabel.setText(MessageManager.getString("label.sort_by"));
2053 sortAnnBy.setFont(LABEL_FONT);
2054 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2055 JLabel sortAnnLabel = new JLabel();
2056 sortAnnLabel.setFont(LABEL_FONT);
2057 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2058 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2059 sortAutocalc.setFont(LABEL_FONT);
2060 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2062 JPanel annsettingsPanel = new JPanel();
2063 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2064 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2065 annsettingsPanel.setBorder(new EtchedBorder());
2066 visualTab.add(annsettingsPanel);
2067 Border jb = new EmptyBorder(1, 1, 4, 5);
2068 annotations.setBorder(jb);
2069 showOccupancy.setBorder(jb);
2070 quality.setBorder(jb);
2071 conservation.setBorder(jb);
2072 identity.setBorder(jb);
2073 showConsensbits.setBorder(jb);
2074 showGroupbits.setBorder(jb);
2075 showGroupConsensus.setBorder(jb);
2076 showGroupConservation.setBorder(jb);
2077 showConsensHistogram.setBorder(jb);
2078 showConsensLogo.setBorder(jb);
2080 JPanel autoAnnotSettings = new JPanel();
2081 annsettingsPanel.add(autoAnnotSettings);
2082 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2083 autoAnnotSettings.add(annotations);
2084 autoAnnotSettings.add(quality);
2085 // second row of autoannotation box
2086 autoAnnotSettings = new JPanel();
2087 annsettingsPanel.add(autoAnnotSettings);
2089 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2090 autoAnnotSettings.add(conservation);
2091 autoAnnotSettings.add(identity);
2092 autoAnnotSettings.add(showOccupancy);
2093 autoAnnotSettings.add(showGroupbits);
2094 autoAnnotSettings.add(showGroupConservation);
2095 autoAnnotSettings.add(showGroupConsensus);
2096 autoAnnotSettings.add(showConsensbits);
2097 autoAnnotSettings.add(showConsensHistogram);
2098 autoAnnotSettings.add(showConsensLogo);
2100 JPanel tooltipSettings = new JPanel();
2101 tooltipSettings.setBorder(new TitledBorder(
2102 MessageManager.getString("label.sequence_id_tooltip")));
2103 tooltipSettings.setBounds(173, 140, 220, 62);
2104 tooltipSettings.setLayout(new GridLayout(2, 1));
2105 tooltipSettings.add(showDbRefTooltip);
2106 tooltipSettings.add(showNpTooltip);
2107 visualTab.add(tooltipSettings);
2109 wrap.setFont(LABEL_FONT);
2110 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2111 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2112 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2113 rightAlign.setFont(LABEL_FONT);
2114 rightAlign.setForeground(Color.black);
2115 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2116 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2117 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2118 idItalics.setFont(LABEL_FONT_ITALIC);
2119 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2120 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2122 MessageManager.getString("label.sequence_name_italics"));
2123 openoverv.setFont(LABEL_FONT);
2124 openoverv.setActionCommand(
2125 MessageManager.getString("label.open_overview"));
2126 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2127 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2128 openoverv.setText(MessageManager.getString("label.open_overview"));
2129 JPanel jPanel2 = new JPanel();
2130 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2131 jPanel2.setLayout(new GridLayout(14, 1));
2132 jPanel2.add(fullScreen);
2133 jPanel2.add(openoverv);
2134 jPanel2.add(seqLimit);
2135 jPanel2.add(rightAlign);
2136 jPanel2.add(fontLabel);
2137 jPanel2.add(showUnconserved);
2138 jPanel2.add(idItalics);
2139 jPanel2.add(smoothFont);
2140 jPanel2.add(scaleProteinToCdna);
2141 jPanel2.add(gapLabel);
2143 jPanel2.add(sortLabel);
2144 jPanel2.add(sortAnnLabel);
2145 jPanel2.add(startupCheckbox);
2146 visualTab.add(jPanel2);
2147 visualTab.add(startupFileTextfield);
2148 visualTab.add(sortby);
2149 visualTab.add(sortAnnBy);
2150 visualTab.add(sortAutocalc);
2151 visualTab.add(gapSymbolCB);
2152 visualTab.add(fontNameCB);
2153 visualTab.add(fontSizeCB);
2154 visualTab.add(fontStyleCB);
2156 if (Platform.isJS())
2158 startupCheckbox.setVisible(false);
2159 startupFileTextfield.setVisible(false);
2166 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2169 protected void loadLastSavedBackupsOptions()
2171 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2172 .getSavedBackupEntry();
2173 enableBackupFiles.setSelected(
2174 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2176 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2177 .createBackupFilesPresetEntry(Cache
2178 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2179 if (backupfilesCustomEntry == null)
2181 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2182 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2184 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2185 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2186 backupfilesCustomEntry);
2188 setComboIntStringKey(backupfilesPresetsCombo,
2189 Cache.getDefault(BackupFiles.NS + "_PRESET",
2190 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2192 backupsSetOptions(savedPreset);
2194 backupsOptionsSetEnabled();
2195 updateBackupFilesExampleLabel();
2199 * Load the saved Memory settings
2201 protected void loadLastSavedMemorySettings()
2203 customiseMemorySetting.setSelected(
2204 Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2205 jvmMemoryPercentSlider
2206 .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2207 jvmMemoryMaxTextField.setText(
2208 Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2211 private boolean warnAboutSuffixReverseChange()
2213 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2214 .getSavedBackupEntry();
2215 boolean savedSuffixReverse = bfpe.reverse;
2216 int savedSuffixDigits = bfpe.digits;
2217 String savedSuffixTemplate = bfpe.suffix;
2219 boolean nowSuffixReverse = suffixReverse.isSelected();
2220 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2221 String nowSuffixTemplate = suffixTemplate.getText();
2222 return nowSuffixReverse != savedSuffixReverse
2223 && nowSuffixDigits == savedSuffixDigits
2224 && nowSuffixTemplate != null
2225 && nowSuffixTemplate.equals(savedSuffixTemplate);
2228 /* Initialises the Startup tabbed panel.
2233 private JPanel initStartupTab()
2235 JPanel startupTab = new JPanel();
2236 startupTab.setBorder(
2237 new TitledBorder(MessageManager.getString("label.memory")));
2238 startupTab.setLayout(new GridBagLayout());
2240 GridBagConstraints gbc = new GridBagConstraints();
2243 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2244 gbc.fill = GridBagConstraints.NONE;
2251 gbc.gridy = 0; // row 1
2253 JLabel memoryText = new JLabel();
2254 memoryText.setFont(LABEL_FONT_ITALIC);
2256 .setText(MessageManager.getString("label.memory_setting_text"));
2257 startupTab.add(memoryText, gbc);
2259 gbc.gridy++; // row 2
2261 JPanel exampleMemoryPanel = new JPanel();
2263 .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2264 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2265 MessageManager.getString("label.memory_example_tooltip")));
2266 JLabel exampleTextLabel = new JLabel();
2268 .setText(MessageManager.getString("label.memory_example_text"));
2269 exampleTextLabel.setForeground(Color.GRAY);
2270 exampleTextLabel.setFont(LABEL_FONT);
2271 exampleMemoryPanel.add(exampleTextLabel);
2272 exampleMemoryPanel.add(exampleMemoryLabel);
2273 exampleMemoryPanel.setBackground(Color.WHITE);
2274 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2275 startupTab.add(exampleMemoryPanel, gbc);
2277 gbc.gridy++; // row 3
2279 startupTab.add(customiseMemorySetting, gbc);
2281 gbc.gridy += 2; // row 4 with a gap
2283 startupTab.add(maxMemoryLabel, gbc);
2285 gbc.gridy += 2; // row 5
2288 startupTab.add(jvmMemoryPercentLabel, gbc);
2290 startupTab.add(jvmMemoryPercentSlider, gbc);
2292 // gbc.weightx = 0.1;
2293 startupTab.add(jvmMemoryPercentDisplay, gbc);
2294 // gbc.weightx = 1.0;
2297 gbc.gridy++; // row 6
2299 startupTab.add(jvmMemoryMaxLabel, gbc);
2301 startupTab.add(jvmMemoryMaxTextField, gbc);
2303 gbc.gridy++; // row 7
2306 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2307 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2308 sp.setBorder(BorderFactory.createEmptyBorder());
2309 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2310 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2311 startupTab.add(sp, gbc);
2313 // fill empty space to push widget to top left
2319 startupTab.add(new JPanel(), gbc);
2321 setMemoryPercentDisplay();
2322 memoryOptionsSetEnabled();
2326 private void initMemoryPanel()
2328 // Enable memory settings checkbox
2329 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2330 customiseMemorySetting.setText(
2331 MessageManager.getString("label.customise_memory_settings"));
2332 customiseMemorySetting.addActionListener(new ActionListener()
2335 public void actionPerformed(ActionEvent e)
2337 memoryOptionsSetEnabled();
2341 loadLastSavedMemorySettings();
2343 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2344 exampleMemoryLabel.setBackground(Color.WHITE);
2346 maxMemoryLabel = new JLabel(
2347 MessageManager.getString("label.maximum_memory_used"));
2348 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2350 // Maximum memory percentage slider
2351 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2352 jvmMemoryPercentLabel.setText(
2353 MessageManager.getString("label.percent_of_physical_memory"));
2354 jvmMemoryPercentSlider.setPaintLabels(true);
2355 jvmMemoryPercentSlider.setPaintTicks(true);
2356 jvmMemoryPercentSlider.setPaintTrack(true);
2357 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2358 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2359 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2362 public void stateChanged(ChangeEvent e)
2364 setMemoryPercentDisplay();
2367 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2368 setMemoryPercentDisplay();
2370 // Maximum memory cap textbox
2371 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2373 .setText(MessageManager.getString("label.maximum_memory"));
2374 initMemoryMaxTextField();
2376 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2377 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2378 exampleMemoryMessageTextArea.setEditable(false);
2379 exampleMemoryMessageTextArea.setLineWrap(true);
2380 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2381 exampleMemoryMessageTextArea.setText(" ");
2382 exampleMemoryMessageTextArea.setRows(2);
2383 exampleMemoryMessageTextArea.setColumns(40);
2385 setExampleMemoryLabel();
2388 private void initMemoryMaxTextField()
2390 jvmMemoryMaxTextField.setToolTipText(
2391 MessageManager.getString("label.maximum_memory_tooltip"));
2392 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2395 public void actionPerformed(ActionEvent arg0)
2397 validateMemoryMaxTextField();
2398 setExampleMemoryLabel();
2402 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2405 public void keyReleased(KeyEvent e)
2407 validateMemoryMaxTextField();
2408 setExampleMemoryLabel();
2412 public void keyPressed(KeyEvent e)
2416 // try and stop invalid typing
2418 public void keyTyped(KeyEvent e)
2420 char c = Character.toLowerCase(e.getKeyChar());
2421 String text = jvmMemoryMaxTextField.getText();
2422 String suffixes = "tgmkb";
2423 int pos = jvmMemoryMaxTextField.getCaretPosition();
2424 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2425 if (!((('0' <= c && c <= '9')
2426 && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2428 || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2430 && pos == text.length() // at end of text and
2431 && suffixPos == -1) // there isn't already one
2441 private boolean isMemoryMaxTextFieldValid()
2443 return MemorySetting
2444 .isValidMemoryString(jvmMemoryMaxTextField.getText());
2447 private void validateMemoryMaxTextField()
2449 if (isMemoryMaxTextFieldValid())
2451 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2455 jvmMemoryMaxTextField.setBackground(Color.PINK);
2459 private void setMemoryPercentDisplay()
2461 jvmMemoryPercentDisplay
2462 .setText(jvmMemoryPercentSlider.getValue() + "%");
2463 setExampleMemoryLabel();
2466 private void setExampleMemoryLabel()
2468 boolean selected = customiseMemorySetting.isSelected();
2469 int jvmmempc = jvmMemoryPercentSlider.getValue();
2470 String jvmmemmax = jvmMemoryMaxTextField.getText();
2473 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2474 && MemorySetting.isValidMemoryString(jvmmemmax))
2476 mem = MemorySetting.getMemorySetting(jvmmemmax,
2477 String.valueOf(jvmmempc), false, true);
2481 mem = MemorySetting.getMemorySetting(null, null, false, true);
2483 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2484 String message = MemorySetting.getAdjustmentMessage();
2485 exampleMemoryMessageTextArea.setText(
2486 MessageManager.getString("label.adjustments_for_this_computer")
2489 ? MessageManager.getString("label.none")
2493 private void memoryOptionsSetEnabled()
2495 boolean enabled = customiseMemorySetting.isSelected();
2496 // leave exampleMemoryLabel enabled always
2497 maxMemoryLabel.setEnabled(enabled);
2498 jvmMemoryPercentLabel.setEnabled(enabled);
2499 jvmMemoryPercentSlider.setEnabled(enabled);
2500 jvmMemoryPercentDisplay.setEnabled(enabled);
2501 jvmMemoryMaxLabel.setEnabled(enabled);
2502 jvmMemoryMaxTextField.setEnabled(enabled);
2503 exampleMemoryMessageTextArea.setEnabled(enabled);
2504 setExampleMemoryLabel();
2508 * Initialises the Backups tabbed panel.
2512 private JPanel initBackupsTab()
2514 JPanel backupsTab = new JPanel();
2515 backupsTab.setBorder(new TitledBorder(
2516 MessageManager.getString("label.backup_files")));
2517 backupsTab.setLayout(new GridBagLayout());
2519 GridBagConstraints gbc = new GridBagConstraints();
2522 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2523 gbc.fill = GridBagConstraints.NONE;
2525 initBackupsTabPresetsPanel();
2526 initBackupsTabSuffixPanel();
2527 initBackupsTabKeepFilesPanel();
2528 initBackupsTabFilenameExamplesPanel();
2530 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2532 .setText(MessageManager.getString("label.enable_backupfiles"));
2533 enableBackupFiles.addActionListener(new ActionListener()
2536 public void actionPerformed(ActionEvent e)
2538 // enable other options only when the first is checked
2539 backupsOptionsSetEnabled();
2543 // enable checkbox 1 col
2547 gbc.gridy = 0; // row 0
2548 backupsTab.add(enableBackupFiles, gbc);
2550 // summary of scheme box (over two rows)
2554 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2555 gbc.fill = GridBagConstraints.BOTH;
2556 backupsTab.add(exampleFilesPanel, gbc);
2558 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2559 gbc.fill = GridBagConstraints.NONE;
2561 // fill empty space on right
2564 backupsTab.add(new JPanel(), gbc);
2569 gbc.gridy++; // row 1
2570 backupsTab.add(presetsPanel, gbc);
2572 // now using whole row
2577 gbc.gridy++; // row 2
2578 backupsTab.add(keepfilesPanel, gbc);
2580 // filename strategy box
2581 gbc.gridy++; // row 3
2582 backupsTab.add(suffixPanel, gbc);
2585 gbc.gridy++; // row 4
2587 backupsTab.add(new JPanel(), gbc);
2589 backupsOptionsSetEnabled();
2593 private JPanel initBackupsTabPresetsPanel()
2596 String title = MessageManager.getString("label.schemes");
2598 presetsPanel.setLayout(new GridBagLayout());
2600 GridBagConstraints gbc = new GridBagConstraints();
2603 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2604 gbc.fill = GridBagConstraints.NONE;
2612 presetsComboLabel = new JLabel(title + ":");
2613 presetsPanel.add(presetsComboLabel, gbc);
2615 List<Object> entries = Arrays.asList(
2616 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2617 List<String> tooltips = Arrays.asList(
2618 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2619 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2622 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2624 backupfilesPresetsCombo
2625 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2629 backupfilesPresetsCombo.addActionListener(new ActionListener()
2632 public void actionPerformed(ActionEvent e)
2634 int key = getComboIntStringKey(backupfilesPresetsCombo);
2635 if (!customiseCheckbox.isSelected())
2637 backupfilesPresetsComboLastSelected = key;
2639 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2641 if (customiseCheckbox.isSelected())
2643 // got here by clicking on customiseCheckbox so don't change the
2645 backupfilesCustomOptionsSetEnabled();
2649 backupsTabUpdatePresets();
2650 backupfilesCustomOptionsSetEnabled();
2655 customiseCheckbox.setSelected(false);
2656 backupsTabUpdatePresets();
2657 backupfilesCustomOptionsSetEnabled();
2662 // dropdown list of preset schemes
2664 presetsPanel.add(backupfilesPresetsCombo, gbc);
2666 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2667 revertButton.setToolTipText(
2668 MessageManager.getString("label.cancel_changes_description"));
2669 revertButton.addActionListener(new ActionListener()
2672 public void actionPerformed(ActionEvent e)
2675 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2676 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2677 backupfilesCustomOptionsSetEnabled();
2681 revertButton.setFont(LABEL_FONT);
2683 customiseCheckbox.setFont(LABEL_FONT);
2684 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2685 customiseCheckbox.addActionListener(new ActionListener()
2688 public void actionPerformed(ActionEvent e)
2690 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2691 if (customiseCheckbox.isSelected())
2693 backupfilesPresetsComboLastSelected = currently;
2694 setComboIntStringKey(backupfilesPresetsCombo,
2695 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2699 setComboIntStringKey(backupfilesPresetsCombo,
2700 backupfilesPresetsComboLastSelected);
2703 backupfilesCustomOptionsSetEnabled();
2706 customiseCheckbox.setToolTipText(
2707 MessageManager.getString("label.customise_description"));
2709 // customise checkbox
2712 presetsPanel.add(customiseCheckbox, gbc);
2714 // "Cancel changes" button (aligned with combo box above)
2716 presetsPanel.add(revertButton, gbc);
2718 return presetsPanel;
2721 private JPanel initBackupsTabFilenameExamplesPanel()
2723 String title = MessageManager.getString("label.scheme_examples");
2724 TitledBorder tb = new TitledBorder(title);
2725 exampleFilesPanel.setBorder(tb);
2726 exampleFilesPanel.setLayout(new GridBagLayout());
2728 backupfilesExampleLabel.setEditable(false);
2729 backupfilesExampleLabel
2730 .setBackground(exampleFilesPanel.getBackground());
2732 updateBackupFilesExampleLabel();
2734 GridBagConstraints gbc = new GridBagConstraints();
2737 gbc.fill = GridBagConstraints.NONE;
2738 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2740 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2741 return exampleFilesPanel;
2744 private void backupsTabUpdatePresets()
2746 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2749 String value = entry.v;
2751 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2755 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2761 "Preset '" + value + "' [key:" + key + "] not implemented");
2764 // Custom options will now be enabled when the customiseCheckbox is checked
2765 // (performed above)
2766 // backupfilesCustomOptionsSetEnabled();
2767 updateBackupFilesExampleLabel();
2770 protected int getComboIntStringKey(
2771 JComboBox<Object> backupfilesPresetsCombo2)
2773 IntKeyStringValueEntry e;
2776 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2778 } catch (Exception ex)
2781 "Problem casting Combo entry to IntKeyStringValueEntry.");
2784 return e != null ? e.k : 0;
2787 protected void setComboIntStringKey(
2788 JComboBox<Object> backupfilesPresetsCombo2, int key)
2790 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2792 IntKeyStringValueEntry e;
2795 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2796 } catch (Exception ex)
2799 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2804 backupfilesPresetsCombo2.setSelectedIndex(i);
2808 // backupsTabUpdatePresets();
2811 private JPanel initBackupsTabSuffixPanel()
2813 suffixPanel.setBorder(new TitledBorder(
2814 MessageManager.getString("label.backup_filename_strategy")));
2815 suffixPanel.setLayout(new GridBagLayout());
2818 .setText(MessageManager.getString("label.append_to_filename"));
2819 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2820 suffixTemplateLabel.setFont(LABEL_FONT);
2822 final String tooltip = JvSwingUtils.wrapTooltip(true,
2823 MessageManager.getString("label.append_to_filename_tooltip"));
2824 suffixTemplate.setToolTipText(tooltip);
2825 suffixTemplate.addActionListener(new ActionListener()
2828 public void actionPerformed(ActionEvent e)
2830 updateBackupFilesExampleLabel();
2831 backupfilesCustomOptionsSetEnabled();
2832 backupfilesRevertButtonSetEnabled(true);
2836 suffixTemplate.addKeyListener(new KeyListener()
2839 public void keyReleased(KeyEvent e)
2841 updateBackupFilesExampleLabel();
2842 backupfilesCustomOptionsSetEnabled();
2843 backupfilesRevertButtonSetEnabled(true);
2847 public void keyPressed(KeyEvent e)
2851 // disable use of ':' or '/' or '\'
2853 public void keyTyped(KeyEvent e)
2855 char c = e.getKeyChar();
2856 if (c == ':' || c == '/' || c == '\\')
2858 // don't process ':' or '/' or '\'
2867 .setText(MessageManager.getString("label.index_digits"));
2868 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2869 suffixDigitsLabel.setFont(LABEL_FONT);
2870 ChangeListener c = new ChangeListener()
2873 public void stateChanged(ChangeEvent e)
2875 backupfilesRevertButtonSetEnabled(true);
2876 updateBackupFilesExampleLabel();
2880 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2881 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2883 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2884 MessageManager.getString("label.increment_index"));
2885 suffixReverse.addActionListener(new ActionListener()
2888 public void actionPerformed(ActionEvent e)
2890 boolean okay = true;
2891 if (warnAboutSuffixReverseChange())
2894 okay = confirmSuffixReverseChange();
2898 backupfilesRevertButtonSetEnabled(true);
2899 updateBackupFilesExampleLabel();
2903 boolean savedSuffixReverse = BackupFilesPresetEntry
2904 .getSavedBackupEntry().reverse;
2905 suffixReverse.setSelected(savedSuffixReverse);
2910 GridBagConstraints sgbc = new GridBagConstraints();
2912 // first row (template text box)
2913 sgbc.anchor = GridBagConstraints.WEST;
2917 sgbc.gridheight = 1;
2920 sgbc.fill = GridBagConstraints.NONE;
2921 suffixPanel.add(suffixTemplateLabel, sgbc);
2924 sgbc.fill = GridBagConstraints.HORIZONTAL;
2925 suffixPanel.add(suffixTemplate, sgbc);
2927 // second row (number of digits spinner)
2931 sgbc.fill = GridBagConstraints.NONE;
2932 suffixPanel.add(suffixDigitsLabel, sgbc);
2935 sgbc.fill = GridBagConstraints.HORIZONTAL;
2936 suffixPanel.add(suffixDigitsSpinner, sgbc);
2938 // third row (forward order radio selection)
2941 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2942 sgbc.fill = GridBagConstraints.HORIZONTAL;
2943 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2945 // fourth row (reverse order radio selection)
2947 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2951 private boolean confirmSuffixReverseChange()
2953 boolean ret = false;
2954 String warningMessage = MessageManager
2955 .getString("label.warning_confirm_change_reverse");
2956 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2958 MessageManager.getString("label.change_increment_decrement"),
2959 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2961 ret = (confirm == JvOptionPane.YES_OPTION);
2965 private JPanel initBackupsTabKeepFilesPanel()
2967 keepfilesPanel.setBorder(
2968 new TitledBorder(MessageManager.getString("label.keep_files")));
2969 keepfilesPanel.setLayout(new GridBagLayout());
2971 backupfilesKeepAll.setLabels(
2972 MessageManager.getString("label.keep_all_backup_files"),
2973 MessageManager.getString(
2974 "label.keep_only_this_number_of_backup_files"));
2975 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2978 public void actionPerformed(ActionEvent e)
2980 backupfilesRevertButtonSetEnabled(true);
2981 updateBackupFilesExampleLabel();
2984 backupfilesKeepAll.addActionListener(new ActionListener()
2987 public void actionPerformed(ActionEvent e)
2989 backupfilesRevertButtonSetEnabled(true);
2990 keepRollMaxOptionsEnabled();
2991 updateBackupFilesExampleLabel();
2995 ChangeListener c = new ChangeListener()
2998 public void stateChanged(ChangeEvent e)
3000 backupfilesRevertButtonSetEnabled(true);
3001 updateBackupFilesExampleLabel();
3005 setIntegerSpinner(backupfilesRollMaxSpinner,
3006 BackupFilesPresetEntry.ROLLMAXMIN,
3007 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3009 backupfilesConfirmDelete.setLabels(
3010 MessageManager.getString("label.always_ask"),
3011 MessageManager.getString("label.auto_delete"));
3012 backupfilesConfirmDelete.addActionListener(new ActionListener()
3015 public void actionPerformed(ActionEvent e)
3017 backupfilesRevertButtonSetEnabled(true);
3020 // update the enabled section
3021 keepRollMaxOptionsEnabled();
3023 GridBagConstraints kgbc = new GridBagConstraints();
3025 // first row (template text box)
3026 kgbc.anchor = GridBagConstraints.WEST;
3029 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3030 kgbc.gridheight = 1;
3033 kgbc.fill = GridBagConstraints.HORIZONTAL;
3034 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3040 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3041 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3044 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3045 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3047 // third row (indented)
3049 kgbc.insets = new Insets(0, 20, 0, 0);
3052 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3053 kgbc.fill = GridBagConstraints.HORIZONTAL;
3056 JPanel jp = new JPanel();
3057 jp.setLayout(new FlowLayout());
3058 oldBackupFilesLabel.setText(
3059 MessageManager.getString("label.autodelete_old_backup_files"));
3060 oldBackupFilesLabel.setFont(LABEL_FONT);
3061 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3062 jp.add(oldBackupFilesLabel);
3063 jp.add(backupfilesConfirmDelete.getTrueButton());
3064 jp.add(backupfilesConfirmDelete.getFalseButton());
3065 keepfilesPanel.add(jp, kgbc);
3067 return keepfilesPanel;
3070 protected void updateBackupFilesExampleLabel()
3072 int exampleindex = 12;
3073 String base = MessageManager.getString("label.filename") + ".fa";
3074 if (base == null || base.length() == 0)
3076 base = "file_name.fa";
3079 boolean reverse = suffixReverse.isSelected();
3080 boolean keepAll = backupfilesKeepAll.isSelected();
3082 String suffix = suffixTemplate.getText();
3085 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3086 if (suffix == null || suffix.length() == 0)
3088 backupfilesExampleLabel
3089 .setText(MessageManager.getString("label.no_backup_files"));
3090 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3094 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3095 rollMax = rollMax < 1 ? 1 : rollMax;
3097 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3102 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3103 digits = digits < 1 ? 1 : digits;
3105 int lowersurround = 2;
3106 int uppersurround = 0;
3107 StringBuilder exampleSB = new StringBuilder();
3108 boolean firstLine = true;
3114 int max = keepAll ? exampleindex : rollMax;
3115 for (int index = min; index <= max; index++)
3117 if (index == min + lowersurround && index < max - uppersurround - 1)
3119 exampleSB.append("\n...");
3122 else if (index > min + lowersurround && index < max - uppersurround)
3134 exampleSB.append("\n");
3137 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3138 base, suffix, digits));
3141 // no extra text needed
3143 else if (index == min)
3145 String newest = MessageManager.getString("label.braced_newest");
3146 if (newest != null && newest.length() > 0)
3148 exampleSB.append(" " + newest);
3151 else if (index == max)
3153 String oldest = MessageManager.getString("label.braced_oldest");
3154 if (oldest != null && oldest.length() > 0)
3156 exampleSB.append(" " + oldest);
3165 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3166 : exampleindex - rollMax + 1;
3167 int max = exampleindex;
3169 for (int index = min; index <= max; index++)
3172 if (index == min + lowersurround && index < max - uppersurround - 1)
3174 exampleSB.append("\n...");
3177 else if (index > min + lowersurround && index < max - uppersurround)
3189 exampleSB.append("\n");
3192 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3193 base, suffix, digits));
3196 // no extra text needed
3198 else if (index == min)
3200 String oldest = MessageManager.getString("label.braced_oldest");
3201 if (oldest != null && oldest.length() > 0)
3203 exampleSB.append(" " + oldest);
3206 else if (index == max)
3208 String newest = MessageManager.getString("label.braced_newest");
3209 if (newest != null && newest.length() > 0)
3211 exampleSB.append(" " + newest);
3219 // add some extra empty lines to pad out the example files box. ugh, please
3221 // me how to do this better
3222 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3223 if (remainingLines > 0)
3225 for (int i = 0; i < remainingLines; i++)
3227 exampleSB.append("\n ");
3232 backupfilesExampleLabel.setText(exampleSB.toString());
3235 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3236 boolean useExistingVal, ChangeListener c)
3243 i = ((Integer) s.getValue()).intValue();
3244 } catch (Exception e)
3247 "Exception casting the initial value of s.getValue()");
3251 setIntegerSpinner(s, min, max, i, c);
3254 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3257 // integer spinner for number of digits
3266 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3269 s.addChangeListener(c);
3273 protected static int getSpinnerInt(JSpinner s, int def)
3279 i = (Integer) s.getValue();
3280 } catch (Exception e)
3282 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3287 private void keepRollMaxOptionsEnabled()
3289 boolean enabled = backupfilesKeepAll.isEnabled()
3290 && !backupfilesKeepAll.isSelected();
3291 oldBackupFilesLabel.setEnabled(enabled);
3292 backupfilesRollMaxSpinner.setEnabled(enabled);
3293 backupfilesConfirmDelete.setEnabled(enabled);
3296 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3298 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3299 && customiseCheckbox.isSelected() && suffixTemplate.getText()
3300 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3301 keepfilesPanel.setEnabled(enabled);
3302 backupfilesKeepAll.setEnabled(enabled);
3303 oldBackupFilesLabel.setEnabled(enabled);
3304 keepRollMaxOptionsEnabled();
3307 private void backupfilesSuffixTemplateDigitsSetEnabled()
3309 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3310 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3311 suffixDigitsLabel.setEnabled(enabled);
3312 suffixDigitsSpinner.setEnabled(enabled);
3313 suffixReverse.setEnabled(enabled);
3316 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3318 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3319 && customiseCheckbox.isSelected();
3320 suffixPanel.setEnabled(enabled);
3321 suffixTemplateLabel.setEnabled(enabled);
3322 suffixTemplate.setEnabled(enabled);
3323 backupfilesSuffixTemplateDigitsSetEnabled();
3326 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3328 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3329 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3330 revertButton.setEnabled(enabled);
3333 private boolean backupfilesCustomChanged()
3335 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3336 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3337 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3338 return !custom.equals(current);
3341 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3343 String suffix = suffixTemplate.getText();
3344 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3345 boolean reverse = suffixReverse.isSelected();
3346 boolean keepAll = backupfilesKeepAll.isSelected();
3347 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3348 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3350 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3351 reverse, keepAll, rollMax, confirmDelete);
3356 protected void backupfilesCustomOptionsSetEnabled()
3358 boolean enabled = customiseCheckbox.isSelected();
3360 backupfilesRevertButtonSetEnabled(enabled);
3361 backupfilesSuffixTemplateSetEnabled(enabled);
3362 backupfilesKeepAllSetEnabled(enabled);
3365 private void backupfilesSummarySetEnabled()
3367 boolean enabled = enableBackupFiles.isSelected();
3368 backupfilesExampleLabel.setEnabled(enabled);
3369 exampleFilesPanel.setEnabled(enabled);
3372 private void backupfilesPresetsSetEnabled()
3374 boolean enabled = enableBackupFiles.isSelected();
3375 presetsPanel.setEnabled(enabled);
3376 presetsComboLabel.setEnabled(enabled);
3377 backupfilesPresetsCombo.setEnabled(enabled);
3378 customiseCheckbox.setEnabled(enabled);
3379 revertButton.setEnabled(enabled);
3382 protected void backupsOptionsSetEnabled()
3384 backupfilesPresetsSetEnabled();
3385 backupfilesSummarySetEnabled();
3386 backupfilesCustomOptionsSetEnabled();
3389 protected void backupsSetOptions(String suffix, int digits,
3390 boolean reverse, boolean keepAll, int rollMax,
3391 boolean confirmDelete)
3393 suffixTemplate.setText(suffix);
3394 suffixDigitsSpinner.setValue(digits);
3395 suffixReverse.setSelected(reverse);
3396 backupfilesKeepAll.setSelected(keepAll);
3397 backupfilesRollMaxSpinner.setValue(rollMax);
3398 backupfilesConfirmDelete.setSelected(confirmDelete);
3401 protected void backupsSetOptions(BackupFilesPresetEntry p)
3403 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3407 protected void autoIdWidth_actionPerformed()
3409 // TODO Auto-generated method stub
3413 protected void userIdWidth_actionPerformed()
3415 // TODO Auto-generated method stub
3419 protected void maxColour_actionPerformed(JPanel panel)
3423 protected void minColour_actionPerformed(JPanel panel)
3427 protected void gapColour_actionPerformed(JPanel panel)
3431 protected void hiddenColour_actionPerformed(JPanel panel)
3435 protected void showunconserved_actionPerformed(ActionEvent e)
3437 // TODO Auto-generated method stub
3441 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3445 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3455 public void ok_actionPerformed(ActionEvent e)
3465 public void cancel_actionPerformed(ActionEvent e)
3475 public void annotations_actionPerformed(ActionEvent e)
3482 public void startupFileTextfield_mouseClicked()
3486 public void newLink_actionPerformed(ActionEvent e)
3491 public void editLink_actionPerformed(ActionEvent e)
3496 public void deleteLink_actionPerformed(ActionEvent e)
3501 public void linkURLList_keyTyped(KeyEvent e)
3506 public void setProxyAuthEnabled()
3508 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3509 proxyAuthUsernameLabel.setEnabled(enabled);
3510 proxyAuthPasswordLabel.setEnabled(enabled);
3511 passwordNotStoredLabel.setEnabled(enabled);
3512 proxyAuthUsernameTB.setEnabled(enabled);
3513 proxyAuthPasswordPB.setEnabled(enabled);
3516 public void setCustomProxyEnabled()
3518 boolean enabled = customProxy.isSelected();
3519 portLabel.setEnabled(enabled);
3520 serverLabel.setEnabled(enabled);
3521 portLabel2.setEnabled(enabled);
3522 serverLabel2.setEnabled(enabled);
3523 httpLabel.setEnabled(enabled);
3524 httpsLabel.setEnabled(enabled);
3525 proxyServerHttpTB.setEnabled(enabled);
3526 proxyPortHttpTB.setEnabled(enabled);
3527 proxyServerHttpsTB.setEnabled(enabled);
3528 proxyPortHttpsTB.setEnabled(enabled);
3529 proxyAuth.setEnabled(enabled);
3530 setProxyAuthEnabled();
3533 public void proxyType_actionPerformed()
3535 setCustomProxyEnabled();
3536 proxyAuthPasswordCheckHighlight(true);
3537 applyProxyButtonEnabled(true);
3540 public void proxyAuth_actionPerformed()
3542 setProxyAuthEnabled();
3543 proxyAuthPasswordCheckHighlight(true);
3544 applyProxyButtonEnabled(true);
3548 * Customer renderer for JTable: supports column of radio buttons
3550 public class RadioButtonRenderer extends JRadioButton
3551 implements TableCellRenderer
3553 public RadioButtonRenderer()
3555 setHorizontalAlignment(CENTER);
3556 setToolTipText(MessageManager.getString("label.urltooltip"));
3560 public Component getTableCellRendererComponent(JTable table,
3561 Object value, boolean isSelected, boolean hasFocus, int row,
3564 setSelected((boolean) value);
3566 // set colours to match rest of table
3569 setBackground(table.getSelectionBackground());
3570 setForeground(table.getSelectionForeground());
3574 setBackground(table.getBackground());
3575 setForeground(table.getForeground());
3582 * Customer cell editor for JTable: supports column of radio buttons in
3583 * conjunction with renderer
3585 public class RadioButtonEditor extends AbstractCellEditor
3586 implements TableCellEditor
3588 private JRadioButton button = new JRadioButton();
3590 public RadioButtonEditor()
3592 button.setHorizontalAlignment(SwingConstants.CENTER);
3593 this.button.addActionListener(new ActionListener()
3596 public void actionPerformed(ActionEvent e)
3598 fireEditingStopped();
3604 public Component getTableCellEditorComponent(JTable table, Object value,
3605 boolean isSelected, int row, int column)
3607 button.setSelected((boolean) value);
3612 public Object getCellEditorValue()
3614 return button.isSelected();