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 jalview.bin.Cache;
24 import jalview.fts.core.FTSDataColumnPreferences;
25 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
26 import jalview.fts.service.pdb.PDBFTSRestClient;
27 import jalview.gui.Desktop;
28 import jalview.gui.JalviewBooleanRadioButtons;
29 import jalview.gui.JvOptionPane;
30 import jalview.gui.JvSwingUtils;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.BackupFilenameParts;
33 import jalview.io.BackupFiles;
34 import jalview.io.BackupFilesPresetEntry;
35 import jalview.io.IntKeyStringValueEntry;
36 import jalview.util.MessageManager;
37 import jalview.util.Platform;
39 import java.awt.BorderLayout;
40 import java.awt.Color;
41 import java.awt.Component;
42 import java.awt.Dimension;
43 import java.awt.FlowLayout;
45 import java.awt.GridBagConstraints;
46 import java.awt.GridBagLayout;
47 import java.awt.GridLayout;
48 import java.awt.Insets;
49 import java.awt.Rectangle;
50 import java.awt.event.ActionEvent;
51 import java.awt.event.ActionListener;
52 import java.awt.event.FocusEvent;
53 import java.awt.event.KeyEvent;
54 import java.awt.event.KeyListener;
55 import java.awt.event.MouseAdapter;
56 import java.awt.event.MouseEvent;
57 import java.util.Arrays;
58 import java.util.List;
60 import javax.swing.AbstractButton;
61 import javax.swing.AbstractCellEditor;
62 import javax.swing.BorderFactory;
63 import javax.swing.BoxLayout;
64 import javax.swing.ButtonGroup;
65 import javax.swing.DefaultListCellRenderer;
66 import javax.swing.JButton;
67 import javax.swing.JCheckBox;
68 import javax.swing.JComboBox;
69 import javax.swing.JComponent;
70 import javax.swing.JFileChooser;
71 import javax.swing.JLabel;
72 import javax.swing.JPanel;
73 import javax.swing.JPasswordField;
74 import javax.swing.JRadioButton;
75 import javax.swing.JScrollPane;
76 import javax.swing.JSpinner;
77 import javax.swing.JTabbedPane;
78 import javax.swing.JTable;
79 import javax.swing.JTextArea;
80 import javax.swing.JTextField;
81 import javax.swing.ListSelectionModel;
82 import javax.swing.SpinnerModel;
83 import javax.swing.SpinnerNumberModel;
84 import javax.swing.SwingConstants;
85 import javax.swing.border.Border;
86 import javax.swing.border.EmptyBorder;
87 import javax.swing.border.EtchedBorder;
88 import javax.swing.border.TitledBorder;
89 import javax.swing.event.ChangeEvent;
90 import javax.swing.event.ChangeListener;
91 import javax.swing.event.DocumentEvent;
92 import javax.swing.event.DocumentListener;
93 import javax.swing.table.TableCellEditor;
94 import javax.swing.table.TableCellRenderer;
97 * Base class for the Preferences panel.
100 * @version $Revision$
102 public class GPreferences extends JPanel
104 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
106 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
107 .getLabelFont(false, true);
109 private static final Font LABEL_FONT_BOLD = JvSwingUtils
110 .getLabelFont(true, false);
113 * Visual tab components
115 protected JCheckBox fullScreen = new JCheckBox();
117 protected JCheckBox openoverv = new JCheckBox();
119 protected JCheckBox seqLimit = new JCheckBox();
121 protected JCheckBox rightAlign = new JCheckBox();
123 protected JComboBox<String> fontSizeCB = new JComboBox<>();
125 protected JComboBox<String> fontStyleCB = new JComboBox<>();
127 protected JComboBox<String> fontNameCB = new JComboBox<>();
129 protected JCheckBox showOccupancy = new JCheckBox();
131 protected JCheckBox showUnconserved = new JCheckBox();
133 protected JCheckBox idItalics = new JCheckBox();
135 protected JCheckBox smoothFont = new JCheckBox();
137 protected JCheckBox scaleProteinToCdna = new JCheckBox();
139 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
141 protected JCheckBox wrap = new JCheckBox();
143 protected JComboBox<String> sortby = new JComboBox<>();
145 protected JComboBox<String> sortAnnBy = new JComboBox<>();
147 protected JComboBox<String> sortAutocalc = new JComboBox<>();
149 protected JCheckBox startupCheckbox = new JCheckBox();
151 protected JTextField startupFileTextfield = new JTextField();
153 // below are in the 'second column'
154 protected JCheckBox annotations = new JCheckBox();
156 protected JCheckBox quality = new JCheckBox();
158 protected JCheckBox conservation = new JCheckBox();
160 protected JCheckBox identity = new JCheckBox();
162 protected JCheckBox showGroupConsensus = new JCheckBox();
164 protected JCheckBox showGroupConservation = new JCheckBox();
166 protected JCheckBox showConsensHistogram = new JCheckBox();
168 protected JCheckBox showConsensLogo = new JCheckBox();
170 protected JCheckBox showInformationHistogram = new JCheckBox();
172 protected JCheckBox showHMMLogo = new JCheckBox();
173 protected JCheckBox showDbRefTooltip = new JCheckBox();
175 protected JCheckBox showNpTooltip = new JCheckBox();
178 * Structure tab and components
180 protected JPanel structureTab;
182 protected JCheckBox structFromPdb = new JCheckBox();
185 protected JCheckBox addSecondaryStructure = new JCheckBox();
187 protected JCheckBox addTempFactor = new JCheckBox();
189 protected JComboBox<String> structViewer = new JComboBox<>();
191 protected JLabel structureViewerPathLabel;
193 protected JTextField structureViewerPath = new JTextField();
195 protected ButtonGroup mappingMethod = new ButtonGroup();
197 protected JRadioButton siftsMapping = new JRadioButton();
199 protected JRadioButton nwMapping = new JRadioButton();
202 * Colours tab components
204 protected JPanel minColour = new JPanel();
206 protected JPanel maxColour = new JPanel();
208 protected JComboBox<String> protColour = new JComboBox<>();
210 protected JComboBox<String> nucColour = new JComboBox<>();
213 * Overview tab components
215 protected JPanel gapColour = new JPanel();
217 protected JPanel hiddenColour = new JPanel();
219 protected JCheckBox useLegacyGap;
221 protected JCheckBox showHiddenAtStart;
223 protected JLabel gapLabel;
226 * Connections tab components
228 protected JPanel connectTab;
230 protected JTable linkUrlTable = new JTable();
232 protected JButton editLink = new JButton();
234 protected JButton deleteLink = new JButton();
236 protected JTextField filterTB = new JTextField();
238 protected JButton doReset = new JButton();
240 protected JButton userOnly = new JButton();
242 protected JLabel httpLabel = new JLabel();
244 protected JLabel httpsLabel = new JLabel();
246 protected JLabel portLabel = new JLabel();
248 protected JLabel serverLabel = new JLabel();
250 protected JLabel portLabel2 = new JLabel();
252 protected JLabel serverLabel2 = new JLabel();
254 protected JLabel proxyAuthUsernameLabel = new JLabel();
256 protected JLabel proxyAuthPasswordLabel = new JLabel();
258 protected JLabel passwordNotStoredLabel = new JLabel();
260 protected JTextField proxyServerHttpTB = new JTextField();
262 protected JTextField proxyPortHttpTB = new JTextField();
264 protected JTextField proxyServerHttpsTB = new JTextField();
266 protected JTextField proxyPortHttpsTB = new JTextField();
268 protected JCheckBox proxyAuth = new JCheckBox();
270 protected JTextField proxyAuthUsernameTB = new JTextField();
272 protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
274 protected JTextField defaultBrowser = new JTextField();
276 protected ButtonGroup proxyType = new ButtonGroup();
278 protected JRadioButton noProxy = new JRadioButton();
280 protected JRadioButton systemProxy = new JRadioButton();
282 protected JRadioButton customProxy = new JRadioButton();
284 protected JButton applyProxyButton = new JButton();
286 protected JCheckBox usagestats = new JCheckBox();
288 protected JCheckBox questionnaire = new JCheckBox();
290 protected JCheckBox versioncheck = new JCheckBox();
293 * Output tab components
295 protected JComboBox<Object> epsRendering = new JComboBox<>();
297 protected JComboBox<Object> htmlRendering = new JComboBox<>();
299 protected JComboBox<Object> svgRendering = new JComboBox<>();
301 protected JLabel userIdWidthlabel = new JLabel();
303 protected JCheckBox autoIdWidth = new JCheckBox();
305 protected JTextField userIdWidth = new JTextField();
307 protected JCheckBox blcjv = new JCheckBox();
309 protected JCheckBox pileupjv = new JCheckBox();
311 protected JCheckBox clustaljv = new JCheckBox();
313 protected JCheckBox msfjv = new JCheckBox();
315 protected JCheckBox fastajv = new JCheckBox();
317 protected JCheckBox pfamjv = new JCheckBox();
319 protected JCheckBox pirjv = new JCheckBox();
321 protected JCheckBox modellerOutput = new JCheckBox();
323 protected JCheckBox embbedBioJSON = new JCheckBox();
326 * Editing tab components
328 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
330 protected JCheckBox padGaps = new JCheckBox();
332 protected JCheckBox sortByTree = new JCheckBox();
335 * hmmer tab and components
337 protected JPanel hmmerTab;
339 protected JCheckBox hmmrTrimTermini;
341 protected AbstractButton hmmerBackgroundUniprot;
343 protected AbstractButton hmmerBackgroundAlignment;
345 protected JTextField hmmerSequenceCount;
347 protected JTextField hmmerPath;
349 protected JTextField cygwinPath;
354 protected JPanel wsTab = new JPanel();
356 protected JPanel slivkaTab = new JPanel();
358 * Backups tab components
359 * a lot of these are member variables instead of local variables only so that they
360 * can be enabled/disabled easily in one go
363 protected JCheckBox enableBackupFiles = new JCheckBox();
365 protected JPanel presetsPanel = new JPanel();
367 protected JLabel presetsComboLabel = new JLabel();
369 protected JCheckBox customiseCheckbox = new JCheckBox();
371 protected JButton revertButton = new JButton();
373 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
375 private int backupfilesPresetsComboLastSelected = 0;
377 protected JPanel suffixPanel = new JPanel();
379 protected JPanel keepfilesPanel = new JPanel();
381 protected JPanel exampleFilesPanel = new JPanel();
383 protected JTextField suffixTemplate = new JTextField(null, 8);
385 protected JLabel suffixTemplateLabel = new JLabel();
387 protected JLabel suffixDigitsLabel = new JLabel();
389 protected JSpinner suffixDigitsSpinner = new JSpinner();
391 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
393 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
395 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
397 protected JLabel oldBackupFilesLabel = new JLabel();
399 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
401 protected JTextArea backupfilesExampleLabel = new JTextArea();
403 private final JTabbedPane tabbedPane = new JTabbedPane();
405 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
407 * Creates a new GPreferences object.
409 public GPreferences()
414 } catch (Exception ex)
416 ex.printStackTrace();
421 * Construct the panel and its tabbed sub-panels.
425 private void jbInit() throws Exception
427 // final JTabbedPane tabbedPane = new JTabbedPane();
428 this.setLayout(new BorderLayout());
429 // message label at top
430 this.add(messageLabel, BorderLayout.NORTH);
431 JPanel okCancelPanel = initOkCancelPanel();
432 this.add(tabbedPane, BorderLayout.CENTER);
433 this.add(okCancelPanel, BorderLayout.SOUTH);
435 tabbedPane.add(initVisualTab(),
436 MessageManager.getString("label.visual"));
438 tabbedPane.add(initColoursTab(),
439 MessageManager.getString("label.colours"));
441 tabbedPane.add(initOverviewTab(),
442 MessageManager.getString("label.overview"));
444 tabbedPane.add(initStructureTab(),
445 MessageManager.getString("label.structure"));
447 tabbedPane.add(initConnectionsTab(),
448 MessageManager.getString("label.connections"));
450 if (!Platform.isJS())
452 tabbedPane.add(initBackupsTab(),
453 MessageManager.getString("label.backups"));
456 tabbedPane.add(initLinksTab(),
457 MessageManager.getString("label.urllinks"));
459 tabbedPane.add(initOutputTab(),
460 MessageManager.getString("label.output"));
462 tabbedPane.add(initEditingTab(),
463 MessageManager.getString("label.editing"));
465 tabbedPane.add(initHMMERTab(), MessageManager.getString("label.hmmer"));
467 * See WsPreferences for the real work of configuring this tab.
469 if (!Platform.isJS())
471 wsTab.setLayout(new BorderLayout());
472 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
475 slivkaTab.setLayout(new BorderLayout());
476 tabbedPane.add(slivkaTab, "Slivka Services");
479 * Handler to validate a tab before leaving it - currently only for
481 * Adding a clearMessage() so messages are cleared when changing tabs.
483 tabbedPane.addChangeListener(new ChangeListener()
485 private Component lastTab;
488 public void stateChanged(ChangeEvent e)
490 if (lastTab == structureTab
491 && tabbedPane.getSelectedComponent() != structureTab)
493 if (!validateStructure())
495 tabbedPane.setSelectedComponent(structureTab);
499 lastTab = tabbedPane.getSelectedComponent();
506 public void setMessage(String message)
510 messageLabel.setText(message);
511 messageLabel.setFont(LABEL_FONT_BOLD);
512 messageLabel.setForeground(Color.RED.darker());
513 messageLabel.revalidate();
514 messageLabel.repaint();
516 // note message not cleared if message is null. call clearMessage()
522 public void clearMessage()
524 // only repaint if message exists
525 if (messageLabel.getText() != null
526 && messageLabel.getText().length() > 0)
528 messageLabel.setText("");
529 messageLabel.revalidate();
530 messageLabel.repaint();
536 public static enum TabRef
538 CONNECTIONS_TAB, STRUCTURE_TAB
541 public void selectTab(TabRef selectTab)
543 // select a given tab - currently only for Connections
546 case CONNECTIONS_TAB:
547 tabbedPane.setSelectedComponent(connectTab);
550 tabbedPane.setSelectedComponent(structureTab);
557 * Initialises the Editing tabbed panel.
561 private JPanel initEditingTab()
563 JPanel editingTab = new JPanel();
564 editingTab.setLayout(null);
565 autoCalculateConsCheck.setFont(LABEL_FONT);
566 autoCalculateConsCheck.setText(
567 MessageManager.getString("label.autocalculate_consensus"));
568 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
569 padGaps.setFont(LABEL_FONT);
571 MessageManager.getString("label.pad_gaps_when_editing"));
572 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
573 sortByTree.setFont(LABEL_FONT);
575 .setText(MessageManager.getString("label.sort_with_new_tree"));
576 sortByTree.setToolTipText(MessageManager.getString(
577 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
578 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
579 editingTab.add(autoCalculateConsCheck);
580 editingTab.add(padGaps);
581 editingTab.add(sortByTree);
586 * Initialises the hmmer tabbed panel
590 private JPanel initHMMERTab()
592 hmmerTab = new JPanel();
593 hmmerTab.setLayout(new BoxLayout(hmmerTab, BoxLayout.Y_AXIS));
594 hmmerTab.setLayout(new MigLayout("flowy"));
597 * path to hmmer binaries folder
599 JPanel installationPanel = new JPanel(new MigLayout("flowy"));
600 // new FlowLayout(FlowLayout.LEFT));
601 JvSwingUtils.createTitledBorder(installationPanel,
602 MessageManager.getString("label.installation"), true);
603 hmmerTab.add(installationPanel);
604 JLabel hmmerLocation = new JLabel(
605 MessageManager.getString("label.hmmer_location"));
606 hmmerLocation.setFont(LABEL_FONT);
607 final int pathFieldLength = 40;
608 hmmerPath = new JTextField(pathFieldLength);
609 hmmerPath.addMouseListener(new MouseAdapter()
612 public void mouseClicked(MouseEvent e)
614 if (e.getClickCount() == 2)
616 String chosen = openFileChooser(true);
619 hmmerPath.setText(chosen);
625 installationPanel.add(hmmerLocation);
626 installationPanel.add(hmmerPath);
629 * path to Cygwin binaries folder (for Windows)
631 if (Platform.isWindowsAndNotJS())
633 JLabel cygwinLocation = new JLabel(
634 MessageManager.getString("label.cygwin_location"));
635 cygwinLocation.setFont(LABEL_FONT);
636 cygwinPath = new JTextField(pathFieldLength);
637 cygwinPath.addMouseListener(new MouseAdapter()
640 public void mouseClicked(MouseEvent e)
642 if (e.getClickCount() == 2)
644 String chosen = openFileChooser(true);
647 cygwinPath.setText(chosen);
648 validateCygwinPath();
653 installationPanel.add(cygwinLocation);
654 installationPanel.add(cygwinPath);
658 * preferences for hmmalign
660 JPanel alignOptionsPanel = new JPanel(new MigLayout());
661 // new FlowLayout(FlowLayout.LEFT));
662 JvSwingUtils.createTitledBorder(alignOptionsPanel,
663 MessageManager.getString("label.hmmalign_options"), true);
664 hmmerTab.add(alignOptionsPanel);
665 hmmrTrimTermini = new JCheckBox();
666 hmmrTrimTermini.setFont(LABEL_FONT);
667 hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
668 alignOptionsPanel.add(hmmrTrimTermini);
671 * preferences for hmmsearch
673 JPanel searchOptions = new JPanel(new MigLayout());
674 // FlowLayout(FlowLayout.LEFT));
675 JvSwingUtils.createTitledBorder(searchOptions,
676 MessageManager.getString("label.hmmsearch_options"), true);
677 hmmerTab.add(searchOptions);
678 JLabel sequencesToKeep = new JLabel(
679 MessageManager.getString("label.no_of_sequences"));
680 sequencesToKeep.setFont(LABEL_FONT);
681 searchOptions.add(sequencesToKeep);
682 hmmerSequenceCount = new JTextField(5);
683 searchOptions.add(hmmerSequenceCount);
686 * preferences for Information Content annotation
688 // JPanel dummy = new JPanel(new FlowLayout(FlowLayout.LEFT));
689 JPanel annotationOptions = new JPanel(new MigLayout("left"));
690 JvSwingUtils.createTitledBorder(annotationOptions,
691 MessageManager.getString("label.information_annotation"), true);
692 // dummy.add(annotationOptions);
693 hmmerTab.add(annotationOptions);
694 ButtonGroup backgroundOptions = new ButtonGroup();
695 hmmerBackgroundUniprot = new JRadioButton(
696 MessageManager.getString("label.freq_uniprot"));
697 hmmerBackgroundUniprot.setFont(LABEL_FONT);
698 hmmerBackgroundAlignment = new JRadioButton(
699 MessageManager.getString("label.freq_alignment"));
700 hmmerBackgroundAlignment.setFont(LABEL_FONT);
701 backgroundOptions.add(hmmerBackgroundUniprot);
702 backgroundOptions.add(hmmerBackgroundAlignment);
703 backgroundOptions.setSelected(hmmerBackgroundUniprot.getModel(), true);
704 // disable buttons for now as annotation only uses Uniprot background
705 hmmerBackgroundAlignment.setEnabled(false);
706 hmmerBackgroundUniprot.setEnabled(false);
707 annotationOptions.add(hmmerBackgroundUniprot, "wrap");
708 annotationOptions.add(hmmerBackgroundAlignment);
714 * Initialises the Output tabbed panel.
718 private JPanel initOutputTab()
720 JPanel outputTab = new JPanel();
721 outputTab.setLayout(null);
723 JLabel epsLabel = new JLabel(
724 MessageManager.formatMessage("label.rendering_style", "EPS"));
725 epsLabel.setFont(LABEL_FONT);
726 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
727 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
728 epsRendering.setFont(LABEL_FONT);
729 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
730 JLabel htmlLabel = new JLabel(
731 MessageManager.formatMessage("label.rendering_style", "HTML"));
732 htmlLabel.setFont(LABEL_FONT);
733 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
734 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
735 htmlRendering.setFont(LABEL_FONT);
736 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
737 JLabel svgLabel = new JLabel(
738 MessageManager.formatMessage("label.rendering_style", "SVG"));
739 svgLabel.setFont(LABEL_FONT);
740 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
741 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
742 svgRendering.setFont(LABEL_FONT);
743 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
745 JLabel jLabel1 = new JLabel();
746 jLabel1.setFont(LABEL_FONT);
747 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
748 jLabel1.setText(MessageManager.getString("label.append_start_end"));
749 jLabel1.setFont(LABEL_FONT);
751 fastajv.setFont(LABEL_FONT);
752 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
753 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
754 blcjv.setText(MessageManager.getString("label.blc") + " ");
755 fastajv.setText(MessageManager.getString("label.fasta") + " ");
756 msfjv.setText(MessageManager.getString("label.msf") + " ");
757 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
758 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
759 msfjv.setFont(LABEL_FONT);
760 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
761 pirjv.setText(MessageManager.getString("label.pir") + " ");
762 JPanel jPanel11 = new JPanel();
763 jPanel11.setFont(LABEL_FONT);
764 TitledBorder titledBorder2 = new TitledBorder(
765 MessageManager.getString("label.file_output"));
766 jPanel11.setBorder(titledBorder2);
767 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
768 GridLayout gridLayout3 = new GridLayout();
769 jPanel11.setLayout(gridLayout3);
770 gridLayout3.setRows(8);
771 blcjv.setFont(LABEL_FONT);
772 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
773 clustaljv.setFont(LABEL_FONT);
774 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
775 pfamjv.setFont(LABEL_FONT);
776 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
777 pileupjv.setFont(LABEL_FONT);
778 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
779 pirjv.setFont(LABEL_FONT);
780 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
781 autoIdWidth.setFont(LABEL_FONT);
783 MessageManager.getString("label.automatically_set_id_width"));
784 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
785 .getString("label.adjusts_width_generated_eps_png")));
786 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
787 autoIdWidth.addActionListener(new ActionListener()
791 public void actionPerformed(ActionEvent e)
793 autoIdWidth_actionPerformed();
796 userIdWidthlabel.setFont(LABEL_FONT);
797 userIdWidthlabel.setText(
798 MessageManager.getString("label.figure_id_column_width"));
799 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
800 .getString("label.manually_specify_width_left_column")));
801 userIdWidthlabel.setToolTipText(
802 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
803 "label.manually_specify_width_left_column")));
804 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
805 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
806 userIdWidth.setText("");
807 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
808 userIdWidth.addActionListener(new ActionListener()
812 public void actionPerformed(ActionEvent e)
814 userIdWidth_actionPerformed();
817 modellerOutput.setFont(LABEL_FONT);
819 .setText(MessageManager.getString("label.use_modeller_output"));
820 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
821 embbedBioJSON.setFont(LABEL_FONT);
822 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
823 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
825 jPanel11.add(jLabel1);
827 jPanel11.add(clustaljv);
828 jPanel11.add(fastajv);
830 jPanel11.add(pfamjv);
831 jPanel11.add(pileupjv);
833 outputTab.add(autoIdWidth);
834 outputTab.add(userIdWidth);
835 outputTab.add(userIdWidthlabel);
836 outputTab.add(modellerOutput);
837 if (!Platform.isJS())
840 * JalviewJS doesn't support Lineart option or SVG output
842 outputTab.add(embbedBioJSON);
843 outputTab.add(epsLabel);
844 outputTab.add(epsRendering);
845 outputTab.add(htmlLabel);
846 outputTab.add(htmlRendering);
847 outputTab.add(svgLabel);
848 outputTab.add(svgRendering);
850 outputTab.add(jPanel11);
855 * Initialises the Connections tabbed panel.
859 private JPanel initConnectionsTab()
861 connectTab = new JPanel();
862 connectTab.setLayout(new GridBagLayout());
864 // Label for browser text box
865 JLabel browserLabel = new JLabel();
866 browserLabel.setFont(LABEL_FONT);
867 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
868 browserLabel.setText(
869 MessageManager.getString("label.default_browser_unix"));
870 defaultBrowser.setFont(LABEL_FONT);
871 defaultBrowser.setText("");
872 final String tooltip = JvSwingUtils.wrapTooltip(true,
873 MessageManager.getString("label.double_click_to_browse"));
874 defaultBrowser.setToolTipText(tooltip);
875 defaultBrowser.addMouseListener(new MouseAdapter()
878 public void mouseClicked(MouseEvent e)
880 if (e.getClickCount() > 1)
882 defaultBrowser_mouseClicked(e);
887 JPanel proxyPanel = initConnTabProxyPanel();
888 initConnTabCheckboxes();
890 // Add default Browser text box
891 connectTab.add(browserLabel,
892 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
893 GridBagConstraints.WEST, GridBagConstraints.NONE,
894 new Insets(10, 0, 5, 5), 5, 1));
895 defaultBrowser.setFont(LABEL_FONT);
896 defaultBrowser.setText("");
898 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
899 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
900 new Insets(10, 0, 5, 10), 30, 1));
902 // Add proxy server panel
903 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
904 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
905 new Insets(10, 0, 5, 12), 4, 10));
907 // Add usage stats, version check and questionnaire checkboxes
908 connectTab.add(usagestats,
909 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
910 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
911 new Insets(0, 2, 5, 5), 70, 1));
912 connectTab.add(questionnaire,
913 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
914 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
915 new Insets(0, 2, 5, 10), 70, 1));
916 connectTab.add(versioncheck,
917 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
918 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
919 new Insets(0, 2, 5, 5), 70, 1));
921 versioncheck.setVisible(false);
923 // Add padding so the panel doesn't look ridiculous
924 JPanel spacePanel = new JPanel();
925 connectTab.add(spacePanel,
926 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
927 GridBagConstraints.WEST, GridBagConstraints.BOTH,
928 new Insets(0, 0, 0, 5), 70, 1));
934 * Initialises the Links tabbed panel.
938 private JPanel initLinksTab()
940 JPanel linkTab = new JPanel();
941 linkTab.setLayout(new GridBagLayout());
943 // Set up table for Url links
944 linkUrlTable.getTableHeader().setReorderingAllowed(false);
945 linkUrlTable.setFillsViewportHeight(true);
946 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
947 linkUrlTable.setAutoCreateRowSorter(true);
948 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
950 // adjust row height so radio buttons actually fit
951 // don't do this in the renderer, it causes the awt thread to activate
953 JRadioButton temp = new JRadioButton();
954 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
956 // Table in scrollpane so that the table is given a scrollbar
957 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
958 linkScrollPane.setBorder(null);
960 // Panel for links functionality
961 JPanel linkPanel = new JPanel(new GridBagLayout());
962 linkPanel.setBorder(new TitledBorder(
963 MessageManager.getString("label.url_linkfrom_sequence_id")));
965 // Put the Url links panel together
967 // Buttons go at top right, resizing only resizes the blank space vertically
968 JPanel buttonPanel = initLinkTabUrlButtons();
969 GridBagConstraints linkConstraints1 = new GridBagConstraints();
970 linkConstraints1.insets = new Insets(0, 0, 5, 0);
971 linkConstraints1.gridx = 0;
972 linkConstraints1.gridy = 0;
973 linkConstraints1.weightx = 1.0;
974 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
975 linkTab.add(buttonPanel, linkConstraints1);
977 // Links table goes at top left, resizing resizes the table
978 GridBagConstraints linkConstraints2 = new GridBagConstraints();
979 linkConstraints2.insets = new Insets(0, 0, 5, 5);
980 linkConstraints2.gridx = 0;
981 linkConstraints2.gridy = 1;
982 linkConstraints2.weightx = 1.0;
983 linkConstraints2.weighty = 1.0;
984 linkConstraints2.fill = GridBagConstraints.BOTH;
985 linkTab.add(linkScrollPane, linkConstraints2);
987 // Filter box and buttons goes at bottom left, resizing resizes the text box
988 JPanel filterPanel = initLinkTabFilterPanel();
989 GridBagConstraints linkConstraints3 = new GridBagConstraints();
990 linkConstraints3.insets = new Insets(0, 0, 0, 5);
991 linkConstraints3.gridx = 0;
992 linkConstraints3.gridy = 2;
993 linkConstraints3.weightx = 1.0;
994 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
995 linkTab.add(filterPanel, linkConstraints3);
1000 private JPanel initLinkTabFilterPanel()
1002 // Filter textbox and reset button
1003 JLabel filterLabel = new JLabel(
1004 MessageManager.getString("label.filter"));
1005 filterLabel.setFont(LABEL_FONT);
1006 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1007 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
1009 filterTB.setFont(LABEL_FONT);
1010 filterTB.setText("");
1012 doReset.setText(MessageManager.getString("action.showall"));
1013 userOnly.setText(MessageManager.getString("action.customfilter"));
1015 // Panel for filter functionality
1016 JPanel filterPanel = new JPanel(new GridBagLayout());
1017 filterPanel.setBorder(new TitledBorder("Filter"));
1018 GridBagConstraints gbc = new GridBagConstraints();
1021 gbc.fill = GridBagConstraints.NONE;
1022 gbc.anchor = GridBagConstraints.WEST;
1024 filterPanel.add(filterLabel, gbc);
1026 GridBagConstraints gbc1 = new GridBagConstraints();
1029 gbc1.fill = GridBagConstraints.HORIZONTAL;
1030 gbc1.anchor = GridBagConstraints.WEST;
1032 filterPanel.add(filterTB, gbc1);
1034 GridBagConstraints gbc2 = new GridBagConstraints();
1036 gbc2.fill = GridBagConstraints.NONE;
1037 gbc2.anchor = GridBagConstraints.WEST;
1038 filterPanel.add(doReset, gbc2);
1040 GridBagConstraints gbc3 = new GridBagConstraints();
1042 gbc3.fill = GridBagConstraints.NONE;
1043 gbc3.anchor = GridBagConstraints.WEST;
1044 filterPanel.add(userOnly, gbc3);
1049 private JPanel initLinkTabUrlButtons()
1051 // Buttons for new / edit / delete Url links
1052 JButton newLink = new JButton();
1053 newLink.setText(MessageManager.getString("action.new"));
1055 editLink.setText(MessageManager.getString("action.edit"));
1057 deleteLink.setText(MessageManager.getString("action.delete"));
1059 // no current selection, so initially disable delete/edit buttons
1060 editLink.setEnabled(false);
1061 deleteLink.setEnabled(false);
1063 newLink.addActionListener(new java.awt.event.ActionListener()
1066 public void actionPerformed(ActionEvent e)
1068 newLink_actionPerformed(e);
1072 editLink.setText(MessageManager.getString("action.edit"));
1073 editLink.addActionListener(new java.awt.event.ActionListener()
1076 public void actionPerformed(ActionEvent e)
1078 editLink_actionPerformed(e);
1082 deleteLink.setText(MessageManager.getString("action.delete"));
1083 deleteLink.addActionListener(new java.awt.event.ActionListener()
1086 public void actionPerformed(ActionEvent e)
1088 deleteLink_actionPerformed(e);
1092 JPanel buttonPanel = new JPanel(new GridBagLayout());
1093 buttonPanel.setBorder(new TitledBorder("Edit links"));
1094 GridBagConstraints gbc = new GridBagConstraints();
1097 gbc.fill = GridBagConstraints.NONE;
1098 buttonPanel.add(newLink, gbc);
1100 GridBagConstraints gbc1 = new GridBagConstraints();
1103 gbc1.fill = GridBagConstraints.NONE;
1104 buttonPanel.add(editLink, gbc1);
1106 GridBagConstraints gbc2 = new GridBagConstraints();
1109 gbc2.fill = GridBagConstraints.NONE;
1110 buttonPanel.add(deleteLink, gbc2);
1112 GridBagConstraints gbc3 = new GridBagConstraints();
1115 gbc3.fill = GridBagConstraints.HORIZONTAL;
1117 JPanel spacePanel = new JPanel();
1118 spacePanel.setBorder(null);
1119 buttonPanel.add(spacePanel, gbc3);
1125 * Initialises the proxy server panel in the Connections tab
1127 * @return the proxy server panel
1129 private JPanel initConnTabProxyPanel()
1131 // Label for server text box
1132 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1133 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1134 serverLabel.setFont(LABEL_FONT);
1135 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1136 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1137 serverLabel2.setFont(LABEL_FONT);
1139 // Proxy server and port text boxes
1140 proxyServerHttpTB.setFont(LABEL_FONT);
1141 proxyServerHttpTB.setColumns(40);
1142 proxyPortHttpTB.setFont(LABEL_FONT);
1143 proxyPortHttpTB.setColumns(4);
1144 proxyServerHttpsTB.setFont(LABEL_FONT);
1145 proxyServerHttpsTB.setColumns(40);
1146 proxyPortHttpsTB.setFont(LABEL_FONT);
1147 proxyPortHttpsTB.setColumns(4);
1148 proxyAuthUsernameTB.setFont(LABEL_FONT);
1149 proxyAuthUsernameTB.setColumns(30);
1151 // check for any change to enable applyProxyButton
1152 DocumentListener d = new DocumentListener()
1155 public void changedUpdate(DocumentEvent e)
1157 applyProxyButtonEnabled(true);
1161 public void insertUpdate(DocumentEvent e)
1163 applyProxyButtonEnabled(true);
1167 public void removeUpdate(DocumentEvent e)
1169 applyProxyButtonEnabled(true);
1172 proxyServerHttpTB.getDocument().addDocumentListener(d);
1173 proxyPortHttpTB.getDocument().addDocumentListener(d);
1174 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1175 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1176 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1177 proxyAuthPasswordPB.setFont(LABEL_FONT);
1178 proxyAuthPasswordPB.setColumns(30);
1179 proxyAuthPasswordPB.getDocument()
1180 .addDocumentListener(new DocumentListener()
1183 public void changedUpdate(DocumentEvent e)
1185 proxyAuthPasswordCheckHighlight(true);
1186 applyProxyButtonEnabled(true);
1190 public void insertUpdate(DocumentEvent e)
1192 proxyAuthPasswordCheckHighlight(true);
1193 applyProxyButtonEnabled(true);
1197 public void removeUpdate(DocumentEvent e)
1199 proxyAuthPasswordCheckHighlight(true);
1200 applyProxyButtonEnabled(true);
1205 // Label for Port text box
1206 portLabel.setFont(LABEL_FONT);
1207 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1208 portLabel.setText(MessageManager.getString("label.port") + ": ");
1209 portLabel2.setFont(LABEL_FONT);
1210 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1211 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1213 httpLabel.setText("HTTP");
1214 httpLabel.setFont(LABEL_FONT_BOLD);
1215 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1216 httpsLabel.setText("HTTPS");
1217 httpsLabel.setFont(LABEL_FONT_BOLD);
1218 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1220 proxyAuthUsernameLabel
1221 .setText(MessageManager.getString("label.username") + ": ");
1222 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1223 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1224 proxyAuthPasswordLabel
1225 .setText(MessageManager.getString("label.password") + ": ");
1226 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1227 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1228 passwordNotStoredLabel.setText(
1229 "(" + MessageManager.getString("label.not_stored") + ")");
1230 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1231 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1233 // Proxy type radio buttons
1234 noProxy.setFont(LABEL_FONT);
1235 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1236 noProxy.setText(MessageManager.getString("label.no_proxy"));
1237 systemProxy.setFont(LABEL_FONT);
1238 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1239 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1240 displayUserHostPort(Cache.startupProxyProperties[4],
1241 Cache.startupProxyProperties[0],
1242 Cache.startupProxyProperties[1]),
1243 displayUserHostPort(Cache.startupProxyProperties[6],
1244 Cache.startupProxyProperties[2],
1245 Cache.startupProxyProperties[3])));
1246 customProxy.setFont(LABEL_FONT);
1247 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1248 customProxy.setText(
1249 MessageManager.getString("label.use_proxy_server") + ":");
1250 ActionListener al = new ActionListener()
1253 public void actionPerformed(ActionEvent e)
1255 proxyType_actionPerformed();
1258 noProxy.addActionListener(al);
1259 systemProxy.addActionListener(al);
1260 customProxy.addActionListener(al);
1261 proxyType.add(noProxy);
1262 proxyType.add(systemProxy);
1263 proxyType.add(customProxy);
1265 proxyAuth.setFont(LABEL_FONT);
1266 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1267 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1268 proxyAuth.addActionListener(new ActionListener()
1271 public void actionPerformed(ActionEvent e)
1273 proxyAuth_actionPerformed();
1276 setCustomProxyEnabled();
1278 // Make proxy server panel
1279 JPanel proxyPanel = new JPanel();
1280 TitledBorder titledBorder1 = new TitledBorder(
1281 MessageManager.getString("label.proxy_servers"));
1282 proxyPanel.setBorder(titledBorder1);
1283 proxyPanel.setLayout(new GridBagLayout());
1284 GridBagConstraints gbc = new GridBagConstraints();
1285 gbc.fill = GridBagConstraints.HORIZONTAL;
1288 GridBagConstraints c = new GridBagConstraints();
1289 // Proxy type radio buttons (3)
1290 JPanel ptPanel = new JPanel();
1291 ptPanel.setLayout(new GridBagLayout());
1296 c.fill = GridBagConstraints.HORIZONTAL;
1297 ptPanel.add(noProxy, c);
1299 ptPanel.add(systemProxy, c);
1301 ptPanel.add(customProxy, c);
1304 proxyPanel.add(ptPanel, gbc);
1306 // host and port text boxes
1307 JPanel hpPanel = new JPanel();
1308 hpPanel.setLayout(new GridBagLayout());
1309 // HTTP host port row
1314 c.anchor = GridBagConstraints.LINE_START;
1315 hpPanel.add(httpLabel, c);
1319 c.anchor = GridBagConstraints.LINE_END;
1320 hpPanel.add(serverLabel, c);
1324 c.anchor = GridBagConstraints.LINE_START;
1325 hpPanel.add(proxyServerHttpTB, c);
1329 c.anchor = GridBagConstraints.LINE_END;
1330 hpPanel.add(portLabel, c);
1334 c.anchor = GridBagConstraints.LINE_START;
1335 hpPanel.add(proxyPortHttpTB, c);
1337 // HTTPS host port row
1342 c.anchor = GridBagConstraints.LINE_START;
1343 hpPanel.add(httpsLabel, c);
1346 c.anchor = GridBagConstraints.LINE_END;
1347 hpPanel.add(serverLabel2, c);
1350 c.anchor = GridBagConstraints.LINE_START;
1351 hpPanel.add(proxyServerHttpsTB, c);
1354 c.anchor = GridBagConstraints.LINE_END;
1355 hpPanel.add(portLabel2, c);
1358 c.anchor = GridBagConstraints.LINE_START;
1359 hpPanel.add(proxyPortHttpsTB, c);
1362 proxyPanel.add(hpPanel, gbc);
1364 if (!Platform.isJS())
1366 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1367 * Authentication options in Preferences.
1373 // Require authentication checkbox
1375 proxyPanel.add(proxyAuth, gbc);
1377 // username and password
1378 JPanel upPanel = new JPanel();
1379 upPanel.setLayout(new GridBagLayout());
1385 c.anchor = GridBagConstraints.LINE_END;
1386 upPanel.add(proxyAuthUsernameLabel, c);
1390 c.anchor = GridBagConstraints.LINE_START;
1391 upPanel.add(proxyAuthUsernameTB, c);
1397 c.anchor = GridBagConstraints.LINE_END;
1398 upPanel.add(proxyAuthPasswordLabel, c);
1402 c.anchor = GridBagConstraints.LINE_START;
1403 upPanel.add(proxyAuthPasswordPB, c);
1407 c.anchor = GridBagConstraints.LINE_START;
1408 upPanel.add(passwordNotStoredLabel, c);
1411 proxyPanel.add(upPanel, gbc);
1415 applyProxyButton.setText(MessageManager.getString("action.apply"));
1416 applyProxyButton.addActionListener(new ActionListener()
1419 public void actionPerformed(ActionEvent e)
1421 saveProxySettings();
1422 applyProxyButton.setEnabled(false);
1426 gbc.fill = GridBagConstraints.NONE;
1427 gbc.anchor = GridBagConstraints.LINE_END;
1428 proxyPanel.add(applyProxyButton, gbc);
1433 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1435 proxyAuthPasswordCheckHighlight(enabled, false);
1438 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1441 if (enabled && proxyType.isSelected(customProxy.getModel())
1442 && proxyAuth.isSelected()
1443 && !proxyAuthUsernameTB.getText().isEmpty()
1444 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1447 proxyAuthPasswordPB.grabFocus();
1448 proxyAuthPasswordPB.setBackground(Color.PINK);
1452 proxyAuthPasswordPB.setBackground(Color.WHITE);
1456 public void applyProxyButtonEnabled(boolean enabled)
1458 applyProxyButton.setEnabled(enabled);
1461 public void saveProxySettings()
1463 // overridden in Preferences
1466 private String displayUserHostPort(String user, String host, String port)
1468 boolean hostBlank = (host == null || host.isEmpty());
1469 boolean portBlank = (port == null || port.isEmpty());
1470 if (hostBlank && portBlank)
1472 return MessageManager.getString("label.none");
1475 StringBuilder sb = new StringBuilder();
1478 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1482 sb.append(hostBlank ? "" : host);
1488 return sb.toString();
1492 * Initialises the checkboxes in the Connections tab
1494 private void initConnTabCheckboxes()
1496 // Usage stats checkbox label
1498 MessageManager.getString("label.send_usage_statistics"));
1499 usagestats.setFont(LABEL_FONT);
1500 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1501 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1503 // Questionnaire checkbox label
1504 questionnaire.setText(
1505 MessageManager.getString("label.check_for_questionnaires"));
1506 questionnaire.setFont(LABEL_FONT);
1507 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1508 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1510 // Check for latest version checkbox label
1511 versioncheck.setText(
1512 MessageManager.getString("label.check_for_latest_version"));
1513 versioncheck.setFont(LABEL_FONT);
1514 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1515 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1519 * Initialises the parent panel which contains the tabbed sections.
1523 private JPanel initOkCancelPanel()
1525 JButton ok = new JButton();
1526 ok.setText(MessageManager.getString("action.ok"));
1527 ok.addActionListener(new ActionListener()
1530 public void actionPerformed(ActionEvent e)
1532 ok_actionPerformed(e);
1535 JButton cancel = new JButton();
1536 cancel.setText(MessageManager.getString("action.cancel"));
1537 cancel.addActionListener(new ActionListener()
1540 public void actionPerformed(ActionEvent e)
1542 cancel_actionPerformed(e);
1545 JPanel okCancelPanel = new JPanel();
1546 okCancelPanel.add(ok);
1547 okCancelPanel.add(cancel);
1548 return okCancelPanel;
1552 * Initialises the Colours tabbed panel.
1556 private JPanel initColoursTab()
1558 JPanel coloursTab = new JPanel();
1559 coloursTab.setBorder(new TitledBorder(
1560 MessageManager.getString("action.open_new_alignment")));
1561 coloursTab.setLayout(new FlowLayout());
1562 JLabel mincolourLabel = new JLabel();
1563 mincolourLabel.setFont(LABEL_FONT);
1564 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1565 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1566 minColour.setFont(LABEL_FONT);
1567 minColour.setBorder(BorderFactory.createEtchedBorder());
1568 minColour.setPreferredSize(new Dimension(40, 20));
1569 minColour.addMouseListener(new MouseAdapter()
1572 public void mousePressed(MouseEvent e)
1574 minColour_actionPerformed(minColour);
1577 JLabel maxcolourLabel = new JLabel();
1578 maxcolourLabel.setFont(LABEL_FONT);
1579 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1580 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1581 maxColour.setFont(LABEL_FONT);
1582 maxColour.setBorder(BorderFactory.createEtchedBorder());
1583 maxColour.setPreferredSize(new Dimension(40, 20));
1584 maxColour.addMouseListener(new MouseAdapter()
1587 public void mousePressed(MouseEvent e)
1589 maxColour_actionPerformed(maxColour);
1593 protColour.setFont(LABEL_FONT);
1594 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1595 JLabel protColourLabel = new JLabel();
1596 protColourLabel.setFont(LABEL_FONT);
1597 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1598 protColourLabel.setText(
1599 MessageManager.getString("label.prot_alignment_colour") + " ");
1600 GPreferences.addtoLayout(coloursTab,
1602 .getString("label.default_colour_scheme_for_alignment"),
1603 protColourLabel, protColour);
1605 nucColour.setFont(LABEL_FONT);
1606 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1607 JLabel nucColourLabel = new JLabel();
1608 nucColourLabel.setFont(LABEL_FONT);
1609 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1610 nucColourLabel.setText(
1611 MessageManager.getString("label.nuc_alignment_colour") + " ");
1612 GPreferences.addtoLayout(coloursTab,
1614 .getString("label.default_colour_scheme_for_alignment"),
1615 nucColourLabel, nucColour);
1617 JPanel annotationShding = new JPanel();
1618 annotationShding.setBorder(new TitledBorder(
1619 MessageManager.getString("label.annotation_shading_default")));
1620 annotationShding.setLayout(new GridLayout(1, 2));
1621 GPreferences.addtoLayout(annotationShding,
1622 MessageManager.getString(
1623 "label.default_minimum_colour_annotation_shading"),
1624 mincolourLabel, minColour);
1625 GPreferences.addtoLayout(annotationShding,
1626 MessageManager.getString(
1627 "label.default_maximum_colour_annotation_shading"),
1628 maxcolourLabel, maxColour);
1629 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1634 * Initialises the Overview tabbed panel.
1638 private JPanel initOverviewTab()
1640 JPanel overviewPanel = new JPanel();
1641 overviewPanel.setBorder(new TitledBorder(
1642 MessageManager.getString("label.overview_settings")));
1644 gapColour.setFont(LABEL_FONT);
1645 // fixing the border colours stops apparent colour bleed from the panel
1646 gapColour.setBorder(
1647 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1648 gapColour.setPreferredSize(new Dimension(40, 20));
1649 gapColour.addMouseListener(new MouseAdapter()
1652 public void mousePressed(MouseEvent e)
1654 gapColour_actionPerformed(gapColour);
1658 hiddenColour.setFont(LABEL_FONT);
1659 // fixing the border colours stops apparent colour bleed from the panel
1660 hiddenColour.setBorder(
1661 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1662 hiddenColour.setPreferredSize(new Dimension(40, 20));
1663 hiddenColour.addMouseListener(new MouseAdapter()
1666 public void mousePressed(MouseEvent e)
1668 hiddenColour_actionPerformed(hiddenColour);
1672 useLegacyGap = new JCheckBox(
1673 MessageManager.getString("label.ov_legacy_gap"));
1674 useLegacyGap.setFont(LABEL_FONT);
1675 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1676 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1677 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1678 gapLabel.setFont(LABEL_FONT);
1679 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1680 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1681 showHiddenAtStart = new JCheckBox(
1682 MessageManager.getString("label.ov_show_hide_default"));
1683 showHiddenAtStart.setFont(LABEL_FONT);
1684 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1685 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1686 JLabel hiddenLabel = new JLabel(
1687 MessageManager.getString("label.hidden_colour"));
1688 hiddenLabel.setFont(LABEL_FONT);
1689 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1690 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1692 useLegacyGap.addActionListener(new ActionListener()
1695 public void actionPerformed(ActionEvent e)
1697 useLegacyGaps_actionPerformed(e);
1701 overviewPanel.setLayout(new GridBagLayout());
1702 GridBagConstraints c1 = new GridBagConstraints();
1704 c1.fill = GridBagConstraints.HORIZONTAL;
1709 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1710 overviewPanel.add(useLegacyGap, c1);
1712 GridBagConstraints c2 = new GridBagConstraints();
1713 c2.fill = GridBagConstraints.HORIZONTAL;
1716 c2.insets = new Insets(0, 15, 0, 10);
1717 overviewPanel.add(gapLabel, c2);
1719 GridBagConstraints c3 = new GridBagConstraints();
1720 c3.fill = GridBagConstraints.HORIZONTAL;
1723 c3.insets = new Insets(0, 0, 0, 15);
1724 overviewPanel.add(gapColour, c3);
1726 GridBagConstraints c4 = new GridBagConstraints();
1727 c4.fill = GridBagConstraints.HORIZONTAL;
1731 overviewPanel.add(showHiddenAtStart, c4);
1733 GridBagConstraints c5 = new GridBagConstraints();
1734 c5.fill = GridBagConstraints.HORIZONTAL;
1737 c5.insets = new Insets(0, 15, 0, 10);
1738 overviewPanel.add(hiddenLabel, c5);
1740 GridBagConstraints c6 = new GridBagConstraints();
1741 c6.fill = GridBagConstraints.HORIZONTAL;
1744 c6.insets = new Insets(0, 0, 0, 15);
1745 overviewPanel.add(hiddenColour, c6);
1747 JButton resetButton = new JButton(
1748 MessageManager.getString("label.reset_to_defaults"));
1750 resetButton.addActionListener(new ActionListener()
1753 public void actionPerformed(ActionEvent e)
1755 resetOvDefaults_actionPerformed(e);
1759 GridBagConstraints c7 = new GridBagConstraints();
1760 c7.fill = GridBagConstraints.NONE;
1763 c7.insets = new Insets(10, 0, 0, 0);
1764 c7.anchor = GridBagConstraints.WEST;
1765 overviewPanel.add(resetButton, c7);
1767 // Add padding so the panel doesn't look ridiculous
1768 JPanel spacePanel = new JPanel();
1769 overviewPanel.add(spacePanel,
1770 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1771 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1772 new Insets(0, 0, 0, 5), 0, 0));
1774 return overviewPanel;
1778 * Initialises the Structure tabbed panel.
1782 private JPanel initStructureTab()
1784 structureTab = new JPanel();
1786 structureTab.setBorder(new TitledBorder(
1787 MessageManager.getString("label.structure_options")));
1788 structureTab.setLayout(null);
1789 final int width = 420;
1790 final int height = 22;
1791 final int lineSpacing = 25;
1794 structFromPdb.setFont(LABEL_FONT);
1796 .setText(MessageManager.getString("label.struct_from_pdb"));
1797 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1798 structFromPdb.addActionListener(new ActionListener()
1801 public void actionPerformed(ActionEvent e)
1803 boolean selected = structFromPdb.isSelected();
1804 // enable other options only when the first is checked
1805 addSecondaryStructure.setEnabled(selected);
1806 addTempFactor.setEnabled(selected);
1809 structureTab.add(structFromPdb);
1811 // indent checkboxes that are conditional on the first one
1813 ypos += lineSpacing;
1814 addSecondaryStructure.setFont(LABEL_FONT);
1815 addSecondaryStructure
1816 .setText(MessageManager.getString("label.autoadd_secstr"));
1817 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1818 structureTab.add(addSecondaryStructure);
1820 ypos += lineSpacing;
1821 addTempFactor.setFont(LABEL_FONT);
1822 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1823 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1824 structureTab.add(addTempFactor);
1826 ypos += lineSpacing;
1827 JLabel viewerLabel = new JLabel();
1828 viewerLabel.setFont(LABEL_FONT);
1829 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1830 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1831 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1832 structureTab.add(viewerLabel);
1835 * add all external viewers as options here - check
1836 * when selected whether the program is installed
1838 structViewer.setFont(LABEL_FONT);
1839 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1840 structViewer.addItem(ViewerType.JMOL.name());
1841 structViewer.addItem(ViewerType.CHIMERA.name());
1842 structViewer.addItem(ViewerType.CHIMERAX.name());
1843 structViewer.addItem(ViewerType.PYMOL.name());
1844 structViewer.addActionListener(new ActionListener()
1847 public void actionPerformed(ActionEvent e)
1849 structureViewer_actionPerformed(
1850 (String) structViewer.getSelectedItem());
1853 structureTab.add(structViewer);
1855 ypos += lineSpacing;
1856 structureViewerPathLabel = new JLabel();
1857 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1859 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1860 structureViewerPathLabel.setText(MessageManager
1861 .formatMessage("label.viewer_path", "Chimera(X)"));
1862 structureViewerPathLabel
1863 .setBounds(new Rectangle(10, ypos, 170, height));
1864 structureViewerPathLabel.setEnabled(false);
1865 structureTab.add(structureViewerPathLabel);
1867 structureViewerPath.setFont(LABEL_FONT);
1868 structureViewerPath.setText("");
1869 structureViewerPath.setEnabled(false);
1870 final String tooltip = JvSwingUtils.wrapTooltip(true,
1871 MessageManager.getString("label.viewer_path_tip"));
1872 structureViewerPath.setToolTipText(tooltip);
1873 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1874 structureViewerPath.addMouseListener(new MouseAdapter()
1877 public void mouseClicked(MouseEvent e)
1879 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1881 structureViewer_actionPerformed(
1882 (String) structViewer.getSelectedItem());
1885 structureTab.add(structViewer);
1886 ypos += lineSpacing;
1887 structureViewerPathLabel = new JLabel();
1888 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1890 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1891 structureViewerPathLabel.setText(MessageManager
1892 .formatMessage("label.viewer_path", "Chimera(X)"));
1893 structureViewerPathLabel
1894 .setBounds(new Rectangle(10, ypos, 170, height));
1895 structureViewerPathLabel.setEnabled(false);
1896 structureTab.add(structureViewerPathLabel);
1898 structureViewerPath.setFont(LABEL_FONT);
1899 structureViewerPath.setText("");
1900 structureViewerPath.setEnabled(false);
1901 final String tooltip = JvSwingUtils.wrapTooltip(true,
1902 MessageManager.getString("label.viewer_path_tip"));
1903 structureViewerPath.setToolTipText(tooltip);
1904 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1905 structureViewerPath.addMouseListener(new MouseAdapter()
1907 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1909 String chosen = openFileChooser();
1912 structureViewerPath.setText(chosen);
1917 structureTab.add(structureViewerPath);
1919 ypos += lineSpacing;
1920 nwMapping.setFont(LABEL_FONT);
1921 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1922 siftsMapping.setFont(LABEL_FONT);
1923 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1924 mappingMethod.add(nwMapping);
1925 mappingMethod.add(siftsMapping);
1926 JPanel mappingPanel = new JPanel();
1927 mappingPanel.setFont(LABEL_FONT);
1928 TitledBorder mmTitledBorder = new TitledBorder(
1929 MessageManager.getString("label.mapping_method"));
1930 mmTitledBorder.setTitleFont(LABEL_FONT);
1931 mappingPanel.setBorder(mmTitledBorder);
1932 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1933 // GridLayout mappingLayout = new GridLayout();
1934 mappingPanel.setLayout(new GridLayout());
1935 mappingPanel.add(nwMapping);
1936 mappingPanel.add(siftsMapping);
1937 structureTab.add(mappingPanel);
1939 ypos += lineSpacing;
1940 ypos += lineSpacing;
1941 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1942 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1943 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1944 structureTab.add(docFieldPref);
1947 * hide Chimera options in JalviewJS
1949 if (Platform.isJS())
1951 structureViewerPathLabel.setVisible(false);
1952 structureViewerPath.setVisible(false);
1953 viewerLabel.setVisible(false);
1954 structViewer.setVisible(false);
1956 return structureTab;
1960 * Action on choosing a structure viewer from combobox options.
1962 * @param selectedItem
1964 protected void structureViewer_actionPerformed(String selectedItem)
1969 * Show a dialog for the user to choose a file. Returns the chosen path, or null
1974 protected String openFileChooser(boolean forFolder)
1976 String choice = null;
1977 JFileChooser chooser = new JFileChooser();
1979 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1980 // hidden executables within .app dirs
1981 if (Platform.isMac())
1983 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1989 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1992 // chooser.setFileView(new JalviewFileView());
1993 chooser.setDialogTitle(
1994 MessageManager.getString("label.open_local_file"));
1995 chooser.setToolTipText(MessageManager.getString("action.open"));
1997 int value = chooser.showOpenDialog(this);
1999 if (value == JFileChooser.APPROVE_OPTION)
2001 choice = chooser.getSelectedFile().getPath();
2007 * Validate the structure tab preferences; if invalid, set focus on this tab.
2011 protected boolean validateStructure(FocusEvent e)
2013 if (!validateStructure())
2015 e.getComponent().requestFocusInWindow();
2021 protected boolean validateStructure()
2027 * Initialises the Visual tabbed panel.
2031 private JPanel initVisualTab()
2033 JPanel visualTab = new JPanel();
2034 visualTab.setBorder(new TitledBorder(
2035 MessageManager.getString("action.open_new_alignment")));
2036 visualTab.setLayout(null);
2037 fullScreen.setFont(LABEL_FONT);
2038 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
2039 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
2040 fullScreen.setText(MessageManager.getString("label.maximize_window"));
2041 quality.setEnabled(false);
2042 quality.setFont(LABEL_FONT);
2043 quality.setHorizontalAlignment(SwingConstants.RIGHT);
2044 quality.setHorizontalTextPosition(SwingConstants.LEFT);
2045 quality.setSelected(true);
2046 quality.setText(MessageManager.getString("label.quality"));
2047 conservation.setEnabled(false);
2048 conservation.setFont(LABEL_FONT);
2049 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
2050 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
2051 conservation.setSelected(true);
2052 conservation.setText(MessageManager.getString("label.conservation"));
2053 identity.setEnabled(false);
2054 identity.setFont(LABEL_FONT);
2055 identity.setHorizontalAlignment(SwingConstants.RIGHT);
2056 identity.setHorizontalTextPosition(SwingConstants.LEFT);
2057 identity.setSelected(true);
2058 identity.setText(MessageManager.getString("label.consensus"));
2059 showOccupancy.setFont(LABEL_FONT);
2060 showOccupancy.setEnabled(false);
2061 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
2062 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
2063 showOccupancy.setSelected(true);
2064 showOccupancy.setText(MessageManager.getString("label.occupancy"));
2066 JLabel showGroupbits = new JLabel();
2067 showGroupbits.setFont(LABEL_FONT);
2068 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
2069 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
2071 .setText(MessageManager.getString("action.show_group") + ":");
2072 JLabel showConsensbits = new JLabel();
2073 showConsensbits.setFont(LABEL_FONT);
2074 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
2075 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
2077 .setText(MessageManager.getString("label.consensus") + ":");
2078 showConsensHistogram.setEnabled(false);
2079 showConsensHistogram.setFont(LABEL_FONT);
2080 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
2081 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
2082 showConsensHistogram.setSelected(true);
2083 showConsensHistogram
2084 .setText(MessageManager.getString("label.histogram"));
2085 showConsensLogo.setEnabled(false);
2086 showConsensLogo.setFont(LABEL_FONT);
2087 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
2088 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
2089 showConsensLogo.setSelected(true);
2090 showConsensLogo.setText(MessageManager.getString("label.logo"));
2091 showGroupConsensus.setEnabled(false);
2092 showGroupConsensus.setFont(LABEL_FONT);
2093 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2094 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2095 showGroupConsensus.setSelected(true);
2096 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
2097 showGroupConservation.setEnabled(false);
2098 showGroupConservation.setFont(LABEL_FONT);
2099 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
2100 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
2101 showGroupConservation.setSelected(true);
2102 showGroupConservation
2103 .setText(MessageManager.getString("label.conservation"));
2104 showNpTooltip.setEnabled(true);
2105 showNpTooltip.setFont(LABEL_FONT);
2106 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2107 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2108 showNpTooltip.setSelected(true);
2109 showNpTooltip.setText(
2110 MessageManager.getString("label.non_positional_features"));
2111 showDbRefTooltip.setEnabled(true);
2112 showDbRefTooltip.setFont(LABEL_FONT);
2113 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2114 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2115 showDbRefTooltip.setSelected(true);
2117 .setText(MessageManager.getString("label.database_references"));
2118 annotations.setFont(LABEL_FONT);
2119 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
2120 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
2121 annotations.setSelected(true);
2122 annotations.setText(MessageManager.getString("label.show_annotations"));
2123 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
2124 annotations.addActionListener(new ActionListener()
2127 public void actionPerformed(ActionEvent e)
2129 annotations_actionPerformed(e);
2132 identity.addActionListener(new ActionListener()
2135 public void actionPerformed(ActionEvent e)
2137 annotations_actionPerformed(e);
2140 showGroupConsensus.addActionListener(new ActionListener()
2143 public void actionPerformed(ActionEvent e)
2145 annotations_actionPerformed(e);
2148 showUnconserved.setFont(LABEL_FONT);
2149 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2150 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2151 showUnconserved.setSelected(true);
2153 .setText(MessageManager.getString("action.show_unconserved"));
2154 showUnconserved.addActionListener(new ActionListener()
2157 public void actionPerformed(ActionEvent e)
2159 showunconserved_actionPerformed(e);
2163 // TODO these are not yet added to / action from Preferences
2164 // JCheckBox shareSelections = new JCheckBox();
2165 // shareSelections.setFont(verdana11);
2166 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2167 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2168 // shareSelections.setSelected(true);
2169 // shareSelections.setText(MessageManager
2170 // .getString("label.share_selection_across_views"));
2171 // JCheckBox followHighlight = new JCheckBox();
2172 // followHighlight.setFont(verdana11);
2173 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2174 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2175 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2176 // followHighlight.setSelected(true);
2177 // followHighlight.setText(MessageManager
2178 // .getString("label.scroll_highlighted_regions"));
2180 seqLimit.setFont(LABEL_FONT);
2181 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2182 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2183 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2184 smoothFont.setFont(LABEL_FONT);
2185 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2186 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2187 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2188 scaleProteinToCdna.setFont(LABEL_FONT);
2189 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2190 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2191 scaleProteinToCdna.setText(
2192 MessageManager.getString("label.scale_protein_to_cdna"));
2193 scaleProteinToCdna.setToolTipText(
2194 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2195 JLabel gapLabel = new JLabel();
2196 gapLabel.setFont(LABEL_FONT);
2197 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2198 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2199 JLabel fontLabel = new JLabel();
2200 fontLabel.setFont(LABEL_FONT);
2201 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2202 fontLabel.setText(MessageManager.getString("label.font"));
2203 fontSizeCB.setFont(LABEL_FONT);
2204 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2205 fontStyleCB.setFont(LABEL_FONT);
2206 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2207 fontNameCB.setFont(LABEL_FONT);
2208 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2209 gapSymbolCB.setFont(LABEL_FONT);
2210 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2211 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2212 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2213 gapSymbolCB.setRenderer(dlcr);
2215 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2216 startupCheckbox.setFont(LABEL_FONT);
2217 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2218 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2219 startupCheckbox.setSelected(true);
2220 startupFileTextfield.setFont(LABEL_FONT);
2221 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2222 final String tooltip = JvSwingUtils.wrapTooltip(true,
2223 MessageManager.getString("label.double_click_to_browse"));
2224 startupFileTextfield.setToolTipText(tooltip);
2225 startupFileTextfield.addMouseListener(new MouseAdapter()
2228 public void mouseClicked(MouseEvent e)
2230 if (e.getClickCount() > 1)
2232 startupFileTextfield_mouseClicked();
2237 sortby.setFont(LABEL_FONT);
2238 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2239 JLabel sortLabel = new JLabel();
2240 sortLabel.setFont(LABEL_FONT);
2241 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2242 sortLabel.setText(MessageManager.getString("label.sort_by"));
2243 sortAnnBy.setFont(LABEL_FONT);
2244 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2245 JLabel sortAnnLabel = new JLabel();
2246 sortAnnLabel.setFont(LABEL_FONT);
2247 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2248 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2249 sortAutocalc.setFont(LABEL_FONT);
2250 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2252 JPanel annsettingsPanel = new JPanel();
2253 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2254 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2255 annsettingsPanel.setBorder(new EtchedBorder());
2256 visualTab.add(annsettingsPanel);
2257 Border jb = new EmptyBorder(1, 1, 4, 5);
2258 annotations.setBorder(jb);
2259 showOccupancy.setBorder(jb);
2260 quality.setBorder(jb);
2261 conservation.setBorder(jb);
2262 identity.setBorder(jb);
2263 showConsensbits.setBorder(jb);
2264 showGroupbits.setBorder(jb);
2265 showGroupConsensus.setBorder(jb);
2266 showGroupConservation.setBorder(jb);
2267 showConsensHistogram.setBorder(jb);
2268 showConsensLogo.setBorder(jb);
2270 JPanel autoAnnotSettings = new JPanel();
2271 annsettingsPanel.add(autoAnnotSettings);
2272 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2273 autoAnnotSettings.add(annotations);
2274 autoAnnotSettings.add(quality);
2275 // second row of autoannotation box
2276 autoAnnotSettings = new JPanel();
2277 annsettingsPanel.add(autoAnnotSettings);
2279 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2280 autoAnnotSettings.add(conservation);
2281 autoAnnotSettings.add(identity);
2282 autoAnnotSettings.add(showOccupancy);
2283 autoAnnotSettings.add(showGroupbits);
2284 autoAnnotSettings.add(showGroupConservation);
2285 autoAnnotSettings.add(showGroupConsensus);
2286 autoAnnotSettings.add(showConsensbits);
2287 autoAnnotSettings.add(showConsensHistogram);
2288 autoAnnotSettings.add(showConsensLogo);
2290 JPanel tooltipSettings = new JPanel();
2291 tooltipSettings.setBorder(new TitledBorder(
2292 MessageManager.getString("label.sequence_id_tooltip")));
2293 tooltipSettings.setBounds(173, 140, 220, 62);
2294 tooltipSettings.setLayout(new GridLayout(2, 1));
2295 tooltipSettings.add(showDbRefTooltip);
2296 tooltipSettings.add(showNpTooltip);
2297 visualTab.add(tooltipSettings);
2299 wrap.setFont(LABEL_FONT);
2300 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2301 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2302 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2303 rightAlign.setFont(LABEL_FONT);
2304 rightAlign.setForeground(Color.black);
2305 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2306 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2307 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2308 idItalics.setFont(LABEL_FONT_ITALIC);
2309 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2310 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2312 MessageManager.getString("label.sequence_name_italics"));
2313 openoverv.setFont(LABEL_FONT);
2314 openoverv.setActionCommand(
2315 MessageManager.getString("label.open_overview"));
2316 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2317 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2318 openoverv.setText(MessageManager.getString("label.open_overview"));
2319 JPanel jPanel2 = new JPanel();
2320 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2321 jPanel2.setLayout(new GridLayout(14, 1));
2322 jPanel2.add(fullScreen);
2323 jPanel2.add(openoverv);
2324 jPanel2.add(seqLimit);
2325 jPanel2.add(rightAlign);
2326 jPanel2.add(fontLabel);
2327 jPanel2.add(showUnconserved);
2328 jPanel2.add(idItalics);
2329 jPanel2.add(smoothFont);
2330 jPanel2.add(scaleProteinToCdna);
2331 jPanel2.add(gapLabel);
2333 jPanel2.add(sortLabel);
2334 jPanel2.add(sortAnnLabel);
2335 jPanel2.add(startupCheckbox);
2336 visualTab.add(jPanel2);
2337 visualTab.add(startupFileTextfield);
2338 visualTab.add(sortby);
2339 visualTab.add(sortAnnBy);
2340 visualTab.add(sortAutocalc);
2341 visualTab.add(gapSymbolCB);
2342 visualTab.add(fontNameCB);
2343 visualTab.add(fontSizeCB);
2344 visualTab.add(fontStyleCB);
2346 if (Platform.isJS())
2348 startupCheckbox.setVisible(false);
2349 startupFileTextfield.setVisible(false);
2356 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2359 protected void loadLastSavedBackupsOptions()
2361 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2362 .getSavedBackupEntry();
2364 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2366 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2367 .createBackupFilesPresetEntry(Cache
2368 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2369 if (backupfilesCustomEntry == null)
2371 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2372 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2374 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2375 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2376 backupfilesCustomEntry);
2378 setComboIntStringKey(backupfilesPresetsCombo,
2379 Cache.getDefault(BackupFiles.NS + "_PRESET",
2380 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2382 backupsSetOptions(savedPreset);
2384 backupsOptionsSetEnabled();
2385 updateBackupFilesExampleLabel();
2388 private boolean warnAboutSuffixReverseChange()
2390 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2391 .getSavedBackupEntry();
2392 boolean savedSuffixReverse = bfpe.reverse;
2393 int savedSuffixDigits = bfpe.digits;
2394 String savedSuffixTemplate = bfpe.suffix;
2396 boolean nowSuffixReverse = suffixReverse.isSelected();
2397 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2398 String nowSuffixTemplate = suffixTemplate.getText();
2399 return nowSuffixReverse != savedSuffixReverse
2400 && nowSuffixDigits == savedSuffixDigits
2401 && nowSuffixTemplate != null
2402 && nowSuffixTemplate.equals(savedSuffixTemplate);
2406 * Initialises the Backups tabbed panel.
2410 private JPanel initBackupsTab()
2412 JPanel backupsTab = new JPanel();
2413 backupsTab.setBorder(new TitledBorder(
2414 MessageManager.getString("label.backup_files")));
2415 backupsTab.setLayout(new GridBagLayout());
2417 GridBagConstraints gbc = new GridBagConstraints();
2420 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2421 gbc.fill = GridBagConstraints.NONE;
2423 initBackupsTabPresetsPanel();
2424 initBackupsTabSuffixPanel();
2425 initBackupsTabKeepFilesPanel();
2426 initBackupsTabFilenameExamplesPanel();
2428 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2430 .setText(MessageManager.getString("label.enable_backupfiles"));
2431 enableBackupFiles.addActionListener(new ActionListener()
2434 public void actionPerformed(ActionEvent e)
2436 // enable other options only when the first is checked
2437 backupsOptionsSetEnabled();
2442 // enable checkbox 1 col
2446 gbc.gridy = 0; // row 0
2447 backupsTab.add(enableBackupFiles, gbc);
2449 // summary of scheme box (over two rows)
2453 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2454 gbc.fill = GridBagConstraints.BOTH;
2455 backupsTab.add(exampleFilesPanel, gbc);
2457 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2458 gbc.fill = GridBagConstraints.NONE;
2460 // fill empty space on right
2463 backupsTab.add(new JPanel(), gbc);
2468 gbc.gridy++; // row 1
2469 backupsTab.add(presetsPanel, gbc);
2471 // now using whole row
2476 gbc.gridy++; // row 2
2477 backupsTab.add(keepfilesPanel, gbc);
2479 // filename strategy box
2480 gbc.gridy++; // row 3
2481 backupsTab.add(suffixPanel, gbc);
2484 gbc.gridy++; // row 4
2486 backupsTab.add(new JPanel(), gbc);
2488 backupsOptionsSetEnabled();
2492 private JPanel initBackupsTabPresetsPanel()
2495 String title = MessageManager.getString("label.schemes");
2497 presetsPanel.setLayout(new GridBagLayout());
2499 GridBagConstraints gbc = new GridBagConstraints();
2502 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2503 gbc.fill = GridBagConstraints.NONE;
2511 presetsComboLabel = new JLabel(title + ":");
2512 presetsPanel.add(presetsComboLabel, gbc);
2514 List<Object> entries = Arrays
2515 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2516 List<String> tooltips = Arrays.asList(
2517 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2518 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2521 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2523 backupfilesPresetsCombo
2524 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2528 backupfilesPresetsCombo.addActionListener(new ActionListener()
2531 public void actionPerformed(ActionEvent e)
2533 int key = getComboIntStringKey(backupfilesPresetsCombo);
2534 if (!customiseCheckbox.isSelected())
2536 backupfilesPresetsComboLastSelected = key;
2538 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2540 if (customiseCheckbox.isSelected())
2542 // got here by clicking on customiseCheckbox so don't change the values
2543 backupfilesCustomOptionsSetEnabled();
2547 backupsTabUpdatePresets();
2548 backupfilesCustomOptionsSetEnabled();
2553 customiseCheckbox.setSelected(false);
2554 backupsTabUpdatePresets();
2555 backupfilesCustomOptionsSetEnabled();
2560 // dropdown list of preset schemes
2562 presetsPanel.add(backupfilesPresetsCombo, gbc);
2564 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2565 revertButton.setToolTipText(
2566 MessageManager.getString("label.cancel_changes_description"));
2567 revertButton.addActionListener(new ActionListener()
2570 public void actionPerformed(ActionEvent e)
2573 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2574 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2575 backupfilesCustomOptionsSetEnabled();
2579 revertButton.setFont(LABEL_FONT);
2581 customiseCheckbox.setFont(LABEL_FONT);
2582 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2583 customiseCheckbox.addActionListener(new ActionListener()
2586 public void actionPerformed(ActionEvent e)
2588 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2589 if (customiseCheckbox.isSelected())
2591 backupfilesPresetsComboLastSelected = currently;
2592 setComboIntStringKey(backupfilesPresetsCombo,
2593 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2597 setComboIntStringKey(backupfilesPresetsCombo,
2598 backupfilesPresetsComboLastSelected);
2601 backupfilesCustomOptionsSetEnabled();
2604 customiseCheckbox.setToolTipText(
2605 MessageManager.getString("label.customise_description"));
2607 // customise checkbox
2610 presetsPanel.add(customiseCheckbox, gbc);
2612 // "Cancel changes" button (aligned with combo box above)
2614 presetsPanel.add(revertButton, gbc);
2616 return presetsPanel;
2619 private JPanel initBackupsTabFilenameExamplesPanel()
2621 String title = MessageManager
2622 .getString("label.scheme_examples");
2623 TitledBorder tb = new TitledBorder(title);
2624 exampleFilesPanel.setBorder(tb);
2625 exampleFilesPanel.setLayout(new GridBagLayout());
2628 backupfilesExampleLabel.setEditable(false);
2629 backupfilesExampleLabel
2630 .setBackground(exampleFilesPanel.getBackground());
2632 updateBackupFilesExampleLabel();
2634 GridBagConstraints gbc = new GridBagConstraints();
2637 gbc.fill = GridBagConstraints.NONE;
2638 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2640 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2641 return exampleFilesPanel;
2644 private void backupsTabUpdatePresets()
2646 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2649 String value = entry.v;
2651 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2655 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2661 "Preset '" + value + "' [key:" + key + "] not implemented");
2664 // Custom options will now be enabled when the customiseCheckbox is checked
2665 // (performed above)
2666 // backupfilesCustomOptionsSetEnabled();
2667 updateBackupFilesExampleLabel();
2670 protected int getComboIntStringKey(
2671 JComboBox<Object> backupfilesPresetsCombo2)
2673 IntKeyStringValueEntry e;
2676 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2678 } catch (Exception ex)
2681 "Problem casting Combo entry to IntKeyStringValueEntry.");
2684 return e != null ? e.k : 0;
2687 protected void setComboIntStringKey(
2688 JComboBox<Object> backupfilesPresetsCombo2,
2691 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2693 IntKeyStringValueEntry e;
2696 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2697 } catch (Exception ex)
2700 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2705 backupfilesPresetsCombo2.setSelectedIndex(i);
2709 // backupsTabUpdatePresets();
2712 private JPanel initBackupsTabSuffixPanel()
2714 suffixPanel.setBorder(new TitledBorder(
2715 MessageManager.getString("label.backup_filename_strategy")));
2716 suffixPanel.setLayout(new GridBagLayout());
2719 .setText(MessageManager.getString("label.append_to_filename"));
2720 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2721 suffixTemplateLabel.setFont(LABEL_FONT);
2723 final String tooltip = JvSwingUtils.wrapTooltip(true,
2724 MessageManager.getString("label.append_to_filename_tooltip"));
2725 suffixTemplate.setToolTipText(tooltip);
2726 suffixTemplate.addActionListener(new ActionListener()
2729 public void actionPerformed(ActionEvent e)
2731 updateBackupFilesExampleLabel();
2732 backupfilesCustomOptionsSetEnabled();
2733 backupfilesRevertButtonSetEnabled(true);
2737 suffixTemplate.addKeyListener(new KeyListener()
2740 public void keyReleased(KeyEvent e)
2742 updateBackupFilesExampleLabel();
2743 backupfilesCustomOptionsSetEnabled();
2744 backupfilesRevertButtonSetEnabled(true);
2748 public void keyPressed(KeyEvent e)
2752 // disable use of ':' or '/' or '\'
2754 public void keyTyped(KeyEvent e)
2756 char c = e.getKeyChar();
2757 if (c == ':' || c == '/' || c == '\\')
2759 // don't process ':' or '/' or '\'
2768 .setText(MessageManager.getString("label.index_digits"));
2769 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2770 suffixDigitsLabel.setFont(LABEL_FONT);
2771 ChangeListener c = new ChangeListener()
2774 public void stateChanged(ChangeEvent e)
2776 backupfilesRevertButtonSetEnabled(true);
2777 updateBackupFilesExampleLabel();
2781 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2782 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2784 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2785 MessageManager.getString("label.increment_index"));
2786 suffixReverse.addActionListener(new ActionListener()
2789 public void actionPerformed(ActionEvent e)
2791 boolean okay = true;
2792 if (warnAboutSuffixReverseChange())
2795 okay = confirmSuffixReverseChange();
2799 backupfilesRevertButtonSetEnabled(true);
2800 updateBackupFilesExampleLabel();
2804 boolean savedSuffixReverse = BackupFilesPresetEntry
2805 .getSavedBackupEntry().reverse;
2806 suffixReverse.setSelected(savedSuffixReverse);
2811 GridBagConstraints sgbc = new GridBagConstraints();
2813 // first row (template text box)
2814 sgbc.anchor = GridBagConstraints.WEST;
2818 sgbc.gridheight = 1;
2821 sgbc.fill = GridBagConstraints.NONE;
2822 suffixPanel.add(suffixTemplateLabel, sgbc);
2825 sgbc.fill = GridBagConstraints.HORIZONTAL;
2826 suffixPanel.add(suffixTemplate, sgbc);
2828 // second row (number of digits spinner)
2832 sgbc.fill = GridBagConstraints.NONE;
2833 suffixPanel.add(suffixDigitsLabel, sgbc);
2836 sgbc.fill = GridBagConstraints.HORIZONTAL;
2837 suffixPanel.add(suffixDigitsSpinner, sgbc);
2839 // third row (forward order radio selection)
2842 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2843 sgbc.fill = GridBagConstraints.HORIZONTAL;
2844 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2846 // fourth row (reverse order radio selection)
2848 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2852 private boolean confirmSuffixReverseChange()
2854 boolean ret = false;
2855 String warningMessage = MessageManager
2856 .getString("label.warning_confirm_change_reverse");
2857 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
2859 MessageManager.getString("label.change_increment_decrement"),
2860 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2862 ret = (confirm == JvOptionPane.YES_OPTION);
2866 private JPanel initBackupsTabKeepFilesPanel()
2868 keepfilesPanel.setBorder(
2869 new TitledBorder(MessageManager.getString("label.keep_files")));
2870 keepfilesPanel.setLayout(new GridBagLayout());
2872 backupfilesKeepAll.setLabels(
2873 MessageManager.getString("label.keep_all_backup_files"),
2874 MessageManager.getString(
2875 "label.keep_only_this_number_of_backup_files"));
2876 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2879 public void actionPerformed(ActionEvent e)
2881 backupfilesRevertButtonSetEnabled(true);
2882 updateBackupFilesExampleLabel();
2885 backupfilesKeepAll.addActionListener(new ActionListener()
2888 public void actionPerformed(ActionEvent e)
2890 backupfilesRevertButtonSetEnabled(true);
2891 keepRollMaxOptionsEnabled();
2892 updateBackupFilesExampleLabel();
2896 ChangeListener c = new ChangeListener()
2899 public void stateChanged(ChangeEvent e)
2901 backupfilesRevertButtonSetEnabled(true);
2902 updateBackupFilesExampleLabel();
2906 setIntegerSpinner(backupfilesRollMaxSpinner,
2907 BackupFilesPresetEntry.ROLLMAXMIN,
2908 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2910 backupfilesConfirmDelete.setLabels(
2911 MessageManager.getString("label.always_ask"),
2912 MessageManager.getString("label.auto_delete"));
2913 backupfilesConfirmDelete.addActionListener(new ActionListener()
2916 public void actionPerformed(ActionEvent e)
2918 backupfilesRevertButtonSetEnabled(true);
2921 // update the enabled section
2922 keepRollMaxOptionsEnabled();
2924 GridBagConstraints kgbc = new GridBagConstraints();
2926 // first row (template text box)
2927 kgbc.anchor = GridBagConstraints.WEST;
2930 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2931 kgbc.gridheight = 1;
2934 kgbc.fill = GridBagConstraints.HORIZONTAL;
2935 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2941 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2942 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2945 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2946 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2948 // third row (indented)
2950 kgbc.insets = new Insets(0, 20, 0, 0);
2953 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2954 kgbc.fill = GridBagConstraints.HORIZONTAL;
2957 JPanel jp = new JPanel();
2958 jp.setLayout(new FlowLayout());
2960 .setText(MessageManager
2961 .getString("label.autodelete_old_backup_files"));
2962 oldBackupFilesLabel.setFont(LABEL_FONT);
2963 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2964 jp.add(oldBackupFilesLabel);
2965 jp.add(backupfilesConfirmDelete.getTrueButton());
2966 jp.add(backupfilesConfirmDelete.getFalseButton());
2967 keepfilesPanel.add(jp, kgbc);
2969 return keepfilesPanel;
2972 protected void updateBackupFilesExampleLabel()
2974 int exampleindex = 12;
2975 String base = MessageManager.getString("label.filename") + ".fa";
2976 if (base == null || base.length() == 0)
2978 base = "file_name.fa";
2981 boolean reverse = suffixReverse.isSelected();
2982 boolean keepAll = backupfilesKeepAll.isSelected();
2984 String suffix = suffixTemplate.getText();
2987 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2988 if (suffix == null || suffix.length() == 0)
2990 backupfilesExampleLabel
2991 .setText(MessageManager.getString("label.no_backup_files"));
2992 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2996 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2997 rollMax = rollMax < 1 ? 1 : rollMax;
2999 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3004 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3005 digits = digits < 1 ? 1 : digits;
3007 int lowersurround = 2;
3008 int uppersurround = 0;
3009 StringBuilder exampleSB = new StringBuilder();
3010 boolean firstLine = true;
3016 int max = keepAll ? exampleindex : rollMax;
3017 for (int index = min; index <= max; index++)
3019 if (index == min + lowersurround && index < max - uppersurround - 1)
3021 exampleSB.append("\n...");
3024 else if (index > min + lowersurround && index < max - uppersurround)
3036 exampleSB.append("\n");
3039 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3040 base, suffix, digits));
3043 // no extra text needed
3045 else if (index == min)
3047 String newest = MessageManager.getString("label.braced_newest");
3048 if (newest != null && newest.length() > 0)
3050 exampleSB.append(" " + newest);
3053 else if (index == max)
3055 String oldest = MessageManager.getString("label.braced_oldest");
3056 if (oldest != null && oldest.length() > 0)
3058 exampleSB.append(" " + oldest);
3067 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3068 : exampleindex - rollMax + 1;
3069 int max = exampleindex;
3071 for (int index = min; index <= max; index++)
3074 if (index == min + lowersurround && index < max - uppersurround - 1)
3076 exampleSB.append("\n...");
3079 else if (index > min + lowersurround && index < max - uppersurround)
3091 exampleSB.append("\n");
3094 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3095 base, suffix, digits));
3098 // no extra text needed
3100 else if (index == min)
3102 String oldest = MessageManager.getString("label.braced_oldest");
3103 if (oldest != null && oldest.length() > 0)
3105 exampleSB.append(" " + oldest);
3108 else if (index == max)
3110 String newest = MessageManager.getString("label.braced_newest");
3111 if (newest != null && newest.length() > 0)
3113 exampleSB.append(" " + newest);
3121 // add some extra empty lines to pad out the example files box. ugh, please tell
3122 // me how to do this better
3123 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3124 if (remainingLines > 0)
3126 for (int i = 0; i < remainingLines; i++)
3128 exampleSB.append("\n ");
3133 backupfilesExampleLabel.setText(exampleSB.toString());
3136 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3137 boolean useExistingVal, ChangeListener c)
3144 i = ((Integer) s.getValue()).intValue();
3145 } catch (Exception e)
3148 "Exception casting the initial value of s.getValue()");
3152 setIntegerSpinner(s, min, max, i, c);
3155 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3158 // integer spinner for number of digits
3167 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3170 s.addChangeListener(c);
3174 protected static int getSpinnerInt(JSpinner s, int def)
3180 i = (Integer) s.getValue();
3181 } catch (Exception e)
3183 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
3188 private void keepRollMaxOptionsEnabled()
3190 boolean enabled = backupfilesKeepAll.isEnabled()
3191 && !backupfilesKeepAll.isSelected();
3192 oldBackupFilesLabel.setEnabled(enabled);
3193 backupfilesRollMaxSpinner.setEnabled(enabled);
3194 backupfilesConfirmDelete.setEnabled(enabled);
3197 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3199 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3200 && customiseCheckbox.isSelected()
3201 && suffixTemplate.getText()
3202 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3203 keepfilesPanel.setEnabled(enabled);
3204 backupfilesKeepAll.setEnabled(enabled);
3205 oldBackupFilesLabel.setEnabled(enabled);
3206 keepRollMaxOptionsEnabled();
3209 private void backupfilesSuffixTemplateDigitsSetEnabled()
3211 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3212 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3213 suffixDigitsLabel.setEnabled(enabled);
3214 suffixDigitsSpinner.setEnabled(enabled);
3215 suffixReverse.setEnabled(enabled);
3218 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3220 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3221 && customiseCheckbox.isSelected();
3222 suffixPanel.setEnabled(enabled);
3223 suffixTemplateLabel.setEnabled(enabled);
3224 suffixTemplate.setEnabled(enabled);
3225 backupfilesSuffixTemplateDigitsSetEnabled();
3228 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3230 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3231 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3232 revertButton.setEnabled(enabled);
3235 private boolean backupfilesCustomChanged()
3237 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3238 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3239 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3240 return !custom.equals(current);
3243 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3245 String suffix = suffixTemplate.getText();
3246 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3247 boolean reverse = suffixReverse.isSelected();
3248 boolean keepAll = backupfilesKeepAll.isSelected();
3249 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3250 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3252 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3253 reverse, keepAll, rollMax, confirmDelete);
3258 protected void backupfilesCustomOptionsSetEnabled()
3260 boolean enabled = customiseCheckbox.isSelected();
3262 backupfilesRevertButtonSetEnabled(enabled);
3263 backupfilesSuffixTemplateSetEnabled(enabled);
3264 backupfilesKeepAllSetEnabled(enabled);
3267 private void backupfilesSummarySetEnabled()
3269 boolean enabled = enableBackupFiles.isSelected();
3270 backupfilesExampleLabel.setEnabled(enabled);
3271 exampleFilesPanel.setEnabled(enabled);
3274 private void backupfilesPresetsSetEnabled()
3276 boolean enabled = enableBackupFiles.isSelected();
3277 presetsPanel.setEnabled(enabled);
3278 presetsComboLabel.setEnabled(enabled);
3279 backupfilesPresetsCombo.setEnabled(enabled);
3280 customiseCheckbox.setEnabled(enabled);
3281 revertButton.setEnabled(enabled);
3284 protected void backupsOptionsSetEnabled()
3286 backupfilesPresetsSetEnabled();
3287 backupfilesSummarySetEnabled();
3288 backupfilesCustomOptionsSetEnabled();
3291 protected void backupsSetOptions(String suffix, int digits,
3292 boolean reverse, boolean keepAll, int rollMax,
3293 boolean confirmDelete)
3295 suffixTemplate.setText(suffix);
3296 suffixDigitsSpinner.setValue(digits);
3297 suffixReverse.setSelected(reverse);
3298 backupfilesKeepAll.setSelected(keepAll);
3299 backupfilesRollMaxSpinner.setValue(rollMax);
3300 backupfilesConfirmDelete.setSelected(confirmDelete);
3303 protected void backupsSetOptions(BackupFilesPresetEntry p)
3305 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3309 protected void autoIdWidth_actionPerformed()
3311 // TODO Auto-generated method stub
3315 protected void userIdWidth_actionPerformed()
3317 // TODO Auto-generated method stub
3321 protected void maxColour_actionPerformed(JPanel panel)
3325 protected void minColour_actionPerformed(JPanel panel)
3329 protected void gapColour_actionPerformed(JPanel panel)
3333 protected void hiddenColour_actionPerformed(JPanel panel)
3337 protected void showunconserved_actionPerformed(ActionEvent e)
3339 // TODO Auto-generated method stub
3343 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3347 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3357 public void ok_actionPerformed(ActionEvent e)
3367 public void cancel_actionPerformed(ActionEvent e)
3377 public void annotations_actionPerformed(ActionEvent e)
3384 public void startupFileTextfield_mouseClicked()
3388 public void newLink_actionPerformed(ActionEvent e)
3393 public void editLink_actionPerformed(ActionEvent e)
3398 public void deleteLink_actionPerformed(ActionEvent e)
3403 public void defaultBrowser_mouseClicked(MouseEvent e)
3408 public void linkURLList_keyTyped(KeyEvent e)
3413 public void setProxyAuthEnabled()
3415 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3416 proxyAuthUsernameLabel.setEnabled(enabled);
3417 proxyAuthPasswordLabel.setEnabled(enabled);
3418 passwordNotStoredLabel.setEnabled(enabled);
3419 proxyAuthUsernameTB.setEnabled(enabled);
3420 proxyAuthPasswordPB.setEnabled(enabled);
3423 public void setCustomProxyEnabled()
3425 boolean enabled = customProxy.isSelected();
3426 portLabel.setEnabled(enabled);
3427 serverLabel.setEnabled(enabled);
3428 portLabel2.setEnabled(enabled);
3429 serverLabel2.setEnabled(enabled);
3430 httpLabel.setEnabled(enabled);
3431 httpsLabel.setEnabled(enabled);
3432 proxyServerHttpTB.setEnabled(enabled);
3433 proxyPortHttpTB.setEnabled(enabled);
3434 proxyServerHttpsTB.setEnabled(enabled);
3435 proxyPortHttpsTB.setEnabled(enabled);
3436 proxyAuth.setEnabled(enabled);
3437 setProxyAuthEnabled();
3440 public void proxyType_actionPerformed()
3442 setCustomProxyEnabled();
3443 proxyAuthPasswordCheckHighlight(true);
3444 applyProxyButtonEnabled(true);
3447 public void proxyAuth_actionPerformed()
3449 setProxyAuthEnabled();
3450 proxyAuthPasswordCheckHighlight(true);
3451 applyProxyButtonEnabled(true);
3455 * Customer renderer for JTable: supports column of radio buttons
3457 public class RadioButtonRenderer extends JRadioButton
3458 implements TableCellRenderer
3460 public RadioButtonRenderer()
3462 setHorizontalAlignment(CENTER);
3463 setToolTipText(MessageManager.getString("label.urltooltip"));
3467 public Component getTableCellRendererComponent(JTable table,
3468 Object value, boolean isSelected, boolean hasFocus, int row,
3471 setSelected((boolean) value);
3473 // set colours to match rest of table
3476 setBackground(table.getSelectionBackground());
3477 setForeground(table.getSelectionForeground());
3481 setBackground(table.getBackground());
3482 setForeground(table.getForeground());
3489 * Customer cell editor for JTable: supports column of radio buttons in
3490 * conjunction with renderer
3492 public class RadioButtonEditor extends AbstractCellEditor
3493 implements TableCellEditor
3495 private JRadioButton button = new JRadioButton();
3497 public RadioButtonEditor()
3499 button.setHorizontalAlignment(SwingConstants.CENTER);
3500 this.button.addActionListener(new ActionListener()
3503 public void actionPerformed(ActionEvent e)
3505 fireEditingStopped();
3511 public Component getTableCellEditorComponent(JTable table, Object value,
3512 boolean isSelected, int row, int column)
3514 button.setSelected((boolean) value);
3519 public Object getCellEditorValue()
3521 return button.isSelected();
3526 protected void validateHmmerPath()
3530 protected void validateCygwinPath()
3535 * A helper method to add a panel containing a label and a component to a
3543 protected static void addtoLayout(JPanel panel, String tooltip,
3544 JComponent label, JComponent valBox)
3546 JPanel laypanel = new JPanel(new GridLayout(1, 2));
3547 JPanel labPanel = new JPanel(new BorderLayout());
3548 JPanel valPanel = new JPanel();
3549 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
3550 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
3551 labPanel.add(label, BorderLayout.WEST);
3552 valPanel.add(valBox);
3553 laypanel.add(labPanel);
3554 laypanel.add(valPanel);
3555 valPanel.setToolTipText(tooltip);
3556 labPanel.setToolTipText(tooltip);
3557 valBox.setToolTipText(tooltip);
3558 panel.add(laypanel);