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 JTextField defaultBrowser = new JTextField();
274 protected ButtonGroup proxyType = new ButtonGroup();
276 protected JRadioButton noProxy = new JRadioButton();
278 protected JRadioButton systemProxy = new JRadioButton();
280 protected JRadioButton customProxy = new JRadioButton();
282 protected JButton applyProxyButton = new JButton();
284 protected JCheckBox usagestats = new JCheckBox();
286 protected JCheckBox questionnaire = new JCheckBox();
288 protected JCheckBox versioncheck = new JCheckBox();
291 * Output tab components
293 protected JComboBox<Object> epsRendering = new JComboBox<>();
295 protected JComboBox<Object> htmlRendering = new JComboBox<>();
297 protected JComboBox<Object> svgRendering = new JComboBox<>();
299 protected JLabel userIdWidthlabel = new JLabel();
301 protected JCheckBox autoIdWidth = new JCheckBox();
303 protected JTextField userIdWidth = new JTextField();
305 protected JCheckBox blcjv = new JCheckBox();
307 protected JCheckBox pileupjv = new JCheckBox();
309 protected JCheckBox clustaljv = new JCheckBox();
311 protected JCheckBox msfjv = new JCheckBox();
313 protected JCheckBox fastajv = new JCheckBox();
315 protected JCheckBox pfamjv = new JCheckBox();
317 protected JCheckBox pirjv = new JCheckBox();
319 protected JCheckBox modellerOutput = new JCheckBox();
321 protected JCheckBox embbedBioJSON = new JCheckBox();
324 * Editing tab components
326 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
328 protected JCheckBox padGaps = new JCheckBox();
330 protected JCheckBox sortByTree = new JCheckBox();
335 protected JPanel wsTab = new JPanel();
338 * Backups tab components
339 * a lot of these are member variables instead of local variables only so that they
340 * can be enabled/disabled easily in one go
343 protected JCheckBox enableBackupFiles = new JCheckBox();
345 protected JPanel presetsPanel = new JPanel();
347 protected JLabel presetsComboLabel = new JLabel();
349 protected JCheckBox customiseCheckbox = new JCheckBox();
351 protected JButton revertButton = new JButton();
353 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
355 private int backupfilesPresetsComboLastSelected = 0;
357 protected JPanel suffixPanel = new JPanel();
359 protected JPanel keepfilesPanel = new JPanel();
361 protected JPanel exampleFilesPanel = new JPanel();
363 protected JTextField suffixTemplate = new JTextField(null, 8);
365 protected JLabel suffixTemplateLabel = new JLabel();
367 protected JLabel suffixDigitsLabel = new JLabel();
369 protected JSpinner suffixDigitsSpinner = new JSpinner();
371 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
373 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
375 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
377 protected JLabel oldBackupFilesLabel = new JLabel();
379 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
381 protected JTextArea backupfilesExampleLabel = new JTextArea();
383 private final JTabbedPane tabbedPane = new JTabbedPane();
385 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
388 * Startup tab components
391 protected JCheckBox customiseMemorySetting = new JCheckBox();
393 protected JLabel exampleMemoryLabel = new JLabel();
395 protected JTextArea exampleMemoryMessageTextArea = new JTextArea();
397 protected JLabel maxMemoryLabel = new JLabel();
399 protected JLabel jvmMemoryPercentLabel = new JLabel();
401 protected JSlider jvmMemoryPercentSlider = new JSlider();
403 protected JLabel jvmMemoryPercentDisplay = new JLabel();
405 protected JLabel jvmMemoryMaxLabel = new JLabel();
407 protected JTextField jvmMemoryMaxTextField = new JTextField(null, 8);
409 protected JComboBox<Object> lafCombo = new JComboBox<>();
412 * Creates a new GPreferences object.
414 public GPreferences()
419 } catch (Exception ex)
421 ex.printStackTrace();
426 * Construct the panel and its tabbed sub-panels.
430 private void jbInit() throws Exception
432 // final JTabbedPane tabbedPane = new JTabbedPane();
433 this.setLayout(new BorderLayout());
435 // message label at top
436 this.add(messageLabel, BorderLayout.NORTH);
438 JPanel okCancelPanel = initOkCancelPanel();
439 this.add(tabbedPane, BorderLayout.CENTER);
440 this.add(okCancelPanel, BorderLayout.SOUTH);
442 tabbedPane.add(initVisualTab(),
443 MessageManager.getString("label.visual"));
445 tabbedPane.add(initColoursTab(),
446 MessageManager.getString("label.colours"));
448 tabbedPane.add(initOverviewTab(),
449 MessageManager.getString("label.overview"));
451 tabbedPane.add(initStructureTab(),
452 MessageManager.getString("label.structure"));
454 tabbedPane.add(initConnectionsTab(),
455 MessageManager.getString("label.connections"));
457 if (!Platform.isJS())
459 tabbedPane.add(initBackupsTab(),
460 MessageManager.getString("label.backups"));
463 tabbedPane.add(initLinksTab(),
464 MessageManager.getString("label.urllinks"));
466 tabbedPane.add(initOutputTab(),
467 MessageManager.getString("label.output"));
469 tabbedPane.add(initEditingTab(),
470 MessageManager.getString("label.editing"));
472 tabbedPane.add(initStartupTab(),
473 MessageManager.getString("label.startup"));
476 * See WsPreferences for the real work of configuring this tab.
478 if (!Platform.isJS())
480 wsTab.setLayout(new BorderLayout());
481 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
485 * Handler to validate a tab before leaving it - currently only for
487 * Adding a clearMessage() so messages are cleared when changing tabs.
489 tabbedPane.addChangeListener(new ChangeListener()
491 private Component lastTab;
494 public void stateChanged(ChangeEvent e)
496 if (lastTab == structureTab
497 && tabbedPane.getSelectedComponent() != structureTab)
499 if (!validateStructure())
501 tabbedPane.setSelectedComponent(structureTab);
505 lastTab = tabbedPane.getSelectedComponent();
513 public void setMessage(String message)
517 messageLabel.setText(message);
518 messageLabel.setFont(LABEL_FONT_BOLD);
519 messageLabel.setForeground(Color.RED.darker());
520 messageLabel.revalidate();
521 messageLabel.repaint();
523 // note message not cleared if message is null. call clearMessage()
529 public void clearMessage()
531 // only repaint if message exists
532 if (messageLabel.getText() != null
533 && messageLabel.getText().length() > 0)
535 messageLabel.setText("");
536 messageLabel.revalidate();
537 messageLabel.repaint();
543 public static enum TabRef
545 CONNECTIONS_TAB, STRUCTURE_TAB
548 public void selectTab(TabRef selectTab)
550 // select a given tab - currently only for Connections
553 case CONNECTIONS_TAB:
554 tabbedPane.setSelectedComponent(connectTab);
557 tabbedPane.setSelectedComponent(structureTab);
564 * Initialises the Editing tabbed panel.
568 private JPanel initEditingTab()
570 JPanel editingTab = new JPanel();
571 editingTab.setLayout(null);
572 autoCalculateConsCheck.setFont(LABEL_FONT);
573 autoCalculateConsCheck.setText(
574 MessageManager.getString("label.autocalculate_consensus"));
575 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
576 padGaps.setFont(LABEL_FONT);
578 MessageManager.getString("label.pad_gaps_when_editing"));
579 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
580 sortByTree.setFont(LABEL_FONT);
582 .setText(MessageManager.getString("label.sort_with_new_tree"));
583 sortByTree.setToolTipText(MessageManager.getString(
584 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
585 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
586 editingTab.add(autoCalculateConsCheck);
587 editingTab.add(padGaps);
588 editingTab.add(sortByTree);
593 * Initialises the Output tab
597 private JPanel initOutputTab()
599 JPanel outputTab = new JPanel();
600 outputTab.setLayout(null);
602 JLabel epsLabel = new JLabel(
603 MessageManager.formatMessage("label.rendering_style", "EPS"));
604 epsLabel.setFont(LABEL_FONT);
605 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
606 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
607 epsRendering.setFont(LABEL_FONT);
608 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
609 JLabel htmlLabel = new JLabel(
610 MessageManager.formatMessage("label.rendering_style", "HTML"));
611 htmlLabel.setFont(LABEL_FONT);
612 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
613 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
614 htmlRendering.setFont(LABEL_FONT);
615 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
616 JLabel svgLabel = new JLabel(
617 MessageManager.formatMessage("label.rendering_style", "SVG"));
618 svgLabel.setFont(LABEL_FONT);
619 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
620 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
621 svgRendering.setFont(LABEL_FONT);
622 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
624 JLabel jLabel1 = new JLabel();
625 jLabel1.setFont(LABEL_FONT);
626 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
627 jLabel1.setText(MessageManager.getString("label.append_start_end"));
628 jLabel1.setFont(LABEL_FONT);
630 fastajv.setFont(LABEL_FONT);
631 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
632 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
633 blcjv.setText(MessageManager.getString("label.blc") + " ");
634 fastajv.setText(MessageManager.getString("label.fasta") + " ");
635 msfjv.setText(MessageManager.getString("label.msf") + " ");
636 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
637 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
638 msfjv.setFont(LABEL_FONT);
639 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
640 pirjv.setText(MessageManager.getString("label.pir") + " ");
641 JPanel jPanel11 = new JPanel();
642 jPanel11.setFont(LABEL_FONT);
643 TitledBorder titledBorder2 = new TitledBorder(
644 MessageManager.getString("label.file_output"));
645 jPanel11.setBorder(titledBorder2);
646 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
647 GridLayout gridLayout3 = new GridLayout();
648 jPanel11.setLayout(gridLayout3);
649 gridLayout3.setRows(8);
650 blcjv.setFont(LABEL_FONT);
651 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
652 clustaljv.setFont(LABEL_FONT);
653 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
654 pfamjv.setFont(LABEL_FONT);
655 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
656 pileupjv.setFont(LABEL_FONT);
657 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
658 pirjv.setFont(LABEL_FONT);
659 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
660 autoIdWidth.setFont(LABEL_FONT);
662 MessageManager.getString("label.automatically_set_id_width"));
663 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
664 .getString("label.adjusts_width_generated_eps_png")));
665 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
666 autoIdWidth.addActionListener(new ActionListener()
670 public void actionPerformed(ActionEvent e)
672 autoIdWidth_actionPerformed();
675 userIdWidthlabel.setFont(LABEL_FONT);
676 userIdWidthlabel.setText(
677 MessageManager.getString("label.figure_id_column_width"));
678 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
679 .getString("label.manually_specify_width_left_column")));
680 userIdWidthlabel.setToolTipText(
681 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
682 "label.manually_specify_width_left_column")));
683 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
684 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
685 userIdWidth.setText("");
686 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
687 userIdWidth.addActionListener(new ActionListener()
691 public void actionPerformed(ActionEvent e)
693 userIdWidth_actionPerformed();
696 modellerOutput.setFont(LABEL_FONT);
698 .setText(MessageManager.getString("label.use_modeller_output"));
699 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
700 embbedBioJSON.setFont(LABEL_FONT);
701 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
702 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
704 jPanel11.add(jLabel1);
706 jPanel11.add(clustaljv);
707 jPanel11.add(fastajv);
709 jPanel11.add(pfamjv);
710 jPanel11.add(pileupjv);
712 outputTab.add(autoIdWidth);
713 outputTab.add(userIdWidth);
714 outputTab.add(userIdWidthlabel);
715 outputTab.add(modellerOutput);
716 if (!Platform.isJS())
719 * JalviewJS doesn't support Lineart option or SVG output
721 outputTab.add(embbedBioJSON);
722 outputTab.add(epsLabel);
723 outputTab.add(epsRendering);
724 outputTab.add(htmlLabel);
725 outputTab.add(htmlRendering);
726 outputTab.add(svgLabel);
727 outputTab.add(svgRendering);
729 outputTab.add(jPanel11);
734 * Initialises the Connections tabbed panel.
738 private JPanel initConnectionsTab()
740 connectTab = new JPanel();
741 connectTab.setLayout(new GridBagLayout());
743 // Label for browser text box
744 JLabel browserLabel = new JLabel();
745 browserLabel.setFont(LABEL_FONT);
746 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
747 browserLabel.setText(
748 MessageManager.getString("label.default_browser_unix"));
749 defaultBrowser.setFont(LABEL_FONT);
750 defaultBrowser.setText("");
751 final String tooltip = JvSwingUtils.wrapTooltip(true,
752 MessageManager.getString("label.double_click_to_browse"));
753 defaultBrowser.setToolTipText(tooltip);
754 defaultBrowser.addMouseListener(new MouseAdapter()
757 public void mouseClicked(MouseEvent e)
759 if (e.getClickCount() > 1)
761 defaultBrowser_mouseClicked(e);
766 JPanel proxyPanel = initConnTabProxyPanel();
767 initConnTabCheckboxes();
769 // Add default Browser text box
770 connectTab.add(browserLabel,
771 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
772 GridBagConstraints.WEST, GridBagConstraints.NONE,
773 new Insets(10, 0, 5, 5), 5, 1));
774 defaultBrowser.setFont(LABEL_FONT);
775 defaultBrowser.setText("");
777 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
778 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
779 new Insets(10, 0, 5, 10), 30, 1));
781 // Add proxy server panel
782 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
783 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
784 new Insets(10, 0, 5, 12), 4, 10));
786 // Add usage stats, version check and questionnaire checkboxes
787 connectTab.add(usagestats,
788 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
789 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
790 new Insets(0, 2, 5, 5), 70, 1));
791 connectTab.add(questionnaire,
792 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
793 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
794 new Insets(0, 2, 5, 10), 70, 1));
795 connectTab.add(versioncheck,
796 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
797 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
798 new Insets(0, 2, 5, 5), 70, 1));
800 versioncheck.setVisible(false);
802 // Add padding so the panel doesn't look ridiculous
803 JPanel spacePanel = new JPanel();
804 connectTab.add(spacePanel,
805 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
806 GridBagConstraints.WEST, GridBagConstraints.BOTH,
807 new Insets(0, 0, 0, 5), 70, 1));
813 * Initialises the Links tabbed panel.
817 private JPanel initLinksTab()
819 JPanel linkTab = new JPanel();
820 linkTab.setLayout(new GridBagLayout());
822 // Set up table for Url links
823 linkUrlTable.getTableHeader().setReorderingAllowed(false);
824 linkUrlTable.setFillsViewportHeight(true);
825 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
826 linkUrlTable.setAutoCreateRowSorter(true);
827 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
829 // adjust row height so radio buttons actually fit
830 // don't do this in the renderer, it causes the awt thread to activate
832 JRadioButton temp = new JRadioButton();
833 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
835 // Table in scrollpane so that the table is given a scrollbar
836 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
837 linkScrollPane.setBorder(null);
839 // Panel for links functionality
840 JPanel linkPanel = new JPanel(new GridBagLayout());
841 linkPanel.setBorder(new TitledBorder(
842 MessageManager.getString("label.url_linkfrom_sequence_id")));
844 // Put the Url links panel together
846 // Buttons go at top right, resizing only resizes the blank space vertically
847 JPanel buttonPanel = initLinkTabUrlButtons();
848 GridBagConstraints linkConstraints1 = new GridBagConstraints();
849 linkConstraints1.insets = new Insets(0, 0, 5, 0);
850 linkConstraints1.gridx = 0;
851 linkConstraints1.gridy = 0;
852 linkConstraints1.weightx = 1.0;
853 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
854 linkTab.add(buttonPanel, linkConstraints1);
856 // Links table goes at top left, resizing resizes the table
857 GridBagConstraints linkConstraints2 = new GridBagConstraints();
858 linkConstraints2.insets = new Insets(0, 0, 5, 5);
859 linkConstraints2.gridx = 0;
860 linkConstraints2.gridy = 1;
861 linkConstraints2.weightx = 1.0;
862 linkConstraints2.weighty = 1.0;
863 linkConstraints2.fill = GridBagConstraints.BOTH;
864 linkTab.add(linkScrollPane, linkConstraints2);
866 // Filter box and buttons goes at bottom left, resizing resizes the text box
867 JPanel filterPanel = initLinkTabFilterPanel();
868 GridBagConstraints linkConstraints3 = new GridBagConstraints();
869 linkConstraints3.insets = new Insets(0, 0, 0, 5);
870 linkConstraints3.gridx = 0;
871 linkConstraints3.gridy = 2;
872 linkConstraints3.weightx = 1.0;
873 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
874 linkTab.add(filterPanel, linkConstraints3);
879 private JPanel initLinkTabFilterPanel()
881 // Filter textbox and reset button
882 JLabel filterLabel = new JLabel(
883 MessageManager.getString("label.filter"));
884 filterLabel.setFont(LABEL_FONT);
885 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
886 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
888 filterTB.setFont(LABEL_FONT);
889 filterTB.setText("");
891 doReset.setText(MessageManager.getString("action.showall"));
892 userOnly.setText(MessageManager.getString("action.customfilter"));
894 // Panel for filter functionality
895 JPanel filterPanel = new JPanel(new GridBagLayout());
896 filterPanel.setBorder(new TitledBorder("Filter"));
897 GridBagConstraints gbc = new GridBagConstraints();
900 gbc.fill = GridBagConstraints.NONE;
901 gbc.anchor = GridBagConstraints.WEST;
903 filterPanel.add(filterLabel, gbc);
905 GridBagConstraints gbc1 = new GridBagConstraints();
908 gbc1.fill = GridBagConstraints.HORIZONTAL;
909 gbc1.anchor = GridBagConstraints.WEST;
911 filterPanel.add(filterTB, gbc1);
913 GridBagConstraints gbc2 = new GridBagConstraints();
915 gbc2.fill = GridBagConstraints.NONE;
916 gbc2.anchor = GridBagConstraints.WEST;
917 filterPanel.add(doReset, gbc2);
919 GridBagConstraints gbc3 = new GridBagConstraints();
921 gbc3.fill = GridBagConstraints.NONE;
922 gbc3.anchor = GridBagConstraints.WEST;
923 filterPanel.add(userOnly, gbc3);
928 private JPanel initLinkTabUrlButtons()
930 // Buttons for new / edit / delete Url links
931 JButton newLink = new JButton();
932 newLink.setText(MessageManager.getString("action.new"));
934 editLink.setText(MessageManager.getString("action.edit"));
936 deleteLink.setText(MessageManager.getString("action.delete"));
938 // no current selection, so initially disable delete/edit buttons
939 editLink.setEnabled(false);
940 deleteLink.setEnabled(false);
942 newLink.addActionListener(new java.awt.event.ActionListener()
945 public void actionPerformed(ActionEvent e)
947 newLink_actionPerformed(e);
951 editLink.setText(MessageManager.getString("action.edit"));
952 editLink.addActionListener(new java.awt.event.ActionListener()
955 public void actionPerformed(ActionEvent e)
957 editLink_actionPerformed(e);
961 deleteLink.setText(MessageManager.getString("action.delete"));
962 deleteLink.addActionListener(new java.awt.event.ActionListener()
965 public void actionPerformed(ActionEvent e)
967 deleteLink_actionPerformed(e);
971 JPanel buttonPanel = new JPanel(new GridBagLayout());
972 buttonPanel.setBorder(new TitledBorder("Edit links"));
973 GridBagConstraints gbc = new GridBagConstraints();
976 gbc.fill = GridBagConstraints.NONE;
977 buttonPanel.add(newLink, gbc);
979 GridBagConstraints gbc1 = new GridBagConstraints();
982 gbc1.fill = GridBagConstraints.NONE;
983 buttonPanel.add(editLink, gbc1);
985 GridBagConstraints gbc2 = new GridBagConstraints();
988 gbc2.fill = GridBagConstraints.NONE;
989 buttonPanel.add(deleteLink, gbc2);
991 GridBagConstraints gbc3 = new GridBagConstraints();
994 gbc3.fill = GridBagConstraints.HORIZONTAL;
996 JPanel spacePanel = new JPanel();
997 spacePanel.setBorder(null);
998 buttonPanel.add(spacePanel, gbc3);
1004 * Initialises the proxy server panel in the Connections tab
1006 * @return the proxy server panel
1008 private JPanel initConnTabProxyPanel()
1010 // Label for server text box
1011 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1012 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1013 serverLabel.setFont(LABEL_FONT);
1014 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1015 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1016 serverLabel2.setFont(LABEL_FONT);
1018 // Proxy server and port text boxes
1019 proxyServerHttpTB.setFont(LABEL_FONT);
1020 proxyServerHttpTB.setColumns(40);
1021 proxyPortHttpTB.setFont(LABEL_FONT);
1022 proxyPortHttpTB.setColumns(4);
1023 proxyServerHttpsTB.setFont(LABEL_FONT);
1024 proxyServerHttpsTB.setColumns(40);
1025 proxyPortHttpsTB.setFont(LABEL_FONT);
1026 proxyPortHttpsTB.setColumns(4);
1027 proxyAuthUsernameTB.setFont(LABEL_FONT);
1028 proxyAuthUsernameTB.setColumns(30);
1030 // check for any change to enable applyProxyButton
1031 DocumentListener d = new DocumentListener()
1034 public void changedUpdate(DocumentEvent e)
1036 applyProxyButtonEnabled(true);
1040 public void insertUpdate(DocumentEvent e)
1042 applyProxyButtonEnabled(true);
1046 public void removeUpdate(DocumentEvent e)
1048 applyProxyButtonEnabled(true);
1051 proxyServerHttpTB.getDocument().addDocumentListener(d);
1052 proxyPortHttpTB.getDocument().addDocumentListener(d);
1053 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1054 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1055 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1056 proxyAuthPasswordPB.setFont(LABEL_FONT);
1057 proxyAuthPasswordPB.setColumns(30);
1058 proxyAuthPasswordPB.getDocument()
1059 .addDocumentListener(new DocumentListener()
1062 public void changedUpdate(DocumentEvent e)
1064 proxyAuthPasswordCheckHighlight(true);
1065 applyProxyButtonEnabled(true);
1069 public void insertUpdate(DocumentEvent e)
1071 proxyAuthPasswordCheckHighlight(true);
1072 applyProxyButtonEnabled(true);
1076 public void removeUpdate(DocumentEvent e)
1078 proxyAuthPasswordCheckHighlight(true);
1079 applyProxyButtonEnabled(true);
1084 // Label for Port text box
1085 portLabel.setFont(LABEL_FONT);
1086 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1087 portLabel.setText(MessageManager.getString("label.port") + ": ");
1088 portLabel2.setFont(LABEL_FONT);
1089 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1090 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1092 httpLabel.setText("HTTP");
1093 httpLabel.setFont(LABEL_FONT_BOLD);
1094 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1095 httpsLabel.setText("HTTPS");
1096 httpsLabel.setFont(LABEL_FONT_BOLD);
1097 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1099 proxyAuthUsernameLabel
1100 .setText(MessageManager.getString("label.username") + ": ");
1101 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1102 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1103 proxyAuthPasswordLabel
1104 .setText(MessageManager.getString("label.password") + ": ");
1105 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1106 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1107 passwordNotStoredLabel.setText(
1108 "(" + MessageManager.getString("label.not_stored") + ")");
1109 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1110 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1112 // Proxy type radio buttons
1113 noProxy.setFont(LABEL_FONT);
1114 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1115 noProxy.setText(MessageManager.getString("label.no_proxy"));
1116 systemProxy.setFont(LABEL_FONT);
1117 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1118 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1119 displayUserHostPort(Cache.startupProxyProperties[4],
1120 Cache.startupProxyProperties[0],
1121 Cache.startupProxyProperties[1]),
1122 displayUserHostPort(Cache.startupProxyProperties[6],
1123 Cache.startupProxyProperties[2],
1124 Cache.startupProxyProperties[3])));
1125 customProxy.setFont(LABEL_FONT);
1126 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1127 customProxy.setText(
1128 MessageManager.getString("label.use_proxy_server") + ":");
1129 ActionListener al = new ActionListener()
1132 public void actionPerformed(ActionEvent e)
1134 proxyType_actionPerformed();
1137 noProxy.addActionListener(al);
1138 systemProxy.addActionListener(al);
1139 customProxy.addActionListener(al);
1140 proxyType.add(noProxy);
1141 proxyType.add(systemProxy);
1142 proxyType.add(customProxy);
1144 proxyAuth.setFont(LABEL_FONT);
1145 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1146 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1147 proxyAuth.addActionListener(new ActionListener()
1150 public void actionPerformed(ActionEvent e)
1152 proxyAuth_actionPerformed();
1156 setCustomProxyEnabled();
1158 // Make proxy server panel
1159 JPanel proxyPanel = new JPanel();
1160 TitledBorder titledBorder1 = new TitledBorder(
1161 MessageManager.getString("label.proxy_servers"));
1162 proxyPanel.setBorder(titledBorder1);
1163 proxyPanel.setLayout(new GridBagLayout());
1164 GridBagConstraints gbc = new GridBagConstraints();
1165 gbc.fill = GridBagConstraints.HORIZONTAL;
1168 GridBagConstraints c = new GridBagConstraints();
1169 // Proxy type radio buttons (3)
1170 JPanel ptPanel = new JPanel();
1171 ptPanel.setLayout(new GridBagLayout());
1176 c.fill = GridBagConstraints.HORIZONTAL;
1177 ptPanel.add(noProxy, c);
1179 ptPanel.add(systemProxy, c);
1181 ptPanel.add(customProxy, c);
1184 proxyPanel.add(ptPanel, gbc);
1186 // host and port text boxes
1187 JPanel hpPanel = new JPanel();
1188 hpPanel.setLayout(new GridBagLayout());
1189 // HTTP host port row
1194 c.anchor = GridBagConstraints.LINE_START;
1195 hpPanel.add(httpLabel, c);
1199 c.anchor = GridBagConstraints.LINE_END;
1200 hpPanel.add(serverLabel, c);
1204 c.anchor = GridBagConstraints.LINE_START;
1205 hpPanel.add(proxyServerHttpTB, c);
1209 c.anchor = GridBagConstraints.LINE_END;
1210 hpPanel.add(portLabel, c);
1214 c.anchor = GridBagConstraints.LINE_START;
1215 hpPanel.add(proxyPortHttpTB, c);
1217 // HTTPS host port row
1222 c.anchor = GridBagConstraints.LINE_START;
1223 hpPanel.add(httpsLabel, c);
1226 c.anchor = GridBagConstraints.LINE_END;
1227 hpPanel.add(serverLabel2, c);
1230 c.anchor = GridBagConstraints.LINE_START;
1231 hpPanel.add(proxyServerHttpsTB, c);
1234 c.anchor = GridBagConstraints.LINE_END;
1235 hpPanel.add(portLabel2, c);
1238 c.anchor = GridBagConstraints.LINE_START;
1239 hpPanel.add(proxyPortHttpsTB, c);
1242 proxyPanel.add(hpPanel, gbc);
1244 if (!Platform.isJS())
1246 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1247 * Authentication options in Preferences.
1253 // Require authentication checkbox
1255 proxyPanel.add(proxyAuth, gbc);
1257 // username and password
1258 JPanel upPanel = new JPanel();
1259 upPanel.setLayout(new GridBagLayout());
1265 c.anchor = GridBagConstraints.LINE_END;
1266 upPanel.add(proxyAuthUsernameLabel, c);
1270 c.anchor = GridBagConstraints.LINE_START;
1271 upPanel.add(proxyAuthUsernameTB, c);
1277 c.anchor = GridBagConstraints.LINE_END;
1278 upPanel.add(proxyAuthPasswordLabel, c);
1282 c.anchor = GridBagConstraints.LINE_START;
1283 upPanel.add(proxyAuthPasswordPB, c);
1287 c.anchor = GridBagConstraints.LINE_START;
1288 upPanel.add(passwordNotStoredLabel, c);
1291 proxyPanel.add(upPanel, gbc);
1295 applyProxyButton.setText(MessageManager.getString("action.apply"));
1296 applyProxyButton.addActionListener(new ActionListener()
1299 public void actionPerformed(ActionEvent e)
1301 saveProxySettings();
1302 applyProxyButton.setEnabled(false);
1306 gbc.fill = GridBagConstraints.NONE;
1307 gbc.anchor = GridBagConstraints.LINE_END;
1308 proxyPanel.add(applyProxyButton, gbc);
1313 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1315 proxyAuthPasswordCheckHighlight(enabled, false);
1318 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1321 if (enabled && proxyType.isSelected(customProxy.getModel())
1322 && proxyAuth.isSelected()
1323 && !proxyAuthUsernameTB.getText().isEmpty()
1324 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1327 proxyAuthPasswordPB.grabFocus();
1328 proxyAuthPasswordPB.setBackground(Color.PINK);
1332 proxyAuthPasswordPB.setBackground(Color.WHITE);
1336 public void applyProxyButtonEnabled(boolean enabled)
1338 applyProxyButton.setEnabled(enabled);
1341 public void saveProxySettings()
1343 // overridden in Preferences
1346 private String displayUserHostPort(String user, String host, String port)
1348 boolean hostBlank = (host == null || host.isEmpty());
1349 boolean portBlank = (port == null || port.isEmpty());
1350 if (hostBlank && portBlank)
1352 return MessageManager.getString("label.none");
1355 StringBuilder sb = new StringBuilder();
1358 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1362 sb.append(hostBlank ? "" : host);
1368 return sb.toString();
1372 * Initialises the checkboxes in the Connections tab
1374 private void initConnTabCheckboxes()
1376 // Usage stats checkbox label
1378 MessageManager.getString("label.send_usage_statistics"));
1379 usagestats.setFont(LABEL_FONT);
1380 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1381 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1383 // Questionnaire checkbox label
1384 questionnaire.setText(
1385 MessageManager.getString("label.check_for_questionnaires"));
1386 questionnaire.setFont(LABEL_FONT);
1387 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1388 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1390 // Check for latest version checkbox label
1391 versioncheck.setText(
1392 MessageManager.getString("label.check_for_latest_version"));
1393 versioncheck.setFont(LABEL_FONT);
1394 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1395 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1399 * Initialises the parent panel which contains the tabbed sections.
1403 private JPanel initOkCancelPanel()
1405 JButton ok = new JButton();
1406 ok.setText(MessageManager.getString("action.ok"));
1407 ok.addActionListener(new ActionListener()
1410 public void actionPerformed(ActionEvent e)
1412 ok_actionPerformed(e);
1415 JButton cancel = new JButton();
1416 cancel.setText(MessageManager.getString("action.cancel"));
1417 cancel.addActionListener(new ActionListener()
1420 public void actionPerformed(ActionEvent e)
1422 cancel_actionPerformed(e);
1425 JPanel okCancelPanel = new JPanel();
1426 okCancelPanel.add(ok);
1427 okCancelPanel.add(cancel);
1428 return okCancelPanel;
1432 * Initialises the Colours tabbed panel.
1436 private JPanel initColoursTab()
1438 JPanel coloursTab = new JPanel();
1439 coloursTab.setBorder(new TitledBorder(
1440 MessageManager.getString("action.open_new_alignment")));
1441 coloursTab.setLayout(new FlowLayout());
1442 JLabel mincolourLabel = new JLabel();
1443 mincolourLabel.setFont(LABEL_FONT);
1444 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1445 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1446 minColour.setFont(LABEL_FONT);
1447 minColour.setBorder(BorderFactory.createEtchedBorder());
1448 minColour.setPreferredSize(new Dimension(40, 20));
1449 minColour.addMouseListener(new MouseAdapter()
1452 public void mousePressed(MouseEvent e)
1454 minColour_actionPerformed(minColour);
1457 JLabel maxcolourLabel = new JLabel();
1458 maxcolourLabel.setFont(LABEL_FONT);
1459 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1460 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1461 maxColour.setFont(LABEL_FONT);
1462 maxColour.setBorder(BorderFactory.createEtchedBorder());
1463 maxColour.setPreferredSize(new Dimension(40, 20));
1464 maxColour.addMouseListener(new MouseAdapter()
1467 public void mousePressed(MouseEvent e)
1469 maxColour_actionPerformed(maxColour);
1473 protColour.setFont(LABEL_FONT);
1474 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1475 JLabel protColourLabel = new JLabel();
1476 protColourLabel.setFont(LABEL_FONT);
1477 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1478 protColourLabel.setText(
1479 MessageManager.getString("label.prot_alignment_colour") + " ");
1480 JvSwingUtils.addtoLayout(coloursTab,
1482 .getString("label.default_colour_scheme_for_alignment"),
1483 protColourLabel, protColour);
1485 nucColour.setFont(LABEL_FONT);
1486 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1487 JLabel nucColourLabel = new JLabel();
1488 nucColourLabel.setFont(LABEL_FONT);
1489 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1490 nucColourLabel.setText(
1491 MessageManager.getString("label.nuc_alignment_colour") + " ");
1492 JvSwingUtils.addtoLayout(coloursTab,
1494 .getString("label.default_colour_scheme_for_alignment"),
1495 nucColourLabel, nucColour);
1497 JPanel annotationShding = new JPanel();
1498 annotationShding.setBorder(new TitledBorder(
1499 MessageManager.getString("label.annotation_shading_default")));
1500 annotationShding.setLayout(new GridLayout(1, 2));
1501 JvSwingUtils.addtoLayout(annotationShding,
1502 MessageManager.getString(
1503 "label.default_minimum_colour_annotation_shading"),
1504 mincolourLabel, minColour);
1505 JvSwingUtils.addtoLayout(annotationShding,
1506 MessageManager.getString(
1507 "label.default_maximum_colour_annotation_shading"),
1508 maxcolourLabel, maxColour);
1509 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1514 * Initialises the Overview tabbed panel.
1518 private JPanel initOverviewTab()
1520 JPanel overviewPanel = new JPanel();
1521 overviewPanel.setBorder(new TitledBorder(
1522 MessageManager.getString("label.overview_settings")));
1524 gapColour.setFont(LABEL_FONT);
1525 // fixing the border colours stops apparent colour bleed from the panel
1526 gapColour.setBorder(
1527 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1528 gapColour.setPreferredSize(new Dimension(40, 20));
1529 gapColour.addMouseListener(new MouseAdapter()
1532 public void mousePressed(MouseEvent e)
1534 gapColour_actionPerformed(gapColour);
1538 hiddenColour.setFont(LABEL_FONT);
1539 // fixing the border colours stops apparent colour bleed from the panel
1540 hiddenColour.setBorder(
1541 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1542 hiddenColour.setPreferredSize(new Dimension(40, 20));
1543 hiddenColour.addMouseListener(new MouseAdapter()
1546 public void mousePressed(MouseEvent e)
1548 hiddenColour_actionPerformed(hiddenColour);
1552 useLegacyGap = new JCheckBox(
1553 MessageManager.getString("label.ov_legacy_gap"));
1554 useLegacyGap.setFont(LABEL_FONT);
1555 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1556 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1557 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1558 gapLabel.setFont(LABEL_FONT);
1559 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1560 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1561 showHiddenAtStart = new JCheckBox(
1562 MessageManager.getString("label.ov_show_hide_default"));
1563 showHiddenAtStart.setFont(LABEL_FONT);
1564 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1565 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1566 JLabel hiddenLabel = new JLabel(
1567 MessageManager.getString("label.hidden_colour"));
1568 hiddenLabel.setFont(LABEL_FONT);
1569 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1570 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1572 useLegacyGap.addActionListener(new ActionListener()
1575 public void actionPerformed(ActionEvent e)
1577 useLegacyGaps_actionPerformed(e);
1581 overviewPanel.setLayout(new GridBagLayout());
1582 GridBagConstraints c1 = new GridBagConstraints();
1584 c1.fill = GridBagConstraints.HORIZONTAL;
1589 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1590 overviewPanel.add(useLegacyGap, c1);
1592 GridBagConstraints c2 = new GridBagConstraints();
1593 c2.fill = GridBagConstraints.HORIZONTAL;
1596 c2.insets = new Insets(0, 15, 0, 10);
1597 overviewPanel.add(gapLabel, c2);
1599 GridBagConstraints c3 = new GridBagConstraints();
1600 c3.fill = GridBagConstraints.HORIZONTAL;
1603 c3.insets = new Insets(0, 0, 0, 15);
1604 overviewPanel.add(gapColour, c3);
1606 GridBagConstraints c4 = new GridBagConstraints();
1607 c4.fill = GridBagConstraints.HORIZONTAL;
1611 overviewPanel.add(showHiddenAtStart, c4);
1613 GridBagConstraints c5 = new GridBagConstraints();
1614 c5.fill = GridBagConstraints.HORIZONTAL;
1617 c5.insets = new Insets(0, 15, 0, 10);
1618 overviewPanel.add(hiddenLabel, c5);
1620 GridBagConstraints c6 = new GridBagConstraints();
1621 c6.fill = GridBagConstraints.HORIZONTAL;
1624 c6.insets = new Insets(0, 0, 0, 15);
1625 overviewPanel.add(hiddenColour, c6);
1627 JButton resetButton = new JButton(
1628 MessageManager.getString("label.reset_to_defaults"));
1630 resetButton.addActionListener(new ActionListener()
1633 public void actionPerformed(ActionEvent e)
1635 resetOvDefaults_actionPerformed(e);
1639 GridBagConstraints c7 = new GridBagConstraints();
1640 c7.fill = GridBagConstraints.NONE;
1643 c7.insets = new Insets(10, 0, 0, 0);
1644 c7.anchor = GridBagConstraints.WEST;
1645 overviewPanel.add(resetButton, c7);
1647 // Add padding so the panel doesn't look ridiculous
1648 JPanel spacePanel = new JPanel();
1649 overviewPanel.add(spacePanel,
1650 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1651 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1652 new Insets(0, 0, 0, 5), 0, 0));
1654 return overviewPanel;
1658 * Initialises the Structure tabbed panel.
1662 private JPanel initStructureTab()
1664 structureTab = new JPanel();
1666 structureTab.setBorder(new TitledBorder(
1667 MessageManager.getString("label.structure_options")));
1668 structureTab.setLayout(null);
1669 final int width = 420;
1670 final int height = 22;
1671 final int lineSpacing = 25;
1674 structFromPdb.setFont(LABEL_FONT);
1676 .setText(MessageManager.getString("label.struct_from_pdb"));
1677 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1678 structFromPdb.addActionListener(new ActionListener()
1681 public void actionPerformed(ActionEvent e)
1683 boolean selected = structFromPdb.isSelected();
1684 // enable other options only when the first is checked
1685 addSecondaryStructure.setEnabled(selected);
1686 addTempFactor.setEnabled(selected);
1689 structureTab.add(structFromPdb);
1691 // indent checkboxes that are conditional on the first one
1692 ypos += lineSpacing;
1693 addSecondaryStructure.setFont(LABEL_FONT);
1694 addSecondaryStructure
1695 .setText(MessageManager.getString("label.autoadd_secstr"));
1696 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1697 structureTab.add(addSecondaryStructure);
1699 ypos += lineSpacing;
1700 addTempFactor.setFont(LABEL_FONT);
1701 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1702 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1703 structureTab.add(addTempFactor);
1705 ypos += lineSpacing;
1706 JLabel viewerLabel = new JLabel();
1707 viewerLabel.setFont(LABEL_FONT);
1708 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1709 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1710 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1711 structureTab.add(viewerLabel);
1714 * add all external viewers as options here - check
1715 * when selected whether the program is installed
1717 structViewer.setFont(LABEL_FONT);
1718 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1719 structViewer.addItem(ViewerType.JMOL.name());
1720 structViewer.addItem(ViewerType.CHIMERA.name());
1721 structViewer.addItem(ViewerType.CHIMERAX.name());
1722 structViewer.addItem(ViewerType.PYMOL.name());
1723 structViewer.addActionListener(new ActionListener()
1726 public void actionPerformed(ActionEvent e)
1728 structureViewer_actionPerformed(
1729 (String) structViewer.getSelectedItem());
1732 structureTab.add(structViewer);
1734 ypos += lineSpacing;
1735 structureViewerPathLabel = new JLabel();
1736 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1738 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1739 structureViewerPathLabel.setText(MessageManager
1740 .formatMessage("label.viewer_path", "Chimera(X)"));
1741 structureViewerPathLabel
1742 .setBounds(new Rectangle(10, ypos, 170, height));
1743 structureViewerPathLabel.setEnabled(false);
1744 structureTab.add(structureViewerPathLabel);
1746 structureViewerPath.setFont(LABEL_FONT);
1747 structureViewerPath.setText("");
1748 structureViewerPath.setEnabled(false);
1749 final String tooltip = JvSwingUtils.wrapTooltip(true,
1750 MessageManager.getString("label.viewer_path_tip"));
1751 structureViewerPath.setToolTipText(tooltip);
1752 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1753 structureViewerPath.addMouseListener(new MouseAdapter()
1756 public void mouseClicked(MouseEvent e)
1758 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1760 String chosen = openFileChooser();
1763 structureViewerPath.setText(chosen);
1768 structureTab.add(structureViewerPath);
1770 ypos += lineSpacing;
1771 nwMapping.setFont(LABEL_FONT);
1772 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1773 siftsMapping.setFont(LABEL_FONT);
1774 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1775 mappingMethod.add(nwMapping);
1776 mappingMethod.add(siftsMapping);
1777 JPanel mappingPanel = new JPanel();
1778 mappingPanel.setFont(LABEL_FONT);
1779 TitledBorder mmTitledBorder = new TitledBorder(
1780 MessageManager.getString("label.mapping_method"));
1781 mmTitledBorder.setTitleFont(LABEL_FONT);
1782 mappingPanel.setBorder(mmTitledBorder);
1783 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1784 // GridLayout mappingLayout = new GridLayout();
1785 mappingPanel.setLayout(new GridLayout());
1786 mappingPanel.add(nwMapping);
1787 mappingPanel.add(siftsMapping);
1788 structureTab.add(mappingPanel);
1790 ypos += lineSpacing;
1791 ypos += lineSpacing;
1792 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1793 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1794 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1795 structureTab.add(docFieldPref);
1798 * hide Chimera options in JalviewJS
1800 if (Platform.isJS())
1802 structureViewerPathLabel.setVisible(false);
1803 structureViewerPath.setVisible(false);
1804 viewerLabel.setVisible(false);
1805 structViewer.setVisible(false);
1808 return structureTab;
1812 * Action on choosing a structure viewer from combobox options.
1814 * @param selectedItem
1816 protected void structureViewer_actionPerformed(String selectedItem)
1821 * Show a dialog for the user to choose a file. Returns the chosen path, or null
1826 protected String openFileChooser()
1828 String choice = null;
1829 JFileChooser chooser = new JFileChooser();
1831 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1832 // hidden executables within .app dirs
1833 if (Platform.isMac())
1835 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1839 // chooser.setFileView(new JalviewFileView());
1840 chooser.setDialogTitle(
1841 MessageManager.getString("label.open_local_file"));
1842 chooser.setToolTipText(MessageManager.getString("action.open"));
1844 int value = chooser.showOpenDialog(this);
1846 if (value == JFileChooser.APPROVE_OPTION)
1848 choice = chooser.getSelectedFile().getPath();
1854 * Validate the structure tab preferences; if invalid, set focus on this tab.
1858 protected boolean validateStructure(FocusEvent e)
1860 if (!validateStructure())
1862 e.getComponent().requestFocusInWindow();
1868 protected boolean validateStructure()
1874 * Initialises the Visual tabbed panel.
1878 private JPanel initVisualTab()
1880 JPanel visualTab = new JPanel();
1881 visualTab.setBorder(new TitledBorder(
1882 MessageManager.getString("action.open_new_alignment")));
1883 visualTab.setLayout(null);
1884 fullScreen.setFont(LABEL_FONT);
1885 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1886 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1887 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1888 quality.setEnabled(false);
1889 quality.setFont(LABEL_FONT);
1890 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1891 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1892 quality.setSelected(true);
1893 quality.setText(MessageManager.getString("label.quality"));
1894 conservation.setEnabled(false);
1895 conservation.setFont(LABEL_FONT);
1896 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1897 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1898 conservation.setSelected(true);
1899 conservation.setText(MessageManager.getString("label.conservation"));
1900 identity.setEnabled(false);
1901 identity.setFont(LABEL_FONT);
1902 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1903 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1904 identity.setSelected(true);
1905 identity.setText(MessageManager.getString("label.consensus"));
1906 showOccupancy.setFont(LABEL_FONT);
1907 showOccupancy.setEnabled(false);
1908 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1909 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1910 showOccupancy.setSelected(true);
1911 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1913 JLabel showGroupbits = new JLabel();
1914 showGroupbits.setFont(LABEL_FONT);
1915 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1916 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1918 .setText(MessageManager.getString("action.show_group") + ":");
1919 JLabel showConsensbits = new JLabel();
1920 showConsensbits.setFont(LABEL_FONT);
1921 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1922 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1924 .setText(MessageManager.getString("label.consensus") + ":");
1925 showConsensHistogram.setEnabled(false);
1926 showConsensHistogram.setFont(LABEL_FONT);
1927 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1928 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1929 showConsensHistogram.setSelected(true);
1930 showConsensHistogram
1931 .setText(MessageManager.getString("label.histogram"));
1932 showConsensLogo.setEnabled(false);
1933 showConsensLogo.setFont(LABEL_FONT);
1934 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1935 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1936 showConsensLogo.setSelected(true);
1937 showConsensLogo.setText(MessageManager.getString("label.logo"));
1938 showGroupConsensus.setEnabled(false);
1939 showGroupConsensus.setFont(LABEL_FONT);
1940 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1941 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1942 showGroupConsensus.setSelected(true);
1943 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1944 showGroupConservation.setEnabled(false);
1945 showGroupConservation.setFont(LABEL_FONT);
1946 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1947 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1948 showGroupConservation.setSelected(true);
1949 showGroupConservation
1950 .setText(MessageManager.getString("label.conservation"));
1951 showNpTooltip.setEnabled(true);
1952 showNpTooltip.setFont(LABEL_FONT);
1953 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1954 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1955 showNpTooltip.setSelected(true);
1956 showNpTooltip.setText(
1957 MessageManager.getString("label.non_positional_features"));
1958 showDbRefTooltip.setEnabled(true);
1959 showDbRefTooltip.setFont(LABEL_FONT);
1960 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1961 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1962 showDbRefTooltip.setSelected(true);
1964 .setText(MessageManager.getString("label.database_references"));
1965 annotations.setFont(LABEL_FONT);
1966 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1967 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1968 annotations.setSelected(true);
1969 annotations.setText(MessageManager.getString("label.show_annotations"));
1970 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1971 annotations.addActionListener(new ActionListener()
1974 public void actionPerformed(ActionEvent e)
1976 annotations_actionPerformed(e);
1979 identity.addActionListener(new ActionListener()
1982 public void actionPerformed(ActionEvent e)
1984 annotations_actionPerformed(e);
1987 showGroupConsensus.addActionListener(new ActionListener()
1990 public void actionPerformed(ActionEvent e)
1992 annotations_actionPerformed(e);
1995 showUnconserved.setFont(LABEL_FONT);
1996 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1997 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1998 showUnconserved.setSelected(true);
2000 .setText(MessageManager.getString("action.show_unconserved"));
2001 showUnconserved.addActionListener(new ActionListener()
2004 public void actionPerformed(ActionEvent e)
2006 showunconserved_actionPerformed(e);
2010 // TODO these are not yet added to / action from Preferences
2011 // JCheckBox shareSelections = new JCheckBox();
2012 // shareSelections.setFont(verdana11);
2013 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2014 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2015 // shareSelections.setSelected(true);
2016 // shareSelections.setText(MessageManager
2017 // .getString("label.share_selection_across_views"));
2018 // JCheckBox followHighlight = new JCheckBox();
2019 // followHighlight.setFont(verdana11);
2020 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2021 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2022 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2023 // followHighlight.setSelected(true);
2024 // followHighlight.setText(MessageManager
2025 // .getString("label.scroll_highlighted_regions"));
2027 seqLimit.setFont(LABEL_FONT);
2028 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2029 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2030 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2031 smoothFont.setFont(LABEL_FONT);
2032 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2033 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2034 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2035 scaleProteinToCdna.setFont(LABEL_FONT);
2036 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2037 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2038 scaleProteinToCdna.setText(
2039 MessageManager.getString("label.scale_protein_to_cdna"));
2040 scaleProteinToCdna.setToolTipText(
2041 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2042 JLabel gapLabel = new JLabel();
2043 gapLabel.setFont(LABEL_FONT);
2044 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2045 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2046 JLabel fontLabel = new JLabel();
2047 fontLabel.setFont(LABEL_FONT);
2048 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2049 fontLabel.setText(MessageManager.getString("label.font"));
2050 fontSizeCB.setFont(LABEL_FONT);
2051 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2052 fontStyleCB.setFont(LABEL_FONT);
2053 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2054 fontNameCB.setFont(LABEL_FONT);
2055 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2056 gapSymbolCB.setFont(LABEL_FONT);
2057 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2058 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2059 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2060 gapSymbolCB.setRenderer(dlcr);
2062 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2063 startupCheckbox.setFont(LABEL_FONT);
2064 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2065 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2066 startupCheckbox.setSelected(true);
2067 startupFileTextfield.setFont(LABEL_FONT);
2068 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2069 final String tooltip = JvSwingUtils.wrapTooltip(true,
2070 MessageManager.getString("label.double_click_to_browse"));
2071 startupFileTextfield.setToolTipText(tooltip);
2072 startupFileTextfield.addMouseListener(new MouseAdapter()
2075 public void mouseClicked(MouseEvent e)
2077 if (e.getClickCount() > 1)
2079 startupFileTextfield_mouseClicked();
2084 sortby.setFont(LABEL_FONT);
2085 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2086 JLabel sortLabel = new JLabel();
2087 sortLabel.setFont(LABEL_FONT);
2088 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2089 sortLabel.setText(MessageManager.getString("label.sort_by"));
2090 sortAnnBy.setFont(LABEL_FONT);
2091 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2092 JLabel sortAnnLabel = new JLabel();
2093 sortAnnLabel.setFont(LABEL_FONT);
2094 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2095 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2096 sortAutocalc.setFont(LABEL_FONT);
2097 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2099 JPanel annsettingsPanel = new JPanel();
2100 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2101 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2102 annsettingsPanel.setBorder(new EtchedBorder());
2103 visualTab.add(annsettingsPanel);
2104 Border jb = new EmptyBorder(1, 1, 4, 5);
2105 annotations.setBorder(jb);
2106 showOccupancy.setBorder(jb);
2107 quality.setBorder(jb);
2108 conservation.setBorder(jb);
2109 identity.setBorder(jb);
2110 showConsensbits.setBorder(jb);
2111 showGroupbits.setBorder(jb);
2112 showGroupConsensus.setBorder(jb);
2113 showGroupConservation.setBorder(jb);
2114 showConsensHistogram.setBorder(jb);
2115 showConsensLogo.setBorder(jb);
2117 JPanel autoAnnotSettings = new JPanel();
2118 annsettingsPanel.add(autoAnnotSettings);
2119 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2120 autoAnnotSettings.add(annotations);
2121 autoAnnotSettings.add(quality);
2122 // second row of autoannotation box
2123 autoAnnotSettings = new JPanel();
2124 annsettingsPanel.add(autoAnnotSettings);
2126 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2127 autoAnnotSettings.add(conservation);
2128 autoAnnotSettings.add(identity);
2129 autoAnnotSettings.add(showOccupancy);
2130 autoAnnotSettings.add(showGroupbits);
2131 autoAnnotSettings.add(showGroupConservation);
2132 autoAnnotSettings.add(showGroupConsensus);
2133 autoAnnotSettings.add(showConsensbits);
2134 autoAnnotSettings.add(showConsensHistogram);
2135 autoAnnotSettings.add(showConsensLogo);
2137 JPanel tooltipSettings = new JPanel();
2138 tooltipSettings.setBorder(new TitledBorder(
2139 MessageManager.getString("label.sequence_id_tooltip")));
2140 tooltipSettings.setBounds(173, 140, 220, 62);
2141 tooltipSettings.setLayout(new GridLayout(2, 1));
2142 tooltipSettings.add(showDbRefTooltip);
2143 tooltipSettings.add(showNpTooltip);
2144 visualTab.add(tooltipSettings);
2146 wrap.setFont(LABEL_FONT);
2147 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2148 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2149 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2150 rightAlign.setFont(LABEL_FONT);
2151 rightAlign.setForeground(Color.black);
2152 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2153 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2154 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2155 idItalics.setFont(LABEL_FONT_ITALIC);
2156 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2157 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2159 MessageManager.getString("label.sequence_name_italics"));
2160 openoverv.setFont(LABEL_FONT);
2161 openoverv.setActionCommand(
2162 MessageManager.getString("label.open_overview"));
2163 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2164 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2165 openoverv.setText(MessageManager.getString("label.open_overview"));
2166 JPanel jPanel2 = new JPanel();
2167 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2168 jPanel2.setLayout(new GridLayout(14, 1));
2169 jPanel2.add(fullScreen);
2170 jPanel2.add(openoverv);
2171 jPanel2.add(seqLimit);
2172 jPanel2.add(rightAlign);
2173 jPanel2.add(fontLabel);
2174 jPanel2.add(showUnconserved);
2175 jPanel2.add(idItalics);
2176 jPanel2.add(smoothFont);
2177 jPanel2.add(scaleProteinToCdna);
2178 jPanel2.add(gapLabel);
2180 jPanel2.add(sortLabel);
2181 jPanel2.add(sortAnnLabel);
2182 jPanel2.add(startupCheckbox);
2183 visualTab.add(jPanel2);
2184 visualTab.add(startupFileTextfield);
2185 visualTab.add(sortby);
2186 visualTab.add(sortAnnBy);
2187 visualTab.add(sortAutocalc);
2188 visualTab.add(gapSymbolCB);
2189 visualTab.add(fontNameCB);
2190 visualTab.add(fontSizeCB);
2191 visualTab.add(fontStyleCB);
2193 if (Platform.isJS())
2195 startupCheckbox.setVisible(false);
2196 startupFileTextfield.setVisible(false);
2203 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2206 protected void loadLastSavedBackupsOptions()
2208 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2209 .getSavedBackupEntry();
2210 enableBackupFiles.setSelected(
2211 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2213 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2214 .createBackupFilesPresetEntry(Cache
2215 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2216 if (backupfilesCustomEntry == null)
2218 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2219 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2221 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2222 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2223 backupfilesCustomEntry);
2225 setComboIntStringKey(backupfilesPresetsCombo,
2226 Cache.getDefault(BackupFiles.NS + "_PRESET",
2227 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2229 backupsSetOptions(savedPreset);
2231 backupsOptionsSetEnabled();
2232 updateBackupFilesExampleLabel();
2236 * Load the saved Memory settings
2238 protected void loadLastSavedMemorySettings()
2240 customiseMemorySetting.setSelected(
2241 Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2242 jvmMemoryPercentSlider
2243 .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2244 jvmMemoryMaxTextField.setText(
2245 Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2248 private boolean warnAboutSuffixReverseChange()
2250 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2251 .getSavedBackupEntry();
2252 boolean savedSuffixReverse = bfpe.reverse;
2253 int savedSuffixDigits = bfpe.digits;
2254 String savedSuffixTemplate = bfpe.suffix;
2256 boolean nowSuffixReverse = suffixReverse.isSelected();
2257 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2258 String nowSuffixTemplate = suffixTemplate.getText();
2259 return nowSuffixReverse != savedSuffixReverse
2260 && nowSuffixDigits == savedSuffixDigits
2261 && nowSuffixTemplate != null
2262 && nowSuffixTemplate.equals(savedSuffixTemplate);
2265 /* Initialises the Startup tabbed panel.
2270 private JPanel initStartupTab()
2272 JPanel startupTab = new JPanel();
2273 startupTab.setBorder(
2274 new TitledBorder(MessageManager.getString("label.memory")));
2275 startupTab.setLayout(new GridBagLayout());
2277 GridBagConstraints gbc = new GridBagConstraints();
2280 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2281 gbc.fill = GridBagConstraints.NONE;
2288 gbc.gridy = 0; // row 1
2290 JLabel memoryText = new JLabel();
2291 memoryText.setFont(LABEL_FONT_ITALIC);
2293 .setText(MessageManager.getString("label.memory_setting_text"));
2294 startupTab.add(memoryText, gbc);
2296 gbc.gridy++; // row 2
2298 JPanel exampleMemoryPanel = new JPanel();
2300 .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2301 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2302 MessageManager.getString("label.memory_example_tooltip")));
2303 JLabel exampleTextLabel = new JLabel();
2305 .setText(MessageManager.getString("label.memory_example_text"));
2306 exampleTextLabel.setForeground(Color.GRAY);
2307 exampleTextLabel.setFont(LABEL_FONT);
2308 exampleMemoryPanel.add(exampleTextLabel);
2309 exampleMemoryPanel.add(exampleMemoryLabel);
2310 exampleMemoryPanel.setBackground(Color.WHITE);
2311 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2312 startupTab.add(exampleMemoryPanel, gbc);
2314 gbc.gridy++; // row 3
2316 startupTab.add(customiseMemorySetting, gbc);
2318 gbc.gridy += 2; // row 4 with a gap
2320 startupTab.add(maxMemoryLabel, gbc);
2322 gbc.gridy += 2; // row 5
2325 startupTab.add(jvmMemoryPercentLabel, gbc);
2327 startupTab.add(jvmMemoryPercentSlider, gbc);
2329 // gbc.weightx = 0.1;
2330 startupTab.add(jvmMemoryPercentDisplay, gbc);
2331 // gbc.weightx = 1.0;
2334 gbc.gridy++; // row 6
2336 startupTab.add(jvmMemoryMaxLabel, gbc);
2338 startupTab.add(jvmMemoryMaxTextField, gbc);
2340 gbc.gridy++; // row 7
2343 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2344 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2345 sp.setBorder(BorderFactory.createEmptyBorder());
2346 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2347 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2348 startupTab.add(sp, gbc);
2350 // fill empty space to push widget to top left
2356 startupTab.add(new JPanel(), gbc);
2358 setMemoryPercentDisplay();
2359 memoryOptionsSetEnabled();
2363 private void initMemoryPanel()
2365 // Enable memory settings checkbox
2366 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2367 customiseMemorySetting.setText(
2368 MessageManager.getString("label.customise_memory_settings"));
2369 customiseMemorySetting.addActionListener(new ActionListener()
2372 public void actionPerformed(ActionEvent e)
2374 memoryOptionsSetEnabled();
2378 loadLastSavedMemorySettings();
2380 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2381 exampleMemoryLabel.setBackground(Color.WHITE);
2383 maxMemoryLabel = new JLabel(
2384 MessageManager.getString("label.maximum_memory_used"));
2385 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2387 // Maximum memory percentage slider
2388 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2389 jvmMemoryPercentLabel.setText(
2390 MessageManager.getString("label.percent_of_physical_memory"));
2391 jvmMemoryPercentSlider.setPaintLabels(true);
2392 jvmMemoryPercentSlider.setPaintTicks(true);
2393 jvmMemoryPercentSlider.setPaintTrack(true);
2394 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2395 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2396 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2399 public void stateChanged(ChangeEvent e)
2401 setMemoryPercentDisplay();
2404 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2405 setMemoryPercentDisplay();
2407 // Maximum memory cap textbox
2408 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2410 .setText(MessageManager.getString("label.maximum_memory"));
2411 initMemoryMaxTextField();
2413 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2414 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2415 exampleMemoryMessageTextArea.setEditable(false);
2416 exampleMemoryMessageTextArea.setLineWrap(true);
2417 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2418 exampleMemoryMessageTextArea.setText(" ");
2419 exampleMemoryMessageTextArea.setRows(2);
2420 exampleMemoryMessageTextArea.setColumns(40);
2422 setExampleMemoryLabel();
2425 private void initMemoryMaxTextField()
2427 jvmMemoryMaxTextField.setToolTipText(
2428 MessageManager.getString("label.maximum_memory_tooltip"));
2429 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2432 public void actionPerformed(ActionEvent arg0)
2434 validateMemoryMaxTextField();
2435 setExampleMemoryLabel();
2439 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2442 public void keyReleased(KeyEvent e)
2444 validateMemoryMaxTextField();
2445 setExampleMemoryLabel();
2449 public void keyPressed(KeyEvent e)
2453 // try and stop invalid typing
2455 public void keyTyped(KeyEvent e)
2457 char c = Character.toLowerCase(e.getKeyChar());
2458 String text = jvmMemoryMaxTextField.getText();
2459 String suffixes = "tgmkb";
2460 int pos = jvmMemoryMaxTextField.getCaretPosition();
2461 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2462 if (!((('0' <= c && c <= '9')
2463 && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2465 || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2467 && pos == text.length() // at end of text and
2468 && suffixPos == -1) // there isn't already one
2478 private boolean isMemoryMaxTextFieldValid()
2480 return MemorySetting
2481 .isValidMemoryString(jvmMemoryMaxTextField.getText());
2484 private void validateMemoryMaxTextField()
2486 if (isMemoryMaxTextFieldValid())
2488 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2492 jvmMemoryMaxTextField.setBackground(Color.PINK);
2496 private void setMemoryPercentDisplay()
2498 jvmMemoryPercentDisplay
2499 .setText(jvmMemoryPercentSlider.getValue() + "%");
2500 setExampleMemoryLabel();
2503 private void setExampleMemoryLabel()
2505 boolean selected = customiseMemorySetting.isSelected();
2506 int jvmmempc = jvmMemoryPercentSlider.getValue();
2507 String jvmmemmax = jvmMemoryMaxTextField.getText();
2510 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2511 && MemorySetting.isValidMemoryString(jvmmemmax))
2513 mem = MemorySetting.getMemorySetting(jvmmemmax,
2514 String.valueOf(jvmmempc), false, true);
2518 mem = MemorySetting.getMemorySetting(null, null, false, true);
2520 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2521 String message = MemorySetting.getAdjustmentMessage();
2522 exampleMemoryMessageTextArea.setText(
2523 MessageManager.getString("label.adjustments_for_this_computer")
2526 ? MessageManager.getString("label.none")
2530 private void memoryOptionsSetEnabled()
2532 boolean enabled = customiseMemorySetting.isSelected();
2533 // leave exampleMemoryLabel enabled always
2534 maxMemoryLabel.setEnabled(enabled);
2535 jvmMemoryPercentLabel.setEnabled(enabled);
2536 jvmMemoryPercentSlider.setEnabled(enabled);
2537 jvmMemoryPercentDisplay.setEnabled(enabled);
2538 jvmMemoryMaxLabel.setEnabled(enabled);
2539 jvmMemoryMaxTextField.setEnabled(enabled);
2540 exampleMemoryMessageTextArea.setEnabled(enabled);
2541 setExampleMemoryLabel();
2545 * Initialises the Backups tabbed panel.
2549 private JPanel initBackupsTab()
2551 JPanel backupsTab = new JPanel();
2552 backupsTab.setBorder(new TitledBorder(
2553 MessageManager.getString("label.backup_files")));
2554 backupsTab.setLayout(new GridBagLayout());
2556 GridBagConstraints gbc = new GridBagConstraints();
2559 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2560 gbc.fill = GridBagConstraints.NONE;
2562 initBackupsTabPresetsPanel();
2563 initBackupsTabSuffixPanel();
2564 initBackupsTabKeepFilesPanel();
2565 initBackupsTabFilenameExamplesPanel();
2567 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2569 .setText(MessageManager.getString("label.enable_backupfiles"));
2570 enableBackupFiles.addActionListener(new ActionListener()
2573 public void actionPerformed(ActionEvent e)
2575 // enable other options only when the first is checked
2576 backupsOptionsSetEnabled();
2580 // enable checkbox 1 col
2584 gbc.gridy = 0; // row 0
2585 backupsTab.add(enableBackupFiles, gbc);
2587 // summary of scheme box (over two rows)
2591 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2592 gbc.fill = GridBagConstraints.BOTH;
2593 backupsTab.add(exampleFilesPanel, gbc);
2595 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2596 gbc.fill = GridBagConstraints.NONE;
2598 // fill empty space on right
2601 backupsTab.add(new JPanel(), gbc);
2606 gbc.gridy++; // row 1
2607 backupsTab.add(presetsPanel, gbc);
2609 // now using whole row
2614 gbc.gridy++; // row 2
2615 backupsTab.add(keepfilesPanel, gbc);
2617 // filename strategy box
2618 gbc.gridy++; // row 3
2619 backupsTab.add(suffixPanel, gbc);
2622 gbc.gridy++; // row 4
2624 backupsTab.add(new JPanel(), gbc);
2626 backupsOptionsSetEnabled();
2630 private JPanel initBackupsTabPresetsPanel()
2633 String title = MessageManager.getString("label.schemes");
2635 presetsPanel.setLayout(new GridBagLayout());
2637 GridBagConstraints gbc = new GridBagConstraints();
2640 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2641 gbc.fill = GridBagConstraints.NONE;
2649 presetsComboLabel = new JLabel(title + ":");
2650 presetsPanel.add(presetsComboLabel, gbc);
2652 List<Object> entries = Arrays.asList(
2653 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2654 List<String> tooltips = Arrays.asList(
2655 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2656 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2659 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2661 backupfilesPresetsCombo
2662 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2666 backupfilesPresetsCombo.addActionListener(new ActionListener()
2669 public void actionPerformed(ActionEvent e)
2671 int key = getComboIntStringKey(backupfilesPresetsCombo);
2672 if (!customiseCheckbox.isSelected())
2674 backupfilesPresetsComboLastSelected = key;
2676 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2678 if (customiseCheckbox.isSelected())
2680 // got here by clicking on customiseCheckbox so don't change the
2682 backupfilesCustomOptionsSetEnabled();
2686 backupsTabUpdatePresets();
2687 backupfilesCustomOptionsSetEnabled();
2692 customiseCheckbox.setSelected(false);
2693 backupsTabUpdatePresets();
2694 backupfilesCustomOptionsSetEnabled();
2699 // dropdown list of preset schemes
2701 presetsPanel.add(backupfilesPresetsCombo, gbc);
2703 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2704 revertButton.setToolTipText(
2705 MessageManager.getString("label.cancel_changes_description"));
2706 revertButton.addActionListener(new ActionListener()
2709 public void actionPerformed(ActionEvent e)
2712 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2713 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2714 backupfilesCustomOptionsSetEnabled();
2718 revertButton.setFont(LABEL_FONT);
2720 customiseCheckbox.setFont(LABEL_FONT);
2721 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2722 customiseCheckbox.addActionListener(new ActionListener()
2725 public void actionPerformed(ActionEvent e)
2727 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2728 if (customiseCheckbox.isSelected())
2730 backupfilesPresetsComboLastSelected = currently;
2731 setComboIntStringKey(backupfilesPresetsCombo,
2732 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2736 setComboIntStringKey(backupfilesPresetsCombo,
2737 backupfilesPresetsComboLastSelected);
2740 backupfilesCustomOptionsSetEnabled();
2743 customiseCheckbox.setToolTipText(
2744 MessageManager.getString("label.customise_description"));
2746 // customise checkbox
2749 presetsPanel.add(customiseCheckbox, gbc);
2751 // "Cancel changes" button (aligned with combo box above)
2753 presetsPanel.add(revertButton, gbc);
2755 return presetsPanel;
2758 private JPanel initBackupsTabFilenameExamplesPanel()
2760 String title = MessageManager.getString("label.scheme_examples");
2761 TitledBorder tb = new TitledBorder(title);
2762 exampleFilesPanel.setBorder(tb);
2763 exampleFilesPanel.setLayout(new GridBagLayout());
2765 backupfilesExampleLabel.setEditable(false);
2766 backupfilesExampleLabel
2767 .setBackground(exampleFilesPanel.getBackground());
2769 updateBackupFilesExampleLabel();
2771 GridBagConstraints gbc = new GridBagConstraints();
2774 gbc.fill = GridBagConstraints.NONE;
2775 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2777 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2778 return exampleFilesPanel;
2781 private void backupsTabUpdatePresets()
2783 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2786 String value = entry.v;
2788 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2792 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2798 "Preset '" + value + "' [key:" + key + "] not implemented");
2801 // Custom options will now be enabled when the customiseCheckbox is checked
2802 // (performed above)
2803 // backupfilesCustomOptionsSetEnabled();
2804 updateBackupFilesExampleLabel();
2807 protected int getComboIntStringKey(
2808 JComboBox<Object> backupfilesPresetsCombo2)
2810 IntKeyStringValueEntry e;
2813 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2815 } catch (Exception ex)
2818 "Problem casting Combo entry to IntKeyStringValueEntry.");
2821 return e != null ? e.k : 0;
2824 protected void setComboIntStringKey(
2825 JComboBox<Object> backupfilesPresetsCombo2, int key)
2827 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2829 IntKeyStringValueEntry e;
2832 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2833 } catch (Exception ex)
2836 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2841 backupfilesPresetsCombo2.setSelectedIndex(i);
2845 // backupsTabUpdatePresets();
2848 private JPanel initBackupsTabSuffixPanel()
2850 suffixPanel.setBorder(new TitledBorder(
2851 MessageManager.getString("label.backup_filename_strategy")));
2852 suffixPanel.setLayout(new GridBagLayout());
2855 .setText(MessageManager.getString("label.append_to_filename"));
2856 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2857 suffixTemplateLabel.setFont(LABEL_FONT);
2859 final String tooltip = JvSwingUtils.wrapTooltip(true,
2860 MessageManager.getString("label.append_to_filename_tooltip"));
2861 suffixTemplate.setToolTipText(tooltip);
2862 suffixTemplate.addActionListener(new ActionListener()
2865 public void actionPerformed(ActionEvent e)
2867 updateBackupFilesExampleLabel();
2868 backupfilesCustomOptionsSetEnabled();
2869 backupfilesRevertButtonSetEnabled(true);
2873 suffixTemplate.addKeyListener(new KeyListener()
2876 public void keyReleased(KeyEvent e)
2878 updateBackupFilesExampleLabel();
2879 backupfilesCustomOptionsSetEnabled();
2880 backupfilesRevertButtonSetEnabled(true);
2884 public void keyPressed(KeyEvent e)
2888 // disable use of ':' or '/' or '\'
2890 public void keyTyped(KeyEvent e)
2892 char c = e.getKeyChar();
2893 if (c == ':' || c == '/' || c == '\\')
2895 // don't process ':' or '/' or '\'
2904 .setText(MessageManager.getString("label.index_digits"));
2905 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2906 suffixDigitsLabel.setFont(LABEL_FONT);
2907 ChangeListener c = new ChangeListener()
2910 public void stateChanged(ChangeEvent e)
2912 backupfilesRevertButtonSetEnabled(true);
2913 updateBackupFilesExampleLabel();
2917 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2918 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2920 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2921 MessageManager.getString("label.increment_index"));
2922 suffixReverse.addActionListener(new ActionListener()
2925 public void actionPerformed(ActionEvent e)
2927 boolean okay = true;
2928 if (warnAboutSuffixReverseChange())
2931 okay = confirmSuffixReverseChange();
2935 backupfilesRevertButtonSetEnabled(true);
2936 updateBackupFilesExampleLabel();
2940 boolean savedSuffixReverse = BackupFilesPresetEntry
2941 .getSavedBackupEntry().reverse;
2942 suffixReverse.setSelected(savedSuffixReverse);
2947 GridBagConstraints sgbc = new GridBagConstraints();
2949 // first row (template text box)
2950 sgbc.anchor = GridBagConstraints.WEST;
2954 sgbc.gridheight = 1;
2957 sgbc.fill = GridBagConstraints.NONE;
2958 suffixPanel.add(suffixTemplateLabel, sgbc);
2961 sgbc.fill = GridBagConstraints.HORIZONTAL;
2962 suffixPanel.add(suffixTemplate, sgbc);
2964 // second row (number of digits spinner)
2968 sgbc.fill = GridBagConstraints.NONE;
2969 suffixPanel.add(suffixDigitsLabel, sgbc);
2972 sgbc.fill = GridBagConstraints.HORIZONTAL;
2973 suffixPanel.add(suffixDigitsSpinner, sgbc);
2975 // third row (forward order radio selection)
2978 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2979 sgbc.fill = GridBagConstraints.HORIZONTAL;
2980 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2982 // fourth row (reverse order radio selection)
2984 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2988 private boolean confirmSuffixReverseChange()
2990 boolean ret = false;
2991 String warningMessage = MessageManager
2992 .getString("label.warning_confirm_change_reverse");
2993 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2995 MessageManager.getString("label.change_increment_decrement"),
2996 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2998 ret = (confirm == JvOptionPane.YES_OPTION);
3002 private JPanel initBackupsTabKeepFilesPanel()
3004 keepfilesPanel.setBorder(
3005 new TitledBorder(MessageManager.getString("label.keep_files")));
3006 keepfilesPanel.setLayout(new GridBagLayout());
3008 backupfilesKeepAll.setLabels(
3009 MessageManager.getString("label.keep_all_backup_files"),
3010 MessageManager.getString(
3011 "label.keep_only_this_number_of_backup_files"));
3012 backupfilesKeepAll.addTrueActionListener(new ActionListener()
3015 public void actionPerformed(ActionEvent e)
3017 backupfilesRevertButtonSetEnabled(true);
3018 updateBackupFilesExampleLabel();
3021 backupfilesKeepAll.addActionListener(new ActionListener()
3024 public void actionPerformed(ActionEvent e)
3026 backupfilesRevertButtonSetEnabled(true);
3027 keepRollMaxOptionsEnabled();
3028 updateBackupFilesExampleLabel();
3032 ChangeListener c = new ChangeListener()
3035 public void stateChanged(ChangeEvent e)
3037 backupfilesRevertButtonSetEnabled(true);
3038 updateBackupFilesExampleLabel();
3042 setIntegerSpinner(backupfilesRollMaxSpinner,
3043 BackupFilesPresetEntry.ROLLMAXMIN,
3044 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3046 backupfilesConfirmDelete.setLabels(
3047 MessageManager.getString("label.always_ask"),
3048 MessageManager.getString("label.auto_delete"));
3049 backupfilesConfirmDelete.addActionListener(new ActionListener()
3052 public void actionPerformed(ActionEvent e)
3054 backupfilesRevertButtonSetEnabled(true);
3057 // update the enabled section
3058 keepRollMaxOptionsEnabled();
3060 GridBagConstraints kgbc = new GridBagConstraints();
3062 // first row (template text box)
3063 kgbc.anchor = GridBagConstraints.WEST;
3066 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3067 kgbc.gridheight = 1;
3070 kgbc.fill = GridBagConstraints.HORIZONTAL;
3071 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3077 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3078 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3081 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3082 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3084 // third row (indented)
3086 kgbc.insets = new Insets(0, 20, 0, 0);
3089 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3090 kgbc.fill = GridBagConstraints.HORIZONTAL;
3093 JPanel jp = new JPanel();
3094 jp.setLayout(new FlowLayout());
3095 oldBackupFilesLabel.setText(
3096 MessageManager.getString("label.autodelete_old_backup_files"));
3097 oldBackupFilesLabel.setFont(LABEL_FONT);
3098 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3099 jp.add(oldBackupFilesLabel);
3100 jp.add(backupfilesConfirmDelete.getTrueButton());
3101 jp.add(backupfilesConfirmDelete.getFalseButton());
3102 keepfilesPanel.add(jp, kgbc);
3104 return keepfilesPanel;
3107 protected void updateBackupFilesExampleLabel()
3109 int exampleindex = 12;
3110 String base = MessageManager.getString("label.filename") + ".fa";
3111 if (base == null || base.length() == 0)
3113 base = "file_name.fa";
3116 boolean reverse = suffixReverse.isSelected();
3117 boolean keepAll = backupfilesKeepAll.isSelected();
3119 String suffix = suffixTemplate.getText();
3122 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3123 if (suffix == null || suffix.length() == 0)
3125 backupfilesExampleLabel
3126 .setText(MessageManager.getString("label.no_backup_files"));
3127 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3131 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3132 rollMax = rollMax < 1 ? 1 : rollMax;
3134 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3139 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3140 digits = digits < 1 ? 1 : digits;
3142 int lowersurround = 2;
3143 int uppersurround = 0;
3144 StringBuilder exampleSB = new StringBuilder();
3145 boolean firstLine = true;
3151 int max = keepAll ? exampleindex : rollMax;
3152 for (int index = min; index <= max; index++)
3154 if (index == min + lowersurround && index < max - uppersurround - 1)
3156 exampleSB.append("\n...");
3159 else if (index > min + lowersurround && index < max - uppersurround)
3171 exampleSB.append("\n");
3174 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3175 base, suffix, digits));
3178 // no extra text needed
3180 else if (index == min)
3182 String newest = MessageManager.getString("label.braced_newest");
3183 if (newest != null && newest.length() > 0)
3185 exampleSB.append(" " + newest);
3188 else if (index == max)
3190 String oldest = MessageManager.getString("label.braced_oldest");
3191 if (oldest != null && oldest.length() > 0)
3193 exampleSB.append(" " + oldest);
3202 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3203 : exampleindex - rollMax + 1;
3204 int max = exampleindex;
3206 for (int index = min; index <= max; index++)
3209 if (index == min + lowersurround && index < max - uppersurround - 1)
3211 exampleSB.append("\n...");
3214 else if (index > min + lowersurround && index < max - uppersurround)
3226 exampleSB.append("\n");
3229 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3230 base, suffix, digits));
3233 // no extra text needed
3235 else if (index == min)
3237 String oldest = MessageManager.getString("label.braced_oldest");
3238 if (oldest != null && oldest.length() > 0)
3240 exampleSB.append(" " + oldest);
3243 else if (index == max)
3245 String newest = MessageManager.getString("label.braced_newest");
3246 if (newest != null && newest.length() > 0)
3248 exampleSB.append(" " + newest);
3256 // add some extra empty lines to pad out the example files box. ugh, please
3258 // me how to do this better
3259 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3260 if (remainingLines > 0)
3262 for (int i = 0; i < remainingLines; i++)
3264 exampleSB.append("\n ");
3269 backupfilesExampleLabel.setText(exampleSB.toString());
3272 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3273 boolean useExistingVal, ChangeListener c)
3280 i = ((Integer) s.getValue()).intValue();
3281 } catch (Exception e)
3284 "Exception casting the initial value of s.getValue()");
3288 setIntegerSpinner(s, min, max, i, c);
3291 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3294 // integer spinner for number of digits
3303 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3306 s.addChangeListener(c);
3310 protected static int getSpinnerInt(JSpinner s, int def)
3316 i = (Integer) s.getValue();
3317 } catch (Exception e)
3319 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3324 private void keepRollMaxOptionsEnabled()
3326 boolean enabled = backupfilesKeepAll.isEnabled()
3327 && !backupfilesKeepAll.isSelected();
3328 oldBackupFilesLabel.setEnabled(enabled);
3329 backupfilesRollMaxSpinner.setEnabled(enabled);
3330 backupfilesConfirmDelete.setEnabled(enabled);
3333 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3335 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3336 && customiseCheckbox.isSelected() && suffixTemplate.getText()
3337 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3338 keepfilesPanel.setEnabled(enabled);
3339 backupfilesKeepAll.setEnabled(enabled);
3340 oldBackupFilesLabel.setEnabled(enabled);
3341 keepRollMaxOptionsEnabled();
3344 private void backupfilesSuffixTemplateDigitsSetEnabled()
3346 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3347 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3348 suffixDigitsLabel.setEnabled(enabled);
3349 suffixDigitsSpinner.setEnabled(enabled);
3350 suffixReverse.setEnabled(enabled);
3353 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3355 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3356 && customiseCheckbox.isSelected();
3357 suffixPanel.setEnabled(enabled);
3358 suffixTemplateLabel.setEnabled(enabled);
3359 suffixTemplate.setEnabled(enabled);
3360 backupfilesSuffixTemplateDigitsSetEnabled();
3363 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3365 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3366 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3367 revertButton.setEnabled(enabled);
3370 private boolean backupfilesCustomChanged()
3372 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3373 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3374 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3375 return !custom.equals(current);
3378 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3380 String suffix = suffixTemplate.getText();
3381 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3382 boolean reverse = suffixReverse.isSelected();
3383 boolean keepAll = backupfilesKeepAll.isSelected();
3384 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3385 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3387 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3388 reverse, keepAll, rollMax, confirmDelete);
3393 protected void backupfilesCustomOptionsSetEnabled()
3395 boolean enabled = customiseCheckbox.isSelected();
3397 backupfilesRevertButtonSetEnabled(enabled);
3398 backupfilesSuffixTemplateSetEnabled(enabled);
3399 backupfilesKeepAllSetEnabled(enabled);
3402 private void backupfilesSummarySetEnabled()
3404 boolean enabled = enableBackupFiles.isSelected();
3405 backupfilesExampleLabel.setEnabled(enabled);
3406 exampleFilesPanel.setEnabled(enabled);
3409 private void backupfilesPresetsSetEnabled()
3411 boolean enabled = enableBackupFiles.isSelected();
3412 presetsPanel.setEnabled(enabled);
3413 presetsComboLabel.setEnabled(enabled);
3414 backupfilesPresetsCombo.setEnabled(enabled);
3415 customiseCheckbox.setEnabled(enabled);
3416 revertButton.setEnabled(enabled);
3419 protected void backupsOptionsSetEnabled()
3421 backupfilesPresetsSetEnabled();
3422 backupfilesSummarySetEnabled();
3423 backupfilesCustomOptionsSetEnabled();
3426 protected void backupsSetOptions(String suffix, int digits,
3427 boolean reverse, boolean keepAll, int rollMax,
3428 boolean confirmDelete)
3430 suffixTemplate.setText(suffix);
3431 suffixDigitsSpinner.setValue(digits);
3432 suffixReverse.setSelected(reverse);
3433 backupfilesKeepAll.setSelected(keepAll);
3434 backupfilesRollMaxSpinner.setValue(rollMax);
3435 backupfilesConfirmDelete.setSelected(confirmDelete);
3438 protected void backupsSetOptions(BackupFilesPresetEntry p)
3440 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3444 protected void autoIdWidth_actionPerformed()
3446 // TODO Auto-generated method stub
3450 protected void userIdWidth_actionPerformed()
3452 // TODO Auto-generated method stub
3456 protected void maxColour_actionPerformed(JPanel panel)
3460 protected void minColour_actionPerformed(JPanel panel)
3464 protected void gapColour_actionPerformed(JPanel panel)
3468 protected void hiddenColour_actionPerformed(JPanel panel)
3472 protected void showunconserved_actionPerformed(ActionEvent e)
3474 // TODO Auto-generated method stub
3478 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3482 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3492 public void ok_actionPerformed(ActionEvent e)
3502 public void cancel_actionPerformed(ActionEvent e)
3512 public void annotations_actionPerformed(ActionEvent e)
3519 public void startupFileTextfield_mouseClicked()
3523 public void newLink_actionPerformed(ActionEvent e)
3528 public void editLink_actionPerformed(ActionEvent e)
3533 public void deleteLink_actionPerformed(ActionEvent e)
3538 public void defaultBrowser_mouseClicked(MouseEvent e)
3543 public void linkURLList_keyTyped(KeyEvent e)
3548 public void setProxyAuthEnabled()
3550 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3551 proxyAuthUsernameLabel.setEnabled(enabled);
3552 proxyAuthPasswordLabel.setEnabled(enabled);
3553 passwordNotStoredLabel.setEnabled(enabled);
3554 proxyAuthUsernameTB.setEnabled(enabled);
3555 proxyAuthPasswordPB.setEnabled(enabled);
3558 public void setCustomProxyEnabled()
3560 boolean enabled = customProxy.isSelected();
3561 portLabel.setEnabled(enabled);
3562 serverLabel.setEnabled(enabled);
3563 portLabel2.setEnabled(enabled);
3564 serverLabel2.setEnabled(enabled);
3565 httpLabel.setEnabled(enabled);
3566 httpsLabel.setEnabled(enabled);
3567 proxyServerHttpTB.setEnabled(enabled);
3568 proxyPortHttpTB.setEnabled(enabled);
3569 proxyServerHttpsTB.setEnabled(enabled);
3570 proxyPortHttpsTB.setEnabled(enabled);
3571 proxyAuth.setEnabled(enabled);
3572 setProxyAuthEnabled();
3575 public void proxyType_actionPerformed()
3577 setCustomProxyEnabled();
3578 proxyAuthPasswordCheckHighlight(true);
3579 applyProxyButtonEnabled(true);
3582 public void proxyAuth_actionPerformed()
3584 setProxyAuthEnabled();
3585 proxyAuthPasswordCheckHighlight(true);
3586 applyProxyButtonEnabled(true);
3590 * Customer renderer for JTable: supports column of radio buttons
3592 public class RadioButtonRenderer extends JRadioButton
3593 implements TableCellRenderer
3595 public RadioButtonRenderer()
3597 setHorizontalAlignment(CENTER);
3598 setToolTipText(MessageManager.getString("label.urltooltip"));
3602 public Component getTableCellRendererComponent(JTable table,
3603 Object value, boolean isSelected, boolean hasFocus, int row,
3606 setSelected((boolean) value);
3608 // set colours to match rest of table
3611 setBackground(table.getSelectionBackground());
3612 setForeground(table.getSelectionForeground());
3616 setBackground(table.getBackground());
3617 setForeground(table.getForeground());
3624 * Customer cell editor for JTable: supports column of radio buttons in
3625 * conjunction with renderer
3627 public class RadioButtonEditor extends AbstractCellEditor
3628 implements TableCellEditor
3630 private JRadioButton button = new JRadioButton();
3632 public RadioButtonEditor()
3634 button.setHorizontalAlignment(SwingConstants.CENTER);
3635 this.button.addActionListener(new ActionListener()
3638 public void actionPerformed(ActionEvent e)
3640 fireEditingStopped();
3646 public Component getTableCellEditorComponent(JTable table, Object value,
3647 boolean isSelected, int row, int column)
3649 button.setSelected((boolean) value);
3654 public Object getCellEditorValue()
3656 return button.isSelected();