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"));
473 slivkaTab.setLayout(new BorderLayout());
474 tabbedPane.add(slivkaTab, "Slivka Services");
478 * Handler to validate a tab before leaving it - currently only for
480 * Adding a clearMessage() so messages are cleared when changing tabs.
482 tabbedPane.addChangeListener(new ChangeListener()
484 private Component lastTab;
487 public void stateChanged(ChangeEvent e)
489 if (lastTab == structureTab
490 && tabbedPane.getSelectedComponent() != structureTab)
492 if (!validateStructure())
494 tabbedPane.setSelectedComponent(structureTab);
498 lastTab = tabbedPane.getSelectedComponent();
505 public void setMessage(String message)
509 messageLabel.setText(message);
510 messageLabel.setFont(LABEL_FONT_BOLD);
511 messageLabel.setForeground(Color.RED.darker());
512 messageLabel.revalidate();
513 messageLabel.repaint();
515 // note message not cleared if message is null. call clearMessage()
521 public void clearMessage()
523 // only repaint if message exists
524 if (messageLabel.getText() != null
525 && messageLabel.getText().length() > 0)
527 messageLabel.setText("");
528 messageLabel.revalidate();
529 messageLabel.repaint();
535 public static enum TabRef
537 CONNECTIONS_TAB, STRUCTURE_TAB
540 public void selectTab(TabRef selectTab)
542 // select a given tab - currently only for Connections
545 case CONNECTIONS_TAB:
546 tabbedPane.setSelectedComponent(connectTab);
549 tabbedPane.setSelectedComponent(structureTab);
556 * Initialises the Editing tabbed panel.
560 private JPanel initEditingTab()
562 JPanel editingTab = new JPanel();
563 editingTab.setLayout(null);
564 autoCalculateConsCheck.setFont(LABEL_FONT);
565 autoCalculateConsCheck.setText(
566 MessageManager.getString("label.autocalculate_consensus"));
567 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
568 padGaps.setFont(LABEL_FONT);
570 MessageManager.getString("label.pad_gaps_when_editing"));
571 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
572 sortByTree.setFont(LABEL_FONT);
574 .setText(MessageManager.getString("label.sort_with_new_tree"));
575 sortByTree.setToolTipText(MessageManager.getString(
576 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
577 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
578 editingTab.add(autoCalculateConsCheck);
579 editingTab.add(padGaps);
580 editingTab.add(sortByTree);
585 * Initialises the hmmer tabbed panel
589 private JPanel initHMMERTab()
591 hmmerTab = new JPanel();
592 hmmerTab.setLayout(new BoxLayout(hmmerTab, BoxLayout.Y_AXIS));
593 hmmerTab.setLayout(new MigLayout("flowy"));
596 * path to hmmer binaries folder
598 JPanel installationPanel = new JPanel(new MigLayout("flowy"));
599 // new FlowLayout(FlowLayout.LEFT));
600 JvSwingUtils.createTitledBorder(installationPanel,
601 MessageManager.getString("label.installation"), true);
602 hmmerTab.add(installationPanel);
603 JLabel hmmerLocation = new JLabel(
604 MessageManager.getString("label.hmmer_location"));
605 hmmerLocation.setFont(LABEL_FONT);
606 final int pathFieldLength = 40;
607 hmmerPath = new JTextField(pathFieldLength);
608 hmmerPath.addMouseListener(new MouseAdapter()
611 public void mouseClicked(MouseEvent e)
613 if (e.getClickCount() == 2)
615 String chosen = openFileChooser(true);
618 hmmerPath.setText(chosen);
624 installationPanel.add(hmmerLocation);
625 installationPanel.add(hmmerPath);
628 * path to Cygwin binaries folder (for Windows)
630 if (Platform.isWindowsAndNotJS())
632 JLabel cygwinLocation = new JLabel(
633 MessageManager.getString("label.cygwin_location"));
634 cygwinLocation.setFont(LABEL_FONT);
635 cygwinPath = new JTextField(pathFieldLength);
636 cygwinPath.addMouseListener(new MouseAdapter()
639 public void mouseClicked(MouseEvent e)
641 if (e.getClickCount() == 2)
643 String chosen = openFileChooser(true);
646 cygwinPath.setText(chosen);
647 validateCygwinPath();
652 installationPanel.add(cygwinLocation);
653 installationPanel.add(cygwinPath);
657 * preferences for hmmalign
659 JPanel alignOptionsPanel = new JPanel(new MigLayout());
660 // new FlowLayout(FlowLayout.LEFT));
661 JvSwingUtils.createTitledBorder(alignOptionsPanel,
662 MessageManager.getString("label.hmmalign_options"), true);
663 hmmerTab.add(alignOptionsPanel);
664 hmmrTrimTermini = new JCheckBox();
665 hmmrTrimTermini.setFont(LABEL_FONT);
666 hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
667 alignOptionsPanel.add(hmmrTrimTermini);
670 * preferences for hmmsearch
672 JPanel searchOptions = new JPanel(new MigLayout());
673 // FlowLayout(FlowLayout.LEFT));
674 JvSwingUtils.createTitledBorder(searchOptions,
675 MessageManager.getString("label.hmmsearch_options"), true);
676 hmmerTab.add(searchOptions);
677 JLabel sequencesToKeep = new JLabel(
678 MessageManager.getString("label.no_of_sequences"));
679 sequencesToKeep.setFont(LABEL_FONT);
680 searchOptions.add(sequencesToKeep);
681 hmmerSequenceCount = new JTextField(5);
682 searchOptions.add(hmmerSequenceCount);
685 * preferences for Information Content annotation
687 // JPanel dummy = new JPanel(new FlowLayout(FlowLayout.LEFT));
688 JPanel annotationOptions = new JPanel(new MigLayout("left"));
689 JvSwingUtils.createTitledBorder(annotationOptions,
690 MessageManager.getString("label.information_annotation"), true);
691 // dummy.add(annotationOptions);
692 hmmerTab.add(annotationOptions);
693 ButtonGroup backgroundOptions = new ButtonGroup();
694 hmmerBackgroundUniprot = new JRadioButton(
695 MessageManager.getString("label.freq_uniprot"));
696 hmmerBackgroundUniprot.setFont(LABEL_FONT);
697 hmmerBackgroundAlignment = new JRadioButton(
698 MessageManager.getString("label.freq_alignment"));
699 hmmerBackgroundAlignment.setFont(LABEL_FONT);
700 backgroundOptions.add(hmmerBackgroundUniprot);
701 backgroundOptions.add(hmmerBackgroundAlignment);
702 backgroundOptions.setSelected(hmmerBackgroundUniprot.getModel(), true);
703 // disable buttons for now as annotation only uses Uniprot background
704 hmmerBackgroundAlignment.setEnabled(false);
705 hmmerBackgroundUniprot.setEnabled(false);
706 annotationOptions.add(hmmerBackgroundUniprot, "wrap");
707 annotationOptions.add(hmmerBackgroundAlignment);
713 * Initialises the Output tabbed panel.
717 private JPanel initOutputTab()
719 JPanel outputTab = new JPanel();
720 outputTab.setLayout(null);
722 JLabel epsLabel = new JLabel(
723 MessageManager.formatMessage("label.rendering_style", "EPS"));
724 epsLabel.setFont(LABEL_FONT);
725 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
726 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
727 epsRendering.setFont(LABEL_FONT);
728 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
729 JLabel htmlLabel = new JLabel(
730 MessageManager.formatMessage("label.rendering_style", "HTML"));
731 htmlLabel.setFont(LABEL_FONT);
732 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
733 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
734 htmlRendering.setFont(LABEL_FONT);
735 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
736 JLabel svgLabel = new JLabel(
737 MessageManager.formatMessage("label.rendering_style", "SVG"));
738 svgLabel.setFont(LABEL_FONT);
739 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
740 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
741 svgRendering.setFont(LABEL_FONT);
742 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
744 JLabel jLabel1 = new JLabel();
745 jLabel1.setFont(LABEL_FONT);
746 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
747 jLabel1.setText(MessageManager.getString("label.append_start_end"));
748 jLabel1.setFont(LABEL_FONT);
750 fastajv.setFont(LABEL_FONT);
751 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
752 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
753 blcjv.setText(MessageManager.getString("label.blc") + " ");
754 fastajv.setText(MessageManager.getString("label.fasta") + " ");
755 msfjv.setText(MessageManager.getString("label.msf") + " ");
756 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
757 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
758 msfjv.setFont(LABEL_FONT);
759 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
760 pirjv.setText(MessageManager.getString("label.pir") + " ");
761 JPanel jPanel11 = new JPanel();
762 jPanel11.setFont(LABEL_FONT);
763 TitledBorder titledBorder2 = new TitledBorder(
764 MessageManager.getString("label.file_output"));
765 jPanel11.setBorder(titledBorder2);
766 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
767 GridLayout gridLayout3 = new GridLayout();
768 jPanel11.setLayout(gridLayout3);
769 gridLayout3.setRows(8);
770 blcjv.setFont(LABEL_FONT);
771 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
772 clustaljv.setFont(LABEL_FONT);
773 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
774 pfamjv.setFont(LABEL_FONT);
775 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
776 pileupjv.setFont(LABEL_FONT);
777 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
778 pirjv.setFont(LABEL_FONT);
779 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
780 autoIdWidth.setFont(LABEL_FONT);
782 MessageManager.getString("label.automatically_set_id_width"));
783 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
784 .getString("label.adjusts_width_generated_eps_png")));
785 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
786 autoIdWidth.addActionListener(new ActionListener()
790 public void actionPerformed(ActionEvent e)
792 autoIdWidth_actionPerformed();
795 userIdWidthlabel.setFont(LABEL_FONT);
796 userIdWidthlabel.setText(
797 MessageManager.getString("label.figure_id_column_width"));
798 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
799 .getString("label.manually_specify_width_left_column")));
800 userIdWidthlabel.setToolTipText(
801 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
802 "label.manually_specify_width_left_column")));
803 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
804 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
805 userIdWidth.setText("");
806 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
807 userIdWidth.addActionListener(new ActionListener()
811 public void actionPerformed(ActionEvent e)
813 userIdWidth_actionPerformed();
816 modellerOutput.setFont(LABEL_FONT);
818 .setText(MessageManager.getString("label.use_modeller_output"));
819 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
820 embbedBioJSON.setFont(LABEL_FONT);
821 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
822 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
824 jPanel11.add(jLabel1);
826 jPanel11.add(clustaljv);
827 jPanel11.add(fastajv);
829 jPanel11.add(pfamjv);
830 jPanel11.add(pileupjv);
832 outputTab.add(autoIdWidth);
833 outputTab.add(userIdWidth);
834 outputTab.add(userIdWidthlabel);
835 outputTab.add(modellerOutput);
836 if (!Platform.isJS())
839 * JalviewJS doesn't support Lineart option or SVG output
841 outputTab.add(embbedBioJSON);
842 outputTab.add(epsLabel);
843 outputTab.add(epsRendering);
844 outputTab.add(htmlLabel);
845 outputTab.add(htmlRendering);
846 outputTab.add(svgLabel);
847 outputTab.add(svgRendering);
849 outputTab.add(jPanel11);
854 * Initialises the Connections tabbed panel.
858 private JPanel initConnectionsTab()
860 connectTab = new JPanel();
861 connectTab.setLayout(new GridBagLayout());
863 // Label for browser text box
864 JLabel browserLabel = new JLabel();
865 browserLabel.setFont(LABEL_FONT);
866 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
867 browserLabel.setText(
868 MessageManager.getString("label.default_browser_unix"));
869 defaultBrowser.setFont(LABEL_FONT);
870 defaultBrowser.setText("");
871 final String tooltip = JvSwingUtils.wrapTooltip(true,
872 MessageManager.getString("label.double_click_to_browse"));
873 defaultBrowser.setToolTipText(tooltip);
874 defaultBrowser.addMouseListener(new MouseAdapter()
877 public void mouseClicked(MouseEvent e)
879 if (e.getClickCount() > 1)
881 defaultBrowser_mouseClicked(e);
886 JPanel proxyPanel = initConnTabProxyPanel();
887 initConnTabCheckboxes();
889 // Add default Browser text box
890 connectTab.add(browserLabel,
891 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
892 GridBagConstraints.WEST, GridBagConstraints.NONE,
893 new Insets(10, 0, 5, 5), 5, 1));
894 defaultBrowser.setFont(LABEL_FONT);
895 defaultBrowser.setText("");
897 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
898 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
899 new Insets(10, 0, 5, 10), 30, 1));
901 // Add proxy server panel
902 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
903 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
904 new Insets(10, 0, 5, 12), 4, 10));
906 // Add usage stats, version check and questionnaire checkboxes
907 connectTab.add(usagestats,
908 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
909 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
910 new Insets(0, 2, 5, 5), 70, 1));
911 connectTab.add(questionnaire,
912 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
913 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
914 new Insets(0, 2, 5, 10), 70, 1));
915 connectTab.add(versioncheck,
916 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
917 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
918 new Insets(0, 2, 5, 5), 70, 1));
920 versioncheck.setVisible(false);
922 // Add padding so the panel doesn't look ridiculous
923 JPanel spacePanel = new JPanel();
924 connectTab.add(spacePanel,
925 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
926 GridBagConstraints.WEST, GridBagConstraints.BOTH,
927 new Insets(0, 0, 0, 5), 70, 1));
933 * Initialises the Links tabbed panel.
937 private JPanel initLinksTab()
939 JPanel linkTab = new JPanel();
940 linkTab.setLayout(new GridBagLayout());
942 // Set up table for Url links
943 linkUrlTable.getTableHeader().setReorderingAllowed(false);
944 linkUrlTable.setFillsViewportHeight(true);
945 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
946 linkUrlTable.setAutoCreateRowSorter(true);
947 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
949 // adjust row height so radio buttons actually fit
950 // don't do this in the renderer, it causes the awt thread to activate
952 JRadioButton temp = new JRadioButton();
953 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
955 // Table in scrollpane so that the table is given a scrollbar
956 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
957 linkScrollPane.setBorder(null);
959 // Panel for links functionality
960 JPanel linkPanel = new JPanel(new GridBagLayout());
961 linkPanel.setBorder(new TitledBorder(
962 MessageManager.getString("label.url_linkfrom_sequence_id")));
964 // Put the Url links panel together
966 // Buttons go at top right, resizing only resizes the blank space vertically
967 JPanel buttonPanel = initLinkTabUrlButtons();
968 GridBagConstraints linkConstraints1 = new GridBagConstraints();
969 linkConstraints1.insets = new Insets(0, 0, 5, 0);
970 linkConstraints1.gridx = 0;
971 linkConstraints1.gridy = 0;
972 linkConstraints1.weightx = 1.0;
973 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
974 linkTab.add(buttonPanel, linkConstraints1);
976 // Links table goes at top left, resizing resizes the table
977 GridBagConstraints linkConstraints2 = new GridBagConstraints();
978 linkConstraints2.insets = new Insets(0, 0, 5, 5);
979 linkConstraints2.gridx = 0;
980 linkConstraints2.gridy = 1;
981 linkConstraints2.weightx = 1.0;
982 linkConstraints2.weighty = 1.0;
983 linkConstraints2.fill = GridBagConstraints.BOTH;
984 linkTab.add(linkScrollPane, linkConstraints2);
986 // Filter box and buttons goes at bottom left, resizing resizes the text box
987 JPanel filterPanel = initLinkTabFilterPanel();
988 GridBagConstraints linkConstraints3 = new GridBagConstraints();
989 linkConstraints3.insets = new Insets(0, 0, 0, 5);
990 linkConstraints3.gridx = 0;
991 linkConstraints3.gridy = 2;
992 linkConstraints3.weightx = 1.0;
993 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
994 linkTab.add(filterPanel, linkConstraints3);
999 private JPanel initLinkTabFilterPanel()
1001 // Filter textbox and reset button
1002 JLabel filterLabel = new JLabel(
1003 MessageManager.getString("label.filter"));
1004 filterLabel.setFont(LABEL_FONT);
1005 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1006 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
1008 filterTB.setFont(LABEL_FONT);
1009 filterTB.setText("");
1011 doReset.setText(MessageManager.getString("action.showall"));
1012 userOnly.setText(MessageManager.getString("action.customfilter"));
1014 // Panel for filter functionality
1015 JPanel filterPanel = new JPanel(new GridBagLayout());
1016 filterPanel.setBorder(new TitledBorder("Filter"));
1017 GridBagConstraints gbc = new GridBagConstraints();
1020 gbc.fill = GridBagConstraints.NONE;
1021 gbc.anchor = GridBagConstraints.WEST;
1023 filterPanel.add(filterLabel, gbc);
1025 GridBagConstraints gbc1 = new GridBagConstraints();
1028 gbc1.fill = GridBagConstraints.HORIZONTAL;
1029 gbc1.anchor = GridBagConstraints.WEST;
1031 filterPanel.add(filterTB, gbc1);
1033 GridBagConstraints gbc2 = new GridBagConstraints();
1035 gbc2.fill = GridBagConstraints.NONE;
1036 gbc2.anchor = GridBagConstraints.WEST;
1037 filterPanel.add(doReset, gbc2);
1039 GridBagConstraints gbc3 = new GridBagConstraints();
1041 gbc3.fill = GridBagConstraints.NONE;
1042 gbc3.anchor = GridBagConstraints.WEST;
1043 filterPanel.add(userOnly, gbc3);
1048 private JPanel initLinkTabUrlButtons()
1050 // Buttons for new / edit / delete Url links
1051 JButton newLink = new JButton();
1052 newLink.setText(MessageManager.getString("action.new"));
1054 editLink.setText(MessageManager.getString("action.edit"));
1056 deleteLink.setText(MessageManager.getString("action.delete"));
1058 // no current selection, so initially disable delete/edit buttons
1059 editLink.setEnabled(false);
1060 deleteLink.setEnabled(false);
1062 newLink.addActionListener(new java.awt.event.ActionListener()
1065 public void actionPerformed(ActionEvent e)
1067 newLink_actionPerformed(e);
1071 editLink.setText(MessageManager.getString("action.edit"));
1072 editLink.addActionListener(new java.awt.event.ActionListener()
1075 public void actionPerformed(ActionEvent e)
1077 editLink_actionPerformed(e);
1081 deleteLink.setText(MessageManager.getString("action.delete"));
1082 deleteLink.addActionListener(new java.awt.event.ActionListener()
1085 public void actionPerformed(ActionEvent e)
1087 deleteLink_actionPerformed(e);
1091 JPanel buttonPanel = new JPanel(new GridBagLayout());
1092 buttonPanel.setBorder(new TitledBorder("Edit links"));
1093 GridBagConstraints gbc = new GridBagConstraints();
1096 gbc.fill = GridBagConstraints.NONE;
1097 buttonPanel.add(newLink, gbc);
1099 GridBagConstraints gbc1 = new GridBagConstraints();
1102 gbc1.fill = GridBagConstraints.NONE;
1103 buttonPanel.add(editLink, gbc1);
1105 GridBagConstraints gbc2 = new GridBagConstraints();
1108 gbc2.fill = GridBagConstraints.NONE;
1109 buttonPanel.add(deleteLink, gbc2);
1111 GridBagConstraints gbc3 = new GridBagConstraints();
1114 gbc3.fill = GridBagConstraints.HORIZONTAL;
1116 JPanel spacePanel = new JPanel();
1117 spacePanel.setBorder(null);
1118 buttonPanel.add(spacePanel, gbc3);
1124 * Initialises the proxy server panel in the Connections tab
1126 * @return the proxy server panel
1128 private JPanel initConnTabProxyPanel()
1130 // Label for server text box
1131 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1132 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1133 serverLabel.setFont(LABEL_FONT);
1134 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1135 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1136 serverLabel2.setFont(LABEL_FONT);
1138 // Proxy server and port text boxes
1139 proxyServerHttpTB.setFont(LABEL_FONT);
1140 proxyServerHttpTB.setColumns(40);
1141 proxyPortHttpTB.setFont(LABEL_FONT);
1142 proxyPortHttpTB.setColumns(4);
1143 proxyServerHttpsTB.setFont(LABEL_FONT);
1144 proxyServerHttpsTB.setColumns(40);
1145 proxyPortHttpsTB.setFont(LABEL_FONT);
1146 proxyPortHttpsTB.setColumns(4);
1147 proxyAuthUsernameTB.setFont(LABEL_FONT);
1148 proxyAuthUsernameTB.setColumns(30);
1150 // check for any change to enable applyProxyButton
1151 DocumentListener d = new DocumentListener()
1154 public void changedUpdate(DocumentEvent e)
1156 applyProxyButtonEnabled(true);
1160 public void insertUpdate(DocumentEvent e)
1162 applyProxyButtonEnabled(true);
1166 public void removeUpdate(DocumentEvent e)
1168 applyProxyButtonEnabled(true);
1171 proxyServerHttpTB.getDocument().addDocumentListener(d);
1172 proxyPortHttpTB.getDocument().addDocumentListener(d);
1173 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1174 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1175 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1176 proxyAuthPasswordPB.setFont(LABEL_FONT);
1177 proxyAuthPasswordPB.setColumns(30);
1178 proxyAuthPasswordPB.getDocument()
1179 .addDocumentListener(new DocumentListener()
1182 public void changedUpdate(DocumentEvent e)
1184 proxyAuthPasswordCheckHighlight(true);
1185 applyProxyButtonEnabled(true);
1189 public void insertUpdate(DocumentEvent e)
1191 proxyAuthPasswordCheckHighlight(true);
1192 applyProxyButtonEnabled(true);
1196 public void removeUpdate(DocumentEvent e)
1198 proxyAuthPasswordCheckHighlight(true);
1199 applyProxyButtonEnabled(true);
1204 // Label for Port text box
1205 portLabel.setFont(LABEL_FONT);
1206 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1207 portLabel.setText(MessageManager.getString("label.port") + ": ");
1208 portLabel2.setFont(LABEL_FONT);
1209 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1210 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1212 httpLabel.setText("HTTP");
1213 httpLabel.setFont(LABEL_FONT_BOLD);
1214 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1215 httpsLabel.setText("HTTPS");
1216 httpsLabel.setFont(LABEL_FONT_BOLD);
1217 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1219 proxyAuthUsernameLabel
1220 .setText(MessageManager.getString("label.username") + ": ");
1221 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1222 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1223 proxyAuthPasswordLabel
1224 .setText(MessageManager.getString("label.password") + ": ");
1225 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1226 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1227 passwordNotStoredLabel.setText(
1228 "(" + MessageManager.getString("label.not_stored") + ")");
1229 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1230 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1232 // Proxy type radio buttons
1233 noProxy.setFont(LABEL_FONT);
1234 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1235 noProxy.setText(MessageManager.getString("label.no_proxy"));
1236 systemProxy.setFont(LABEL_FONT);
1237 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1238 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1239 displayUserHostPort(Cache.startupProxyProperties[4],
1240 Cache.startupProxyProperties[0],
1241 Cache.startupProxyProperties[1]),
1242 displayUserHostPort(Cache.startupProxyProperties[6],
1243 Cache.startupProxyProperties[2],
1244 Cache.startupProxyProperties[3])));
1245 customProxy.setFont(LABEL_FONT);
1246 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1247 customProxy.setText(
1248 MessageManager.getString("label.use_proxy_server") + ":");
1249 ActionListener al = new ActionListener()
1252 public void actionPerformed(ActionEvent e)
1254 proxyType_actionPerformed();
1257 noProxy.addActionListener(al);
1258 systemProxy.addActionListener(al);
1259 customProxy.addActionListener(al);
1260 proxyType.add(noProxy);
1261 proxyType.add(systemProxy);
1262 proxyType.add(customProxy);
1264 proxyAuth.setFont(LABEL_FONT);
1265 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1266 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1267 proxyAuth.addActionListener(new ActionListener()
1270 public void actionPerformed(ActionEvent e)
1272 proxyAuth_actionPerformed();
1275 setCustomProxyEnabled();
1277 // Make proxy server panel
1278 JPanel proxyPanel = new JPanel();
1279 TitledBorder titledBorder1 = new TitledBorder(
1280 MessageManager.getString("label.proxy_servers"));
1281 proxyPanel.setBorder(titledBorder1);
1282 proxyPanel.setLayout(new GridBagLayout());
1283 GridBagConstraints gbc = new GridBagConstraints();
1284 gbc.fill = GridBagConstraints.HORIZONTAL;
1287 GridBagConstraints c = new GridBagConstraints();
1288 // Proxy type radio buttons (3)
1289 JPanel ptPanel = new JPanel();
1290 ptPanel.setLayout(new GridBagLayout());
1295 c.fill = GridBagConstraints.HORIZONTAL;
1296 ptPanel.add(noProxy, c);
1298 ptPanel.add(systemProxy, c);
1300 ptPanel.add(customProxy, c);
1303 proxyPanel.add(ptPanel, gbc);
1305 // host and port text boxes
1306 JPanel hpPanel = new JPanel();
1307 hpPanel.setLayout(new GridBagLayout());
1308 // HTTP host port row
1313 c.anchor = GridBagConstraints.LINE_START;
1314 hpPanel.add(httpLabel, c);
1318 c.anchor = GridBagConstraints.LINE_END;
1319 hpPanel.add(serverLabel, c);
1323 c.anchor = GridBagConstraints.LINE_START;
1324 hpPanel.add(proxyServerHttpTB, c);
1328 c.anchor = GridBagConstraints.LINE_END;
1329 hpPanel.add(portLabel, c);
1333 c.anchor = GridBagConstraints.LINE_START;
1334 hpPanel.add(proxyPortHttpTB, c);
1336 // HTTPS host port row
1341 c.anchor = GridBagConstraints.LINE_START;
1342 hpPanel.add(httpsLabel, c);
1345 c.anchor = GridBagConstraints.LINE_END;
1346 hpPanel.add(serverLabel2, c);
1349 c.anchor = GridBagConstraints.LINE_START;
1350 hpPanel.add(proxyServerHttpsTB, c);
1353 c.anchor = GridBagConstraints.LINE_END;
1354 hpPanel.add(portLabel2, c);
1357 c.anchor = GridBagConstraints.LINE_START;
1358 hpPanel.add(proxyPortHttpsTB, c);
1361 proxyPanel.add(hpPanel, gbc);
1363 if (!Platform.isJS())
1365 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1366 * Authentication options in Preferences.
1372 // Require authentication checkbox
1374 proxyPanel.add(proxyAuth, gbc);
1376 // username and password
1377 JPanel upPanel = new JPanel();
1378 upPanel.setLayout(new GridBagLayout());
1384 c.anchor = GridBagConstraints.LINE_END;
1385 upPanel.add(proxyAuthUsernameLabel, c);
1389 c.anchor = GridBagConstraints.LINE_START;
1390 upPanel.add(proxyAuthUsernameTB, c);
1396 c.anchor = GridBagConstraints.LINE_END;
1397 upPanel.add(proxyAuthPasswordLabel, c);
1401 c.anchor = GridBagConstraints.LINE_START;
1402 upPanel.add(proxyAuthPasswordPB, c);
1406 c.anchor = GridBagConstraints.LINE_START;
1407 upPanel.add(passwordNotStoredLabel, c);
1410 proxyPanel.add(upPanel, gbc);
1414 applyProxyButton.setText(MessageManager.getString("action.apply"));
1415 applyProxyButton.addActionListener(new ActionListener()
1418 public void actionPerformed(ActionEvent e)
1420 saveProxySettings();
1421 applyProxyButton.setEnabled(false);
1425 gbc.fill = GridBagConstraints.NONE;
1426 gbc.anchor = GridBagConstraints.LINE_END;
1427 proxyPanel.add(applyProxyButton, gbc);
1432 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1434 proxyAuthPasswordCheckHighlight(enabled, false);
1437 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1440 if (enabled && proxyType.isSelected(customProxy.getModel())
1441 && proxyAuth.isSelected()
1442 && !proxyAuthUsernameTB.getText().isEmpty()
1443 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1446 proxyAuthPasswordPB.grabFocus();
1447 proxyAuthPasswordPB.setBackground(Color.PINK);
1451 proxyAuthPasswordPB.setBackground(Color.WHITE);
1455 public void applyProxyButtonEnabled(boolean enabled)
1457 applyProxyButton.setEnabled(enabled);
1460 public void saveProxySettings()
1462 // overridden in Preferences
1465 private String displayUserHostPort(String user, String host, String port)
1467 boolean hostBlank = (host == null || host.isEmpty());
1468 boolean portBlank = (port == null || port.isEmpty());
1469 if (hostBlank && portBlank)
1471 return MessageManager.getString("label.none");
1474 StringBuilder sb = new StringBuilder();
1477 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1481 sb.append(hostBlank ? "" : host);
1487 return sb.toString();
1491 * Initialises the checkboxes in the Connections tab
1493 private void initConnTabCheckboxes()
1495 // Usage stats checkbox label
1497 MessageManager.getString("label.send_usage_statistics"));
1498 usagestats.setFont(LABEL_FONT);
1499 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1500 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1502 // Questionnaire checkbox label
1503 questionnaire.setText(
1504 MessageManager.getString("label.check_for_questionnaires"));
1505 questionnaire.setFont(LABEL_FONT);
1506 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1507 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1509 // Check for latest version checkbox label
1510 versioncheck.setText(
1511 MessageManager.getString("label.check_for_latest_version"));
1512 versioncheck.setFont(LABEL_FONT);
1513 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1514 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1518 * Initialises the parent panel which contains the tabbed sections.
1522 private JPanel initOkCancelPanel()
1524 JButton ok = new JButton();
1525 ok.setText(MessageManager.getString("action.ok"));
1526 ok.addActionListener(new ActionListener()
1529 public void actionPerformed(ActionEvent e)
1531 ok_actionPerformed(e);
1534 JButton cancel = new JButton();
1535 cancel.setText(MessageManager.getString("action.cancel"));
1536 cancel.addActionListener(new ActionListener()
1539 public void actionPerformed(ActionEvent e)
1541 cancel_actionPerformed(e);
1544 JPanel okCancelPanel = new JPanel();
1545 okCancelPanel.add(ok);
1546 okCancelPanel.add(cancel);
1547 return okCancelPanel;
1551 * Initialises the Colours tabbed panel.
1555 private JPanel initColoursTab()
1557 JPanel coloursTab = new JPanel();
1558 coloursTab.setBorder(new TitledBorder(
1559 MessageManager.getString("action.open_new_alignment")));
1560 coloursTab.setLayout(new FlowLayout());
1561 JLabel mincolourLabel = new JLabel();
1562 mincolourLabel.setFont(LABEL_FONT);
1563 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1564 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1565 minColour.setFont(LABEL_FONT);
1566 minColour.setBorder(BorderFactory.createEtchedBorder());
1567 minColour.setPreferredSize(new Dimension(40, 20));
1568 minColour.addMouseListener(new MouseAdapter()
1571 public void mousePressed(MouseEvent e)
1573 minColour_actionPerformed(minColour);
1576 JLabel maxcolourLabel = new JLabel();
1577 maxcolourLabel.setFont(LABEL_FONT);
1578 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1579 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1580 maxColour.setFont(LABEL_FONT);
1581 maxColour.setBorder(BorderFactory.createEtchedBorder());
1582 maxColour.setPreferredSize(new Dimension(40, 20));
1583 maxColour.addMouseListener(new MouseAdapter()
1586 public void mousePressed(MouseEvent e)
1588 maxColour_actionPerformed(maxColour);
1592 protColour.setFont(LABEL_FONT);
1593 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1594 JLabel protColourLabel = new JLabel();
1595 protColourLabel.setFont(LABEL_FONT);
1596 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1597 protColourLabel.setText(
1598 MessageManager.getString("label.prot_alignment_colour") + " ");
1599 GPreferences.addtoLayout(coloursTab,
1601 .getString("label.default_colour_scheme_for_alignment"),
1602 protColourLabel, protColour);
1604 nucColour.setFont(LABEL_FONT);
1605 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1606 JLabel nucColourLabel = new JLabel();
1607 nucColourLabel.setFont(LABEL_FONT);
1608 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1609 nucColourLabel.setText(
1610 MessageManager.getString("label.nuc_alignment_colour") + " ");
1611 GPreferences.addtoLayout(coloursTab,
1613 .getString("label.default_colour_scheme_for_alignment"),
1614 nucColourLabel, nucColour);
1616 JPanel annotationShding = new JPanel();
1617 annotationShding.setBorder(new TitledBorder(
1618 MessageManager.getString("label.annotation_shading_default")));
1619 annotationShding.setLayout(new GridLayout(1, 2));
1620 GPreferences.addtoLayout(annotationShding,
1621 MessageManager.getString(
1622 "label.default_minimum_colour_annotation_shading"),
1623 mincolourLabel, minColour);
1624 GPreferences.addtoLayout(annotationShding,
1625 MessageManager.getString(
1626 "label.default_maximum_colour_annotation_shading"),
1627 maxcolourLabel, maxColour);
1628 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1633 * Initialises the Overview tabbed panel.
1637 private JPanel initOverviewTab()
1639 JPanel overviewPanel = new JPanel();
1640 overviewPanel.setBorder(new TitledBorder(
1641 MessageManager.getString("label.overview_settings")));
1643 gapColour.setFont(LABEL_FONT);
1644 // fixing the border colours stops apparent colour bleed from the panel
1645 gapColour.setBorder(
1646 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1647 gapColour.setPreferredSize(new Dimension(40, 20));
1648 gapColour.addMouseListener(new MouseAdapter()
1651 public void mousePressed(MouseEvent e)
1653 gapColour_actionPerformed(gapColour);
1657 hiddenColour.setFont(LABEL_FONT);
1658 // fixing the border colours stops apparent colour bleed from the panel
1659 hiddenColour.setBorder(
1660 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1661 hiddenColour.setPreferredSize(new Dimension(40, 20));
1662 hiddenColour.addMouseListener(new MouseAdapter()
1665 public void mousePressed(MouseEvent e)
1667 hiddenColour_actionPerformed(hiddenColour);
1671 useLegacyGap = new JCheckBox(
1672 MessageManager.getString("label.ov_legacy_gap"));
1673 useLegacyGap.setFont(LABEL_FONT);
1674 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1675 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1676 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1677 gapLabel.setFont(LABEL_FONT);
1678 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1679 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1680 showHiddenAtStart = new JCheckBox(
1681 MessageManager.getString("label.ov_show_hide_default"));
1682 showHiddenAtStart.setFont(LABEL_FONT);
1683 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1684 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1685 JLabel hiddenLabel = new JLabel(
1686 MessageManager.getString("label.hidden_colour"));
1687 hiddenLabel.setFont(LABEL_FONT);
1688 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1689 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1691 useLegacyGap.addActionListener(new ActionListener()
1694 public void actionPerformed(ActionEvent e)
1696 useLegacyGaps_actionPerformed(e);
1700 overviewPanel.setLayout(new GridBagLayout());
1701 GridBagConstraints c1 = new GridBagConstraints();
1703 c1.fill = GridBagConstraints.HORIZONTAL;
1708 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1709 overviewPanel.add(useLegacyGap, c1);
1711 GridBagConstraints c2 = new GridBagConstraints();
1712 c2.fill = GridBagConstraints.HORIZONTAL;
1715 c2.insets = new Insets(0, 15, 0, 10);
1716 overviewPanel.add(gapLabel, c2);
1718 GridBagConstraints c3 = new GridBagConstraints();
1719 c3.fill = GridBagConstraints.HORIZONTAL;
1722 c3.insets = new Insets(0, 0, 0, 15);
1723 overviewPanel.add(gapColour, c3);
1725 GridBagConstraints c4 = new GridBagConstraints();
1726 c4.fill = GridBagConstraints.HORIZONTAL;
1730 overviewPanel.add(showHiddenAtStart, c4);
1732 GridBagConstraints c5 = new GridBagConstraints();
1733 c5.fill = GridBagConstraints.HORIZONTAL;
1736 c5.insets = new Insets(0, 15, 0, 10);
1737 overviewPanel.add(hiddenLabel, c5);
1739 GridBagConstraints c6 = new GridBagConstraints();
1740 c6.fill = GridBagConstraints.HORIZONTAL;
1743 c6.insets = new Insets(0, 0, 0, 15);
1744 overviewPanel.add(hiddenColour, c6);
1746 JButton resetButton = new JButton(
1747 MessageManager.getString("label.reset_to_defaults"));
1749 resetButton.addActionListener(new ActionListener()
1752 public void actionPerformed(ActionEvent e)
1754 resetOvDefaults_actionPerformed(e);
1758 GridBagConstraints c7 = new GridBagConstraints();
1759 c7.fill = GridBagConstraints.NONE;
1762 c7.insets = new Insets(10, 0, 0, 0);
1763 c7.anchor = GridBagConstraints.WEST;
1764 overviewPanel.add(resetButton, c7);
1766 // Add padding so the panel doesn't look ridiculous
1767 JPanel spacePanel = new JPanel();
1768 overviewPanel.add(spacePanel,
1769 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1770 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1771 new Insets(0, 0, 0, 5), 0, 0));
1773 return overviewPanel;
1777 * Initialises the Structure tabbed panel.
1781 private JPanel initStructureTab()
1783 structureTab = new JPanel();
1785 structureTab.setBorder(new TitledBorder(
1786 MessageManager.getString("label.structure_options")));
1787 structureTab.setLayout(null);
1788 final int width = 420;
1789 final int height = 22;
1790 final int lineSpacing = 25;
1793 structFromPdb.setFont(LABEL_FONT);
1795 .setText(MessageManager.getString("label.struct_from_pdb"));
1796 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1797 structFromPdb.addActionListener(new ActionListener()
1800 public void actionPerformed(ActionEvent e)
1802 boolean selected = structFromPdb.isSelected();
1803 // enable other options only when the first is checked
1804 addSecondaryStructure.setEnabled(selected);
1805 addTempFactor.setEnabled(selected);
1808 structureTab.add(structFromPdb);
1810 // indent checkboxes that are conditional on the first one
1812 ypos += lineSpacing;
1813 addSecondaryStructure.setFont(LABEL_FONT);
1814 addSecondaryStructure
1815 .setText(MessageManager.getString("label.autoadd_secstr"));
1816 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1817 structureTab.add(addSecondaryStructure);
1819 ypos += lineSpacing;
1820 addTempFactor.setFont(LABEL_FONT);
1821 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1822 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1823 structureTab.add(addTempFactor);
1825 ypos += lineSpacing;
1826 JLabel viewerLabel = new JLabel();
1827 viewerLabel.setFont(LABEL_FONT);
1828 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1829 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1830 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1831 structureTab.add(viewerLabel);
1834 * add all external viewers as options here - check
1835 * when selected whether the program is installed
1837 structViewer.setFont(LABEL_FONT);
1838 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1839 structViewer.addItem(ViewerType.JMOL.name());
1840 structViewer.addItem(ViewerType.CHIMERA.name());
1841 structViewer.addItem(ViewerType.CHIMERAX.name());
1842 structViewer.addItem(ViewerType.PYMOL.name());
1843 structViewer.addActionListener(new ActionListener()
1846 public void actionPerformed(ActionEvent e)
1848 structureViewer_actionPerformed(
1849 (String) structViewer.getSelectedItem());
1852 structureTab.add(structViewer);
1854 ypos += lineSpacing;
1855 structureViewerPathLabel = new JLabel();
1856 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1858 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1859 structureViewerPathLabel.setText(MessageManager
1860 .formatMessage("label.viewer_path", "Chimera(X)"));
1861 structureViewerPathLabel
1862 .setBounds(new Rectangle(10, ypos, 170, height));
1863 structureViewerPathLabel.setEnabled(false);
1864 structureTab.add(structureViewerPathLabel);
1866 structureViewerPath.setFont(LABEL_FONT);
1867 structureViewerPath.setText("");
1868 structureViewerPath.setEnabled(false);
1869 final String tooltip = JvSwingUtils.wrapTooltip(true,
1870 MessageManager.getString("label.viewer_path_tip"));
1871 structureViewerPath.setToolTipText(tooltip);
1872 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1873 structureViewerPath.addMouseListener(new MouseAdapter()
1876 public void mouseClicked(MouseEvent e)
1878 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1880 structureViewer_actionPerformed(
1881 (String) structViewer.getSelectedItem());
1884 structureTab.add(structViewer);
1885 ypos += lineSpacing;
1886 structureViewerPathLabel = new JLabel();
1887 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1889 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1890 structureViewerPathLabel.setText(MessageManager
1891 .formatMessage("label.viewer_path", "Chimera(X)"));
1892 structureViewerPathLabel
1893 .setBounds(new Rectangle(10, ypos, 170, height));
1894 structureViewerPathLabel.setEnabled(false);
1895 structureTab.add(structureViewerPathLabel);
1897 structureViewerPath.setFont(LABEL_FONT);
1898 structureViewerPath.setText("");
1899 structureViewerPath.setEnabled(false);
1900 final String tooltip = JvSwingUtils.wrapTooltip(true,
1901 MessageManager.getString("label.viewer_path_tip"));
1902 structureViewerPath.setToolTipText(tooltip);
1903 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1904 structureViewerPath.addMouseListener(new MouseAdapter()
1906 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1908 String chosen = openFileChooser();
1911 structureViewerPath.setText(chosen);
1916 structureTab.add(structureViewerPath);
1918 ypos += lineSpacing;
1919 nwMapping.setFont(LABEL_FONT);
1920 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1921 siftsMapping.setFont(LABEL_FONT);
1922 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1923 mappingMethod.add(nwMapping);
1924 mappingMethod.add(siftsMapping);
1925 JPanel mappingPanel = new JPanel();
1926 mappingPanel.setFont(LABEL_FONT);
1927 TitledBorder mmTitledBorder = new TitledBorder(
1928 MessageManager.getString("label.mapping_method"));
1929 mmTitledBorder.setTitleFont(LABEL_FONT);
1930 mappingPanel.setBorder(mmTitledBorder);
1931 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1932 // GridLayout mappingLayout = new GridLayout();
1933 mappingPanel.setLayout(new GridLayout());
1934 mappingPanel.add(nwMapping);
1935 mappingPanel.add(siftsMapping);
1936 structureTab.add(mappingPanel);
1938 ypos += lineSpacing;
1939 ypos += lineSpacing;
1940 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1941 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1942 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1943 structureTab.add(docFieldPref);
1946 * hide Chimera options in JalviewJS
1948 if (Platform.isJS())
1950 structureViewerPathLabel.setVisible(false);
1951 structureViewerPath.setVisible(false);
1952 viewerLabel.setVisible(false);
1953 structViewer.setVisible(false);
1955 return structureTab;
1959 * Action on choosing a structure viewer from combobox options.
1961 * @param selectedItem
1963 protected void structureViewer_actionPerformed(String selectedItem)
1968 * Show a dialog for the user to choose a file. Returns the chosen path, or null
1973 protected String openFileChooser(boolean forFolder)
1975 String choice = null;
1976 JFileChooser chooser = new JFileChooser();
1978 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1979 // hidden executables within .app dirs
1980 if (Platform.isMac())
1982 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1988 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1991 // chooser.setFileView(new JalviewFileView());
1992 chooser.setDialogTitle(
1993 MessageManager.getString("label.open_local_file"));
1994 chooser.setToolTipText(MessageManager.getString("action.open"));
1996 int value = chooser.showOpenDialog(this);
1998 if (value == JFileChooser.APPROVE_OPTION)
2000 choice = chooser.getSelectedFile().getPath();
2006 * Validate the structure tab preferences; if invalid, set focus on this tab.
2010 protected boolean validateStructure(FocusEvent e)
2012 if (!validateStructure())
2014 e.getComponent().requestFocusInWindow();
2020 protected boolean validateStructure()
2026 * Initialises the Visual tabbed panel.
2030 private JPanel initVisualTab()
2032 JPanel visualTab = new JPanel();
2033 visualTab.setBorder(new TitledBorder(
2034 MessageManager.getString("action.open_new_alignment")));
2035 visualTab.setLayout(null);
2036 fullScreen.setFont(LABEL_FONT);
2037 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
2038 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
2039 fullScreen.setText(MessageManager.getString("label.maximize_window"));
2040 quality.setEnabled(false);
2041 quality.setFont(LABEL_FONT);
2042 quality.setHorizontalAlignment(SwingConstants.RIGHT);
2043 quality.setHorizontalTextPosition(SwingConstants.LEFT);
2044 quality.setSelected(true);
2045 quality.setText(MessageManager.getString("label.quality"));
2046 conservation.setEnabled(false);
2047 conservation.setFont(LABEL_FONT);
2048 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
2049 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
2050 conservation.setSelected(true);
2051 conservation.setText(MessageManager.getString("label.conservation"));
2052 identity.setEnabled(false);
2053 identity.setFont(LABEL_FONT);
2054 identity.setHorizontalAlignment(SwingConstants.RIGHT);
2055 identity.setHorizontalTextPosition(SwingConstants.LEFT);
2056 identity.setSelected(true);
2057 identity.setText(MessageManager.getString("label.consensus"));
2058 showOccupancy.setFont(LABEL_FONT);
2059 showOccupancy.setEnabled(false);
2060 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
2061 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
2062 showOccupancy.setSelected(true);
2063 showOccupancy.setText(MessageManager.getString("label.occupancy"));
2065 JLabel showGroupbits = new JLabel();
2066 showGroupbits.setFont(LABEL_FONT);
2067 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
2068 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
2070 .setText(MessageManager.getString("action.show_group") + ":");
2071 JLabel showConsensbits = new JLabel();
2072 showConsensbits.setFont(LABEL_FONT);
2073 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
2074 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
2076 .setText(MessageManager.getString("label.consensus") + ":");
2077 showConsensHistogram.setEnabled(false);
2078 showConsensHistogram.setFont(LABEL_FONT);
2079 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
2080 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
2081 showConsensHistogram.setSelected(true);
2082 showConsensHistogram
2083 .setText(MessageManager.getString("label.histogram"));
2084 showConsensLogo.setEnabled(false);
2085 showConsensLogo.setFont(LABEL_FONT);
2086 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
2087 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
2088 showConsensLogo.setSelected(true);
2089 showConsensLogo.setText(MessageManager.getString("label.logo"));
2090 showGroupConsensus.setEnabled(false);
2091 showGroupConsensus.setFont(LABEL_FONT);
2092 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2093 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2094 showGroupConsensus.setSelected(true);
2095 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
2096 showGroupConservation.setEnabled(false);
2097 showGroupConservation.setFont(LABEL_FONT);
2098 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
2099 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
2100 showGroupConservation.setSelected(true);
2101 showGroupConservation
2102 .setText(MessageManager.getString("label.conservation"));
2103 showNpTooltip.setEnabled(true);
2104 showNpTooltip.setFont(LABEL_FONT);
2105 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2106 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2107 showNpTooltip.setSelected(true);
2108 showNpTooltip.setText(
2109 MessageManager.getString("label.non_positional_features"));
2110 showDbRefTooltip.setEnabled(true);
2111 showDbRefTooltip.setFont(LABEL_FONT);
2112 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2113 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2114 showDbRefTooltip.setSelected(true);
2116 .setText(MessageManager.getString("label.database_references"));
2117 annotations.setFont(LABEL_FONT);
2118 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
2119 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
2120 annotations.setSelected(true);
2121 annotations.setText(MessageManager.getString("label.show_annotations"));
2122 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
2123 annotations.addActionListener(new ActionListener()
2126 public void actionPerformed(ActionEvent e)
2128 annotations_actionPerformed(e);
2131 identity.addActionListener(new ActionListener()
2134 public void actionPerformed(ActionEvent e)
2136 annotations_actionPerformed(e);
2139 showGroupConsensus.addActionListener(new ActionListener()
2142 public void actionPerformed(ActionEvent e)
2144 annotations_actionPerformed(e);
2147 showUnconserved.setFont(LABEL_FONT);
2148 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2149 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2150 showUnconserved.setSelected(true);
2152 .setText(MessageManager.getString("action.show_unconserved"));
2153 showUnconserved.addActionListener(new ActionListener()
2156 public void actionPerformed(ActionEvent e)
2158 showunconserved_actionPerformed(e);
2162 // TODO these are not yet added to / action from Preferences
2163 // JCheckBox shareSelections = new JCheckBox();
2164 // shareSelections.setFont(verdana11);
2165 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2166 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2167 // shareSelections.setSelected(true);
2168 // shareSelections.setText(MessageManager
2169 // .getString("label.share_selection_across_views"));
2170 // JCheckBox followHighlight = new JCheckBox();
2171 // followHighlight.setFont(verdana11);
2172 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2173 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2174 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2175 // followHighlight.setSelected(true);
2176 // followHighlight.setText(MessageManager
2177 // .getString("label.scroll_highlighted_regions"));
2179 seqLimit.setFont(LABEL_FONT);
2180 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2181 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2182 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2183 smoothFont.setFont(LABEL_FONT);
2184 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2185 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2186 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2187 scaleProteinToCdna.setFont(LABEL_FONT);
2188 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2189 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2190 scaleProteinToCdna.setText(
2191 MessageManager.getString("label.scale_protein_to_cdna"));
2192 scaleProteinToCdna.setToolTipText(
2193 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2194 JLabel gapLabel = new JLabel();
2195 gapLabel.setFont(LABEL_FONT);
2196 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2197 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2198 JLabel fontLabel = new JLabel();
2199 fontLabel.setFont(LABEL_FONT);
2200 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2201 fontLabel.setText(MessageManager.getString("label.font"));
2202 fontSizeCB.setFont(LABEL_FONT);
2203 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2204 fontStyleCB.setFont(LABEL_FONT);
2205 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2206 fontNameCB.setFont(LABEL_FONT);
2207 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2208 gapSymbolCB.setFont(LABEL_FONT);
2209 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2210 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2211 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2212 gapSymbolCB.setRenderer(dlcr);
2214 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2215 startupCheckbox.setFont(LABEL_FONT);
2216 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2217 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2218 startupCheckbox.setSelected(true);
2219 startupFileTextfield.setFont(LABEL_FONT);
2220 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2221 final String tooltip = JvSwingUtils.wrapTooltip(true,
2222 MessageManager.getString("label.double_click_to_browse"));
2223 startupFileTextfield.setToolTipText(tooltip);
2224 startupFileTextfield.addMouseListener(new MouseAdapter()
2227 public void mouseClicked(MouseEvent e)
2229 if (e.getClickCount() > 1)
2231 startupFileTextfield_mouseClicked();
2236 sortby.setFont(LABEL_FONT);
2237 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2238 JLabel sortLabel = new JLabel();
2239 sortLabel.setFont(LABEL_FONT);
2240 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2241 sortLabel.setText(MessageManager.getString("label.sort_by"));
2242 sortAnnBy.setFont(LABEL_FONT);
2243 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2244 JLabel sortAnnLabel = new JLabel();
2245 sortAnnLabel.setFont(LABEL_FONT);
2246 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2247 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2248 sortAutocalc.setFont(LABEL_FONT);
2249 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2251 JPanel annsettingsPanel = new JPanel();
2252 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2253 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2254 annsettingsPanel.setBorder(new EtchedBorder());
2255 visualTab.add(annsettingsPanel);
2256 Border jb = new EmptyBorder(1, 1, 4, 5);
2257 annotations.setBorder(jb);
2258 showOccupancy.setBorder(jb);
2259 quality.setBorder(jb);
2260 conservation.setBorder(jb);
2261 identity.setBorder(jb);
2262 showConsensbits.setBorder(jb);
2263 showGroupbits.setBorder(jb);
2264 showGroupConsensus.setBorder(jb);
2265 showGroupConservation.setBorder(jb);
2266 showConsensHistogram.setBorder(jb);
2267 showConsensLogo.setBorder(jb);
2269 JPanel autoAnnotSettings = new JPanel();
2270 annsettingsPanel.add(autoAnnotSettings);
2271 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2272 autoAnnotSettings.add(annotations);
2273 autoAnnotSettings.add(quality);
2274 // second row of autoannotation box
2275 autoAnnotSettings = new JPanel();
2276 annsettingsPanel.add(autoAnnotSettings);
2278 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2279 autoAnnotSettings.add(conservation);
2280 autoAnnotSettings.add(identity);
2281 autoAnnotSettings.add(showOccupancy);
2282 autoAnnotSettings.add(showGroupbits);
2283 autoAnnotSettings.add(showGroupConservation);
2284 autoAnnotSettings.add(showGroupConsensus);
2285 autoAnnotSettings.add(showConsensbits);
2286 autoAnnotSettings.add(showConsensHistogram);
2287 autoAnnotSettings.add(showConsensLogo);
2289 JPanel tooltipSettings = new JPanel();
2290 tooltipSettings.setBorder(new TitledBorder(
2291 MessageManager.getString("label.sequence_id_tooltip")));
2292 tooltipSettings.setBounds(173, 140, 220, 62);
2293 tooltipSettings.setLayout(new GridLayout(2, 1));
2294 tooltipSettings.add(showDbRefTooltip);
2295 tooltipSettings.add(showNpTooltip);
2296 visualTab.add(tooltipSettings);
2298 wrap.setFont(LABEL_FONT);
2299 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2300 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2301 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2302 rightAlign.setFont(LABEL_FONT);
2303 rightAlign.setForeground(Color.black);
2304 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2305 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2306 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2307 idItalics.setFont(LABEL_FONT_ITALIC);
2308 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2309 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2311 MessageManager.getString("label.sequence_name_italics"));
2312 openoverv.setFont(LABEL_FONT);
2313 openoverv.setActionCommand(
2314 MessageManager.getString("label.open_overview"));
2315 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2316 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2317 openoverv.setText(MessageManager.getString("label.open_overview"));
2318 JPanel jPanel2 = new JPanel();
2319 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2320 jPanel2.setLayout(new GridLayout(14, 1));
2321 jPanel2.add(fullScreen);
2322 jPanel2.add(openoverv);
2323 jPanel2.add(seqLimit);
2324 jPanel2.add(rightAlign);
2325 jPanel2.add(fontLabel);
2326 jPanel2.add(showUnconserved);
2327 jPanel2.add(idItalics);
2328 jPanel2.add(smoothFont);
2329 jPanel2.add(scaleProteinToCdna);
2330 jPanel2.add(gapLabel);
2332 jPanel2.add(sortLabel);
2333 jPanel2.add(sortAnnLabel);
2334 jPanel2.add(startupCheckbox);
2335 visualTab.add(jPanel2);
2336 visualTab.add(startupFileTextfield);
2337 visualTab.add(sortby);
2338 visualTab.add(sortAnnBy);
2339 visualTab.add(sortAutocalc);
2340 visualTab.add(gapSymbolCB);
2341 visualTab.add(fontNameCB);
2342 visualTab.add(fontSizeCB);
2343 visualTab.add(fontStyleCB);
2345 if (Platform.isJS())
2347 startupCheckbox.setVisible(false);
2348 startupFileTextfield.setVisible(false);
2355 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2358 protected void loadLastSavedBackupsOptions()
2360 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2361 .getSavedBackupEntry();
2363 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2365 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2366 .createBackupFilesPresetEntry(Cache
2367 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2368 if (backupfilesCustomEntry == null)
2370 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2371 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2373 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2374 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2375 backupfilesCustomEntry);
2377 setComboIntStringKey(backupfilesPresetsCombo,
2378 Cache.getDefault(BackupFiles.NS + "_PRESET",
2379 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2381 backupsSetOptions(savedPreset);
2383 backupsOptionsSetEnabled();
2384 updateBackupFilesExampleLabel();
2387 private boolean warnAboutSuffixReverseChange()
2389 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2390 .getSavedBackupEntry();
2391 boolean savedSuffixReverse = bfpe.reverse;
2392 int savedSuffixDigits = bfpe.digits;
2393 String savedSuffixTemplate = bfpe.suffix;
2395 boolean nowSuffixReverse = suffixReverse.isSelected();
2396 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2397 String nowSuffixTemplate = suffixTemplate.getText();
2398 return nowSuffixReverse != savedSuffixReverse
2399 && nowSuffixDigits == savedSuffixDigits
2400 && nowSuffixTemplate != null
2401 && nowSuffixTemplate.equals(savedSuffixTemplate);
2405 * Initialises the Backups tabbed panel.
2409 private JPanel initBackupsTab()
2411 JPanel backupsTab = new JPanel();
2412 backupsTab.setBorder(new TitledBorder(
2413 MessageManager.getString("label.backup_files")));
2414 backupsTab.setLayout(new GridBagLayout());
2416 GridBagConstraints gbc = new GridBagConstraints();
2419 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2420 gbc.fill = GridBagConstraints.NONE;
2422 initBackupsTabPresetsPanel();
2423 initBackupsTabSuffixPanel();
2424 initBackupsTabKeepFilesPanel();
2425 initBackupsTabFilenameExamplesPanel();
2427 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2429 .setText(MessageManager.getString("label.enable_backupfiles"));
2430 enableBackupFiles.addActionListener(new ActionListener()
2433 public void actionPerformed(ActionEvent e)
2435 // enable other options only when the first is checked
2436 backupsOptionsSetEnabled();
2441 // enable checkbox 1 col
2445 gbc.gridy = 0; // row 0
2446 backupsTab.add(enableBackupFiles, gbc);
2448 // summary of scheme box (over two rows)
2452 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2453 gbc.fill = GridBagConstraints.BOTH;
2454 backupsTab.add(exampleFilesPanel, gbc);
2456 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2457 gbc.fill = GridBagConstraints.NONE;
2459 // fill empty space on right
2462 backupsTab.add(new JPanel(), gbc);
2467 gbc.gridy++; // row 1
2468 backupsTab.add(presetsPanel, gbc);
2470 // now using whole row
2475 gbc.gridy++; // row 2
2476 backupsTab.add(keepfilesPanel, gbc);
2478 // filename strategy box
2479 gbc.gridy++; // row 3
2480 backupsTab.add(suffixPanel, gbc);
2483 gbc.gridy++; // row 4
2485 backupsTab.add(new JPanel(), gbc);
2487 backupsOptionsSetEnabled();
2491 private JPanel initBackupsTabPresetsPanel()
2494 String title = MessageManager.getString("label.schemes");
2496 presetsPanel.setLayout(new GridBagLayout());
2498 GridBagConstraints gbc = new GridBagConstraints();
2501 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2502 gbc.fill = GridBagConstraints.NONE;
2510 presetsComboLabel = new JLabel(title + ":");
2511 presetsPanel.add(presetsComboLabel, gbc);
2513 List<Object> entries = Arrays
2514 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2515 List<String> tooltips = Arrays.asList(
2516 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2517 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2520 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2522 backupfilesPresetsCombo
2523 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2527 backupfilesPresetsCombo.addActionListener(new ActionListener()
2530 public void actionPerformed(ActionEvent e)
2532 int key = getComboIntStringKey(backupfilesPresetsCombo);
2533 if (!customiseCheckbox.isSelected())
2535 backupfilesPresetsComboLastSelected = key;
2537 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2539 if (customiseCheckbox.isSelected())
2541 // got here by clicking on customiseCheckbox so don't change the values
2542 backupfilesCustomOptionsSetEnabled();
2546 backupsTabUpdatePresets();
2547 backupfilesCustomOptionsSetEnabled();
2552 customiseCheckbox.setSelected(false);
2553 backupsTabUpdatePresets();
2554 backupfilesCustomOptionsSetEnabled();
2559 // dropdown list of preset schemes
2561 presetsPanel.add(backupfilesPresetsCombo, gbc);
2563 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2564 revertButton.setToolTipText(
2565 MessageManager.getString("label.cancel_changes_description"));
2566 revertButton.addActionListener(new ActionListener()
2569 public void actionPerformed(ActionEvent e)
2572 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2573 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2574 backupfilesCustomOptionsSetEnabled();
2578 revertButton.setFont(LABEL_FONT);
2580 customiseCheckbox.setFont(LABEL_FONT);
2581 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2582 customiseCheckbox.addActionListener(new ActionListener()
2585 public void actionPerformed(ActionEvent e)
2587 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2588 if (customiseCheckbox.isSelected())
2590 backupfilesPresetsComboLastSelected = currently;
2591 setComboIntStringKey(backupfilesPresetsCombo,
2592 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2596 setComboIntStringKey(backupfilesPresetsCombo,
2597 backupfilesPresetsComboLastSelected);
2600 backupfilesCustomOptionsSetEnabled();
2603 customiseCheckbox.setToolTipText(
2604 MessageManager.getString("label.customise_description"));
2606 // customise checkbox
2609 presetsPanel.add(customiseCheckbox, gbc);
2611 // "Cancel changes" button (aligned with combo box above)
2613 presetsPanel.add(revertButton, gbc);
2615 return presetsPanel;
2618 private JPanel initBackupsTabFilenameExamplesPanel()
2620 String title = MessageManager
2621 .getString("label.scheme_examples");
2622 TitledBorder tb = new TitledBorder(title);
2623 exampleFilesPanel.setBorder(tb);
2624 exampleFilesPanel.setLayout(new GridBagLayout());
2627 backupfilesExampleLabel.setEditable(false);
2628 backupfilesExampleLabel
2629 .setBackground(exampleFilesPanel.getBackground());
2631 updateBackupFilesExampleLabel();
2633 GridBagConstraints gbc = new GridBagConstraints();
2636 gbc.fill = GridBagConstraints.NONE;
2637 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2639 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2640 return exampleFilesPanel;
2643 private void backupsTabUpdatePresets()
2645 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2648 String value = entry.v;
2650 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2654 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2660 "Preset '" + value + "' [key:" + key + "] not implemented");
2663 // Custom options will now be enabled when the customiseCheckbox is checked
2664 // (performed above)
2665 // backupfilesCustomOptionsSetEnabled();
2666 updateBackupFilesExampleLabel();
2669 protected int getComboIntStringKey(
2670 JComboBox<Object> backupfilesPresetsCombo2)
2672 IntKeyStringValueEntry e;
2675 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2677 } catch (Exception ex)
2680 "Problem casting Combo entry to IntKeyStringValueEntry.");
2683 return e != null ? e.k : 0;
2686 protected void setComboIntStringKey(
2687 JComboBox<Object> backupfilesPresetsCombo2,
2690 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2692 IntKeyStringValueEntry e;
2695 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2696 } catch (Exception ex)
2699 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2704 backupfilesPresetsCombo2.setSelectedIndex(i);
2708 // backupsTabUpdatePresets();
2711 private JPanel initBackupsTabSuffixPanel()
2713 suffixPanel.setBorder(new TitledBorder(
2714 MessageManager.getString("label.backup_filename_strategy")));
2715 suffixPanel.setLayout(new GridBagLayout());
2718 .setText(MessageManager.getString("label.append_to_filename"));
2719 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2720 suffixTemplateLabel.setFont(LABEL_FONT);
2722 final String tooltip = JvSwingUtils.wrapTooltip(true,
2723 MessageManager.getString("label.append_to_filename_tooltip"));
2724 suffixTemplate.setToolTipText(tooltip);
2725 suffixTemplate.addActionListener(new ActionListener()
2728 public void actionPerformed(ActionEvent e)
2730 updateBackupFilesExampleLabel();
2731 backupfilesCustomOptionsSetEnabled();
2732 backupfilesRevertButtonSetEnabled(true);
2736 suffixTemplate.addKeyListener(new KeyListener()
2739 public void keyReleased(KeyEvent e)
2741 updateBackupFilesExampleLabel();
2742 backupfilesCustomOptionsSetEnabled();
2743 backupfilesRevertButtonSetEnabled(true);
2747 public void keyPressed(KeyEvent e)
2751 // disable use of ':' or '/' or '\'
2753 public void keyTyped(KeyEvent e)
2755 char c = e.getKeyChar();
2756 if (c == ':' || c == '/' || c == '\\')
2758 // don't process ':' or '/' or '\'
2767 .setText(MessageManager.getString("label.index_digits"));
2768 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2769 suffixDigitsLabel.setFont(LABEL_FONT);
2770 ChangeListener c = new ChangeListener()
2773 public void stateChanged(ChangeEvent e)
2775 backupfilesRevertButtonSetEnabled(true);
2776 updateBackupFilesExampleLabel();
2780 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2781 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2783 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2784 MessageManager.getString("label.increment_index"));
2785 suffixReverse.addActionListener(new ActionListener()
2788 public void actionPerformed(ActionEvent e)
2790 boolean okay = true;
2791 if (warnAboutSuffixReverseChange())
2794 okay = confirmSuffixReverseChange();
2798 backupfilesRevertButtonSetEnabled(true);
2799 updateBackupFilesExampleLabel();
2803 boolean savedSuffixReverse = BackupFilesPresetEntry
2804 .getSavedBackupEntry().reverse;
2805 suffixReverse.setSelected(savedSuffixReverse);
2810 GridBagConstraints sgbc = new GridBagConstraints();
2812 // first row (template text box)
2813 sgbc.anchor = GridBagConstraints.WEST;
2817 sgbc.gridheight = 1;
2820 sgbc.fill = GridBagConstraints.NONE;
2821 suffixPanel.add(suffixTemplateLabel, sgbc);
2824 sgbc.fill = GridBagConstraints.HORIZONTAL;
2825 suffixPanel.add(suffixTemplate, sgbc);
2827 // second row (number of digits spinner)
2831 sgbc.fill = GridBagConstraints.NONE;
2832 suffixPanel.add(suffixDigitsLabel, sgbc);
2835 sgbc.fill = GridBagConstraints.HORIZONTAL;
2836 suffixPanel.add(suffixDigitsSpinner, sgbc);
2838 // third row (forward order radio selection)
2841 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2842 sgbc.fill = GridBagConstraints.HORIZONTAL;
2843 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2845 // fourth row (reverse order radio selection)
2847 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2851 private boolean confirmSuffixReverseChange()
2853 boolean ret = false;
2854 String warningMessage = MessageManager
2855 .getString("label.warning_confirm_change_reverse");
2856 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
2858 MessageManager.getString("label.change_increment_decrement"),
2859 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2861 ret = (confirm == JvOptionPane.YES_OPTION);
2865 private JPanel initBackupsTabKeepFilesPanel()
2867 keepfilesPanel.setBorder(
2868 new TitledBorder(MessageManager.getString("label.keep_files")));
2869 keepfilesPanel.setLayout(new GridBagLayout());
2871 backupfilesKeepAll.setLabels(
2872 MessageManager.getString("label.keep_all_backup_files"),
2873 MessageManager.getString(
2874 "label.keep_only_this_number_of_backup_files"));
2875 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2878 public void actionPerformed(ActionEvent e)
2880 backupfilesRevertButtonSetEnabled(true);
2881 updateBackupFilesExampleLabel();
2884 backupfilesKeepAll.addActionListener(new ActionListener()
2887 public void actionPerformed(ActionEvent e)
2889 backupfilesRevertButtonSetEnabled(true);
2890 keepRollMaxOptionsEnabled();
2891 updateBackupFilesExampleLabel();
2895 ChangeListener c = new ChangeListener()
2898 public void stateChanged(ChangeEvent e)
2900 backupfilesRevertButtonSetEnabled(true);
2901 updateBackupFilesExampleLabel();
2905 setIntegerSpinner(backupfilesRollMaxSpinner,
2906 BackupFilesPresetEntry.ROLLMAXMIN,
2907 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2909 backupfilesConfirmDelete.setLabels(
2910 MessageManager.getString("label.always_ask"),
2911 MessageManager.getString("label.auto_delete"));
2912 backupfilesConfirmDelete.addActionListener(new ActionListener()
2915 public void actionPerformed(ActionEvent e)
2917 backupfilesRevertButtonSetEnabled(true);
2920 // update the enabled section
2921 keepRollMaxOptionsEnabled();
2923 GridBagConstraints kgbc = new GridBagConstraints();
2925 // first row (template text box)
2926 kgbc.anchor = GridBagConstraints.WEST;
2929 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2930 kgbc.gridheight = 1;
2933 kgbc.fill = GridBagConstraints.HORIZONTAL;
2934 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2940 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2941 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2944 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2945 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2947 // third row (indented)
2949 kgbc.insets = new Insets(0, 20, 0, 0);
2952 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2953 kgbc.fill = GridBagConstraints.HORIZONTAL;
2956 JPanel jp = new JPanel();
2957 jp.setLayout(new FlowLayout());
2959 .setText(MessageManager
2960 .getString("label.autodelete_old_backup_files"));
2961 oldBackupFilesLabel.setFont(LABEL_FONT);
2962 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2963 jp.add(oldBackupFilesLabel);
2964 jp.add(backupfilesConfirmDelete.getTrueButton());
2965 jp.add(backupfilesConfirmDelete.getFalseButton());
2966 keepfilesPanel.add(jp, kgbc);
2968 return keepfilesPanel;
2971 protected void updateBackupFilesExampleLabel()
2973 int exampleindex = 12;
2974 String base = MessageManager.getString("label.filename") + ".fa";
2975 if (base == null || base.length() == 0)
2977 base = "file_name.fa";
2980 boolean reverse = suffixReverse.isSelected();
2981 boolean keepAll = backupfilesKeepAll.isSelected();
2983 String suffix = suffixTemplate.getText();
2986 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2987 if (suffix == null || suffix.length() == 0)
2989 backupfilesExampleLabel
2990 .setText(MessageManager.getString("label.no_backup_files"));
2991 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2995 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2996 rollMax = rollMax < 1 ? 1 : rollMax;
2998 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3003 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3004 digits = digits < 1 ? 1 : digits;
3006 int lowersurround = 2;
3007 int uppersurround = 0;
3008 StringBuilder exampleSB = new StringBuilder();
3009 boolean firstLine = true;
3015 int max = keepAll ? exampleindex : rollMax;
3016 for (int index = min; index <= max; index++)
3018 if (index == min + lowersurround && index < max - uppersurround - 1)
3020 exampleSB.append("\n...");
3023 else if (index > min + lowersurround && index < max - uppersurround)
3035 exampleSB.append("\n");
3038 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3039 base, suffix, digits));
3042 // no extra text needed
3044 else if (index == min)
3046 String newest = MessageManager.getString("label.braced_newest");
3047 if (newest != null && newest.length() > 0)
3049 exampleSB.append(" " + newest);
3052 else if (index == max)
3054 String oldest = MessageManager.getString("label.braced_oldest");
3055 if (oldest != null && oldest.length() > 0)
3057 exampleSB.append(" " + oldest);
3066 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3067 : exampleindex - rollMax + 1;
3068 int max = exampleindex;
3070 for (int index = min; index <= max; index++)
3073 if (index == min + lowersurround && index < max - uppersurround - 1)
3075 exampleSB.append("\n...");
3078 else if (index > min + lowersurround && index < max - uppersurround)
3090 exampleSB.append("\n");
3093 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3094 base, suffix, digits));
3097 // no extra text needed
3099 else if (index == min)
3101 String oldest = MessageManager.getString("label.braced_oldest");
3102 if (oldest != null && oldest.length() > 0)
3104 exampleSB.append(" " + oldest);
3107 else if (index == max)
3109 String newest = MessageManager.getString("label.braced_newest");
3110 if (newest != null && newest.length() > 0)
3112 exampleSB.append(" " + newest);
3120 // add some extra empty lines to pad out the example files box. ugh, please tell
3121 // me how to do this better
3122 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3123 if (remainingLines > 0)
3125 for (int i = 0; i < remainingLines; i++)
3127 exampleSB.append("\n ");
3132 backupfilesExampleLabel.setText(exampleSB.toString());
3135 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3136 boolean useExistingVal, ChangeListener c)
3143 i = ((Integer) s.getValue()).intValue();
3144 } catch (Exception e)
3147 "Exception casting the initial value of s.getValue()");
3151 setIntegerSpinner(s, min, max, i, c);
3154 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3157 // integer spinner for number of digits
3166 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3169 s.addChangeListener(c);
3173 protected static int getSpinnerInt(JSpinner s, int def)
3179 i = (Integer) s.getValue();
3180 } catch (Exception e)
3182 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
3187 private void keepRollMaxOptionsEnabled()
3189 boolean enabled = backupfilesKeepAll.isEnabled()
3190 && !backupfilesKeepAll.isSelected();
3191 oldBackupFilesLabel.setEnabled(enabled);
3192 backupfilesRollMaxSpinner.setEnabled(enabled);
3193 backupfilesConfirmDelete.setEnabled(enabled);
3196 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3198 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3199 && customiseCheckbox.isSelected()
3200 && suffixTemplate.getText()
3201 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3202 keepfilesPanel.setEnabled(enabled);
3203 backupfilesKeepAll.setEnabled(enabled);
3204 oldBackupFilesLabel.setEnabled(enabled);
3205 keepRollMaxOptionsEnabled();
3208 private void backupfilesSuffixTemplateDigitsSetEnabled()
3210 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3211 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3212 suffixDigitsLabel.setEnabled(enabled);
3213 suffixDigitsSpinner.setEnabled(enabled);
3214 suffixReverse.setEnabled(enabled);
3217 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3219 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3220 && customiseCheckbox.isSelected();
3221 suffixPanel.setEnabled(enabled);
3222 suffixTemplateLabel.setEnabled(enabled);
3223 suffixTemplate.setEnabled(enabled);
3224 backupfilesSuffixTemplateDigitsSetEnabled();
3227 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3229 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3230 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3231 revertButton.setEnabled(enabled);
3234 private boolean backupfilesCustomChanged()
3236 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3237 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3238 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3239 return !custom.equals(current);
3242 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3244 String suffix = suffixTemplate.getText();
3245 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3246 boolean reverse = suffixReverse.isSelected();
3247 boolean keepAll = backupfilesKeepAll.isSelected();
3248 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3249 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3251 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3252 reverse, keepAll, rollMax, confirmDelete);
3257 protected void backupfilesCustomOptionsSetEnabled()
3259 boolean enabled = customiseCheckbox.isSelected();
3261 backupfilesRevertButtonSetEnabled(enabled);
3262 backupfilesSuffixTemplateSetEnabled(enabled);
3263 backupfilesKeepAllSetEnabled(enabled);
3266 private void backupfilesSummarySetEnabled()
3268 boolean enabled = enableBackupFiles.isSelected();
3269 backupfilesExampleLabel.setEnabled(enabled);
3270 exampleFilesPanel.setEnabled(enabled);
3273 private void backupfilesPresetsSetEnabled()
3275 boolean enabled = enableBackupFiles.isSelected();
3276 presetsPanel.setEnabled(enabled);
3277 presetsComboLabel.setEnabled(enabled);
3278 backupfilesPresetsCombo.setEnabled(enabled);
3279 customiseCheckbox.setEnabled(enabled);
3280 revertButton.setEnabled(enabled);
3283 protected void backupsOptionsSetEnabled()
3285 backupfilesPresetsSetEnabled();
3286 backupfilesSummarySetEnabled();
3287 backupfilesCustomOptionsSetEnabled();
3290 protected void backupsSetOptions(String suffix, int digits,
3291 boolean reverse, boolean keepAll, int rollMax,
3292 boolean confirmDelete)
3294 suffixTemplate.setText(suffix);
3295 suffixDigitsSpinner.setValue(digits);
3296 suffixReverse.setSelected(reverse);
3297 backupfilesKeepAll.setSelected(keepAll);
3298 backupfilesRollMaxSpinner.setValue(rollMax);
3299 backupfilesConfirmDelete.setSelected(confirmDelete);
3302 protected void backupsSetOptions(BackupFilesPresetEntry p)
3304 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3308 protected void autoIdWidth_actionPerformed()
3310 // TODO Auto-generated method stub
3314 protected void userIdWidth_actionPerformed()
3316 // TODO Auto-generated method stub
3320 protected void maxColour_actionPerformed(JPanel panel)
3324 protected void minColour_actionPerformed(JPanel panel)
3328 protected void gapColour_actionPerformed(JPanel panel)
3332 protected void hiddenColour_actionPerformed(JPanel panel)
3336 protected void showunconserved_actionPerformed(ActionEvent e)
3338 // TODO Auto-generated method stub
3342 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3346 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3356 public void ok_actionPerformed(ActionEvent e)
3366 public void cancel_actionPerformed(ActionEvent e)
3376 public void annotations_actionPerformed(ActionEvent e)
3383 public void startupFileTextfield_mouseClicked()
3387 public void newLink_actionPerformed(ActionEvent e)
3392 public void editLink_actionPerformed(ActionEvent e)
3397 public void deleteLink_actionPerformed(ActionEvent e)
3402 public void defaultBrowser_mouseClicked(MouseEvent e)
3407 public void linkURLList_keyTyped(KeyEvent e)
3412 public void setProxyAuthEnabled()
3414 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3415 proxyAuthUsernameLabel.setEnabled(enabled);
3416 proxyAuthPasswordLabel.setEnabled(enabled);
3417 passwordNotStoredLabel.setEnabled(enabled);
3418 proxyAuthUsernameTB.setEnabled(enabled);
3419 proxyAuthPasswordPB.setEnabled(enabled);
3422 public void setCustomProxyEnabled()
3424 boolean enabled = customProxy.isSelected();
3425 portLabel.setEnabled(enabled);
3426 serverLabel.setEnabled(enabled);
3427 portLabel2.setEnabled(enabled);
3428 serverLabel2.setEnabled(enabled);
3429 httpLabel.setEnabled(enabled);
3430 httpsLabel.setEnabled(enabled);
3431 proxyServerHttpTB.setEnabled(enabled);
3432 proxyPortHttpTB.setEnabled(enabled);
3433 proxyServerHttpsTB.setEnabled(enabled);
3434 proxyPortHttpsTB.setEnabled(enabled);
3435 proxyAuth.setEnabled(enabled);
3436 setProxyAuthEnabled();
3439 public void proxyType_actionPerformed()
3441 setCustomProxyEnabled();
3442 proxyAuthPasswordCheckHighlight(true);
3443 applyProxyButtonEnabled(true);
3446 public void proxyAuth_actionPerformed()
3448 setProxyAuthEnabled();
3449 proxyAuthPasswordCheckHighlight(true);
3450 applyProxyButtonEnabled(true);
3454 * Customer renderer for JTable: supports column of radio buttons
3456 public class RadioButtonRenderer extends JRadioButton
3457 implements TableCellRenderer
3459 public RadioButtonRenderer()
3461 setHorizontalAlignment(CENTER);
3462 setToolTipText(MessageManager.getString("label.urltooltip"));
3466 public Component getTableCellRendererComponent(JTable table,
3467 Object value, boolean isSelected, boolean hasFocus, int row,
3470 setSelected((boolean) value);
3472 // set colours to match rest of table
3475 setBackground(table.getSelectionBackground());
3476 setForeground(table.getSelectionForeground());
3480 setBackground(table.getBackground());
3481 setForeground(table.getForeground());
3488 * Customer cell editor for JTable: supports column of radio buttons in
3489 * conjunction with renderer
3491 public class RadioButtonEditor extends AbstractCellEditor
3492 implements TableCellEditor
3494 private JRadioButton button = new JRadioButton();
3496 public RadioButtonEditor()
3498 button.setHorizontalAlignment(SwingConstants.CENTER);
3499 this.button.addActionListener(new ActionListener()
3502 public void actionPerformed(ActionEvent e)
3504 fireEditingStopped();
3510 public Component getTableCellEditorComponent(JTable table, Object value,
3511 boolean isSelected, int row, int column)
3513 button.setSelected((boolean) value);
3518 public Object getCellEditorValue()
3520 return button.isSelected();
3525 protected void validateHmmerPath()
3529 protected void validateCygwinPath()
3534 * A helper method to add a panel containing a label and a component to a
3542 protected static void addtoLayout(JPanel panel, String tooltip,
3543 JComponent label, JComponent valBox)
3545 JPanel laypanel = new JPanel(new GridLayout(1, 2));
3546 JPanel labPanel = new JPanel(new BorderLayout());
3547 JPanel valPanel = new JPanel();
3548 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
3549 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
3550 labPanel.add(label, BorderLayout.WEST);
3551 valPanel.add(valBox);
3552 laypanel.add(labPanel);
3553 laypanel.add(valPanel);
3554 valPanel.setToolTipText(tooltip);
3555 labPanel.setToolTipText(tooltip);
3556 valBox.setToolTipText(tooltip);
3557 panel.add(laypanel);