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 JComboBox defaultBrowser = new JComboBox<String>();
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_windows"));
749 defaultBrowser.setFont(LABEL_FONT);
750 final String tooltip = JvSwingUtils.wrapTooltip(true,
751 MessageManager.getString("label.double_click_to_browse"));
752 defaultBrowser.setToolTipText(tooltip);
754 defaultBrowser.addMouseListener(new MouseAdapter()
757 public void mouseClicked(MouseEvent e)
759 if (e.getClickCount() > 1)
761 defaultBrowser_mouseClicked(e);
767 JPanel proxyPanel = initConnTabProxyPanel();
768 initConnTabCheckboxes();
770 /* removing default browser preference and using Desktop.browse()
771 // Add default Browser text box
772 connectTab.add(browserLabel,
773 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
774 GridBagConstraints.WEST, GridBagConstraints.NONE,
775 new Insets(10, 0, 5, 5), 5, 1));
776 defaultBrowser.setFont(LABEL_FONT);
778 ComboBoxModel<String> cbModel = new DefaultComboBoxModel(
779 BrowserLauncher.getInstance().getBrowserList().toArray());
780 String browserPref = Cache.getProperty("DEFAULT_BROWSER");
781 if (browserPref != null)
783 cbModel.setSelectedItem(browserPref);
785 defaultBrowser.setModel(cbModel);
787 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
788 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
789 new Insets(10, 0, 5, 10), 30, 1));
792 // Add proxy server panel
793 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
794 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
795 new Insets(10, 0, 5, 12), 4, 10));
797 // Add usage stats, version check and questionnaire checkboxes
798 connectTab.add(usagestats,
799 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
800 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
801 new Insets(0, 2, 5, 5), 70, 1));
802 connectTab.add(questionnaire,
803 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
804 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
805 new Insets(0, 2, 5, 10), 70, 1));
806 connectTab.add(versioncheck,
807 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
808 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
809 new Insets(0, 2, 5, 5), 70, 1));
811 versioncheck.setVisible(false);
813 // Add padding so the panel doesn't look ridiculous
814 JPanel spacePanel = new JPanel();
815 connectTab.add(spacePanel,
816 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
817 GridBagConstraints.WEST, GridBagConstraints.BOTH,
818 new Insets(0, 0, 0, 5), 70, 1));
824 * Initialises the Links tabbed panel.
828 private JPanel initLinksTab()
830 JPanel linkTab = new JPanel();
831 linkTab.setLayout(new GridBagLayout());
833 // Set up table for Url links
834 linkUrlTable.getTableHeader().setReorderingAllowed(false);
835 linkUrlTable.setFillsViewportHeight(true);
836 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
837 linkUrlTable.setAutoCreateRowSorter(true);
838 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
840 // adjust row height so radio buttons actually fit
841 // don't do this in the renderer, it causes the awt thread to activate
843 JRadioButton temp = new JRadioButton();
844 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
846 // Table in scrollpane so that the table is given a scrollbar
847 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
848 linkScrollPane.setBorder(null);
850 // Panel for links functionality
851 JPanel linkPanel = new JPanel(new GridBagLayout());
852 linkPanel.setBorder(new TitledBorder(
853 MessageManager.getString("label.url_linkfrom_sequence_id")));
855 // Put the Url links panel together
857 // Buttons go at top right, resizing only resizes the blank space vertically
858 JPanel buttonPanel = initLinkTabUrlButtons();
859 GridBagConstraints linkConstraints1 = new GridBagConstraints();
860 linkConstraints1.insets = new Insets(0, 0, 5, 0);
861 linkConstraints1.gridx = 0;
862 linkConstraints1.gridy = 0;
863 linkConstraints1.weightx = 1.0;
864 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
865 linkTab.add(buttonPanel, linkConstraints1);
867 // Links table goes at top left, resizing resizes the table
868 GridBagConstraints linkConstraints2 = new GridBagConstraints();
869 linkConstraints2.insets = new Insets(0, 0, 5, 5);
870 linkConstraints2.gridx = 0;
871 linkConstraints2.gridy = 1;
872 linkConstraints2.weightx = 1.0;
873 linkConstraints2.weighty = 1.0;
874 linkConstraints2.fill = GridBagConstraints.BOTH;
875 linkTab.add(linkScrollPane, linkConstraints2);
877 // Filter box and buttons goes at bottom left, resizing resizes the text box
878 JPanel filterPanel = initLinkTabFilterPanel();
879 GridBagConstraints linkConstraints3 = new GridBagConstraints();
880 linkConstraints3.insets = new Insets(0, 0, 0, 5);
881 linkConstraints3.gridx = 0;
882 linkConstraints3.gridy = 2;
883 linkConstraints3.weightx = 1.0;
884 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
885 linkTab.add(filterPanel, linkConstraints3);
890 private JPanel initLinkTabFilterPanel()
892 // Filter textbox and reset button
893 JLabel filterLabel = new JLabel(
894 MessageManager.getString("label.filter"));
895 filterLabel.setFont(LABEL_FONT);
896 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
897 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
899 filterTB.setFont(LABEL_FONT);
900 filterTB.setText("");
902 doReset.setText(MessageManager.getString("action.showall"));
903 userOnly.setText(MessageManager.getString("action.customfilter"));
905 // Panel for filter functionality
906 JPanel filterPanel = new JPanel(new GridBagLayout());
907 filterPanel.setBorder(new TitledBorder("Filter"));
908 GridBagConstraints gbc = new GridBagConstraints();
911 gbc.fill = GridBagConstraints.NONE;
912 gbc.anchor = GridBagConstraints.WEST;
914 filterPanel.add(filterLabel, gbc);
916 GridBagConstraints gbc1 = new GridBagConstraints();
919 gbc1.fill = GridBagConstraints.HORIZONTAL;
920 gbc1.anchor = GridBagConstraints.WEST;
922 filterPanel.add(filterTB, gbc1);
924 GridBagConstraints gbc2 = new GridBagConstraints();
926 gbc2.fill = GridBagConstraints.NONE;
927 gbc2.anchor = GridBagConstraints.WEST;
928 filterPanel.add(doReset, gbc2);
930 GridBagConstraints gbc3 = new GridBagConstraints();
932 gbc3.fill = GridBagConstraints.NONE;
933 gbc3.anchor = GridBagConstraints.WEST;
934 filterPanel.add(userOnly, gbc3);
939 private JPanel initLinkTabUrlButtons()
941 // Buttons for new / edit / delete Url links
942 JButton newLink = new JButton();
943 newLink.setText(MessageManager.getString("action.new"));
945 editLink.setText(MessageManager.getString("action.edit"));
947 deleteLink.setText(MessageManager.getString("action.delete"));
949 // no current selection, so initially disable delete/edit buttons
950 editLink.setEnabled(false);
951 deleteLink.setEnabled(false);
953 newLink.addActionListener(new java.awt.event.ActionListener()
956 public void actionPerformed(ActionEvent e)
958 newLink_actionPerformed(e);
962 editLink.setText(MessageManager.getString("action.edit"));
963 editLink.addActionListener(new java.awt.event.ActionListener()
966 public void actionPerformed(ActionEvent e)
968 editLink_actionPerformed(e);
972 deleteLink.setText(MessageManager.getString("action.delete"));
973 deleteLink.addActionListener(new java.awt.event.ActionListener()
976 public void actionPerformed(ActionEvent e)
978 deleteLink_actionPerformed(e);
982 JPanel buttonPanel = new JPanel(new GridBagLayout());
983 buttonPanel.setBorder(new TitledBorder("Edit links"));
984 GridBagConstraints gbc = new GridBagConstraints();
987 gbc.fill = GridBagConstraints.NONE;
988 buttonPanel.add(newLink, gbc);
990 GridBagConstraints gbc1 = new GridBagConstraints();
993 gbc1.fill = GridBagConstraints.NONE;
994 buttonPanel.add(editLink, gbc1);
996 GridBagConstraints gbc2 = new GridBagConstraints();
999 gbc2.fill = GridBagConstraints.NONE;
1000 buttonPanel.add(deleteLink, gbc2);
1002 GridBagConstraints gbc3 = new GridBagConstraints();
1005 gbc3.fill = GridBagConstraints.HORIZONTAL;
1007 JPanel spacePanel = new JPanel();
1008 spacePanel.setBorder(null);
1009 buttonPanel.add(spacePanel, gbc3);
1015 * Initialises the proxy server panel in the Connections tab
1017 * @return the proxy server panel
1019 private JPanel initConnTabProxyPanel()
1021 // Label for server text box
1022 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1023 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1024 serverLabel.setFont(LABEL_FONT);
1025 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1026 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1027 serverLabel2.setFont(LABEL_FONT);
1029 // Proxy server and port text boxes
1030 proxyServerHttpTB.setFont(LABEL_FONT);
1031 proxyServerHttpTB.setColumns(40);
1032 proxyPortHttpTB.setFont(LABEL_FONT);
1033 proxyPortHttpTB.setColumns(4);
1034 proxyServerHttpsTB.setFont(LABEL_FONT);
1035 proxyServerHttpsTB.setColumns(40);
1036 proxyPortHttpsTB.setFont(LABEL_FONT);
1037 proxyPortHttpsTB.setColumns(4);
1038 proxyAuthUsernameTB.setFont(LABEL_FONT);
1039 proxyAuthUsernameTB.setColumns(30);
1041 // check for any change to enable applyProxyButton
1042 DocumentListener d = new DocumentListener()
1045 public void changedUpdate(DocumentEvent e)
1047 applyProxyButtonEnabled(true);
1051 public void insertUpdate(DocumentEvent e)
1053 applyProxyButtonEnabled(true);
1057 public void removeUpdate(DocumentEvent e)
1059 applyProxyButtonEnabled(true);
1062 proxyServerHttpTB.getDocument().addDocumentListener(d);
1063 proxyPortHttpTB.getDocument().addDocumentListener(d);
1064 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1065 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1066 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1067 proxyAuthPasswordPB.setFont(LABEL_FONT);
1068 proxyAuthPasswordPB.setColumns(30);
1069 proxyAuthPasswordPB.getDocument()
1070 .addDocumentListener(new DocumentListener()
1073 public void changedUpdate(DocumentEvent e)
1075 proxyAuthPasswordCheckHighlight(true);
1076 applyProxyButtonEnabled(true);
1080 public void insertUpdate(DocumentEvent e)
1082 proxyAuthPasswordCheckHighlight(true);
1083 applyProxyButtonEnabled(true);
1087 public void removeUpdate(DocumentEvent e)
1089 proxyAuthPasswordCheckHighlight(true);
1090 applyProxyButtonEnabled(true);
1095 // Label for Port text box
1096 portLabel.setFont(LABEL_FONT);
1097 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1098 portLabel.setText(MessageManager.getString("label.port") + ": ");
1099 portLabel2.setFont(LABEL_FONT);
1100 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1101 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1103 httpLabel.setText("HTTP");
1104 httpLabel.setFont(LABEL_FONT_BOLD);
1105 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1106 httpsLabel.setText("HTTPS");
1107 httpsLabel.setFont(LABEL_FONT_BOLD);
1108 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1110 proxyAuthUsernameLabel
1111 .setText(MessageManager.getString("label.username") + ": ");
1112 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1113 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1114 proxyAuthPasswordLabel
1115 .setText(MessageManager.getString("label.password") + ": ");
1116 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1117 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1118 passwordNotStoredLabel.setText(
1119 "(" + MessageManager.getString("label.not_stored") + ")");
1120 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1121 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1123 // Proxy type radio buttons
1124 noProxy.setFont(LABEL_FONT);
1125 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1126 noProxy.setText(MessageManager.getString("label.no_proxy"));
1127 systemProxy.setFont(LABEL_FONT);
1128 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1129 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1130 displayUserHostPort(Cache.startupProxyProperties[4],
1131 Cache.startupProxyProperties[0],
1132 Cache.startupProxyProperties[1]),
1133 displayUserHostPort(Cache.startupProxyProperties[6],
1134 Cache.startupProxyProperties[2],
1135 Cache.startupProxyProperties[3])));
1136 customProxy.setFont(LABEL_FONT);
1137 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1138 customProxy.setText(
1139 MessageManager.getString("label.use_proxy_server") + ":");
1140 ActionListener al = new ActionListener()
1143 public void actionPerformed(ActionEvent e)
1145 proxyType_actionPerformed();
1148 noProxy.addActionListener(al);
1149 systemProxy.addActionListener(al);
1150 customProxy.addActionListener(al);
1151 proxyType.add(noProxy);
1152 proxyType.add(systemProxy);
1153 proxyType.add(customProxy);
1155 proxyAuth.setFont(LABEL_FONT);
1156 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1157 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1158 proxyAuth.addActionListener(new ActionListener()
1161 public void actionPerformed(ActionEvent e)
1163 proxyAuth_actionPerformed();
1167 setCustomProxyEnabled();
1169 // Make proxy server panel
1170 JPanel proxyPanel = new JPanel();
1171 TitledBorder titledBorder1 = new TitledBorder(
1172 MessageManager.getString("label.proxy_servers"));
1173 proxyPanel.setBorder(titledBorder1);
1174 proxyPanel.setLayout(new GridBagLayout());
1175 GridBagConstraints gbc = new GridBagConstraints();
1176 gbc.fill = GridBagConstraints.HORIZONTAL;
1179 GridBagConstraints c = new GridBagConstraints();
1180 // Proxy type radio buttons (3)
1181 JPanel ptPanel = new JPanel();
1182 ptPanel.setLayout(new GridBagLayout());
1187 c.fill = GridBagConstraints.HORIZONTAL;
1188 ptPanel.add(noProxy, c);
1190 ptPanel.add(systemProxy, c);
1192 ptPanel.add(customProxy, c);
1195 proxyPanel.add(ptPanel, gbc);
1197 // host and port text boxes
1198 JPanel hpPanel = new JPanel();
1199 hpPanel.setLayout(new GridBagLayout());
1200 // HTTP host port row
1205 c.anchor = GridBagConstraints.LINE_START;
1206 hpPanel.add(httpLabel, c);
1210 c.anchor = GridBagConstraints.LINE_END;
1211 hpPanel.add(serverLabel, c);
1215 c.anchor = GridBagConstraints.LINE_START;
1216 hpPanel.add(proxyServerHttpTB, c);
1220 c.anchor = GridBagConstraints.LINE_END;
1221 hpPanel.add(portLabel, c);
1225 c.anchor = GridBagConstraints.LINE_START;
1226 hpPanel.add(proxyPortHttpTB, c);
1228 // HTTPS host port row
1233 c.anchor = GridBagConstraints.LINE_START;
1234 hpPanel.add(httpsLabel, c);
1237 c.anchor = GridBagConstraints.LINE_END;
1238 hpPanel.add(serverLabel2, c);
1241 c.anchor = GridBagConstraints.LINE_START;
1242 hpPanel.add(proxyServerHttpsTB, c);
1245 c.anchor = GridBagConstraints.LINE_END;
1246 hpPanel.add(portLabel2, c);
1249 c.anchor = GridBagConstraints.LINE_START;
1250 hpPanel.add(proxyPortHttpsTB, c);
1253 proxyPanel.add(hpPanel, gbc);
1255 if (!Platform.isJS())
1257 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1258 * Authentication options in Preferences.
1264 // Require authentication checkbox
1266 proxyPanel.add(proxyAuth, gbc);
1268 // username and password
1269 JPanel upPanel = new JPanel();
1270 upPanel.setLayout(new GridBagLayout());
1276 c.anchor = GridBagConstraints.LINE_END;
1277 upPanel.add(proxyAuthUsernameLabel, c);
1281 c.anchor = GridBagConstraints.LINE_START;
1282 upPanel.add(proxyAuthUsernameTB, c);
1288 c.anchor = GridBagConstraints.LINE_END;
1289 upPanel.add(proxyAuthPasswordLabel, c);
1293 c.anchor = GridBagConstraints.LINE_START;
1294 upPanel.add(proxyAuthPasswordPB, c);
1298 c.anchor = GridBagConstraints.LINE_START;
1299 upPanel.add(passwordNotStoredLabel, c);
1302 proxyPanel.add(upPanel, gbc);
1306 applyProxyButton.setText(MessageManager.getString("action.apply"));
1307 applyProxyButton.addActionListener(new ActionListener()
1310 public void actionPerformed(ActionEvent e)
1312 saveProxySettings();
1313 applyProxyButton.setEnabled(false);
1317 gbc.fill = GridBagConstraints.NONE;
1318 gbc.anchor = GridBagConstraints.LINE_END;
1319 proxyPanel.add(applyProxyButton, gbc);
1324 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1326 proxyAuthPasswordCheckHighlight(enabled, false);
1329 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1332 if (enabled && proxyType.isSelected(customProxy.getModel())
1333 && proxyAuth.isSelected()
1334 && !proxyAuthUsernameTB.getText().isEmpty()
1335 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1338 proxyAuthPasswordPB.grabFocus();
1339 proxyAuthPasswordPB.setBackground(Color.PINK);
1343 proxyAuthPasswordPB.setBackground(Color.WHITE);
1347 public void applyProxyButtonEnabled(boolean enabled)
1349 applyProxyButton.setEnabled(enabled);
1352 public void saveProxySettings()
1354 // overridden in Preferences
1357 private String displayUserHostPort(String user, String host, String port)
1359 boolean hostBlank = (host == null || host.isEmpty());
1360 boolean portBlank = (port == null || port.isEmpty());
1361 if (hostBlank && portBlank)
1363 return MessageManager.getString("label.none");
1366 StringBuilder sb = new StringBuilder();
1369 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1373 sb.append(hostBlank ? "" : host);
1379 return sb.toString();
1383 * Initialises the checkboxes in the Connections tab
1385 private void initConnTabCheckboxes()
1387 // Usage stats checkbox label
1389 MessageManager.getString("label.send_usage_statistics"));
1390 usagestats.setFont(LABEL_FONT);
1391 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1392 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1394 // Questionnaire checkbox label
1395 questionnaire.setText(
1396 MessageManager.getString("label.check_for_questionnaires"));
1397 questionnaire.setFont(LABEL_FONT);
1398 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1399 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1401 // Check for latest version checkbox label
1402 versioncheck.setText(
1403 MessageManager.getString("label.check_for_latest_version"));
1404 versioncheck.setFont(LABEL_FONT);
1405 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1406 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1410 * Initialises the parent panel which contains the tabbed sections.
1414 private JPanel initOkCancelPanel()
1416 JButton ok = new JButton();
1417 ok.setText(MessageManager.getString("action.ok"));
1418 ok.addActionListener(new ActionListener()
1421 public void actionPerformed(ActionEvent e)
1423 ok_actionPerformed(e);
1426 JButton cancel = new JButton();
1427 cancel.setText(MessageManager.getString("action.cancel"));
1428 cancel.addActionListener(new ActionListener()
1431 public void actionPerformed(ActionEvent e)
1433 cancel_actionPerformed(e);
1436 JPanel okCancelPanel = new JPanel();
1437 okCancelPanel.add(ok);
1438 okCancelPanel.add(cancel);
1439 return okCancelPanel;
1443 * Initialises the Colours tabbed panel.
1447 private JPanel initColoursTab()
1449 JPanel coloursTab = new JPanel();
1450 coloursTab.setBorder(new TitledBorder(
1451 MessageManager.getString("action.open_new_alignment")));
1452 coloursTab.setLayout(new FlowLayout());
1453 JLabel mincolourLabel = new JLabel();
1454 mincolourLabel.setFont(LABEL_FONT);
1455 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1456 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1457 minColour.setFont(LABEL_FONT);
1458 minColour.setBorder(BorderFactory.createEtchedBorder());
1459 minColour.setPreferredSize(new Dimension(40, 20));
1460 minColour.addMouseListener(new MouseAdapter()
1463 public void mousePressed(MouseEvent e)
1465 minColour_actionPerformed(minColour);
1468 JLabel maxcolourLabel = new JLabel();
1469 maxcolourLabel.setFont(LABEL_FONT);
1470 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1471 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1472 maxColour.setFont(LABEL_FONT);
1473 maxColour.setBorder(BorderFactory.createEtchedBorder());
1474 maxColour.setPreferredSize(new Dimension(40, 20));
1475 maxColour.addMouseListener(new MouseAdapter()
1478 public void mousePressed(MouseEvent e)
1480 maxColour_actionPerformed(maxColour);
1484 protColour.setFont(LABEL_FONT);
1485 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1486 JLabel protColourLabel = new JLabel();
1487 protColourLabel.setFont(LABEL_FONT);
1488 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1489 protColourLabel.setText(
1490 MessageManager.getString("label.prot_alignment_colour") + " ");
1491 JvSwingUtils.addtoLayout(coloursTab,
1493 .getString("label.default_colour_scheme_for_alignment"),
1494 protColourLabel, protColour);
1496 nucColour.setFont(LABEL_FONT);
1497 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1498 JLabel nucColourLabel = new JLabel();
1499 nucColourLabel.setFont(LABEL_FONT);
1500 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1501 nucColourLabel.setText(
1502 MessageManager.getString("label.nuc_alignment_colour") + " ");
1503 JvSwingUtils.addtoLayout(coloursTab,
1505 .getString("label.default_colour_scheme_for_alignment"),
1506 nucColourLabel, nucColour);
1508 JPanel annotationShding = new JPanel();
1509 annotationShding.setBorder(new TitledBorder(
1510 MessageManager.getString("label.annotation_shading_default")));
1511 annotationShding.setLayout(new GridLayout(1, 2));
1512 JvSwingUtils.addtoLayout(annotationShding,
1513 MessageManager.getString(
1514 "label.default_minimum_colour_annotation_shading"),
1515 mincolourLabel, minColour);
1516 JvSwingUtils.addtoLayout(annotationShding,
1517 MessageManager.getString(
1518 "label.default_maximum_colour_annotation_shading"),
1519 maxcolourLabel, maxColour);
1520 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1525 * Initialises the Overview tabbed panel.
1529 private JPanel initOverviewTab()
1531 JPanel overviewPanel = new JPanel();
1532 overviewPanel.setBorder(new TitledBorder(
1533 MessageManager.getString("label.overview_settings")));
1535 gapColour.setFont(LABEL_FONT);
1536 // fixing the border colours stops apparent colour bleed from the panel
1537 gapColour.setBorder(
1538 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1539 gapColour.setPreferredSize(new Dimension(40, 20));
1540 gapColour.addMouseListener(new MouseAdapter()
1543 public void mousePressed(MouseEvent e)
1545 gapColour_actionPerformed(gapColour);
1549 hiddenColour.setFont(LABEL_FONT);
1550 // fixing the border colours stops apparent colour bleed from the panel
1551 hiddenColour.setBorder(
1552 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1553 hiddenColour.setPreferredSize(new Dimension(40, 20));
1554 hiddenColour.addMouseListener(new MouseAdapter()
1557 public void mousePressed(MouseEvent e)
1559 hiddenColour_actionPerformed(hiddenColour);
1563 useLegacyGap = new JCheckBox(
1564 MessageManager.getString("label.ov_legacy_gap"));
1565 useLegacyGap.setFont(LABEL_FONT);
1566 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1567 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1568 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1569 gapLabel.setFont(LABEL_FONT);
1570 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1571 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1572 showHiddenAtStart = new JCheckBox(
1573 MessageManager.getString("label.ov_show_hide_default"));
1574 showHiddenAtStart.setFont(LABEL_FONT);
1575 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1576 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1577 JLabel hiddenLabel = new JLabel(
1578 MessageManager.getString("label.hidden_colour"));
1579 hiddenLabel.setFont(LABEL_FONT);
1580 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1581 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1583 useLegacyGap.addActionListener(new ActionListener()
1586 public void actionPerformed(ActionEvent e)
1588 useLegacyGaps_actionPerformed(e);
1592 overviewPanel.setLayout(new GridBagLayout());
1593 GridBagConstraints c1 = new GridBagConstraints();
1595 c1.fill = GridBagConstraints.HORIZONTAL;
1600 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1601 overviewPanel.add(useLegacyGap, c1);
1603 GridBagConstraints c2 = new GridBagConstraints();
1604 c2.fill = GridBagConstraints.HORIZONTAL;
1607 c2.insets = new Insets(0, 15, 0, 10);
1608 overviewPanel.add(gapLabel, c2);
1610 GridBagConstraints c3 = new GridBagConstraints();
1611 c3.fill = GridBagConstraints.HORIZONTAL;
1614 c3.insets = new Insets(0, 0, 0, 15);
1615 overviewPanel.add(gapColour, c3);
1617 GridBagConstraints c4 = new GridBagConstraints();
1618 c4.fill = GridBagConstraints.HORIZONTAL;
1622 overviewPanel.add(showHiddenAtStart, c4);
1624 GridBagConstraints c5 = new GridBagConstraints();
1625 c5.fill = GridBagConstraints.HORIZONTAL;
1628 c5.insets = new Insets(0, 15, 0, 10);
1629 overviewPanel.add(hiddenLabel, c5);
1631 GridBagConstraints c6 = new GridBagConstraints();
1632 c6.fill = GridBagConstraints.HORIZONTAL;
1635 c6.insets = new Insets(0, 0, 0, 15);
1636 overviewPanel.add(hiddenColour, c6);
1638 JButton resetButton = new JButton(
1639 MessageManager.getString("label.reset_to_defaults"));
1641 resetButton.addActionListener(new ActionListener()
1644 public void actionPerformed(ActionEvent e)
1646 resetOvDefaults_actionPerformed(e);
1650 GridBagConstraints c7 = new GridBagConstraints();
1651 c7.fill = GridBagConstraints.NONE;
1654 c7.insets = new Insets(10, 0, 0, 0);
1655 c7.anchor = GridBagConstraints.WEST;
1656 overviewPanel.add(resetButton, c7);
1658 // Add padding so the panel doesn't look ridiculous
1659 JPanel spacePanel = new JPanel();
1660 overviewPanel.add(spacePanel,
1661 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1662 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1663 new Insets(0, 0, 0, 5), 0, 0));
1665 return overviewPanel;
1669 * Initialises the Structure tabbed panel.
1673 private JPanel initStructureTab()
1675 structureTab = new JPanel();
1677 structureTab.setBorder(new TitledBorder(
1678 MessageManager.getString("label.structure_options")));
1679 structureTab.setLayout(null);
1680 final int width = 420;
1681 final int height = 22;
1682 final int lineSpacing = 25;
1685 structFromPdb.setFont(LABEL_FONT);
1687 .setText(MessageManager.getString("label.struct_from_pdb"));
1688 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1689 structFromPdb.addActionListener(new ActionListener()
1692 public void actionPerformed(ActionEvent e)
1694 boolean selected = structFromPdb.isSelected();
1695 // enable other options only when the first is checked
1696 addSecondaryStructure.setEnabled(selected);
1697 addTempFactor.setEnabled(selected);
1700 structureTab.add(structFromPdb);
1702 // indent checkboxes that are conditional on the first one
1703 ypos += lineSpacing;
1704 addSecondaryStructure.setFont(LABEL_FONT);
1705 addSecondaryStructure
1706 .setText(MessageManager.getString("label.autoadd_secstr"));
1707 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1708 structureTab.add(addSecondaryStructure);
1710 ypos += lineSpacing;
1711 addTempFactor.setFont(LABEL_FONT);
1712 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1713 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1714 structureTab.add(addTempFactor);
1716 ypos += lineSpacing;
1717 JLabel viewerLabel = new JLabel();
1718 viewerLabel.setFont(LABEL_FONT);
1719 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1720 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1721 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1722 structureTab.add(viewerLabel);
1725 * add all external viewers as options here - check
1726 * when selected whether the program is installed
1728 structViewer.setFont(LABEL_FONT);
1729 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1730 structViewer.addItem(ViewerType.JMOL.name());
1731 structViewer.addItem(ViewerType.CHIMERA.name());
1732 structViewer.addItem(ViewerType.CHIMERAX.name());
1733 structViewer.addItem(ViewerType.PYMOL.name());
1734 structViewer.addActionListener(new ActionListener()
1737 public void actionPerformed(ActionEvent e)
1739 structureViewer_actionPerformed(
1740 (String) structViewer.getSelectedItem());
1743 structureTab.add(structViewer);
1745 ypos += lineSpacing;
1746 structureViewerPathLabel = new JLabel();
1747 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1749 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1750 structureViewerPathLabel.setText(MessageManager
1751 .formatMessage("label.viewer_path", "Chimera(X)"));
1752 structureViewerPathLabel
1753 .setBounds(new Rectangle(10, ypos, 170, height));
1754 structureViewerPathLabel.setEnabled(false);
1755 structureTab.add(structureViewerPathLabel);
1757 structureViewerPath.setFont(LABEL_FONT);
1758 structureViewerPath.setText("");
1759 structureViewerPath.setEnabled(false);
1760 final String tooltip = JvSwingUtils.wrapTooltip(true,
1761 MessageManager.getString("label.viewer_path_tip"));
1762 structureViewerPath.setToolTipText(tooltip);
1763 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1764 structureViewerPath.addMouseListener(new MouseAdapter()
1767 public void mouseClicked(MouseEvent e)
1769 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1771 String chosen = openFileChooser();
1774 structureViewerPath.setText(chosen);
1779 structureTab.add(structureViewerPath);
1781 ypos += lineSpacing;
1782 nwMapping.setFont(LABEL_FONT);
1783 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1784 siftsMapping.setFont(LABEL_FONT);
1785 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1786 mappingMethod.add(nwMapping);
1787 mappingMethod.add(siftsMapping);
1788 JPanel mappingPanel = new JPanel();
1789 mappingPanel.setFont(LABEL_FONT);
1790 TitledBorder mmTitledBorder = new TitledBorder(
1791 MessageManager.getString("label.mapping_method"));
1792 mmTitledBorder.setTitleFont(LABEL_FONT);
1793 mappingPanel.setBorder(mmTitledBorder);
1794 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1795 // GridLayout mappingLayout = new GridLayout();
1796 mappingPanel.setLayout(new GridLayout());
1797 mappingPanel.add(nwMapping);
1798 mappingPanel.add(siftsMapping);
1799 structureTab.add(mappingPanel);
1801 ypos += lineSpacing;
1802 ypos += lineSpacing;
1803 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1804 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1805 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1806 structureTab.add(docFieldPref);
1809 * hide Chimera options in JalviewJS
1811 if (Platform.isJS())
1813 structureViewerPathLabel.setVisible(false);
1814 structureViewerPath.setVisible(false);
1815 viewerLabel.setVisible(false);
1816 structViewer.setVisible(false);
1819 return structureTab;
1823 * Action on choosing a structure viewer from combobox options.
1825 * @param selectedItem
1827 protected void structureViewer_actionPerformed(String selectedItem)
1832 * Show a dialog for the user to choose a file. Returns the chosen path, or
1837 protected String openFileChooser()
1839 String choice = null;
1840 JFileChooser chooser = new JFileChooser();
1842 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1843 // hidden executables within .app dirs
1844 if (Platform.isMac())
1846 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1850 // chooser.setFileView(new JalviewFileView());
1851 chooser.setDialogTitle(
1852 MessageManager.getString("label.open_local_file"));
1853 chooser.setToolTipText(MessageManager.getString("action.open"));
1855 int value = chooser.showOpenDialog(this);
1857 if (value == JFileChooser.APPROVE_OPTION)
1859 choice = chooser.getSelectedFile().getPath();
1865 * Validate the structure tab preferences; if invalid, set focus on this tab.
1869 protected boolean validateStructure(FocusEvent e)
1871 if (!validateStructure())
1873 e.getComponent().requestFocusInWindow();
1879 protected boolean validateStructure()
1885 * Initialises the Visual tabbed panel.
1889 private JPanel initVisualTab()
1891 JPanel visualTab = new JPanel();
1892 visualTab.setBorder(new TitledBorder(
1893 MessageManager.getString("action.open_new_alignment")));
1894 visualTab.setLayout(null);
1895 fullScreen.setFont(LABEL_FONT);
1896 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1897 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1898 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1899 quality.setEnabled(false);
1900 quality.setFont(LABEL_FONT);
1901 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1902 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1903 quality.setSelected(true);
1904 quality.setText(MessageManager.getString("label.quality"));
1905 conservation.setEnabled(false);
1906 conservation.setFont(LABEL_FONT);
1907 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1908 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1909 conservation.setSelected(true);
1910 conservation.setText(MessageManager.getString("label.conservation"));
1911 identity.setEnabled(false);
1912 identity.setFont(LABEL_FONT);
1913 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1914 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1915 identity.setSelected(true);
1916 identity.setText(MessageManager.getString("label.consensus"));
1917 showOccupancy.setFont(LABEL_FONT);
1918 showOccupancy.setEnabled(false);
1919 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1920 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1921 showOccupancy.setSelected(true);
1922 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1924 JLabel showGroupbits = new JLabel();
1925 showGroupbits.setFont(LABEL_FONT);
1926 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1927 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1929 .setText(MessageManager.getString("action.show_group") + ":");
1930 JLabel showConsensbits = new JLabel();
1931 showConsensbits.setFont(LABEL_FONT);
1932 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1933 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1935 .setText(MessageManager.getString("label.consensus") + ":");
1936 showConsensHistogram.setEnabled(false);
1937 showConsensHistogram.setFont(LABEL_FONT);
1938 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1939 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1940 showConsensHistogram.setSelected(true);
1941 showConsensHistogram
1942 .setText(MessageManager.getString("label.histogram"));
1943 showConsensLogo.setEnabled(false);
1944 showConsensLogo.setFont(LABEL_FONT);
1945 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1946 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1947 showConsensLogo.setSelected(true);
1948 showConsensLogo.setText(MessageManager.getString("label.logo"));
1949 showGroupConsensus.setEnabled(false);
1950 showGroupConsensus.setFont(LABEL_FONT);
1951 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1952 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1953 showGroupConsensus.setSelected(true);
1954 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1955 showGroupConservation.setEnabled(false);
1956 showGroupConservation.setFont(LABEL_FONT);
1957 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1958 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1959 showGroupConservation.setSelected(true);
1960 showGroupConservation
1961 .setText(MessageManager.getString("label.conservation"));
1962 showNpTooltip.setEnabled(true);
1963 showNpTooltip.setFont(LABEL_FONT);
1964 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1965 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1966 showNpTooltip.setSelected(true);
1967 showNpTooltip.setText(
1968 MessageManager.getString("label.non_positional_features"));
1969 showDbRefTooltip.setEnabled(true);
1970 showDbRefTooltip.setFont(LABEL_FONT);
1971 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1972 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1973 showDbRefTooltip.setSelected(true);
1975 .setText(MessageManager.getString("label.database_references"));
1976 annotations.setFont(LABEL_FONT);
1977 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1978 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1979 annotations.setSelected(true);
1980 annotations.setText(MessageManager.getString("label.show_annotations"));
1981 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1982 annotations.addActionListener(new ActionListener()
1985 public void actionPerformed(ActionEvent e)
1987 annotations_actionPerformed(e);
1990 identity.addActionListener(new ActionListener()
1993 public void actionPerformed(ActionEvent e)
1995 annotations_actionPerformed(e);
1998 showGroupConsensus.addActionListener(new ActionListener()
2001 public void actionPerformed(ActionEvent e)
2003 annotations_actionPerformed(e);
2006 showUnconserved.setFont(LABEL_FONT);
2007 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2008 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2009 showUnconserved.setSelected(true);
2011 .setText(MessageManager.getString("action.show_unconserved"));
2012 showUnconserved.addActionListener(new ActionListener()
2015 public void actionPerformed(ActionEvent e)
2017 showunconserved_actionPerformed(e);
2021 // TODO these are not yet added to / action from Preferences
2022 // JCheckBox shareSelections = new JCheckBox();
2023 // shareSelections.setFont(verdana11);
2024 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2025 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2026 // shareSelections.setSelected(true);
2027 // shareSelections.setText(MessageManager
2028 // .getString("label.share_selection_across_views"));
2029 // JCheckBox followHighlight = new JCheckBox();
2030 // followHighlight.setFont(verdana11);
2031 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2032 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2033 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2034 // followHighlight.setSelected(true);
2035 // followHighlight.setText(MessageManager
2036 // .getString("label.scroll_highlighted_regions"));
2038 seqLimit.setFont(LABEL_FONT);
2039 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2040 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2041 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2042 smoothFont.setFont(LABEL_FONT);
2043 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2044 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2045 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2046 scaleProteinToCdna.setFont(LABEL_FONT);
2047 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2048 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2049 scaleProteinToCdna.setText(
2050 MessageManager.getString("label.scale_protein_to_cdna"));
2051 scaleProteinToCdna.setToolTipText(
2052 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2053 JLabel gapLabel = new JLabel();
2054 gapLabel.setFont(LABEL_FONT);
2055 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2056 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2057 JLabel fontLabel = new JLabel();
2058 fontLabel.setFont(LABEL_FONT);
2059 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2060 fontLabel.setText(MessageManager.getString("label.font"));
2061 fontSizeCB.setFont(LABEL_FONT);
2062 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2063 fontStyleCB.setFont(LABEL_FONT);
2064 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2065 fontNameCB.setFont(LABEL_FONT);
2066 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2067 gapSymbolCB.setFont(LABEL_FONT);
2068 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2069 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2070 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2071 gapSymbolCB.setRenderer(dlcr);
2073 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2074 startupCheckbox.setFont(LABEL_FONT);
2075 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2076 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2077 startupCheckbox.setSelected(true);
2078 startupFileTextfield.setFont(LABEL_FONT);
2079 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2080 final String tooltip = JvSwingUtils.wrapTooltip(true,
2081 MessageManager.getString("label.double_click_to_browse"));
2082 startupFileTextfield.setToolTipText(tooltip);
2083 startupFileTextfield.addMouseListener(new MouseAdapter()
2086 public void mouseClicked(MouseEvent e)
2088 if (e.getClickCount() > 1)
2090 startupFileTextfield_mouseClicked();
2095 sortby.setFont(LABEL_FONT);
2096 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2097 JLabel sortLabel = new JLabel();
2098 sortLabel.setFont(LABEL_FONT);
2099 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2100 sortLabel.setText(MessageManager.getString("label.sort_by"));
2101 sortAnnBy.setFont(LABEL_FONT);
2102 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2103 JLabel sortAnnLabel = new JLabel();
2104 sortAnnLabel.setFont(LABEL_FONT);
2105 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2106 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2107 sortAutocalc.setFont(LABEL_FONT);
2108 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2110 JPanel annsettingsPanel = new JPanel();
2111 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2112 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2113 annsettingsPanel.setBorder(new EtchedBorder());
2114 visualTab.add(annsettingsPanel);
2115 Border jb = new EmptyBorder(1, 1, 4, 5);
2116 annotations.setBorder(jb);
2117 showOccupancy.setBorder(jb);
2118 quality.setBorder(jb);
2119 conservation.setBorder(jb);
2120 identity.setBorder(jb);
2121 showConsensbits.setBorder(jb);
2122 showGroupbits.setBorder(jb);
2123 showGroupConsensus.setBorder(jb);
2124 showGroupConservation.setBorder(jb);
2125 showConsensHistogram.setBorder(jb);
2126 showConsensLogo.setBorder(jb);
2128 JPanel autoAnnotSettings = new JPanel();
2129 annsettingsPanel.add(autoAnnotSettings);
2130 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2131 autoAnnotSettings.add(annotations);
2132 autoAnnotSettings.add(quality);
2133 // second row of autoannotation box
2134 autoAnnotSettings = new JPanel();
2135 annsettingsPanel.add(autoAnnotSettings);
2137 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2138 autoAnnotSettings.add(conservation);
2139 autoAnnotSettings.add(identity);
2140 autoAnnotSettings.add(showOccupancy);
2141 autoAnnotSettings.add(showGroupbits);
2142 autoAnnotSettings.add(showGroupConservation);
2143 autoAnnotSettings.add(showGroupConsensus);
2144 autoAnnotSettings.add(showConsensbits);
2145 autoAnnotSettings.add(showConsensHistogram);
2146 autoAnnotSettings.add(showConsensLogo);
2148 JPanel tooltipSettings = new JPanel();
2149 tooltipSettings.setBorder(new TitledBorder(
2150 MessageManager.getString("label.sequence_id_tooltip")));
2151 tooltipSettings.setBounds(173, 140, 220, 62);
2152 tooltipSettings.setLayout(new GridLayout(2, 1));
2153 tooltipSettings.add(showDbRefTooltip);
2154 tooltipSettings.add(showNpTooltip);
2155 visualTab.add(tooltipSettings);
2157 wrap.setFont(LABEL_FONT);
2158 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2159 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2160 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2161 rightAlign.setFont(LABEL_FONT);
2162 rightAlign.setForeground(Color.black);
2163 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2164 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2165 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2166 idItalics.setFont(LABEL_FONT_ITALIC);
2167 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2168 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2170 MessageManager.getString("label.sequence_name_italics"));
2171 openoverv.setFont(LABEL_FONT);
2172 openoverv.setActionCommand(
2173 MessageManager.getString("label.open_overview"));
2174 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2175 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2176 openoverv.setText(MessageManager.getString("label.open_overview"));
2177 JPanel jPanel2 = new JPanel();
2178 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2179 jPanel2.setLayout(new GridLayout(14, 1));
2180 jPanel2.add(fullScreen);
2181 jPanel2.add(openoverv);
2182 jPanel2.add(seqLimit);
2183 jPanel2.add(rightAlign);
2184 jPanel2.add(fontLabel);
2185 jPanel2.add(showUnconserved);
2186 jPanel2.add(idItalics);
2187 jPanel2.add(smoothFont);
2188 jPanel2.add(scaleProteinToCdna);
2189 jPanel2.add(gapLabel);
2191 jPanel2.add(sortLabel);
2192 jPanel2.add(sortAnnLabel);
2193 jPanel2.add(startupCheckbox);
2194 visualTab.add(jPanel2);
2195 visualTab.add(startupFileTextfield);
2196 visualTab.add(sortby);
2197 visualTab.add(sortAnnBy);
2198 visualTab.add(sortAutocalc);
2199 visualTab.add(gapSymbolCB);
2200 visualTab.add(fontNameCB);
2201 visualTab.add(fontSizeCB);
2202 visualTab.add(fontStyleCB);
2204 if (Platform.isJS())
2206 startupCheckbox.setVisible(false);
2207 startupFileTextfield.setVisible(false);
2214 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2217 protected void loadLastSavedBackupsOptions()
2219 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2220 .getSavedBackupEntry();
2221 enableBackupFiles.setSelected(
2222 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2224 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2225 .createBackupFilesPresetEntry(Cache
2226 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2227 if (backupfilesCustomEntry == null)
2229 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2230 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2232 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2233 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2234 backupfilesCustomEntry);
2236 setComboIntStringKey(backupfilesPresetsCombo,
2237 Cache.getDefault(BackupFiles.NS + "_PRESET",
2238 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2240 backupsSetOptions(savedPreset);
2242 backupsOptionsSetEnabled();
2243 updateBackupFilesExampleLabel();
2247 * Load the saved Memory settings
2249 protected void loadLastSavedMemorySettings()
2251 customiseMemorySetting.setSelected(
2252 Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2253 jvmMemoryPercentSlider
2254 .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2255 jvmMemoryMaxTextField.setText(
2256 Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2259 private boolean warnAboutSuffixReverseChange()
2261 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2262 .getSavedBackupEntry();
2263 boolean savedSuffixReverse = bfpe.reverse;
2264 int savedSuffixDigits = bfpe.digits;
2265 String savedSuffixTemplate = bfpe.suffix;
2267 boolean nowSuffixReverse = suffixReverse.isSelected();
2268 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2269 String nowSuffixTemplate = suffixTemplate.getText();
2270 return nowSuffixReverse != savedSuffixReverse
2271 && nowSuffixDigits == savedSuffixDigits
2272 && nowSuffixTemplate != null
2273 && nowSuffixTemplate.equals(savedSuffixTemplate);
2276 /* Initialises the Startup tabbed panel.
2281 private JPanel initStartupTab()
2283 JPanel startupTab = new JPanel();
2284 startupTab.setBorder(
2285 new TitledBorder(MessageManager.getString("label.memory")));
2286 startupTab.setLayout(new GridBagLayout());
2288 GridBagConstraints gbc = new GridBagConstraints();
2291 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2292 gbc.fill = GridBagConstraints.NONE;
2299 gbc.gridy = 0; // row 1
2301 JLabel memoryText = new JLabel();
2302 memoryText.setFont(LABEL_FONT_ITALIC);
2304 .setText(MessageManager.getString("label.memory_setting_text"));
2305 startupTab.add(memoryText, gbc);
2307 gbc.gridy++; // row 2
2309 JPanel exampleMemoryPanel = new JPanel();
2311 .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2312 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2313 MessageManager.getString("label.memory_example_tooltip")));
2314 JLabel exampleTextLabel = new JLabel();
2316 .setText(MessageManager.getString("label.memory_example_text"));
2317 exampleTextLabel.setForeground(Color.GRAY);
2318 exampleTextLabel.setFont(LABEL_FONT);
2319 exampleMemoryPanel.add(exampleTextLabel);
2320 exampleMemoryPanel.add(exampleMemoryLabel);
2321 exampleMemoryPanel.setBackground(Color.WHITE);
2322 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2323 startupTab.add(exampleMemoryPanel, gbc);
2325 gbc.gridy++; // row 3
2327 startupTab.add(customiseMemorySetting, gbc);
2329 gbc.gridy += 2; // row 4 with a gap
2331 startupTab.add(maxMemoryLabel, gbc);
2333 gbc.gridy += 2; // row 5
2336 startupTab.add(jvmMemoryPercentLabel, gbc);
2338 startupTab.add(jvmMemoryPercentSlider, gbc);
2340 // gbc.weightx = 0.1;
2341 startupTab.add(jvmMemoryPercentDisplay, gbc);
2342 // gbc.weightx = 1.0;
2345 gbc.gridy++; // row 6
2347 startupTab.add(jvmMemoryMaxLabel, gbc);
2349 startupTab.add(jvmMemoryMaxTextField, gbc);
2351 gbc.gridy++; // row 7
2354 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2355 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2356 sp.setBorder(BorderFactory.createEmptyBorder());
2357 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2358 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2359 startupTab.add(sp, gbc);
2361 // fill empty space to push widget to top left
2367 startupTab.add(new JPanel(), gbc);
2369 setMemoryPercentDisplay();
2370 memoryOptionsSetEnabled();
2374 private void initMemoryPanel()
2376 // Enable memory settings checkbox
2377 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2378 customiseMemorySetting.setText(
2379 MessageManager.getString("label.customise_memory_settings"));
2380 customiseMemorySetting.addActionListener(new ActionListener()
2383 public void actionPerformed(ActionEvent e)
2385 memoryOptionsSetEnabled();
2389 loadLastSavedMemorySettings();
2391 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2392 exampleMemoryLabel.setBackground(Color.WHITE);
2394 maxMemoryLabel = new JLabel(
2395 MessageManager.getString("label.maximum_memory_used"));
2396 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2398 // Maximum memory percentage slider
2399 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2400 jvmMemoryPercentLabel.setText(
2401 MessageManager.getString("label.percent_of_physical_memory"));
2402 jvmMemoryPercentSlider.setPaintLabels(true);
2403 jvmMemoryPercentSlider.setPaintTicks(true);
2404 jvmMemoryPercentSlider.setPaintTrack(true);
2405 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2406 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2407 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2410 public void stateChanged(ChangeEvent e)
2412 setMemoryPercentDisplay();
2415 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2416 setMemoryPercentDisplay();
2418 // Maximum memory cap textbox
2419 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2421 .setText(MessageManager.getString("label.maximum_memory"));
2422 initMemoryMaxTextField();
2424 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2425 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2426 exampleMemoryMessageTextArea.setEditable(false);
2427 exampleMemoryMessageTextArea.setLineWrap(true);
2428 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2429 exampleMemoryMessageTextArea.setText(" ");
2430 exampleMemoryMessageTextArea.setRows(2);
2431 exampleMemoryMessageTextArea.setColumns(40);
2433 setExampleMemoryLabel();
2436 private void initMemoryMaxTextField()
2438 jvmMemoryMaxTextField.setToolTipText(
2439 MessageManager.getString("label.maximum_memory_tooltip"));
2440 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2443 public void actionPerformed(ActionEvent arg0)
2445 validateMemoryMaxTextField();
2446 setExampleMemoryLabel();
2450 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2453 public void keyReleased(KeyEvent e)
2455 validateMemoryMaxTextField();
2456 setExampleMemoryLabel();
2460 public void keyPressed(KeyEvent e)
2464 // try and stop invalid typing
2466 public void keyTyped(KeyEvent e)
2468 char c = Character.toLowerCase(e.getKeyChar());
2469 String text = jvmMemoryMaxTextField.getText();
2470 String suffixes = "tgmkb";
2471 int pos = jvmMemoryMaxTextField.getCaretPosition();
2472 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2473 if (!((('0' <= c && c <= '9')
2474 && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2476 || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2478 && pos == text.length() // at end of text and
2479 && suffixPos == -1) // there isn't already one
2489 private boolean isMemoryMaxTextFieldValid()
2491 return MemorySetting
2492 .isValidMemoryString(jvmMemoryMaxTextField.getText());
2495 private void validateMemoryMaxTextField()
2497 if (isMemoryMaxTextFieldValid())
2499 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2503 jvmMemoryMaxTextField.setBackground(Color.PINK);
2507 private void setMemoryPercentDisplay()
2509 jvmMemoryPercentDisplay
2510 .setText(jvmMemoryPercentSlider.getValue() + "%");
2511 setExampleMemoryLabel();
2514 private void setExampleMemoryLabel()
2516 boolean selected = customiseMemorySetting.isSelected();
2517 int jvmmempc = jvmMemoryPercentSlider.getValue();
2518 String jvmmemmax = jvmMemoryMaxTextField.getText();
2521 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2522 && MemorySetting.isValidMemoryString(jvmmemmax))
2524 mem = MemorySetting.getMemorySetting(jvmmemmax,
2525 String.valueOf(jvmmempc), false, true);
2529 mem = MemorySetting.getMemorySetting(null, null, false, true);
2531 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2532 String message = MemorySetting.getAdjustmentMessage();
2533 exampleMemoryMessageTextArea.setText(
2534 MessageManager.getString("label.adjustments_for_this_computer")
2537 ? MessageManager.getString("label.none")
2541 private void memoryOptionsSetEnabled()
2543 boolean enabled = customiseMemorySetting.isSelected();
2544 // leave exampleMemoryLabel enabled always
2545 maxMemoryLabel.setEnabled(enabled);
2546 jvmMemoryPercentLabel.setEnabled(enabled);
2547 jvmMemoryPercentSlider.setEnabled(enabled);
2548 jvmMemoryPercentDisplay.setEnabled(enabled);
2549 jvmMemoryMaxLabel.setEnabled(enabled);
2550 jvmMemoryMaxTextField.setEnabled(enabled);
2551 exampleMemoryMessageTextArea.setEnabled(enabled);
2552 setExampleMemoryLabel();
2556 * Initialises the Backups tabbed panel.
2560 private JPanel initBackupsTab()
2562 JPanel backupsTab = new JPanel();
2563 backupsTab.setBorder(new TitledBorder(
2564 MessageManager.getString("label.backup_files")));
2565 backupsTab.setLayout(new GridBagLayout());
2567 GridBagConstraints gbc = new GridBagConstraints();
2570 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2571 gbc.fill = GridBagConstraints.NONE;
2573 initBackupsTabPresetsPanel();
2574 initBackupsTabSuffixPanel();
2575 initBackupsTabKeepFilesPanel();
2576 initBackupsTabFilenameExamplesPanel();
2578 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2580 .setText(MessageManager.getString("label.enable_backupfiles"));
2581 enableBackupFiles.addActionListener(new ActionListener()
2584 public void actionPerformed(ActionEvent e)
2586 // enable other options only when the first is checked
2587 backupsOptionsSetEnabled();
2591 // enable checkbox 1 col
2595 gbc.gridy = 0; // row 0
2596 backupsTab.add(enableBackupFiles, gbc);
2598 // summary of scheme box (over two rows)
2602 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2603 gbc.fill = GridBagConstraints.BOTH;
2604 backupsTab.add(exampleFilesPanel, gbc);
2606 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2607 gbc.fill = GridBagConstraints.NONE;
2609 // fill empty space on right
2612 backupsTab.add(new JPanel(), gbc);
2617 gbc.gridy++; // row 1
2618 backupsTab.add(presetsPanel, gbc);
2620 // now using whole row
2625 gbc.gridy++; // row 2
2626 backupsTab.add(keepfilesPanel, gbc);
2628 // filename strategy box
2629 gbc.gridy++; // row 3
2630 backupsTab.add(suffixPanel, gbc);
2633 gbc.gridy++; // row 4
2635 backupsTab.add(new JPanel(), gbc);
2637 backupsOptionsSetEnabled();
2641 private JPanel initBackupsTabPresetsPanel()
2644 String title = MessageManager.getString("label.schemes");
2646 presetsPanel.setLayout(new GridBagLayout());
2648 GridBagConstraints gbc = new GridBagConstraints();
2651 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2652 gbc.fill = GridBagConstraints.NONE;
2660 presetsComboLabel = new JLabel(title + ":");
2661 presetsPanel.add(presetsComboLabel, gbc);
2663 List<Object> entries = Arrays.asList(
2664 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2665 List<String> tooltips = Arrays.asList(
2666 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2667 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2670 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2672 backupfilesPresetsCombo
2673 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2677 backupfilesPresetsCombo.addActionListener(new ActionListener()
2680 public void actionPerformed(ActionEvent e)
2682 int key = getComboIntStringKey(backupfilesPresetsCombo);
2683 if (!customiseCheckbox.isSelected())
2685 backupfilesPresetsComboLastSelected = key;
2687 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2689 if (customiseCheckbox.isSelected())
2691 // got here by clicking on customiseCheckbox so don't change the
2693 backupfilesCustomOptionsSetEnabled();
2697 backupsTabUpdatePresets();
2698 backupfilesCustomOptionsSetEnabled();
2703 customiseCheckbox.setSelected(false);
2704 backupsTabUpdatePresets();
2705 backupfilesCustomOptionsSetEnabled();
2710 // dropdown list of preset schemes
2712 presetsPanel.add(backupfilesPresetsCombo, gbc);
2714 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2715 revertButton.setToolTipText(
2716 MessageManager.getString("label.cancel_changes_description"));
2717 revertButton.addActionListener(new ActionListener()
2720 public void actionPerformed(ActionEvent e)
2723 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2724 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2725 backupfilesCustomOptionsSetEnabled();
2729 revertButton.setFont(LABEL_FONT);
2731 customiseCheckbox.setFont(LABEL_FONT);
2732 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2733 customiseCheckbox.addActionListener(new ActionListener()
2736 public void actionPerformed(ActionEvent e)
2738 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2739 if (customiseCheckbox.isSelected())
2741 backupfilesPresetsComboLastSelected = currently;
2742 setComboIntStringKey(backupfilesPresetsCombo,
2743 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2747 setComboIntStringKey(backupfilesPresetsCombo,
2748 backupfilesPresetsComboLastSelected);
2751 backupfilesCustomOptionsSetEnabled();
2754 customiseCheckbox.setToolTipText(
2755 MessageManager.getString("label.customise_description"));
2757 // customise checkbox
2760 presetsPanel.add(customiseCheckbox, gbc);
2762 // "Cancel changes" button (aligned with combo box above)
2764 presetsPanel.add(revertButton, gbc);
2766 return presetsPanel;
2769 private JPanel initBackupsTabFilenameExamplesPanel()
2771 String title = MessageManager.getString("label.scheme_examples");
2772 TitledBorder tb = new TitledBorder(title);
2773 exampleFilesPanel.setBorder(tb);
2774 exampleFilesPanel.setLayout(new GridBagLayout());
2776 backupfilesExampleLabel.setEditable(false);
2777 backupfilesExampleLabel
2778 .setBackground(exampleFilesPanel.getBackground());
2780 updateBackupFilesExampleLabel();
2782 GridBagConstraints gbc = new GridBagConstraints();
2785 gbc.fill = GridBagConstraints.NONE;
2786 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2788 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2789 return exampleFilesPanel;
2792 private void backupsTabUpdatePresets()
2794 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2797 String value = entry.v;
2799 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2803 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2809 "Preset '" + value + "' [key:" + key + "] not implemented");
2812 // Custom options will now be enabled when the customiseCheckbox is checked
2813 // (performed above)
2814 // backupfilesCustomOptionsSetEnabled();
2815 updateBackupFilesExampleLabel();
2818 protected int getComboIntStringKey(
2819 JComboBox<Object> backupfilesPresetsCombo2)
2821 IntKeyStringValueEntry e;
2824 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2826 } catch (Exception ex)
2829 "Problem casting Combo entry to IntKeyStringValueEntry.");
2832 return e != null ? e.k : 0;
2835 protected void setComboIntStringKey(
2836 JComboBox<Object> backupfilesPresetsCombo2, int key)
2838 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2840 IntKeyStringValueEntry e;
2843 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2844 } catch (Exception ex)
2847 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2852 backupfilesPresetsCombo2.setSelectedIndex(i);
2856 // backupsTabUpdatePresets();
2859 private JPanel initBackupsTabSuffixPanel()
2861 suffixPanel.setBorder(new TitledBorder(
2862 MessageManager.getString("label.backup_filename_strategy")));
2863 suffixPanel.setLayout(new GridBagLayout());
2866 .setText(MessageManager.getString("label.append_to_filename"));
2867 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2868 suffixTemplateLabel.setFont(LABEL_FONT);
2870 final String tooltip = JvSwingUtils.wrapTooltip(true,
2871 MessageManager.getString("label.append_to_filename_tooltip"));
2872 suffixTemplate.setToolTipText(tooltip);
2873 suffixTemplate.addActionListener(new ActionListener()
2876 public void actionPerformed(ActionEvent e)
2878 updateBackupFilesExampleLabel();
2879 backupfilesCustomOptionsSetEnabled();
2880 backupfilesRevertButtonSetEnabled(true);
2884 suffixTemplate.addKeyListener(new KeyListener()
2887 public void keyReleased(KeyEvent e)
2889 updateBackupFilesExampleLabel();
2890 backupfilesCustomOptionsSetEnabled();
2891 backupfilesRevertButtonSetEnabled(true);
2895 public void keyPressed(KeyEvent e)
2899 // disable use of ':' or '/' or '\'
2901 public void keyTyped(KeyEvent e)
2903 char c = e.getKeyChar();
2904 if (c == ':' || c == '/' || c == '\\')
2906 // don't process ':' or '/' or '\'
2915 .setText(MessageManager.getString("label.index_digits"));
2916 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2917 suffixDigitsLabel.setFont(LABEL_FONT);
2918 ChangeListener c = new ChangeListener()
2921 public void stateChanged(ChangeEvent e)
2923 backupfilesRevertButtonSetEnabled(true);
2924 updateBackupFilesExampleLabel();
2928 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2929 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2931 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2932 MessageManager.getString("label.increment_index"));
2933 suffixReverse.addActionListener(new ActionListener()
2936 public void actionPerformed(ActionEvent e)
2938 boolean okay = true;
2939 if (warnAboutSuffixReverseChange())
2942 okay = confirmSuffixReverseChange();
2946 backupfilesRevertButtonSetEnabled(true);
2947 updateBackupFilesExampleLabel();
2951 boolean savedSuffixReverse = BackupFilesPresetEntry
2952 .getSavedBackupEntry().reverse;
2953 suffixReverse.setSelected(savedSuffixReverse);
2958 GridBagConstraints sgbc = new GridBagConstraints();
2960 // first row (template text box)
2961 sgbc.anchor = GridBagConstraints.WEST;
2965 sgbc.gridheight = 1;
2968 sgbc.fill = GridBagConstraints.NONE;
2969 suffixPanel.add(suffixTemplateLabel, sgbc);
2972 sgbc.fill = GridBagConstraints.HORIZONTAL;
2973 suffixPanel.add(suffixTemplate, sgbc);
2975 // second row (number of digits spinner)
2979 sgbc.fill = GridBagConstraints.NONE;
2980 suffixPanel.add(suffixDigitsLabel, sgbc);
2983 sgbc.fill = GridBagConstraints.HORIZONTAL;
2984 suffixPanel.add(suffixDigitsSpinner, sgbc);
2986 // third row (forward order radio selection)
2989 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2990 sgbc.fill = GridBagConstraints.HORIZONTAL;
2991 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2993 // fourth row (reverse order radio selection)
2995 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2999 private boolean confirmSuffixReverseChange()
3001 boolean ret = false;
3002 String warningMessage = MessageManager
3003 .getString("label.warning_confirm_change_reverse");
3004 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
3006 MessageManager.getString("label.change_increment_decrement"),
3007 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
3009 ret = (confirm == JvOptionPane.YES_OPTION);
3013 private JPanel initBackupsTabKeepFilesPanel()
3015 keepfilesPanel.setBorder(
3016 new TitledBorder(MessageManager.getString("label.keep_files")));
3017 keepfilesPanel.setLayout(new GridBagLayout());
3019 backupfilesKeepAll.setLabels(
3020 MessageManager.getString("label.keep_all_backup_files"),
3021 MessageManager.getString(
3022 "label.keep_only_this_number_of_backup_files"));
3023 backupfilesKeepAll.addTrueActionListener(new ActionListener()
3026 public void actionPerformed(ActionEvent e)
3028 backupfilesRevertButtonSetEnabled(true);
3029 updateBackupFilesExampleLabel();
3032 backupfilesKeepAll.addActionListener(new ActionListener()
3035 public void actionPerformed(ActionEvent e)
3037 backupfilesRevertButtonSetEnabled(true);
3038 keepRollMaxOptionsEnabled();
3039 updateBackupFilesExampleLabel();
3043 ChangeListener c = new ChangeListener()
3046 public void stateChanged(ChangeEvent e)
3048 backupfilesRevertButtonSetEnabled(true);
3049 updateBackupFilesExampleLabel();
3053 setIntegerSpinner(backupfilesRollMaxSpinner,
3054 BackupFilesPresetEntry.ROLLMAXMIN,
3055 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3057 backupfilesConfirmDelete.setLabels(
3058 MessageManager.getString("label.always_ask"),
3059 MessageManager.getString("label.auto_delete"));
3060 backupfilesConfirmDelete.addActionListener(new ActionListener()
3063 public void actionPerformed(ActionEvent e)
3065 backupfilesRevertButtonSetEnabled(true);
3068 // update the enabled section
3069 keepRollMaxOptionsEnabled();
3071 GridBagConstraints kgbc = new GridBagConstraints();
3073 // first row (template text box)
3074 kgbc.anchor = GridBagConstraints.WEST;
3077 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3078 kgbc.gridheight = 1;
3081 kgbc.fill = GridBagConstraints.HORIZONTAL;
3082 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3088 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3089 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3092 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3093 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3095 // third row (indented)
3097 kgbc.insets = new Insets(0, 20, 0, 0);
3100 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3101 kgbc.fill = GridBagConstraints.HORIZONTAL;
3104 JPanel jp = new JPanel();
3105 jp.setLayout(new FlowLayout());
3106 oldBackupFilesLabel.setText(
3107 MessageManager.getString("label.autodelete_old_backup_files"));
3108 oldBackupFilesLabel.setFont(LABEL_FONT);
3109 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3110 jp.add(oldBackupFilesLabel);
3111 jp.add(backupfilesConfirmDelete.getTrueButton());
3112 jp.add(backupfilesConfirmDelete.getFalseButton());
3113 keepfilesPanel.add(jp, kgbc);
3115 return keepfilesPanel;
3118 protected void updateBackupFilesExampleLabel()
3120 int exampleindex = 12;
3121 String base = MessageManager.getString("label.filename") + ".fa";
3122 if (base == null || base.length() == 0)
3124 base = "file_name.fa";
3127 boolean reverse = suffixReverse.isSelected();
3128 boolean keepAll = backupfilesKeepAll.isSelected();
3130 String suffix = suffixTemplate.getText();
3133 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3134 if (suffix == null || suffix.length() == 0)
3136 backupfilesExampleLabel
3137 .setText(MessageManager.getString("label.no_backup_files"));
3138 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3142 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3143 rollMax = rollMax < 1 ? 1 : rollMax;
3145 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3150 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3151 digits = digits < 1 ? 1 : digits;
3153 int lowersurround = 2;
3154 int uppersurround = 0;
3155 StringBuilder exampleSB = new StringBuilder();
3156 boolean firstLine = true;
3162 int max = keepAll ? exampleindex : rollMax;
3163 for (int index = min; index <= max; index++)
3165 if (index == min + lowersurround && index < max - uppersurround - 1)
3167 exampleSB.append("\n...");
3170 else if (index > min + lowersurround && index < max - uppersurround)
3182 exampleSB.append("\n");
3185 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3186 base, suffix, digits));
3189 // no extra text needed
3191 else if (index == min)
3193 String newest = MessageManager.getString("label.braced_newest");
3194 if (newest != null && newest.length() > 0)
3196 exampleSB.append(" " + newest);
3199 else if (index == max)
3201 String oldest = MessageManager.getString("label.braced_oldest");
3202 if (oldest != null && oldest.length() > 0)
3204 exampleSB.append(" " + oldest);
3213 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3214 : exampleindex - rollMax + 1;
3215 int max = exampleindex;
3217 for (int index = min; index <= max; index++)
3220 if (index == min + lowersurround && index < max - uppersurround - 1)
3222 exampleSB.append("\n...");
3225 else if (index > min + lowersurround && index < max - uppersurround)
3237 exampleSB.append("\n");
3240 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3241 base, suffix, digits));
3244 // no extra text needed
3246 else if (index == min)
3248 String oldest = MessageManager.getString("label.braced_oldest");
3249 if (oldest != null && oldest.length() > 0)
3251 exampleSB.append(" " + oldest);
3254 else if (index == max)
3256 String newest = MessageManager.getString("label.braced_newest");
3257 if (newest != null && newest.length() > 0)
3259 exampleSB.append(" " + newest);
3267 // add some extra empty lines to pad out the example files box. ugh, please
3269 // me how to do this better
3270 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3271 if (remainingLines > 0)
3273 for (int i = 0; i < remainingLines; i++)
3275 exampleSB.append("\n ");
3280 backupfilesExampleLabel.setText(exampleSB.toString());
3283 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3284 boolean useExistingVal, ChangeListener c)
3291 i = ((Integer) s.getValue()).intValue();
3292 } catch (Exception e)
3295 "Exception casting the initial value of s.getValue()");
3299 setIntegerSpinner(s, min, max, i, c);
3302 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3305 // integer spinner for number of digits
3314 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3317 s.addChangeListener(c);
3321 protected static int getSpinnerInt(JSpinner s, int def)
3327 i = (Integer) s.getValue();
3328 } catch (Exception e)
3330 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3335 private void keepRollMaxOptionsEnabled()
3337 boolean enabled = backupfilesKeepAll.isEnabled()
3338 && !backupfilesKeepAll.isSelected();
3339 oldBackupFilesLabel.setEnabled(enabled);
3340 backupfilesRollMaxSpinner.setEnabled(enabled);
3341 backupfilesConfirmDelete.setEnabled(enabled);
3344 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3346 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3347 && customiseCheckbox.isSelected() && suffixTemplate.getText()
3348 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3349 keepfilesPanel.setEnabled(enabled);
3350 backupfilesKeepAll.setEnabled(enabled);
3351 oldBackupFilesLabel.setEnabled(enabled);
3352 keepRollMaxOptionsEnabled();
3355 private void backupfilesSuffixTemplateDigitsSetEnabled()
3357 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3358 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3359 suffixDigitsLabel.setEnabled(enabled);
3360 suffixDigitsSpinner.setEnabled(enabled);
3361 suffixReverse.setEnabled(enabled);
3364 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3366 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3367 && customiseCheckbox.isSelected();
3368 suffixPanel.setEnabled(enabled);
3369 suffixTemplateLabel.setEnabled(enabled);
3370 suffixTemplate.setEnabled(enabled);
3371 backupfilesSuffixTemplateDigitsSetEnabled();
3374 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3376 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3377 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3378 revertButton.setEnabled(enabled);
3381 private boolean backupfilesCustomChanged()
3383 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3384 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3385 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3386 return !custom.equals(current);
3389 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3391 String suffix = suffixTemplate.getText();
3392 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3393 boolean reverse = suffixReverse.isSelected();
3394 boolean keepAll = backupfilesKeepAll.isSelected();
3395 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3396 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3398 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3399 reverse, keepAll, rollMax, confirmDelete);
3404 protected void backupfilesCustomOptionsSetEnabled()
3406 boolean enabled = customiseCheckbox.isSelected();
3408 backupfilesRevertButtonSetEnabled(enabled);
3409 backupfilesSuffixTemplateSetEnabled(enabled);
3410 backupfilesKeepAllSetEnabled(enabled);
3413 private void backupfilesSummarySetEnabled()
3415 boolean enabled = enableBackupFiles.isSelected();
3416 backupfilesExampleLabel.setEnabled(enabled);
3417 exampleFilesPanel.setEnabled(enabled);
3420 private void backupfilesPresetsSetEnabled()
3422 boolean enabled = enableBackupFiles.isSelected();
3423 presetsPanel.setEnabled(enabled);
3424 presetsComboLabel.setEnabled(enabled);
3425 backupfilesPresetsCombo.setEnabled(enabled);
3426 customiseCheckbox.setEnabled(enabled);
3427 revertButton.setEnabled(enabled);
3430 protected void backupsOptionsSetEnabled()
3432 backupfilesPresetsSetEnabled();
3433 backupfilesSummarySetEnabled();
3434 backupfilesCustomOptionsSetEnabled();
3437 protected void backupsSetOptions(String suffix, int digits,
3438 boolean reverse, boolean keepAll, int rollMax,
3439 boolean confirmDelete)
3441 suffixTemplate.setText(suffix);
3442 suffixDigitsSpinner.setValue(digits);
3443 suffixReverse.setSelected(reverse);
3444 backupfilesKeepAll.setSelected(keepAll);
3445 backupfilesRollMaxSpinner.setValue(rollMax);
3446 backupfilesConfirmDelete.setSelected(confirmDelete);
3449 protected void backupsSetOptions(BackupFilesPresetEntry p)
3451 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3455 protected void autoIdWidth_actionPerformed()
3457 // TODO Auto-generated method stub
3461 protected void userIdWidth_actionPerformed()
3463 // TODO Auto-generated method stub
3467 protected void maxColour_actionPerformed(JPanel panel)
3471 protected void minColour_actionPerformed(JPanel panel)
3475 protected void gapColour_actionPerformed(JPanel panel)
3479 protected void hiddenColour_actionPerformed(JPanel panel)
3483 protected void showunconserved_actionPerformed(ActionEvent e)
3485 // TODO Auto-generated method stub
3489 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3493 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3503 public void ok_actionPerformed(ActionEvent e)
3513 public void cancel_actionPerformed(ActionEvent e)
3523 public void annotations_actionPerformed(ActionEvent e)
3530 public void startupFileTextfield_mouseClicked()
3534 public void newLink_actionPerformed(ActionEvent e)
3539 public void editLink_actionPerformed(ActionEvent e)
3544 public void deleteLink_actionPerformed(ActionEvent e)
3549 public void defaultBrowser_mouseClicked(MouseEvent e)
3554 public void linkURLList_keyTyped(KeyEvent e)
3559 public void setProxyAuthEnabled()
3561 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3562 proxyAuthUsernameLabel.setEnabled(enabled);
3563 proxyAuthPasswordLabel.setEnabled(enabled);
3564 passwordNotStoredLabel.setEnabled(enabled);
3565 proxyAuthUsernameTB.setEnabled(enabled);
3566 proxyAuthPasswordPB.setEnabled(enabled);
3569 public void setCustomProxyEnabled()
3571 boolean enabled = customProxy.isSelected();
3572 portLabel.setEnabled(enabled);
3573 serverLabel.setEnabled(enabled);
3574 portLabel2.setEnabled(enabled);
3575 serverLabel2.setEnabled(enabled);
3576 httpLabel.setEnabled(enabled);
3577 httpsLabel.setEnabled(enabled);
3578 proxyServerHttpTB.setEnabled(enabled);
3579 proxyPortHttpTB.setEnabled(enabled);
3580 proxyServerHttpsTB.setEnabled(enabled);
3581 proxyPortHttpsTB.setEnabled(enabled);
3582 proxyAuth.setEnabled(enabled);
3583 setProxyAuthEnabled();
3586 public void proxyType_actionPerformed()
3588 setCustomProxyEnabled();
3589 proxyAuthPasswordCheckHighlight(true);
3590 applyProxyButtonEnabled(true);
3593 public void proxyAuth_actionPerformed()
3595 setProxyAuthEnabled();
3596 proxyAuthPasswordCheckHighlight(true);
3597 applyProxyButtonEnabled(true);
3601 * Customer renderer for JTable: supports column of radio buttons
3603 public class RadioButtonRenderer extends JRadioButton
3604 implements TableCellRenderer
3606 public RadioButtonRenderer()
3608 setHorizontalAlignment(CENTER);
3609 setToolTipText(MessageManager.getString("label.urltooltip"));
3613 public Component getTableCellRendererComponent(JTable table,
3614 Object value, boolean isSelected, boolean hasFocus, int row,
3617 setSelected((boolean) value);
3619 // set colours to match rest of table
3622 setBackground(table.getSelectionBackground());
3623 setForeground(table.getSelectionForeground());
3627 setBackground(table.getBackground());
3628 setForeground(table.getForeground());
3635 * Customer cell editor for JTable: supports column of radio buttons in
3636 * conjunction with renderer
3638 public class RadioButtonEditor extends AbstractCellEditor
3639 implements TableCellEditor
3641 private JRadioButton button = new JRadioButton();
3643 public RadioButtonEditor()
3645 button.setHorizontalAlignment(SwingConstants.CENTER);
3646 this.button.addActionListener(new ActionListener()
3649 public void actionPerformed(ActionEvent e)
3651 fireEditingStopped();
3657 public Component getTableCellEditorComponent(JTable table, Object value,
3658 boolean isSelected, int row, int column)
3660 button.setSelected((boolean) value);
3665 public Object getCellEditorValue()
3667 return button.isSelected();