2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.util.Arrays;
42 import java.util.List;
44 import javax.swing.AbstractCellEditor;
45 import javax.swing.BorderFactory;
46 import javax.swing.BoxLayout;
47 import javax.swing.ButtonGroup;
48 import javax.swing.DefaultListCellRenderer;
49 import javax.swing.JButton;
50 import javax.swing.JCheckBox;
51 import javax.swing.JComboBox;
52 import javax.swing.JFileChooser;
53 import javax.swing.JLabel;
54 import javax.swing.JPanel;
55 import javax.swing.JPasswordField;
56 import javax.swing.JRadioButton;
57 import javax.swing.JScrollPane;
58 import javax.swing.JSlider;
59 import javax.swing.JSpinner;
60 import javax.swing.JTabbedPane;
61 import javax.swing.JTable;
62 import javax.swing.JTextArea;
63 import javax.swing.JTextField;
64 import javax.swing.ListSelectionModel;
65 import javax.swing.SpinnerModel;
66 import javax.swing.SpinnerNumberModel;
67 import javax.swing.SwingConstants;
68 import javax.swing.border.Border;
69 import javax.swing.border.EmptyBorder;
70 import javax.swing.border.EtchedBorder;
71 import javax.swing.border.TitledBorder;
72 import javax.swing.event.ChangeEvent;
73 import javax.swing.event.ChangeListener;
74 import javax.swing.event.DocumentEvent;
75 import javax.swing.event.DocumentListener;
76 import javax.swing.table.TableCellEditor;
77 import javax.swing.table.TableCellRenderer;
79 import jalview.bin.Cache;
80 import jalview.bin.MemorySetting;
81 import jalview.fts.core.FTSDataColumnPreferences;
82 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
83 import jalview.fts.service.pdb.PDBFTSRestClient;
84 import jalview.gui.Desktop;
85 import jalview.gui.JalviewBooleanRadioButtons;
86 import jalview.gui.JvOptionPane;
87 import jalview.gui.JvSwingUtils;
88 import jalview.gui.StructureViewer.ViewerType;
89 import jalview.io.BackupFilenameParts;
90 import jalview.io.BackupFiles;
91 import jalview.io.BackupFilesPresetEntry;
92 import jalview.io.IntKeyStringValueEntry;
93 import jalview.util.MessageManager;
94 import jalview.util.Platform;
95 import jalview.util.StringUtils;
98 * Base class for the Preferences panel.
101 * @version $Revision$
103 public class GPreferences extends JPanel
105 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
107 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
108 .getLabelFont(false, true);
110 private static final Font LABEL_FONT_BOLD = JvSwingUtils
111 .getLabelFont(true, false);
114 * Visual tab components
116 protected JCheckBox fullScreen = new JCheckBox();
118 protected JCheckBox openoverv = new JCheckBox();
120 protected JCheckBox seqLimit = new JCheckBox();
122 protected JCheckBox rightAlign = new JCheckBox();
124 protected JComboBox<String> fontSizeCB = new JComboBox<>();
126 protected JComboBox<String> fontStyleCB = new JComboBox<>();
128 protected JComboBox<String> fontNameCB = new JComboBox<>();
130 protected JCheckBox showOccupancy = new JCheckBox();
132 protected JCheckBox showUnconserved = new JCheckBox();
134 protected JCheckBox idItalics = new JCheckBox();
136 protected JCheckBox smoothFont = new JCheckBox();
138 protected JCheckBox scaleProteinToCdna = new JCheckBox();
140 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
142 protected JCheckBox wrap = new JCheckBox();
144 protected JComboBox<String> sortby = new JComboBox<>();
146 protected JComboBox<String> sortAnnBy = new JComboBox<>();
148 protected JComboBox<String> sortAutocalc = new JComboBox<>();
150 protected JCheckBox startupCheckbox = new JCheckBox();
152 protected JTextField startupFileTextfield = new JTextField();
154 // below are in the 'second column'
155 protected JCheckBox annotations = new JCheckBox();
157 protected JCheckBox quality = new JCheckBox();
159 protected JCheckBox conservation = new JCheckBox();
161 protected JCheckBox identity = new JCheckBox();
163 protected JCheckBox showGroupConsensus = new JCheckBox();
165 protected JCheckBox showGroupConservation = new JCheckBox();
167 protected JCheckBox showConsensHistogram = new JCheckBox();
169 protected JCheckBox showConsensLogo = new JCheckBox();
171 protected JCheckBox showDbRefTooltip = new JCheckBox();
173 protected JCheckBox showNpTooltip = new JCheckBox();
176 * Structure tab and components
178 protected JPanel structureTab;
180 protected JCheckBox structFromPdb = new JCheckBox();
182 protected JCheckBox addSecondaryStructure = new JCheckBox();
184 protected JCheckBox addTempFactor = new JCheckBox();
186 protected JComboBox<String> structViewer = new JComboBox<>();
188 protected JLabel structureViewerPathLabel;
190 protected JTextField structureViewerPath = new JTextField();
192 protected ButtonGroup mappingMethod = new ButtonGroup();
194 protected JRadioButton siftsMapping = new JRadioButton();
196 protected JRadioButton nwMapping = new JRadioButton();
199 * Colours tab components
201 protected JPanel minColour = new JPanel();
203 protected JPanel maxColour = new JPanel();
205 protected JComboBox<String> protColour = new JComboBox<>();
207 protected JComboBox<String> nucColour = new JComboBox<>();
210 * Overview tab components
212 protected JPanel gapColour = new JPanel();
214 protected JPanel hiddenColour = new JPanel();
216 protected JCheckBox useLegacyGap;
218 protected JCheckBox showHiddenAtStart;
220 protected JLabel gapLabel;
223 * Connections tab components
225 protected JPanel connectTab;
227 protected JTable linkUrlTable = new JTable();
229 protected JButton editLink = new JButton();
231 protected JButton deleteLink = new JButton();
233 protected JTextField filterTB = new JTextField();
235 protected JButton doReset = new JButton();
237 protected JButton userOnly = new JButton();
239 protected JLabel httpLabel = new JLabel();
241 protected JLabel httpsLabel = new JLabel();
243 protected JLabel portLabel = new JLabel();
245 protected JLabel serverLabel = new JLabel();
247 protected JLabel portLabel2 = new JLabel();
249 protected JLabel serverLabel2 = new JLabel();
251 protected JLabel proxyAuthUsernameLabel = new JLabel();
253 protected JLabel proxyAuthPasswordLabel = new JLabel();
255 protected JLabel passwordNotStoredLabel = new JLabel();
257 protected JTextField proxyServerHttpTB = new JTextField();
259 protected JTextField proxyPortHttpTB = new JTextField();
261 protected JTextField proxyServerHttpsTB = new JTextField();
263 protected JTextField proxyPortHttpsTB = new JTextField();
265 protected JCheckBox proxyAuth = new JCheckBox();
267 protected JTextField proxyAuthUsernameTB = new JTextField();
269 protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
271 protected JTextField defaultBrowser = new JTextField();
273 protected ButtonGroup proxyType = new ButtonGroup();
275 protected JRadioButton noProxy = new JRadioButton();
277 protected JRadioButton systemProxy = new JRadioButton();
279 protected JRadioButton customProxy = new JRadioButton();
281 protected JButton applyProxyButton = new JButton();
283 protected JCheckBox usagestats = new JCheckBox();
285 protected JCheckBox questionnaire = new JCheckBox();
287 protected JCheckBox versioncheck = new JCheckBox();
290 * Output tab components
292 protected JComboBox<Object> epsRendering = new JComboBox<>();
294 protected JComboBox<Object> htmlRendering = new JComboBox<>();
296 protected JComboBox<Object> svgRendering = new JComboBox<>();
298 protected JLabel userIdWidthlabel = new JLabel();
300 protected JCheckBox autoIdWidth = new JCheckBox();
302 protected JTextField userIdWidth = new JTextField();
304 protected JCheckBox blcjv = new JCheckBox();
306 protected JCheckBox pileupjv = new JCheckBox();
308 protected JCheckBox clustaljv = new JCheckBox();
310 protected JCheckBox msfjv = new JCheckBox();
312 protected JCheckBox fastajv = new JCheckBox();
314 protected JCheckBox pfamjv = new JCheckBox();
316 protected JCheckBox pirjv = new JCheckBox();
318 protected JCheckBox modellerOutput = new JCheckBox();
320 protected JCheckBox embbedBioJSON = new JCheckBox();
323 * Editing tab components
325 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
327 protected JCheckBox padGaps = new JCheckBox();
329 protected JCheckBox sortByTree = new JCheckBox();
334 protected JPanel wsTab = new JPanel();
337 * Backups tab components
338 * a lot of these are member variables instead of local variables only so that they
339 * can be enabled/disabled easily in one go
342 protected JCheckBox enableBackupFiles = new JCheckBox();
344 protected JPanel presetsPanel = new JPanel();
346 protected JLabel presetsComboLabel = new JLabel();
348 protected JCheckBox customiseCheckbox = new JCheckBox();
350 protected JButton revertButton = new JButton();
352 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
354 private int backupfilesPresetsComboLastSelected = 0;
356 protected JPanel suffixPanel = new JPanel();
358 protected JPanel keepfilesPanel = new JPanel();
360 protected JPanel exampleFilesPanel = new JPanel();
362 protected JTextField suffixTemplate = new JTextField(null, 8);
364 protected JLabel suffixTemplateLabel = new JLabel();
366 protected JLabel suffixDigitsLabel = new JLabel();
368 protected JSpinner suffixDigitsSpinner = new JSpinner();
370 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
372 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
374 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
376 protected JLabel oldBackupFilesLabel = new JLabel();
378 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
380 protected JTextArea backupfilesExampleLabel = new JTextArea();
382 private final JTabbedPane tabbedPane = new JTabbedPane();
384 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
387 * Startup tab components
390 protected JCheckBox customiseMemorySetting = new JCheckBox();
392 protected JLabel exampleMemoryLabel = new JLabel();
394 protected JTextArea exampleMemoryMessageTextArea = new JTextArea();
396 protected JLabel maxMemoryLabel = new JLabel();
398 protected JLabel jvmMemoryPercentLabel = new JLabel();
400 protected JSlider jvmMemoryPercentSlider = new JSlider();
402 protected JLabel jvmMemoryPercentDisplay = new JLabel();
404 protected JLabel jvmMemoryMaxLabel = new JLabel();
406 protected JTextField jvmMemoryMaxTextField = new JTextField(null, 8);
408 protected JComboBox<Object> lafCombo = new JComboBox<>();
411 * Creates a new GPreferences object.
413 public GPreferences()
418 } catch (Exception ex)
420 ex.printStackTrace();
425 * Construct the panel and its tabbed sub-panels.
429 private void jbInit() throws Exception
431 // final JTabbedPane tabbedPane = new JTabbedPane();
432 this.setLayout(new BorderLayout());
434 // message label at top
435 this.add(messageLabel, BorderLayout.NORTH);
437 JPanel okCancelPanel = initOkCancelPanel();
438 this.add(tabbedPane, BorderLayout.CENTER);
439 this.add(okCancelPanel, BorderLayout.SOUTH);
441 tabbedPane.add(initVisualTab(),
442 MessageManager.getString("label.visual"));
444 tabbedPane.add(initColoursTab(),
445 MessageManager.getString("label.colours"));
447 tabbedPane.add(initOverviewTab(),
448 MessageManager.getString("label.overview"));
450 tabbedPane.add(initStructureTab(),
451 MessageManager.getString("label.structure"));
453 tabbedPane.add(initConnectionsTab(),
454 MessageManager.getString("label.connections"));
456 if (!Platform.isJS())
458 tabbedPane.add(initBackupsTab(),
459 MessageManager.getString("label.backups"));
462 tabbedPane.add(initLinksTab(),
463 MessageManager.getString("label.urllinks"));
465 tabbedPane.add(initOutputTab(),
466 MessageManager.getString("label.output"));
468 tabbedPane.add(initEditingTab(),
469 MessageManager.getString("label.editing"));
471 tabbedPane.add(initStartupTab(),
472 MessageManager.getString("label.startup"));
475 * See WsPreferences for the real work of configuring this tab.
477 if (!Platform.isJS())
479 wsTab.setLayout(new BorderLayout());
480 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
484 * Handler to validate a tab before leaving it - currently only for
486 * Adding a clearMessage() so messages are cleared when changing tabs.
488 tabbedPane.addChangeListener(new ChangeListener()
490 private Component lastTab;
493 public void stateChanged(ChangeEvent e)
495 if (lastTab == structureTab
496 && tabbedPane.getSelectedComponent() != structureTab)
498 if (!validateStructure())
500 tabbedPane.setSelectedComponent(structureTab);
504 lastTab = tabbedPane.getSelectedComponent();
512 public void setMessage(String message)
516 messageLabel.setText(message);
517 messageLabel.setFont(LABEL_FONT_BOLD);
518 messageLabel.setForeground(Color.RED.darker());
519 messageLabel.revalidate();
520 messageLabel.repaint();
522 // note message not cleared if message is null. call clearMessage()
528 public void clearMessage()
530 // only repaint if message exists
531 if (messageLabel.getText() != null
532 && messageLabel.getText().length() > 0)
534 messageLabel.setText("");
535 messageLabel.revalidate();
536 messageLabel.repaint();
542 public static enum TabRef
544 CONNECTIONS_TAB, STRUCTURE_TAB
547 public void selectTab(TabRef selectTab)
549 // select a given tab - currently only for Connections
552 case CONNECTIONS_TAB:
553 tabbedPane.setSelectedComponent(connectTab);
556 tabbedPane.setSelectedComponent(structureTab);
563 * Initialises the Editing tabbed panel.
567 private JPanel initEditingTab()
569 JPanel editingTab = new JPanel();
570 editingTab.setLayout(null);
571 autoCalculateConsCheck.setFont(LABEL_FONT);
572 autoCalculateConsCheck.setText(
573 MessageManager.getString("label.autocalculate_consensus"));
574 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
575 padGaps.setFont(LABEL_FONT);
577 MessageManager.getString("label.pad_gaps_when_editing"));
578 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
579 sortByTree.setFont(LABEL_FONT);
581 .setText(MessageManager.getString("label.sort_with_new_tree"));
582 sortByTree.setToolTipText(MessageManager.getString(
583 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
584 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
585 editingTab.add(autoCalculateConsCheck);
586 editingTab.add(padGaps);
587 editingTab.add(sortByTree);
592 * Initialises the Output tab
596 private JPanel initOutputTab()
598 JPanel outputTab = new JPanel();
599 outputTab.setLayout(null);
601 JLabel epsLabel = new JLabel(
602 MessageManager.formatMessage("label.rendering_style", "EPS"));
603 epsLabel.setFont(LABEL_FONT);
604 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
605 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
606 epsRendering.setFont(LABEL_FONT);
607 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
608 JLabel htmlLabel = new JLabel(
609 MessageManager.formatMessage("label.rendering_style", "HTML"));
610 htmlLabel.setFont(LABEL_FONT);
611 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
612 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
613 htmlRendering.setFont(LABEL_FONT);
614 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
615 JLabel svgLabel = new JLabel(
616 MessageManager.formatMessage("label.rendering_style", "SVG"));
617 svgLabel.setFont(LABEL_FONT);
618 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
619 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
620 svgRendering.setFont(LABEL_FONT);
621 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
623 JLabel jLabel1 = new JLabel();
624 jLabel1.setFont(LABEL_FONT);
625 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
626 jLabel1.setText(MessageManager.getString("label.append_start_end"));
627 jLabel1.setFont(LABEL_FONT);
629 fastajv.setFont(LABEL_FONT);
630 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
631 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
632 blcjv.setText(MessageManager.getString("label.blc") + " ");
633 fastajv.setText(MessageManager.getString("label.fasta") + " ");
634 msfjv.setText(MessageManager.getString("label.msf") + " ");
635 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
636 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
637 msfjv.setFont(LABEL_FONT);
638 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
639 pirjv.setText(MessageManager.getString("label.pir") + " ");
640 JPanel jPanel11 = new JPanel();
641 jPanel11.setFont(LABEL_FONT);
642 TitledBorder titledBorder2 = new TitledBorder(
643 MessageManager.getString("label.file_output"));
644 jPanel11.setBorder(titledBorder2);
645 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
646 GridLayout gridLayout3 = new GridLayout();
647 jPanel11.setLayout(gridLayout3);
648 gridLayout3.setRows(8);
649 blcjv.setFont(LABEL_FONT);
650 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
651 clustaljv.setFont(LABEL_FONT);
652 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
653 pfamjv.setFont(LABEL_FONT);
654 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
655 pileupjv.setFont(LABEL_FONT);
656 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
657 pirjv.setFont(LABEL_FONT);
658 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
659 autoIdWidth.setFont(LABEL_FONT);
661 MessageManager.getString("label.automatically_set_id_width"));
662 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
663 .getString("label.adjusts_width_generated_eps_png")));
664 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
665 autoIdWidth.addActionListener(new ActionListener()
669 public void actionPerformed(ActionEvent e)
671 autoIdWidth_actionPerformed();
674 userIdWidthlabel.setFont(LABEL_FONT);
675 userIdWidthlabel.setText(
676 MessageManager.getString("label.figure_id_column_width"));
677 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
678 .getString("label.manually_specify_width_left_column")));
679 userIdWidthlabel.setToolTipText(
680 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
681 "label.manually_specify_width_left_column")));
682 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
683 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
684 userIdWidth.setText("");
685 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
686 userIdWidth.addActionListener(new ActionListener()
690 public void actionPerformed(ActionEvent e)
692 userIdWidth_actionPerformed();
695 modellerOutput.setFont(LABEL_FONT);
697 .setText(MessageManager.getString("label.use_modeller_output"));
698 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
699 embbedBioJSON.setFont(LABEL_FONT);
700 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
701 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
703 jPanel11.add(jLabel1);
705 jPanel11.add(clustaljv);
706 jPanel11.add(fastajv);
708 jPanel11.add(pfamjv);
709 jPanel11.add(pileupjv);
711 outputTab.add(autoIdWidth);
712 outputTab.add(userIdWidth);
713 outputTab.add(userIdWidthlabel);
714 outputTab.add(modellerOutput);
715 if (!Platform.isJS())
718 * JalviewJS doesn't support Lineart option or SVG output
720 outputTab.add(embbedBioJSON);
721 outputTab.add(epsLabel);
722 outputTab.add(epsRendering);
723 outputTab.add(htmlLabel);
724 outputTab.add(htmlRendering);
725 outputTab.add(svgLabel);
726 outputTab.add(svgRendering);
728 outputTab.add(jPanel11);
733 * Initialises the Connections tabbed panel.
737 private JPanel initConnectionsTab()
739 connectTab = new JPanel();
740 connectTab.setLayout(new GridBagLayout());
742 // Label for browser text box
743 JLabel browserLabel = new JLabel();
744 browserLabel.setFont(LABEL_FONT);
745 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
746 browserLabel.setText(
747 MessageManager.getString("label.default_browser_unix"));
748 defaultBrowser.setFont(LABEL_FONT);
749 defaultBrowser.setText("");
750 final String tooltip = JvSwingUtils.wrapTooltip(true,
751 MessageManager.getString("label.double_click_to_browse"));
752 defaultBrowser.setToolTipText(tooltip);
753 defaultBrowser.addMouseListener(new MouseAdapter()
756 public void mouseClicked(MouseEvent e)
758 if (e.getClickCount() > 1)
760 defaultBrowser_mouseClicked(e);
765 JPanel proxyPanel = initConnTabProxyPanel();
766 initConnTabCheckboxes();
768 // Add default Browser text box
769 connectTab.add(browserLabel,
770 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
771 GridBagConstraints.WEST, GridBagConstraints.NONE,
772 new Insets(10, 0, 5, 5), 5, 1));
773 defaultBrowser.setFont(LABEL_FONT);
774 defaultBrowser.setText("");
776 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
777 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
778 new Insets(10, 0, 5, 10), 30, 1));
780 // Add proxy server panel
781 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
782 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
783 new Insets(10, 0, 5, 12), 4, 10));
785 // Add usage stats, version check and questionnaire checkboxes
786 connectTab.add(usagestats,
787 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
788 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
789 new Insets(0, 2, 5, 5), 70, 1));
790 connectTab.add(questionnaire,
791 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
792 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
793 new Insets(0, 2, 5, 10), 70, 1));
794 connectTab.add(versioncheck,
795 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
796 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
797 new Insets(0, 2, 5, 5), 70, 1));
799 versioncheck.setVisible(false);
801 // Add padding so the panel doesn't look ridiculous
802 JPanel spacePanel = new JPanel();
803 connectTab.add(spacePanel,
804 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
805 GridBagConstraints.WEST, GridBagConstraints.BOTH,
806 new Insets(0, 0, 0, 5), 70, 1));
812 * Initialises the Links tabbed panel.
816 private JPanel initLinksTab()
818 JPanel linkTab = new JPanel();
819 linkTab.setLayout(new GridBagLayout());
821 // Set up table for Url links
822 linkUrlTable.getTableHeader().setReorderingAllowed(false);
823 linkUrlTable.setFillsViewportHeight(true);
824 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
825 linkUrlTable.setAutoCreateRowSorter(true);
826 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
828 // adjust row height so radio buttons actually fit
829 // don't do this in the renderer, it causes the awt thread to activate
831 JRadioButton temp = new JRadioButton();
832 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
834 // Table in scrollpane so that the table is given a scrollbar
835 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
836 linkScrollPane.setBorder(null);
838 // Panel for links functionality
839 JPanel linkPanel = new JPanel(new GridBagLayout());
840 linkPanel.setBorder(new TitledBorder(
841 MessageManager.getString("label.url_linkfrom_sequence_id")));
843 // Put the Url links panel together
845 // Buttons go at top right, resizing only resizes the blank space vertically
846 JPanel buttonPanel = initLinkTabUrlButtons();
847 GridBagConstraints linkConstraints1 = new GridBagConstraints();
848 linkConstraints1.insets = new Insets(0, 0, 5, 0);
849 linkConstraints1.gridx = 0;
850 linkConstraints1.gridy = 0;
851 linkConstraints1.weightx = 1.0;
852 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
853 linkTab.add(buttonPanel, linkConstraints1);
855 // Links table goes at top left, resizing resizes the table
856 GridBagConstraints linkConstraints2 = new GridBagConstraints();
857 linkConstraints2.insets = new Insets(0, 0, 5, 5);
858 linkConstraints2.gridx = 0;
859 linkConstraints2.gridy = 1;
860 linkConstraints2.weightx = 1.0;
861 linkConstraints2.weighty = 1.0;
862 linkConstraints2.fill = GridBagConstraints.BOTH;
863 linkTab.add(linkScrollPane, linkConstraints2);
865 // Filter box and buttons goes at bottom left, resizing resizes the text box
866 JPanel filterPanel = initLinkTabFilterPanel();
867 GridBagConstraints linkConstraints3 = new GridBagConstraints();
868 linkConstraints3.insets = new Insets(0, 0, 0, 5);
869 linkConstraints3.gridx = 0;
870 linkConstraints3.gridy = 2;
871 linkConstraints3.weightx = 1.0;
872 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
873 linkTab.add(filterPanel, linkConstraints3);
878 private JPanel initLinkTabFilterPanel()
880 // Filter textbox and reset button
881 JLabel filterLabel = new JLabel(
882 MessageManager.getString("label.filter"));
883 filterLabel.setFont(LABEL_FONT);
884 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
885 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
887 filterTB.setFont(LABEL_FONT);
888 filterTB.setText("");
890 doReset.setText(MessageManager.getString("action.showall"));
891 userOnly.setText(MessageManager.getString("action.customfilter"));
893 // Panel for filter functionality
894 JPanel filterPanel = new JPanel(new GridBagLayout());
895 filterPanel.setBorder(new TitledBorder("Filter"));
896 GridBagConstraints gbc = new GridBagConstraints();
899 gbc.fill = GridBagConstraints.NONE;
900 gbc.anchor = GridBagConstraints.WEST;
902 filterPanel.add(filterLabel, gbc);
904 GridBagConstraints gbc1 = new GridBagConstraints();
907 gbc1.fill = GridBagConstraints.HORIZONTAL;
908 gbc1.anchor = GridBagConstraints.WEST;
910 filterPanel.add(filterTB, gbc1);
912 GridBagConstraints gbc2 = new GridBagConstraints();
914 gbc2.fill = GridBagConstraints.NONE;
915 gbc2.anchor = GridBagConstraints.WEST;
916 filterPanel.add(doReset, gbc2);
918 GridBagConstraints gbc3 = new GridBagConstraints();
920 gbc3.fill = GridBagConstraints.NONE;
921 gbc3.anchor = GridBagConstraints.WEST;
922 filterPanel.add(userOnly, gbc3);
927 private JPanel initLinkTabUrlButtons()
929 // Buttons for new / edit / delete Url links
930 JButton newLink = new JButton();
931 newLink.setText(MessageManager.getString("action.new"));
933 editLink.setText(MessageManager.getString("action.edit"));
935 deleteLink.setText(MessageManager.getString("action.delete"));
937 // no current selection, so initially disable delete/edit buttons
938 editLink.setEnabled(false);
939 deleteLink.setEnabled(false);
941 newLink.addActionListener(new java.awt.event.ActionListener()
944 public void actionPerformed(ActionEvent e)
946 newLink_actionPerformed(e);
950 editLink.setText(MessageManager.getString("action.edit"));
951 editLink.addActionListener(new java.awt.event.ActionListener()
954 public void actionPerformed(ActionEvent e)
956 editLink_actionPerformed(e);
960 deleteLink.setText(MessageManager.getString("action.delete"));
961 deleteLink.addActionListener(new java.awt.event.ActionListener()
964 public void actionPerformed(ActionEvent e)
966 deleteLink_actionPerformed(e);
970 JPanel buttonPanel = new JPanel(new GridBagLayout());
971 buttonPanel.setBorder(new TitledBorder("Edit links"));
972 GridBagConstraints gbc = new GridBagConstraints();
975 gbc.fill = GridBagConstraints.NONE;
976 buttonPanel.add(newLink, gbc);
978 GridBagConstraints gbc1 = new GridBagConstraints();
981 gbc1.fill = GridBagConstraints.NONE;
982 buttonPanel.add(editLink, gbc1);
984 GridBagConstraints gbc2 = new GridBagConstraints();
987 gbc2.fill = GridBagConstraints.NONE;
988 buttonPanel.add(deleteLink, gbc2);
990 GridBagConstraints gbc3 = new GridBagConstraints();
993 gbc3.fill = GridBagConstraints.HORIZONTAL;
995 JPanel spacePanel = new JPanel();
996 spacePanel.setBorder(null);
997 buttonPanel.add(spacePanel, gbc3);
1003 * Initialises the proxy server panel in the Connections tab
1005 * @return the proxy server panel
1007 private JPanel initConnTabProxyPanel()
1009 // Label for server text box
1010 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1011 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1012 serverLabel.setFont(LABEL_FONT);
1013 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1014 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1015 serverLabel2.setFont(LABEL_FONT);
1017 // Proxy server and port text boxes
1018 proxyServerHttpTB.setFont(LABEL_FONT);
1019 proxyServerHttpTB.setColumns(40);
1020 proxyPortHttpTB.setFont(LABEL_FONT);
1021 proxyPortHttpTB.setColumns(4);
1022 proxyServerHttpsTB.setFont(LABEL_FONT);
1023 proxyServerHttpsTB.setColumns(40);
1024 proxyPortHttpsTB.setFont(LABEL_FONT);
1025 proxyPortHttpsTB.setColumns(4);
1026 proxyAuthUsernameTB.setFont(LABEL_FONT);
1027 proxyAuthUsernameTB.setColumns(30);
1029 // check for any change to enable applyProxyButton
1030 DocumentListener d = new DocumentListener()
1033 public void changedUpdate(DocumentEvent e)
1035 applyProxyButtonEnabled(true);
1039 public void insertUpdate(DocumentEvent e)
1041 applyProxyButtonEnabled(true);
1045 public void removeUpdate(DocumentEvent e)
1047 applyProxyButtonEnabled(true);
1050 proxyServerHttpTB.getDocument().addDocumentListener(d);
1051 proxyPortHttpTB.getDocument().addDocumentListener(d);
1052 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1053 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1054 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1055 proxyAuthPasswordPB.setFont(LABEL_FONT);
1056 proxyAuthPasswordPB.setColumns(30);
1057 proxyAuthPasswordPB.getDocument()
1058 .addDocumentListener(new DocumentListener()
1061 public void changedUpdate(DocumentEvent e)
1063 proxyAuthPasswordCheckHighlight(true);
1064 applyProxyButtonEnabled(true);
1068 public void insertUpdate(DocumentEvent e)
1070 proxyAuthPasswordCheckHighlight(true);
1071 applyProxyButtonEnabled(true);
1075 public void removeUpdate(DocumentEvent e)
1077 proxyAuthPasswordCheckHighlight(true);
1078 applyProxyButtonEnabled(true);
1083 // Label for Port text box
1084 portLabel.setFont(LABEL_FONT);
1085 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1086 portLabel.setText(MessageManager.getString("label.port") + ": ");
1087 portLabel2.setFont(LABEL_FONT);
1088 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1089 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1091 httpLabel.setText("HTTP");
1092 httpLabel.setFont(LABEL_FONT_BOLD);
1093 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1094 httpsLabel.setText("HTTPS");
1095 httpsLabel.setFont(LABEL_FONT_BOLD);
1096 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1098 proxyAuthUsernameLabel
1099 .setText(MessageManager.getString("label.username") + ": ");
1100 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1101 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1102 proxyAuthPasswordLabel
1103 .setText(MessageManager.getString("label.password") + ": ");
1104 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1105 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1106 passwordNotStoredLabel.setText(
1107 "(" + MessageManager.getString("label.not_stored") + ")");
1108 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1109 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1111 // Proxy type radio buttons
1112 noProxy.setFont(LABEL_FONT);
1113 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1114 noProxy.setText(MessageManager.getString("label.no_proxy"));
1115 systemProxy.setFont(LABEL_FONT);
1116 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1117 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1118 displayUserHostPort(Cache.startupProxyProperties[4],
1119 Cache.startupProxyProperties[0],
1120 Cache.startupProxyProperties[1]),
1121 displayUserHostPort(Cache.startupProxyProperties[6],
1122 Cache.startupProxyProperties[2],
1123 Cache.startupProxyProperties[3])));
1124 customProxy.setFont(LABEL_FONT);
1125 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1126 customProxy.setText(
1127 MessageManager.getString("label.use_proxy_server") + ":");
1128 ActionListener al = new ActionListener()
1131 public void actionPerformed(ActionEvent e)
1133 proxyType_actionPerformed();
1136 noProxy.addActionListener(al);
1137 systemProxy.addActionListener(al);
1138 customProxy.addActionListener(al);
1139 proxyType.add(noProxy);
1140 proxyType.add(systemProxy);
1141 proxyType.add(customProxy);
1143 proxyAuth.setFont(LABEL_FONT);
1144 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1145 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1146 proxyAuth.addActionListener(new ActionListener()
1149 public void actionPerformed(ActionEvent e)
1151 proxyAuth_actionPerformed();
1155 setCustomProxyEnabled();
1157 // Make proxy server panel
1158 JPanel proxyPanel = new JPanel();
1159 TitledBorder titledBorder1 = new TitledBorder(
1160 MessageManager.getString("label.proxy_servers"));
1161 proxyPanel.setBorder(titledBorder1);
1162 proxyPanel.setLayout(new GridBagLayout());
1163 GridBagConstraints gbc = new GridBagConstraints();
1164 gbc.fill = GridBagConstraints.HORIZONTAL;
1167 GridBagConstraints c = new GridBagConstraints();
1168 // Proxy type radio buttons (3)
1169 JPanel ptPanel = new JPanel();
1170 ptPanel.setLayout(new GridBagLayout());
1175 c.fill = GridBagConstraints.HORIZONTAL;
1176 ptPanel.add(noProxy, c);
1178 ptPanel.add(systemProxy, c);
1180 ptPanel.add(customProxy, c);
1183 proxyPanel.add(ptPanel, gbc);
1185 // host and port text boxes
1186 JPanel hpPanel = new JPanel();
1187 hpPanel.setLayout(new GridBagLayout());
1188 // HTTP host port row
1193 c.anchor = GridBagConstraints.LINE_START;
1194 hpPanel.add(httpLabel, c);
1198 c.anchor = GridBagConstraints.LINE_END;
1199 hpPanel.add(serverLabel, c);
1203 c.anchor = GridBagConstraints.LINE_START;
1204 hpPanel.add(proxyServerHttpTB, c);
1208 c.anchor = GridBagConstraints.LINE_END;
1209 hpPanel.add(portLabel, c);
1213 c.anchor = GridBagConstraints.LINE_START;
1214 hpPanel.add(proxyPortHttpTB, c);
1216 // HTTPS host port row
1221 c.anchor = GridBagConstraints.LINE_START;
1222 hpPanel.add(httpsLabel, c);
1225 c.anchor = GridBagConstraints.LINE_END;
1226 hpPanel.add(serverLabel2, c);
1229 c.anchor = GridBagConstraints.LINE_START;
1230 hpPanel.add(proxyServerHttpsTB, c);
1233 c.anchor = GridBagConstraints.LINE_END;
1234 hpPanel.add(portLabel2, c);
1237 c.anchor = GridBagConstraints.LINE_START;
1238 hpPanel.add(proxyPortHttpsTB, c);
1241 proxyPanel.add(hpPanel, gbc);
1243 if (!Platform.isJS())
1245 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1246 * Authentication options in Preferences.
1252 // Require authentication checkbox
1254 proxyPanel.add(proxyAuth, gbc);
1256 // username and password
1257 JPanel upPanel = new JPanel();
1258 upPanel.setLayout(new GridBagLayout());
1264 c.anchor = GridBagConstraints.LINE_END;
1265 upPanel.add(proxyAuthUsernameLabel, c);
1269 c.anchor = GridBagConstraints.LINE_START;
1270 upPanel.add(proxyAuthUsernameTB, c);
1276 c.anchor = GridBagConstraints.LINE_END;
1277 upPanel.add(proxyAuthPasswordLabel, c);
1281 c.anchor = GridBagConstraints.LINE_START;
1282 upPanel.add(proxyAuthPasswordPB, c);
1286 c.anchor = GridBagConstraints.LINE_START;
1287 upPanel.add(passwordNotStoredLabel, c);
1290 proxyPanel.add(upPanel, gbc);
1294 applyProxyButton.setText(MessageManager.getString("action.apply"));
1295 applyProxyButton.addActionListener(new ActionListener()
1298 public void actionPerformed(ActionEvent e)
1300 saveProxySettings();
1301 applyProxyButton.setEnabled(false);
1305 gbc.fill = GridBagConstraints.NONE;
1306 gbc.anchor = GridBagConstraints.LINE_END;
1307 proxyPanel.add(applyProxyButton, gbc);
1312 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1314 proxyAuthPasswordCheckHighlight(enabled, false);
1317 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1320 if (enabled && proxyType.isSelected(customProxy.getModel())
1321 && proxyAuth.isSelected()
1322 && !proxyAuthUsernameTB.getText().isEmpty()
1323 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1326 proxyAuthPasswordPB.grabFocus();
1327 proxyAuthPasswordPB.setBackground(Color.PINK);
1331 proxyAuthPasswordPB.setBackground(Color.WHITE);
1335 public void applyProxyButtonEnabled(boolean enabled)
1337 applyProxyButton.setEnabled(enabled);
1340 public void saveProxySettings()
1342 // overridden in Preferences
1345 private String displayUserHostPort(String user, String host, String port)
1347 boolean hostBlank = (host == null || host.isEmpty());
1348 boolean portBlank = (port == null || port.isEmpty());
1349 if (hostBlank && portBlank)
1351 return MessageManager.getString("label.none");
1354 StringBuilder sb = new StringBuilder();
1357 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1361 sb.append(hostBlank ? "" : host);
1367 return sb.toString();
1371 * Initialises the checkboxes in the Connections tab
1373 private void initConnTabCheckboxes()
1375 // Usage stats checkbox label
1377 MessageManager.getString("label.send_usage_statistics"));
1378 usagestats.setFont(LABEL_FONT);
1379 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1380 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1382 // Questionnaire checkbox label
1383 questionnaire.setText(
1384 MessageManager.getString("label.check_for_questionnaires"));
1385 questionnaire.setFont(LABEL_FONT);
1386 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1387 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1389 // Check for latest version checkbox label
1390 versioncheck.setText(
1391 MessageManager.getString("label.check_for_latest_version"));
1392 versioncheck.setFont(LABEL_FONT);
1393 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1394 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1398 * Initialises the parent panel which contains the tabbed sections.
1402 private JPanel initOkCancelPanel()
1404 JButton ok = new JButton();
1405 ok.setText(MessageManager.getString("action.ok"));
1406 ok.addActionListener(new ActionListener()
1409 public void actionPerformed(ActionEvent e)
1411 ok_actionPerformed(e);
1414 JButton cancel = new JButton();
1415 cancel.setText(MessageManager.getString("action.cancel"));
1416 cancel.addActionListener(new ActionListener()
1419 public void actionPerformed(ActionEvent e)
1421 cancel_actionPerformed(e);
1424 JPanel okCancelPanel = new JPanel();
1425 okCancelPanel.add(ok);
1426 okCancelPanel.add(cancel);
1427 return okCancelPanel;
1431 * Initialises the Colours tabbed panel.
1435 private JPanel initColoursTab()
1437 JPanel coloursTab = new JPanel();
1438 coloursTab.setBorder(new TitledBorder(
1439 MessageManager.getString("action.open_new_alignment")));
1440 coloursTab.setLayout(new FlowLayout());
1441 JLabel mincolourLabel = new JLabel();
1442 mincolourLabel.setFont(LABEL_FONT);
1443 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1444 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1445 minColour.setFont(LABEL_FONT);
1446 minColour.setBorder(BorderFactory.createEtchedBorder());
1447 minColour.setPreferredSize(new Dimension(40, 20));
1448 minColour.addMouseListener(new MouseAdapter()
1451 public void mousePressed(MouseEvent e)
1453 minColour_actionPerformed(minColour);
1456 JLabel maxcolourLabel = new JLabel();
1457 maxcolourLabel.setFont(LABEL_FONT);
1458 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1459 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1460 maxColour.setFont(LABEL_FONT);
1461 maxColour.setBorder(BorderFactory.createEtchedBorder());
1462 maxColour.setPreferredSize(new Dimension(40, 20));
1463 maxColour.addMouseListener(new MouseAdapter()
1466 public void mousePressed(MouseEvent e)
1468 maxColour_actionPerformed(maxColour);
1472 protColour.setFont(LABEL_FONT);
1473 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1474 JLabel protColourLabel = new JLabel();
1475 protColourLabel.setFont(LABEL_FONT);
1476 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1477 protColourLabel.setText(
1478 MessageManager.getString("label.prot_alignment_colour") + " ");
1479 JvSwingUtils.addtoLayout(coloursTab,
1481 .getString("label.default_colour_scheme_for_alignment"),
1482 protColourLabel, protColour);
1484 nucColour.setFont(LABEL_FONT);
1485 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1486 JLabel nucColourLabel = new JLabel();
1487 nucColourLabel.setFont(LABEL_FONT);
1488 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1489 nucColourLabel.setText(
1490 MessageManager.getString("label.nuc_alignment_colour") + " ");
1491 JvSwingUtils.addtoLayout(coloursTab,
1493 .getString("label.default_colour_scheme_for_alignment"),
1494 nucColourLabel, nucColour);
1496 JPanel annotationShding = new JPanel();
1497 annotationShding.setBorder(new TitledBorder(
1498 MessageManager.getString("label.annotation_shading_default")));
1499 annotationShding.setLayout(new GridLayout(1, 2));
1500 JvSwingUtils.addtoLayout(annotationShding,
1501 MessageManager.getString(
1502 "label.default_minimum_colour_annotation_shading"),
1503 mincolourLabel, minColour);
1504 JvSwingUtils.addtoLayout(annotationShding,
1505 MessageManager.getString(
1506 "label.default_maximum_colour_annotation_shading"),
1507 maxcolourLabel, maxColour);
1508 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1513 * Initialises the Overview tabbed panel.
1517 private JPanel initOverviewTab()
1519 JPanel overviewPanel = new JPanel();
1520 overviewPanel.setBorder(new TitledBorder(
1521 MessageManager.getString("label.overview_settings")));
1523 gapColour.setFont(LABEL_FONT);
1524 // fixing the border colours stops apparent colour bleed from the panel
1525 gapColour.setBorder(
1526 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1527 gapColour.setPreferredSize(new Dimension(40, 20));
1528 gapColour.addMouseListener(new MouseAdapter()
1531 public void mousePressed(MouseEvent e)
1533 gapColour_actionPerformed(gapColour);
1537 hiddenColour.setFont(LABEL_FONT);
1538 // fixing the border colours stops apparent colour bleed from the panel
1539 hiddenColour.setBorder(
1540 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1541 hiddenColour.setPreferredSize(new Dimension(40, 20));
1542 hiddenColour.addMouseListener(new MouseAdapter()
1545 public void mousePressed(MouseEvent e)
1547 hiddenColour_actionPerformed(hiddenColour);
1551 useLegacyGap = new JCheckBox(
1552 MessageManager.getString("label.ov_legacy_gap"));
1553 useLegacyGap.setFont(LABEL_FONT);
1554 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1555 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1556 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1557 gapLabel.setFont(LABEL_FONT);
1558 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1559 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1560 showHiddenAtStart = new JCheckBox(
1561 MessageManager.getString("label.ov_show_hide_default"));
1562 showHiddenAtStart.setFont(LABEL_FONT);
1563 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1564 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1565 JLabel hiddenLabel = new JLabel(
1566 MessageManager.getString("label.hidden_colour"));
1567 hiddenLabel.setFont(LABEL_FONT);
1568 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1569 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1571 useLegacyGap.addActionListener(new ActionListener()
1574 public void actionPerformed(ActionEvent e)
1576 useLegacyGaps_actionPerformed(e);
1580 overviewPanel.setLayout(new GridBagLayout());
1581 GridBagConstraints c1 = new GridBagConstraints();
1583 c1.fill = GridBagConstraints.HORIZONTAL;
1588 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1589 overviewPanel.add(useLegacyGap, c1);
1591 GridBagConstraints c2 = new GridBagConstraints();
1592 c2.fill = GridBagConstraints.HORIZONTAL;
1595 c2.insets = new Insets(0, 15, 0, 10);
1596 overviewPanel.add(gapLabel, c2);
1598 GridBagConstraints c3 = new GridBagConstraints();
1599 c3.fill = GridBagConstraints.HORIZONTAL;
1602 c3.insets = new Insets(0, 0, 0, 15);
1603 overviewPanel.add(gapColour, c3);
1605 GridBagConstraints c4 = new GridBagConstraints();
1606 c4.fill = GridBagConstraints.HORIZONTAL;
1610 overviewPanel.add(showHiddenAtStart, c4);
1612 GridBagConstraints c5 = new GridBagConstraints();
1613 c5.fill = GridBagConstraints.HORIZONTAL;
1616 c5.insets = new Insets(0, 15, 0, 10);
1617 overviewPanel.add(hiddenLabel, c5);
1619 GridBagConstraints c6 = new GridBagConstraints();
1620 c6.fill = GridBagConstraints.HORIZONTAL;
1623 c6.insets = new Insets(0, 0, 0, 15);
1624 overviewPanel.add(hiddenColour, c6);
1626 JButton resetButton = new JButton(
1627 MessageManager.getString("label.reset_to_defaults"));
1629 resetButton.addActionListener(new ActionListener()
1632 public void actionPerformed(ActionEvent e)
1634 resetOvDefaults_actionPerformed(e);
1638 GridBagConstraints c7 = new GridBagConstraints();
1639 c7.fill = GridBagConstraints.NONE;
1642 c7.insets = new Insets(10, 0, 0, 0);
1643 c7.anchor = GridBagConstraints.WEST;
1644 overviewPanel.add(resetButton, c7);
1646 // Add padding so the panel doesn't look ridiculous
1647 JPanel spacePanel = new JPanel();
1648 overviewPanel.add(spacePanel,
1649 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1650 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1651 new Insets(0, 0, 0, 5), 0, 0));
1653 return overviewPanel;
1657 * Initialises the Structure tabbed panel.
1661 private JPanel initStructureTab()
1663 structureTab = new JPanel();
1665 structureTab.setBorder(new TitledBorder(
1666 MessageManager.getString("label.structure_options")));
1667 structureTab.setLayout(null);
1668 final int width = 420;
1669 final int height = 22;
1670 final int lineSpacing = 25;
1673 structFromPdb.setFont(LABEL_FONT);
1675 .setText(MessageManager.getString("label.struct_from_pdb"));
1676 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1677 structFromPdb.addActionListener(new ActionListener()
1680 public void actionPerformed(ActionEvent e)
1682 boolean selected = structFromPdb.isSelected();
1683 // enable other options only when the first is checked
1684 addSecondaryStructure.setEnabled(selected);
1685 addTempFactor.setEnabled(selected);
1688 structureTab.add(structFromPdb);
1690 // indent checkboxes that are conditional on the first one
1691 ypos += lineSpacing;
1692 addSecondaryStructure.setFont(LABEL_FONT);
1693 addSecondaryStructure
1694 .setText(MessageManager.getString("label.autoadd_secstr"));
1695 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1696 structureTab.add(addSecondaryStructure);
1698 ypos += lineSpacing;
1699 addTempFactor.setFont(LABEL_FONT);
1700 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1701 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1702 structureTab.add(addTempFactor);
1704 ypos += lineSpacing;
1705 JLabel viewerLabel = new JLabel();
1706 viewerLabel.setFont(LABEL_FONT);
1707 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1708 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1709 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1710 structureTab.add(viewerLabel);
1713 * add all external viewers as options here - check
1714 * when selected whether the program is installed
1716 structViewer.setFont(LABEL_FONT);
1717 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1718 structViewer.addItem(ViewerType.JMOL.name());
1719 structViewer.addItem(ViewerType.CHIMERA.name());
1720 structViewer.addItem(ViewerType.CHIMERAX.name());
1721 structViewer.addItem(ViewerType.PYMOL.name());
1722 structViewer.addActionListener(new ActionListener()
1725 public void actionPerformed(ActionEvent e)
1727 structureViewer_actionPerformed(
1728 (String) structViewer.getSelectedItem());
1731 structureTab.add(structViewer);
1733 ypos += lineSpacing;
1734 structureViewerPathLabel = new JLabel();
1735 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1737 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1738 structureViewerPathLabel.setText(MessageManager
1739 .formatMessage("label.viewer_path", "Chimera(X)"));
1740 structureViewerPathLabel
1741 .setBounds(new Rectangle(10, ypos, 170, height));
1742 structureViewerPathLabel.setEnabled(false);
1743 structureTab.add(structureViewerPathLabel);
1745 structureViewerPath.setFont(LABEL_FONT);
1746 structureViewerPath.setText("");
1747 structureViewerPath.setEnabled(false);
1748 final String tooltip = JvSwingUtils.wrapTooltip(true,
1749 MessageManager.getString("label.viewer_path_tip"));
1750 structureViewerPath.setToolTipText(tooltip);
1751 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1752 structureViewerPath.addMouseListener(new MouseAdapter()
1755 public void mouseClicked(MouseEvent e)
1757 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1759 String chosen = openFileChooser();
1762 structureViewerPath.setText(chosen);
1767 structureTab.add(structureViewerPath);
1769 ypos += lineSpacing;
1770 nwMapping.setFont(LABEL_FONT);
1771 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1772 siftsMapping.setFont(LABEL_FONT);
1773 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1774 mappingMethod.add(nwMapping);
1775 mappingMethod.add(siftsMapping);
1776 JPanel mappingPanel = new JPanel();
1777 mappingPanel.setFont(LABEL_FONT);
1778 TitledBorder mmTitledBorder = new TitledBorder(
1779 MessageManager.getString("label.mapping_method"));
1780 mmTitledBorder.setTitleFont(LABEL_FONT);
1781 mappingPanel.setBorder(mmTitledBorder);
1782 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1783 // GridLayout mappingLayout = new GridLayout();
1784 mappingPanel.setLayout(new GridLayout());
1785 mappingPanel.add(nwMapping);
1786 mappingPanel.add(siftsMapping);
1787 structureTab.add(mappingPanel);
1789 ypos += lineSpacing;
1790 ypos += lineSpacing;
1791 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1792 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1793 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1794 structureTab.add(docFieldPref);
1797 * hide Chimera options in JalviewJS
1799 if (Platform.isJS())
1801 structureViewerPathLabel.setVisible(false);
1802 structureViewerPath.setVisible(false);
1803 viewerLabel.setVisible(false);
1804 structViewer.setVisible(false);
1807 return structureTab;
1811 * Action on choosing a structure viewer from combobox options.
1813 * @param selectedItem
1815 protected void structureViewer_actionPerformed(String selectedItem)
1820 * Show a dialog for the user to choose a file. Returns the chosen path, or null
1825 protected String openFileChooser()
1827 String choice = null;
1828 JFileChooser chooser = new JFileChooser();
1830 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1831 // hidden executables within .app dirs
1832 if (Platform.isMac())
1834 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1838 // chooser.setFileView(new JalviewFileView());
1839 chooser.setDialogTitle(
1840 MessageManager.getString("label.open_local_file"));
1841 chooser.setToolTipText(MessageManager.getString("action.open"));
1843 int value = chooser.showOpenDialog(this);
1845 if (value == JFileChooser.APPROVE_OPTION)
1847 choice = chooser.getSelectedFile().getPath();
1853 * Validate the structure tab preferences; if invalid, set focus on this tab.
1857 protected boolean validateStructure(FocusEvent e)
1859 if (!validateStructure())
1861 e.getComponent().requestFocusInWindow();
1867 protected boolean validateStructure()
1873 * Initialises the Visual tabbed panel.
1877 private JPanel initVisualTab()
1879 JPanel visualTab = new JPanel();
1880 visualTab.setBorder(new TitledBorder(
1881 MessageManager.getString("action.open_new_alignment")));
1882 visualTab.setLayout(null);
1883 fullScreen.setFont(LABEL_FONT);
1884 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1885 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1886 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1887 quality.setEnabled(false);
1888 quality.setFont(LABEL_FONT);
1889 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1890 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1891 quality.setSelected(true);
1892 quality.setText(MessageManager.getString("label.quality"));
1893 conservation.setEnabled(false);
1894 conservation.setFont(LABEL_FONT);
1895 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1896 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1897 conservation.setSelected(true);
1898 conservation.setText(MessageManager.getString("label.conservation"));
1899 identity.setEnabled(false);
1900 identity.setFont(LABEL_FONT);
1901 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1902 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1903 identity.setSelected(true);
1904 identity.setText(MessageManager.getString("label.consensus"));
1905 showOccupancy.setFont(LABEL_FONT);
1906 showOccupancy.setEnabled(false);
1907 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1908 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1909 showOccupancy.setSelected(true);
1910 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1912 JLabel showGroupbits = new JLabel();
1913 showGroupbits.setFont(LABEL_FONT);
1914 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1915 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1917 .setText(MessageManager.getString("action.show_group") + ":");
1918 JLabel showConsensbits = new JLabel();
1919 showConsensbits.setFont(LABEL_FONT);
1920 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1921 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1923 .setText(MessageManager.getString("label.consensus") + ":");
1924 showConsensHistogram.setEnabled(false);
1925 showConsensHistogram.setFont(LABEL_FONT);
1926 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1927 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1928 showConsensHistogram.setSelected(true);
1929 showConsensHistogram
1930 .setText(MessageManager.getString("label.histogram"));
1931 showConsensLogo.setEnabled(false);
1932 showConsensLogo.setFont(LABEL_FONT);
1933 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1934 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1935 showConsensLogo.setSelected(true);
1936 showConsensLogo.setText(MessageManager.getString("label.logo"));
1937 showGroupConsensus.setEnabled(false);
1938 showGroupConsensus.setFont(LABEL_FONT);
1939 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1940 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1941 showGroupConsensus.setSelected(true);
1942 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1943 showGroupConservation.setEnabled(false);
1944 showGroupConservation.setFont(LABEL_FONT);
1945 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1946 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1947 showGroupConservation.setSelected(true);
1948 showGroupConservation
1949 .setText(MessageManager.getString("label.conservation"));
1950 showNpTooltip.setEnabled(true);
1951 showNpTooltip.setFont(LABEL_FONT);
1952 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1953 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1954 showNpTooltip.setSelected(true);
1955 showNpTooltip.setText(
1956 MessageManager.getString("label.non_positional_features"));
1957 showDbRefTooltip.setEnabled(true);
1958 showDbRefTooltip.setFont(LABEL_FONT);
1959 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1960 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1961 showDbRefTooltip.setSelected(true);
1963 .setText(MessageManager.getString("label.database_references"));
1964 annotations.setFont(LABEL_FONT);
1965 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1966 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1967 annotations.setSelected(true);
1968 annotations.setText(MessageManager.getString("label.show_annotations"));
1969 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1970 annotations.addActionListener(new ActionListener()
1973 public void actionPerformed(ActionEvent e)
1975 annotations_actionPerformed(e);
1978 identity.addActionListener(new ActionListener()
1981 public void actionPerformed(ActionEvent e)
1983 annotations_actionPerformed(e);
1986 showGroupConsensus.addActionListener(new ActionListener()
1989 public void actionPerformed(ActionEvent e)
1991 annotations_actionPerformed(e);
1994 showUnconserved.setFont(LABEL_FONT);
1995 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1996 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1997 showUnconserved.setSelected(true);
1999 .setText(MessageManager.getString("action.show_unconserved"));
2000 showUnconserved.addActionListener(new ActionListener()
2003 public void actionPerformed(ActionEvent e)
2005 showunconserved_actionPerformed(e);
2009 // TODO these are not yet added to / action from Preferences
2010 // JCheckBox shareSelections = new JCheckBox();
2011 // shareSelections.setFont(verdana11);
2012 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2013 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2014 // shareSelections.setSelected(true);
2015 // shareSelections.setText(MessageManager
2016 // .getString("label.share_selection_across_views"));
2017 // JCheckBox followHighlight = new JCheckBox();
2018 // followHighlight.setFont(verdana11);
2019 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2020 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2021 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2022 // followHighlight.setSelected(true);
2023 // followHighlight.setText(MessageManager
2024 // .getString("label.scroll_highlighted_regions"));
2026 seqLimit.setFont(LABEL_FONT);
2027 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2028 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2029 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2030 smoothFont.setFont(LABEL_FONT);
2031 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2032 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2033 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2034 scaleProteinToCdna.setFont(LABEL_FONT);
2035 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2036 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2037 scaleProteinToCdna.setText(
2038 MessageManager.getString("label.scale_protein_to_cdna"));
2039 scaleProteinToCdna.setToolTipText(
2040 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2041 JLabel gapLabel = new JLabel();
2042 gapLabel.setFont(LABEL_FONT);
2043 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2044 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2045 JLabel fontLabel = new JLabel();
2046 fontLabel.setFont(LABEL_FONT);
2047 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2048 fontLabel.setText(MessageManager.getString("label.font"));
2049 fontSizeCB.setFont(LABEL_FONT);
2050 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2051 fontStyleCB.setFont(LABEL_FONT);
2052 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2053 fontNameCB.setFont(LABEL_FONT);
2054 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2055 gapSymbolCB.setFont(LABEL_FONT);
2056 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2057 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2058 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2059 gapSymbolCB.setRenderer(dlcr);
2061 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2062 startupCheckbox.setFont(LABEL_FONT);
2063 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2064 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2065 startupCheckbox.setSelected(true);
2066 startupFileTextfield.setFont(LABEL_FONT);
2067 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2068 final String tooltip = JvSwingUtils.wrapTooltip(true,
2069 MessageManager.getString("label.double_click_to_browse"));
2070 startupFileTextfield.setToolTipText(tooltip);
2071 startupFileTextfield.addMouseListener(new MouseAdapter()
2074 public void mouseClicked(MouseEvent e)
2076 if (e.getClickCount() > 1)
2078 startupFileTextfield_mouseClicked();
2083 sortby.setFont(LABEL_FONT);
2084 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2085 JLabel sortLabel = new JLabel();
2086 sortLabel.setFont(LABEL_FONT);
2087 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2088 sortLabel.setText(MessageManager.getString("label.sort_by"));
2089 sortAnnBy.setFont(LABEL_FONT);
2090 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2091 JLabel sortAnnLabel = new JLabel();
2092 sortAnnLabel.setFont(LABEL_FONT);
2093 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2094 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2095 sortAutocalc.setFont(LABEL_FONT);
2096 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2098 JPanel annsettingsPanel = new JPanel();
2099 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2100 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2101 annsettingsPanel.setBorder(new EtchedBorder());
2102 visualTab.add(annsettingsPanel);
2103 Border jb = new EmptyBorder(1, 1, 4, 5);
2104 annotations.setBorder(jb);
2105 showOccupancy.setBorder(jb);
2106 quality.setBorder(jb);
2107 conservation.setBorder(jb);
2108 identity.setBorder(jb);
2109 showConsensbits.setBorder(jb);
2110 showGroupbits.setBorder(jb);
2111 showGroupConsensus.setBorder(jb);
2112 showGroupConservation.setBorder(jb);
2113 showConsensHistogram.setBorder(jb);
2114 showConsensLogo.setBorder(jb);
2116 JPanel autoAnnotSettings = new JPanel();
2117 annsettingsPanel.add(autoAnnotSettings);
2118 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2119 autoAnnotSettings.add(annotations);
2120 autoAnnotSettings.add(quality);
2121 // second row of autoannotation box
2122 autoAnnotSettings = new JPanel();
2123 annsettingsPanel.add(autoAnnotSettings);
2125 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2126 autoAnnotSettings.add(conservation);
2127 autoAnnotSettings.add(identity);
2128 autoAnnotSettings.add(showOccupancy);
2129 autoAnnotSettings.add(showGroupbits);
2130 autoAnnotSettings.add(showGroupConservation);
2131 autoAnnotSettings.add(showGroupConsensus);
2132 autoAnnotSettings.add(showConsensbits);
2133 autoAnnotSettings.add(showConsensHistogram);
2134 autoAnnotSettings.add(showConsensLogo);
2136 JPanel tooltipSettings = new JPanel();
2137 tooltipSettings.setBorder(new TitledBorder(
2138 MessageManager.getString("label.sequence_id_tooltip")));
2139 tooltipSettings.setBounds(173, 140, 220, 62);
2140 tooltipSettings.setLayout(new GridLayout(2, 1));
2141 tooltipSettings.add(showDbRefTooltip);
2142 tooltipSettings.add(showNpTooltip);
2143 visualTab.add(tooltipSettings);
2145 wrap.setFont(LABEL_FONT);
2146 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2147 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2148 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2149 rightAlign.setFont(LABEL_FONT);
2150 rightAlign.setForeground(Color.black);
2151 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2152 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2153 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2154 idItalics.setFont(LABEL_FONT_ITALIC);
2155 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2156 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2158 MessageManager.getString("label.sequence_name_italics"));
2159 openoverv.setFont(LABEL_FONT);
2160 openoverv.setActionCommand(
2161 MessageManager.getString("label.open_overview"));
2162 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2163 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2164 openoverv.setText(MessageManager.getString("label.open_overview"));
2165 JPanel jPanel2 = new JPanel();
2166 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2167 jPanel2.setLayout(new GridLayout(14, 1));
2168 jPanel2.add(fullScreen);
2169 jPanel2.add(openoverv);
2170 jPanel2.add(seqLimit);
2171 jPanel2.add(rightAlign);
2172 jPanel2.add(fontLabel);
2173 jPanel2.add(showUnconserved);
2174 jPanel2.add(idItalics);
2175 jPanel2.add(smoothFont);
2176 jPanel2.add(scaleProteinToCdna);
2177 jPanel2.add(gapLabel);
2179 jPanel2.add(sortLabel);
2180 jPanel2.add(sortAnnLabel);
2181 jPanel2.add(startupCheckbox);
2182 visualTab.add(jPanel2);
2183 visualTab.add(startupFileTextfield);
2184 visualTab.add(sortby);
2185 visualTab.add(sortAnnBy);
2186 visualTab.add(sortAutocalc);
2187 visualTab.add(gapSymbolCB);
2188 visualTab.add(fontNameCB);
2189 visualTab.add(fontSizeCB);
2190 visualTab.add(fontStyleCB);
2192 if (Platform.isJS())
2194 startupCheckbox.setVisible(false);
2195 startupFileTextfield.setVisible(false);
2202 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2205 protected void loadLastSavedBackupsOptions()
2207 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2208 .getSavedBackupEntry();
2209 enableBackupFiles.setSelected(
2210 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2212 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2213 .createBackupFilesPresetEntry(Cache
2214 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2215 if (backupfilesCustomEntry == null)
2217 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2218 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2220 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2221 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2222 backupfilesCustomEntry);
2224 setComboIntStringKey(backupfilesPresetsCombo,
2225 Cache.getDefault(BackupFiles.NS + "_PRESET",
2226 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2228 backupsSetOptions(savedPreset);
2230 backupsOptionsSetEnabled();
2231 updateBackupFilesExampleLabel();
2235 * Load the saved Memory settings
2237 protected void loadLastSavedMemorySettings()
2239 customiseMemorySetting.setSelected(
2240 Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2241 jvmMemoryPercentSlider
2242 .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2243 jvmMemoryMaxTextField.setText(
2244 Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2247 private boolean warnAboutSuffixReverseChange()
2249 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2250 .getSavedBackupEntry();
2251 boolean savedSuffixReverse = bfpe.reverse;
2252 int savedSuffixDigits = bfpe.digits;
2253 String savedSuffixTemplate = bfpe.suffix;
2255 boolean nowSuffixReverse = suffixReverse.isSelected();
2256 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2257 String nowSuffixTemplate = suffixTemplate.getText();
2258 return nowSuffixReverse != savedSuffixReverse
2259 && nowSuffixDigits == savedSuffixDigits
2260 && nowSuffixTemplate != null
2261 && nowSuffixTemplate.equals(savedSuffixTemplate);
2264 /* Initialises the Startup tabbed panel.
2269 private JPanel initStartupTab()
2271 JPanel startupTab = new JPanel();
2272 startupTab.setBorder(
2273 new TitledBorder(MessageManager.getString("label.memory")));
2274 startupTab.setLayout(new GridBagLayout());
2276 GridBagConstraints gbc = new GridBagConstraints();
2279 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2280 gbc.fill = GridBagConstraints.NONE;
2287 gbc.gridy = 0; // row 1
2289 JLabel memoryText = new JLabel();
2290 memoryText.setFont(LABEL_FONT_ITALIC);
2292 .setText(MessageManager.getString("label.memory_setting_text"));
2293 startupTab.add(memoryText, gbc);
2295 gbc.gridy++; // row 2
2297 JPanel exampleMemoryPanel = new JPanel();
2299 .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2300 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2301 MessageManager.getString("label.memory_example_tooltip")));
2302 JLabel exampleTextLabel = new JLabel();
2304 .setText(MessageManager.getString("label.memory_example_text"));
2305 exampleTextLabel.setForeground(Color.GRAY);
2306 exampleTextLabel.setFont(LABEL_FONT);
2307 exampleMemoryPanel.add(exampleTextLabel);
2308 exampleMemoryPanel.add(exampleMemoryLabel);
2309 exampleMemoryPanel.setBackground(Color.WHITE);
2310 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2311 startupTab.add(exampleMemoryPanel, gbc);
2313 gbc.gridy++; // row 3
2315 startupTab.add(customiseMemorySetting, gbc);
2317 gbc.gridy += 2; // row 4 with a gap
2319 startupTab.add(maxMemoryLabel, gbc);
2321 gbc.gridy += 2; // row 5
2324 startupTab.add(jvmMemoryPercentLabel, gbc);
2326 startupTab.add(jvmMemoryPercentSlider, gbc);
2328 // gbc.weightx = 0.1;
2329 startupTab.add(jvmMemoryPercentDisplay, gbc);
2330 // gbc.weightx = 1.0;
2333 gbc.gridy++; // row 6
2335 startupTab.add(jvmMemoryMaxLabel, gbc);
2337 startupTab.add(jvmMemoryMaxTextField, gbc);
2339 gbc.gridy++; // row 7
2342 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2343 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2344 sp.setBorder(BorderFactory.createEmptyBorder());
2345 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2346 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2347 startupTab.add(sp, gbc);
2349 // fill empty space to push widget to top left
2355 startupTab.add(new JPanel(), gbc);
2357 setMemoryPercentDisplay();
2358 memoryOptionsSetEnabled();
2362 private void initMemoryPanel()
2364 // Enable memory settings checkbox
2365 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2366 customiseMemorySetting.setText(
2367 MessageManager.getString("label.customise_memory_settings"));
2368 customiseMemorySetting.addActionListener(new ActionListener()
2371 public void actionPerformed(ActionEvent e)
2373 memoryOptionsSetEnabled();
2377 loadLastSavedMemorySettings();
2379 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2380 exampleMemoryLabel.setBackground(Color.WHITE);
2382 maxMemoryLabel = new JLabel(
2383 MessageManager.getString("label.maximum_memory_used"));
2384 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2386 // Maximum memory percentage slider
2387 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2388 jvmMemoryPercentLabel.setText(
2389 MessageManager.getString("label.percent_of_physical_memory"));
2390 jvmMemoryPercentSlider.setPaintLabels(true);
2391 jvmMemoryPercentSlider.setPaintTicks(true);
2392 jvmMemoryPercentSlider.setPaintTrack(true);
2393 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2394 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2395 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2398 public void stateChanged(ChangeEvent e)
2400 setMemoryPercentDisplay();
2403 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2404 setMemoryPercentDisplay();
2406 // Maximum memory cap textbox
2407 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2409 .setText(MessageManager.getString("label.maximum_memory"));
2410 initMemoryMaxTextField();
2412 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2413 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2414 exampleMemoryMessageTextArea.setEditable(false);
2415 exampleMemoryMessageTextArea.setLineWrap(true);
2416 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2417 exampleMemoryMessageTextArea.setText(" ");
2418 exampleMemoryMessageTextArea.setRows(2);
2419 exampleMemoryMessageTextArea.setColumns(40);
2421 setExampleMemoryLabel();
2424 private void initMemoryMaxTextField()
2426 jvmMemoryMaxTextField.setToolTipText(
2427 MessageManager.getString("label.maximum_memory_tooltip"));
2428 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2431 public void actionPerformed(ActionEvent arg0)
2433 validateMemoryMaxTextField();
2434 setExampleMemoryLabel();
2438 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2441 public void keyReleased(KeyEvent e)
2443 validateMemoryMaxTextField();
2444 setExampleMemoryLabel();
2448 public void keyPressed(KeyEvent e)
2452 // try and stop invalid typing
2454 public void keyTyped(KeyEvent e)
2456 char c = Character.toLowerCase(e.getKeyChar());
2457 String text = jvmMemoryMaxTextField.getText();
2458 String suffixes = "tgmkb";
2459 int pos = jvmMemoryMaxTextField.getCaretPosition();
2460 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2461 if (!((('0' <= c && c <= '9')
2462 && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2464 || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2466 && pos == text.length() // at end of text and
2467 && suffixPos == -1) // there isn't already one
2477 private boolean isMemoryMaxTextFieldValid()
2479 return MemorySetting
2480 .isValidMemoryString(jvmMemoryMaxTextField.getText());
2483 private void validateMemoryMaxTextField()
2485 if (isMemoryMaxTextFieldValid())
2487 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2491 jvmMemoryMaxTextField.setBackground(Color.PINK);
2495 private void setMemoryPercentDisplay()
2497 jvmMemoryPercentDisplay
2498 .setText(jvmMemoryPercentSlider.getValue() + "%");
2499 setExampleMemoryLabel();
2502 private void setExampleMemoryLabel()
2504 boolean selected = customiseMemorySetting.isSelected();
2505 int jvmmempc = jvmMemoryPercentSlider.getValue();
2506 String jvmmemmax = jvmMemoryMaxTextField.getText();
2509 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2510 && MemorySetting.isValidMemoryString(jvmmemmax))
2512 mem = MemorySetting.getMemorySetting(jvmmemmax,
2513 String.valueOf(jvmmempc), false, true);
2517 mem = MemorySetting.getMemorySetting(null, null, false, true);
2519 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2520 String message = MemorySetting.getAdjustmentMessage();
2521 exampleMemoryMessageTextArea.setText(
2522 MessageManager.getString("label.adjustments_for_this_computer")
2525 ? MessageManager.getString("label.none")
2529 private void memoryOptionsSetEnabled()
2531 boolean enabled = customiseMemorySetting.isSelected();
2532 // leave exampleMemoryLabel enabled always
2533 maxMemoryLabel.setEnabled(enabled);
2534 jvmMemoryPercentLabel.setEnabled(enabled);
2535 jvmMemoryPercentSlider.setEnabled(enabled);
2536 jvmMemoryPercentDisplay.setEnabled(enabled);
2537 jvmMemoryMaxLabel.setEnabled(enabled);
2538 jvmMemoryMaxTextField.setEnabled(enabled);
2539 exampleMemoryMessageTextArea.setEnabled(enabled);
2540 setExampleMemoryLabel();
2544 * Initialises the Backups tabbed panel.
2548 private JPanel initBackupsTab()
2550 JPanel backupsTab = new JPanel();
2551 backupsTab.setBorder(new TitledBorder(
2552 MessageManager.getString("label.backup_files")));
2553 backupsTab.setLayout(new GridBagLayout());
2555 GridBagConstraints gbc = new GridBagConstraints();
2558 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2559 gbc.fill = GridBagConstraints.NONE;
2561 initBackupsTabPresetsPanel();
2562 initBackupsTabSuffixPanel();
2563 initBackupsTabKeepFilesPanel();
2564 initBackupsTabFilenameExamplesPanel();
2566 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2568 .setText(MessageManager.getString("label.enable_backupfiles"));
2569 enableBackupFiles.addActionListener(new ActionListener()
2572 public void actionPerformed(ActionEvent e)
2574 // enable other options only when the first is checked
2575 backupsOptionsSetEnabled();
2579 // enable checkbox 1 col
2583 gbc.gridy = 0; // row 0
2584 backupsTab.add(enableBackupFiles, gbc);
2586 // summary of scheme box (over two rows)
2590 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2591 gbc.fill = GridBagConstraints.BOTH;
2592 backupsTab.add(exampleFilesPanel, gbc);
2594 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2595 gbc.fill = GridBagConstraints.NONE;
2597 // fill empty space on right
2600 backupsTab.add(new JPanel(), gbc);
2605 gbc.gridy++; // row 1
2606 backupsTab.add(presetsPanel, gbc);
2608 // now using whole row
2613 gbc.gridy++; // row 2
2614 backupsTab.add(keepfilesPanel, gbc);
2616 // filename strategy box
2617 gbc.gridy++; // row 3
2618 backupsTab.add(suffixPanel, gbc);
2621 gbc.gridy++; // row 4
2623 backupsTab.add(new JPanel(), gbc);
2625 backupsOptionsSetEnabled();
2629 private JPanel initBackupsTabPresetsPanel()
2632 String title = MessageManager.getString("label.schemes");
2634 presetsPanel.setLayout(new GridBagLayout());
2636 GridBagConstraints gbc = new GridBagConstraints();
2639 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2640 gbc.fill = GridBagConstraints.NONE;
2648 presetsComboLabel = new JLabel(title + ":");
2649 presetsPanel.add(presetsComboLabel, gbc);
2651 List<Object> entries = Arrays.asList(
2652 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2653 List<String> tooltips = Arrays.asList(
2654 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2655 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2658 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2660 backupfilesPresetsCombo
2661 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2665 backupfilesPresetsCombo.addActionListener(new ActionListener()
2668 public void actionPerformed(ActionEvent e)
2670 int key = getComboIntStringKey(backupfilesPresetsCombo);
2671 if (!customiseCheckbox.isSelected())
2673 backupfilesPresetsComboLastSelected = key;
2675 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2677 if (customiseCheckbox.isSelected())
2679 // got here by clicking on customiseCheckbox so don't change the
2681 backupfilesCustomOptionsSetEnabled();
2685 backupsTabUpdatePresets();
2686 backupfilesCustomOptionsSetEnabled();
2691 customiseCheckbox.setSelected(false);
2692 backupsTabUpdatePresets();
2693 backupfilesCustomOptionsSetEnabled();
2698 // dropdown list of preset schemes
2700 presetsPanel.add(backupfilesPresetsCombo, gbc);
2702 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2703 revertButton.setToolTipText(
2704 MessageManager.getString("label.cancel_changes_description"));
2705 revertButton.addActionListener(new ActionListener()
2708 public void actionPerformed(ActionEvent e)
2711 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2712 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2713 backupfilesCustomOptionsSetEnabled();
2717 revertButton.setFont(LABEL_FONT);
2719 customiseCheckbox.setFont(LABEL_FONT);
2720 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2721 customiseCheckbox.addActionListener(new ActionListener()
2724 public void actionPerformed(ActionEvent e)
2726 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2727 if (customiseCheckbox.isSelected())
2729 backupfilesPresetsComboLastSelected = currently;
2730 setComboIntStringKey(backupfilesPresetsCombo,
2731 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2735 setComboIntStringKey(backupfilesPresetsCombo,
2736 backupfilesPresetsComboLastSelected);
2739 backupfilesCustomOptionsSetEnabled();
2742 customiseCheckbox.setToolTipText(
2743 MessageManager.getString("label.customise_description"));
2745 // customise checkbox
2748 presetsPanel.add(customiseCheckbox, gbc);
2750 // "Cancel changes" button (aligned with combo box above)
2752 presetsPanel.add(revertButton, gbc);
2754 return presetsPanel;
2757 private JPanel initBackupsTabFilenameExamplesPanel()
2759 String title = MessageManager.getString("label.scheme_examples");
2760 TitledBorder tb = new TitledBorder(title);
2761 exampleFilesPanel.setBorder(tb);
2762 exampleFilesPanel.setLayout(new GridBagLayout());
2764 backupfilesExampleLabel.setEditable(false);
2765 backupfilesExampleLabel
2766 .setBackground(exampleFilesPanel.getBackground());
2768 updateBackupFilesExampleLabel();
2770 GridBagConstraints gbc = new GridBagConstraints();
2773 gbc.fill = GridBagConstraints.NONE;
2774 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2776 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2777 return exampleFilesPanel;
2780 private void backupsTabUpdatePresets()
2782 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2785 String value = entry.v;
2787 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2791 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2797 "Preset '" + value + "' [key:" + key + "] not implemented");
2800 // Custom options will now be enabled when the customiseCheckbox is checked
2801 // (performed above)
2802 // backupfilesCustomOptionsSetEnabled();
2803 updateBackupFilesExampleLabel();
2806 protected int getComboIntStringKey(
2807 JComboBox<Object> backupfilesPresetsCombo2)
2809 IntKeyStringValueEntry e;
2812 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2814 } catch (Exception ex)
2817 "Problem casting Combo entry to IntKeyStringValueEntry.");
2820 return e != null ? e.k : 0;
2823 protected void setComboIntStringKey(
2824 JComboBox<Object> backupfilesPresetsCombo2, int key)
2826 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2828 IntKeyStringValueEntry e;
2831 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2832 } catch (Exception ex)
2835 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2840 backupfilesPresetsCombo2.setSelectedIndex(i);
2844 // backupsTabUpdatePresets();
2847 private JPanel initBackupsTabSuffixPanel()
2849 suffixPanel.setBorder(new TitledBorder(
2850 MessageManager.getString("label.backup_filename_strategy")));
2851 suffixPanel.setLayout(new GridBagLayout());
2854 .setText(MessageManager.getString("label.append_to_filename"));
2855 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2856 suffixTemplateLabel.setFont(LABEL_FONT);
2858 final String tooltip = JvSwingUtils.wrapTooltip(true,
2859 MessageManager.getString("label.append_to_filename_tooltip"));
2860 suffixTemplate.setToolTipText(tooltip);
2861 suffixTemplate.addActionListener(new ActionListener()
2864 public void actionPerformed(ActionEvent e)
2866 updateBackupFilesExampleLabel();
2867 backupfilesCustomOptionsSetEnabled();
2868 backupfilesRevertButtonSetEnabled(true);
2872 suffixTemplate.addKeyListener(new KeyListener()
2875 public void keyReleased(KeyEvent e)
2877 updateBackupFilesExampleLabel();
2878 backupfilesCustomOptionsSetEnabled();
2879 backupfilesRevertButtonSetEnabled(true);
2883 public void keyPressed(KeyEvent e)
2887 // disable use of ':' or '/' or '\'
2889 public void keyTyped(KeyEvent e)
2891 char c = e.getKeyChar();
2892 if (c == ':' || c == '/' || c == '\\')
2894 // don't process ':' or '/' or '\'
2903 .setText(MessageManager.getString("label.index_digits"));
2904 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2905 suffixDigitsLabel.setFont(LABEL_FONT);
2906 ChangeListener c = new ChangeListener()
2909 public void stateChanged(ChangeEvent e)
2911 backupfilesRevertButtonSetEnabled(true);
2912 updateBackupFilesExampleLabel();
2916 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2917 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2919 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2920 MessageManager.getString("label.increment_index"));
2921 suffixReverse.addActionListener(new ActionListener()
2924 public void actionPerformed(ActionEvent e)
2926 boolean okay = true;
2927 if (warnAboutSuffixReverseChange())
2930 okay = confirmSuffixReverseChange();
2934 backupfilesRevertButtonSetEnabled(true);
2935 updateBackupFilesExampleLabel();
2939 boolean savedSuffixReverse = BackupFilesPresetEntry
2940 .getSavedBackupEntry().reverse;
2941 suffixReverse.setSelected(savedSuffixReverse);
2946 GridBagConstraints sgbc = new GridBagConstraints();
2948 // first row (template text box)
2949 sgbc.anchor = GridBagConstraints.WEST;
2953 sgbc.gridheight = 1;
2956 sgbc.fill = GridBagConstraints.NONE;
2957 suffixPanel.add(suffixTemplateLabel, sgbc);
2960 sgbc.fill = GridBagConstraints.HORIZONTAL;
2961 suffixPanel.add(suffixTemplate, sgbc);
2963 // second row (number of digits spinner)
2967 sgbc.fill = GridBagConstraints.NONE;
2968 suffixPanel.add(suffixDigitsLabel, sgbc);
2971 sgbc.fill = GridBagConstraints.HORIZONTAL;
2972 suffixPanel.add(suffixDigitsSpinner, sgbc);
2974 // third row (forward order radio selection)
2977 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2978 sgbc.fill = GridBagConstraints.HORIZONTAL;
2979 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2981 // fourth row (reverse order radio selection)
2983 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2987 private boolean confirmSuffixReverseChange()
2989 boolean ret = false;
2990 String warningMessage = MessageManager
2991 .getString("label.warning_confirm_change_reverse");
2992 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2994 MessageManager.getString("label.change_increment_decrement"),
2995 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2997 ret = (confirm == JvOptionPane.YES_OPTION);
3001 private JPanel initBackupsTabKeepFilesPanel()
3003 keepfilesPanel.setBorder(
3004 new TitledBorder(MessageManager.getString("label.keep_files")));
3005 keepfilesPanel.setLayout(new GridBagLayout());
3007 backupfilesKeepAll.setLabels(
3008 MessageManager.getString("label.keep_all_backup_files"),
3009 MessageManager.getString(
3010 "label.keep_only_this_number_of_backup_files"));
3011 backupfilesKeepAll.addTrueActionListener(new ActionListener()
3014 public void actionPerformed(ActionEvent e)
3016 backupfilesRevertButtonSetEnabled(true);
3017 updateBackupFilesExampleLabel();
3020 backupfilesKeepAll.addActionListener(new ActionListener()
3023 public void actionPerformed(ActionEvent e)
3025 backupfilesRevertButtonSetEnabled(true);
3026 keepRollMaxOptionsEnabled();
3027 updateBackupFilesExampleLabel();
3031 ChangeListener c = new ChangeListener()
3034 public void stateChanged(ChangeEvent e)
3036 backupfilesRevertButtonSetEnabled(true);
3037 updateBackupFilesExampleLabel();
3041 setIntegerSpinner(backupfilesRollMaxSpinner,
3042 BackupFilesPresetEntry.ROLLMAXMIN,
3043 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3045 backupfilesConfirmDelete.setLabels(
3046 MessageManager.getString("label.always_ask"),
3047 MessageManager.getString("label.auto_delete"));
3048 backupfilesConfirmDelete.addActionListener(new ActionListener()
3051 public void actionPerformed(ActionEvent e)
3053 backupfilesRevertButtonSetEnabled(true);
3056 // update the enabled section
3057 keepRollMaxOptionsEnabled();
3059 GridBagConstraints kgbc = new GridBagConstraints();
3061 // first row (template text box)
3062 kgbc.anchor = GridBagConstraints.WEST;
3065 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3066 kgbc.gridheight = 1;
3069 kgbc.fill = GridBagConstraints.HORIZONTAL;
3070 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3076 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3077 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3080 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3081 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3083 // third row (indented)
3085 kgbc.insets = new Insets(0, 20, 0, 0);
3088 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3089 kgbc.fill = GridBagConstraints.HORIZONTAL;
3092 JPanel jp = new JPanel();
3093 jp.setLayout(new FlowLayout());
3094 oldBackupFilesLabel.setText(
3095 MessageManager.getString("label.autodelete_old_backup_files"));
3096 oldBackupFilesLabel.setFont(LABEL_FONT);
3097 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3098 jp.add(oldBackupFilesLabel);
3099 jp.add(backupfilesConfirmDelete.getTrueButton());
3100 jp.add(backupfilesConfirmDelete.getFalseButton());
3101 keepfilesPanel.add(jp, kgbc);
3103 return keepfilesPanel;
3106 protected void updateBackupFilesExampleLabel()
3108 int exampleindex = 12;
3109 String base = MessageManager.getString("label.filename") + ".fa";
3110 if (base == null || base.length() == 0)
3112 base = "file_name.fa";
3115 boolean reverse = suffixReverse.isSelected();
3116 boolean keepAll = backupfilesKeepAll.isSelected();
3118 String suffix = suffixTemplate.getText();
3121 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3122 if (suffix == null || suffix.length() == 0)
3124 backupfilesExampleLabel
3125 .setText(MessageManager.getString("label.no_backup_files"));
3126 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3130 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3131 rollMax = rollMax < 1 ? 1 : rollMax;
3133 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3138 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3139 digits = digits < 1 ? 1 : digits;
3141 int lowersurround = 2;
3142 int uppersurround = 0;
3143 StringBuilder exampleSB = new StringBuilder();
3144 boolean firstLine = true;
3150 int max = keepAll ? exampleindex : rollMax;
3151 for (int index = min; index <= max; index++)
3153 if (index == min + lowersurround && index < max - uppersurround - 1)
3155 exampleSB.append("\n...");
3158 else if (index > min + lowersurround && index < max - uppersurround)
3170 exampleSB.append("\n");
3173 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3174 base, suffix, digits));
3177 // no extra text needed
3179 else if (index == min)
3181 String newest = MessageManager.getString("label.braced_newest");
3182 if (newest != null && newest.length() > 0)
3184 exampleSB.append(" " + newest);
3187 else if (index == max)
3189 String oldest = MessageManager.getString("label.braced_oldest");
3190 if (oldest != null && oldest.length() > 0)
3192 exampleSB.append(" " + oldest);
3201 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3202 : exampleindex - rollMax + 1;
3203 int max = exampleindex;
3205 for (int index = min; index <= max; index++)
3208 if (index == min + lowersurround && index < max - uppersurround - 1)
3210 exampleSB.append("\n...");
3213 else if (index > min + lowersurround && index < max - uppersurround)
3225 exampleSB.append("\n");
3228 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3229 base, suffix, digits));
3232 // no extra text needed
3234 else if (index == min)
3236 String oldest = MessageManager.getString("label.braced_oldest");
3237 if (oldest != null && oldest.length() > 0)
3239 exampleSB.append(" " + oldest);
3242 else if (index == max)
3244 String newest = MessageManager.getString("label.braced_newest");
3245 if (newest != null && newest.length() > 0)
3247 exampleSB.append(" " + newest);
3255 // add some extra empty lines to pad out the example files box. ugh, please
3257 // me how to do this better
3258 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3259 if (remainingLines > 0)
3261 for (int i = 0; i < remainingLines; i++)
3263 exampleSB.append("\n ");
3268 backupfilesExampleLabel.setText(exampleSB.toString());
3271 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3272 boolean useExistingVal, ChangeListener c)
3279 i = ((Integer) s.getValue()).intValue();
3280 } catch (Exception e)
3283 "Exception casting the initial value of s.getValue()");
3287 setIntegerSpinner(s, min, max, i, c);
3290 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3293 // integer spinner for number of digits
3302 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3305 s.addChangeListener(c);
3309 protected static int getSpinnerInt(JSpinner s, int def)
3315 i = (Integer) s.getValue();
3316 } catch (Exception e)
3318 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
3323 private void keepRollMaxOptionsEnabled()
3325 boolean enabled = backupfilesKeepAll.isEnabled()
3326 && !backupfilesKeepAll.isSelected();
3327 oldBackupFilesLabel.setEnabled(enabled);
3328 backupfilesRollMaxSpinner.setEnabled(enabled);
3329 backupfilesConfirmDelete.setEnabled(enabled);
3332 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3334 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3335 && customiseCheckbox.isSelected() && suffixTemplate.getText()
3336 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3337 keepfilesPanel.setEnabled(enabled);
3338 backupfilesKeepAll.setEnabled(enabled);
3339 oldBackupFilesLabel.setEnabled(enabled);
3340 keepRollMaxOptionsEnabled();
3343 private void backupfilesSuffixTemplateDigitsSetEnabled()
3345 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3346 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3347 suffixDigitsLabel.setEnabled(enabled);
3348 suffixDigitsSpinner.setEnabled(enabled);
3349 suffixReverse.setEnabled(enabled);
3352 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3354 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3355 && customiseCheckbox.isSelected();
3356 suffixPanel.setEnabled(enabled);
3357 suffixTemplateLabel.setEnabled(enabled);
3358 suffixTemplate.setEnabled(enabled);
3359 backupfilesSuffixTemplateDigitsSetEnabled();
3362 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3364 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3365 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3366 revertButton.setEnabled(enabled);
3369 private boolean backupfilesCustomChanged()
3371 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3372 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3373 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3374 return !custom.equals(current);
3377 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3379 String suffix = suffixTemplate.getText();
3380 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3381 boolean reverse = suffixReverse.isSelected();
3382 boolean keepAll = backupfilesKeepAll.isSelected();
3383 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3384 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3386 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3387 reverse, keepAll, rollMax, confirmDelete);
3392 protected void backupfilesCustomOptionsSetEnabled()
3394 boolean enabled = customiseCheckbox.isSelected();
3396 backupfilesRevertButtonSetEnabled(enabled);
3397 backupfilesSuffixTemplateSetEnabled(enabled);
3398 backupfilesKeepAllSetEnabled(enabled);
3401 private void backupfilesSummarySetEnabled()
3403 boolean enabled = enableBackupFiles.isSelected();
3404 backupfilesExampleLabel.setEnabled(enabled);
3405 exampleFilesPanel.setEnabled(enabled);
3408 private void backupfilesPresetsSetEnabled()
3410 boolean enabled = enableBackupFiles.isSelected();
3411 presetsPanel.setEnabled(enabled);
3412 presetsComboLabel.setEnabled(enabled);
3413 backupfilesPresetsCombo.setEnabled(enabled);
3414 customiseCheckbox.setEnabled(enabled);
3415 revertButton.setEnabled(enabled);
3418 protected void backupsOptionsSetEnabled()
3420 backupfilesPresetsSetEnabled();
3421 backupfilesSummarySetEnabled();
3422 backupfilesCustomOptionsSetEnabled();
3425 protected void backupsSetOptions(String suffix, int digits,
3426 boolean reverse, boolean keepAll, int rollMax,
3427 boolean confirmDelete)
3429 suffixTemplate.setText(suffix);
3430 suffixDigitsSpinner.setValue(digits);
3431 suffixReverse.setSelected(reverse);
3432 backupfilesKeepAll.setSelected(keepAll);
3433 backupfilesRollMaxSpinner.setValue(rollMax);
3434 backupfilesConfirmDelete.setSelected(confirmDelete);
3437 protected void backupsSetOptions(BackupFilesPresetEntry p)
3439 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3443 protected void autoIdWidth_actionPerformed()
3445 // TODO Auto-generated method stub
3449 protected void userIdWidth_actionPerformed()
3451 // TODO Auto-generated method stub
3455 protected void maxColour_actionPerformed(JPanel panel)
3459 protected void minColour_actionPerformed(JPanel panel)
3463 protected void gapColour_actionPerformed(JPanel panel)
3467 protected void hiddenColour_actionPerformed(JPanel panel)
3471 protected void showunconserved_actionPerformed(ActionEvent e)
3473 // TODO Auto-generated method stub
3477 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3481 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3491 public void ok_actionPerformed(ActionEvent e)
3501 public void cancel_actionPerformed(ActionEvent e)
3511 public void annotations_actionPerformed(ActionEvent e)
3518 public void startupFileTextfield_mouseClicked()
3522 public void newLink_actionPerformed(ActionEvent e)
3527 public void editLink_actionPerformed(ActionEvent e)
3532 public void deleteLink_actionPerformed(ActionEvent e)
3537 public void defaultBrowser_mouseClicked(MouseEvent e)
3542 public void linkURLList_keyTyped(KeyEvent e)
3547 public void setProxyAuthEnabled()
3549 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3550 proxyAuthUsernameLabel.setEnabled(enabled);
3551 proxyAuthPasswordLabel.setEnabled(enabled);
3552 passwordNotStoredLabel.setEnabled(enabled);
3553 proxyAuthUsernameTB.setEnabled(enabled);
3554 proxyAuthPasswordPB.setEnabled(enabled);
3557 public void setCustomProxyEnabled()
3559 boolean enabled = customProxy.isSelected();
3560 portLabel.setEnabled(enabled);
3561 serverLabel.setEnabled(enabled);
3562 portLabel2.setEnabled(enabled);
3563 serverLabel2.setEnabled(enabled);
3564 httpLabel.setEnabled(enabled);
3565 httpsLabel.setEnabled(enabled);
3566 proxyServerHttpTB.setEnabled(enabled);
3567 proxyPortHttpTB.setEnabled(enabled);
3568 proxyServerHttpsTB.setEnabled(enabled);
3569 proxyPortHttpsTB.setEnabled(enabled);
3570 proxyAuth.setEnabled(enabled);
3571 setProxyAuthEnabled();
3574 public void proxyType_actionPerformed()
3576 setCustomProxyEnabled();
3577 proxyAuthPasswordCheckHighlight(true);
3578 applyProxyButtonEnabled(true);
3581 public void proxyAuth_actionPerformed()
3583 setProxyAuthEnabled();
3584 proxyAuthPasswordCheckHighlight(true);
3585 applyProxyButtonEnabled(true);
3589 * Customer renderer for JTable: supports column of radio buttons
3591 public class RadioButtonRenderer extends JRadioButton
3592 implements TableCellRenderer
3594 public RadioButtonRenderer()
3596 setHorizontalAlignment(CENTER);
3597 setToolTipText(MessageManager.getString("label.urltooltip"));
3601 public Component getTableCellRendererComponent(JTable table,
3602 Object value, boolean isSelected, boolean hasFocus, int row,
3605 setSelected((boolean) value);
3607 // set colours to match rest of table
3610 setBackground(table.getSelectionBackground());
3611 setForeground(table.getSelectionForeground());
3615 setBackground(table.getBackground());
3616 setForeground(table.getForeground());
3623 * Customer cell editor for JTable: supports column of radio buttons in
3624 * conjunction with renderer
3626 public class RadioButtonEditor extends AbstractCellEditor
3627 implements TableCellEditor
3629 private JRadioButton button = new JRadioButton();
3631 public RadioButtonEditor()
3633 button.setHorizontalAlignment(SwingConstants.CENTER);
3634 this.button.addActionListener(new ActionListener()
3637 public void actionPerformed(ActionEvent e)
3639 fireEditingStopped();
3645 public Component getTableCellEditorComponent(JTable table, Object value,
3646 boolean isSelected, int row, int column)
3648 button.setSelected((boolean) value);
3653 public Object getCellEditorValue()
3655 return button.isSelected();