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.ComboBoxModel;
49 import javax.swing.DefaultComboBoxModel;
50 import javax.swing.DefaultListCellRenderer;
51 import javax.swing.JButton;
52 import javax.swing.JCheckBox;
53 import javax.swing.JComboBox;
54 import javax.swing.JFileChooser;
55 import javax.swing.JLabel;
56 import javax.swing.JPanel;
57 import javax.swing.JPasswordField;
58 import javax.swing.JRadioButton;
59 import javax.swing.JScrollPane;
60 import javax.swing.JSlider;
61 import javax.swing.JSpinner;
62 import javax.swing.JTabbedPane;
63 import javax.swing.JTable;
64 import javax.swing.JTextArea;
65 import javax.swing.JTextField;
66 import javax.swing.ListSelectionModel;
67 import javax.swing.SpinnerModel;
68 import javax.swing.SpinnerNumberModel;
69 import javax.swing.SwingConstants;
70 import javax.swing.border.Border;
71 import javax.swing.border.EmptyBorder;
72 import javax.swing.border.EtchedBorder;
73 import javax.swing.border.TitledBorder;
74 import javax.swing.event.ChangeEvent;
75 import javax.swing.event.ChangeListener;
76 import javax.swing.event.DocumentEvent;
77 import javax.swing.event.DocumentListener;
78 import javax.swing.table.TableCellEditor;
79 import javax.swing.table.TableCellRenderer;
81 import jalview.bin.Cache;
82 import jalview.bin.Console;
83 import jalview.bin.MemorySetting;
84 import jalview.fts.core.FTSDataColumnPreferences;
85 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
86 import jalview.fts.service.pdb.PDBFTSRestClient;
87 import jalview.gui.Desktop;
88 import jalview.gui.JalviewBooleanRadioButtons;
89 import jalview.gui.JvOptionPane;
90 import jalview.gui.JvSwingUtils;
91 import jalview.gui.StructureViewer.ViewerType;
92 import jalview.io.BackupFilenameParts;
93 import jalview.io.BackupFiles;
94 import jalview.io.BackupFilesPresetEntry;
95 import jalview.io.IntKeyStringValueEntry;
96 import jalview.util.BrowserLauncher;
97 import jalview.util.MessageManager;
98 import jalview.util.Platform;
99 import jalview.util.StringUtils;
102 * Base class for the Preferences panel.
105 * @version $Revision$
107 public class GPreferences extends JPanel
109 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
111 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
112 .getLabelFont(false, true);
114 private static final Font LABEL_FONT_BOLD = JvSwingUtils
115 .getLabelFont(true, false);
118 * Visual tab components
120 protected JCheckBox fullScreen = new JCheckBox();
122 protected JCheckBox openoverv = new JCheckBox();
124 protected JCheckBox seqLimit = new JCheckBox();
126 protected JCheckBox rightAlign = new JCheckBox();
128 protected JComboBox<String> fontSizeCB = new JComboBox<>();
130 protected JComboBox<String> fontStyleCB = new JComboBox<>();
132 protected JComboBox<String> fontNameCB = new JComboBox<>();
134 protected JCheckBox showOccupancy = new JCheckBox();
136 protected JCheckBox showUnconserved = new JCheckBox();
138 protected JCheckBox idItalics = new JCheckBox();
140 protected JCheckBox smoothFont = new JCheckBox();
142 protected JCheckBox scaleProteinToCdna = new JCheckBox();
144 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
146 protected JCheckBox wrap = new JCheckBox();
148 protected JComboBox<String> sortby = new JComboBox<>();
150 protected JComboBox<String> sortAnnBy = new JComboBox<>();
152 protected JComboBox<String> sortAutocalc = new JComboBox<>();
154 protected JCheckBox startupCheckbox = new JCheckBox();
156 protected JTextField startupFileTextfield = new JTextField();
158 // below are in the 'second column'
159 protected JCheckBox annotations = new JCheckBox();
161 protected JCheckBox quality = new JCheckBox();
163 protected JCheckBox conservation = new JCheckBox();
165 protected JCheckBox identity = new JCheckBox();
167 protected JCheckBox showGroupConsensus = new JCheckBox();
169 protected JCheckBox showGroupConservation = new JCheckBox();
171 protected JCheckBox showConsensHistogram = new JCheckBox();
173 protected JCheckBox showConsensLogo = new JCheckBox();
175 protected JCheckBox showDbRefTooltip = new JCheckBox();
177 protected JCheckBox showNpTooltip = new JCheckBox();
180 * Structure tab and components
182 protected JPanel structureTab;
184 protected JCheckBox structFromPdb = new JCheckBox();
186 protected JCheckBox addSecondaryStructure = new JCheckBox();
188 protected JCheckBox addTempFactor = new JCheckBox();
190 protected JComboBox<String> structViewer = new JComboBox<>();
192 protected JLabel structureViewerPathLabel;
194 protected JTextField structureViewerPath = new JTextField();
196 protected ButtonGroup mappingMethod = new ButtonGroup();
198 protected JRadioButton siftsMapping = new JRadioButton();
200 protected JRadioButton nwMapping = new JRadioButton();
203 * Colours tab components
205 protected JPanel minColour = new JPanel();
207 protected JPanel maxColour = new JPanel();
209 protected JComboBox<String> protColour = new JComboBox<>();
211 protected JComboBox<String> nucColour = new JComboBox<>();
214 * Overview tab components
216 protected JPanel gapColour = new JPanel();
218 protected JPanel hiddenColour = new JPanel();
220 protected JCheckBox useLegacyGap;
222 protected JCheckBox showHiddenAtStart;
224 protected JLabel gapLabel;
227 * Connections tab components
229 protected JPanel connectTab;
231 protected JTable linkUrlTable = new JTable();
233 protected JButton editLink = new JButton();
235 protected JButton deleteLink = new JButton();
237 protected JTextField filterTB = new JTextField();
239 protected JButton doReset = new JButton();
241 protected JButton userOnly = new JButton();
243 protected JLabel httpLabel = new JLabel();
245 protected JLabel httpsLabel = new JLabel();
247 protected JLabel portLabel = new JLabel();
249 protected JLabel serverLabel = new JLabel();
251 protected JLabel portLabel2 = new JLabel();
253 protected JLabel serverLabel2 = new JLabel();
255 protected JLabel proxyAuthUsernameLabel = new JLabel();
257 protected JLabel proxyAuthPasswordLabel = new JLabel();
259 protected JLabel passwordNotStoredLabel = new JLabel();
261 protected JTextField proxyServerHttpTB = new JTextField();
263 protected JTextField proxyPortHttpTB = new JTextField();
265 protected JTextField proxyServerHttpsTB = new JTextField();
267 protected JTextField proxyPortHttpsTB = new JTextField();
269 protected JCheckBox proxyAuth = new JCheckBox();
271 protected JTextField proxyAuthUsernameTB = new JTextField();
273 protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
275 protected JComboBox defaultBrowser = new JComboBox<String>();
277 protected ButtonGroup proxyType = new ButtonGroup();
279 protected JRadioButton noProxy = new JRadioButton();
281 protected JRadioButton systemProxy = new JRadioButton();
283 protected JRadioButton customProxy = new JRadioButton();
285 protected JButton applyProxyButton = new JButton();
287 protected JCheckBox usagestats = new JCheckBox();
289 protected JCheckBox questionnaire = new JCheckBox();
291 protected JCheckBox versioncheck = new JCheckBox();
294 * Output tab components
296 protected JComboBox<Object> epsRendering = new JComboBox<>();
298 protected JComboBox<Object> htmlRendering = new JComboBox<>();
300 protected JComboBox<Object> svgRendering = new JComboBox<>();
302 protected JLabel userIdWidthlabel = new JLabel();
304 protected JCheckBox autoIdWidth = new JCheckBox();
306 protected JTextField userIdWidth = new JTextField();
308 protected JCheckBox blcjv = new JCheckBox();
310 protected JCheckBox pileupjv = new JCheckBox();
312 protected JCheckBox clustaljv = new JCheckBox();
314 protected JCheckBox msfjv = new JCheckBox();
316 protected JCheckBox fastajv = new JCheckBox();
318 protected JCheckBox pfamjv = new JCheckBox();
320 protected JCheckBox pirjv = new JCheckBox();
322 protected JCheckBox modellerOutput = new JCheckBox();
324 protected JCheckBox embbedBioJSON = new JCheckBox();
327 * Editing tab components
329 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
331 protected JCheckBox padGaps = new JCheckBox();
333 protected JCheckBox sortByTree = new JCheckBox();
338 protected JPanel wsTab = new JPanel();
341 * Backups tab components
342 * a lot of these are member variables instead of local variables only so that they
343 * can be enabled/disabled easily in one go
346 protected JCheckBox enableBackupFiles = new JCheckBox();
348 protected JPanel presetsPanel = new JPanel();
350 protected JLabel presetsComboLabel = new JLabel();
352 protected JCheckBox customiseCheckbox = new JCheckBox();
354 protected JButton revertButton = new JButton();
356 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
358 private int backupfilesPresetsComboLastSelected = 0;
360 protected JPanel suffixPanel = new JPanel();
362 protected JPanel keepfilesPanel = new JPanel();
364 protected JPanel exampleFilesPanel = new JPanel();
366 protected JTextField suffixTemplate = new JTextField(null, 8);
368 protected JLabel suffixTemplateLabel = new JLabel();
370 protected JLabel suffixDigitsLabel = new JLabel();
372 protected JSpinner suffixDigitsSpinner = new JSpinner();
374 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
376 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
378 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
380 protected JLabel oldBackupFilesLabel = new JLabel();
382 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
384 protected JTextArea backupfilesExampleLabel = new JTextArea();
386 private final JTabbedPane tabbedPane = new JTabbedPane();
388 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
391 * Startup tab components
394 protected JCheckBox customiseMemorySetting = new JCheckBox();
396 protected JLabel exampleMemoryLabel = new JLabel();
398 protected JTextArea exampleMemoryMessageTextArea = new JTextArea();
400 protected JLabel maxMemoryLabel = new JLabel();
402 protected JLabel jvmMemoryPercentLabel = new JLabel();
404 protected JSlider jvmMemoryPercentSlider = new JSlider();
406 protected JLabel jvmMemoryPercentDisplay = new JLabel();
408 protected JLabel jvmMemoryMaxLabel = new JLabel();
410 protected JTextField jvmMemoryMaxTextField = new JTextField(null, 8);
412 protected JComboBox<Object> lafCombo = new JComboBox<>();
415 * Creates a new GPreferences object.
417 public GPreferences()
422 } catch (Exception ex)
424 ex.printStackTrace();
429 * Construct the panel and its tabbed sub-panels.
433 private void jbInit() throws Exception
435 // final JTabbedPane tabbedPane = new JTabbedPane();
436 this.setLayout(new BorderLayout());
438 // message label at top
439 this.add(messageLabel, BorderLayout.NORTH);
441 JPanel okCancelPanel = initOkCancelPanel();
442 this.add(tabbedPane, BorderLayout.CENTER);
443 this.add(okCancelPanel, BorderLayout.SOUTH);
445 tabbedPane.add(initVisualTab(),
446 MessageManager.getString("label.visual"));
448 tabbedPane.add(initColoursTab(),
449 MessageManager.getString("label.colours"));
451 tabbedPane.add(initOverviewTab(),
452 MessageManager.getString("label.overview"));
454 tabbedPane.add(initStructureTab(),
455 MessageManager.getString("label.structure"));
457 tabbedPane.add(initConnectionsTab(),
458 MessageManager.getString("label.connections"));
460 if (!Platform.isJS())
462 tabbedPane.add(initBackupsTab(),
463 MessageManager.getString("label.backups"));
466 tabbedPane.add(initLinksTab(),
467 MessageManager.getString("label.urllinks"));
469 tabbedPane.add(initOutputTab(),
470 MessageManager.getString("label.output"));
472 tabbedPane.add(initEditingTab(),
473 MessageManager.getString("label.editing"));
475 tabbedPane.add(initStartupTab(),
476 MessageManager.getString("label.startup"));
479 * See WsPreferences for the real work of configuring this tab.
481 if (!Platform.isJS())
483 wsTab.setLayout(new BorderLayout());
484 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
488 * Handler to validate a tab before leaving it - currently only for
490 * Adding a clearMessage() so messages are cleared when changing tabs.
492 tabbedPane.addChangeListener(new ChangeListener()
494 private Component lastTab;
497 public void stateChanged(ChangeEvent e)
499 if (lastTab == structureTab
500 && tabbedPane.getSelectedComponent() != structureTab)
502 if (!validateStructure())
504 tabbedPane.setSelectedComponent(structureTab);
508 lastTab = tabbedPane.getSelectedComponent();
516 public void setMessage(String message)
520 messageLabel.setText(message);
521 messageLabel.setFont(LABEL_FONT_BOLD);
522 messageLabel.setForeground(Color.RED.darker());
523 messageLabel.revalidate();
524 messageLabel.repaint();
526 // note message not cleared if message is null. call clearMessage()
532 public void clearMessage()
534 // only repaint if message exists
535 if (messageLabel.getText() != null
536 && messageLabel.getText().length() > 0)
538 messageLabel.setText("");
539 messageLabel.revalidate();
540 messageLabel.repaint();
546 public static enum TabRef
548 CONNECTIONS_TAB, STRUCTURE_TAB
551 public void selectTab(TabRef selectTab)
553 // select a given tab - currently only for Connections
556 case CONNECTIONS_TAB:
557 tabbedPane.setSelectedComponent(connectTab);
560 tabbedPane.setSelectedComponent(structureTab);
567 * Initialises the Editing tabbed panel.
571 private JPanel initEditingTab()
573 JPanel editingTab = new JPanel();
574 editingTab.setLayout(null);
575 autoCalculateConsCheck.setFont(LABEL_FONT);
576 autoCalculateConsCheck.setText(
577 MessageManager.getString("label.autocalculate_consensus"));
578 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
579 padGaps.setFont(LABEL_FONT);
581 MessageManager.getString("label.pad_gaps_when_editing"));
582 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
583 sortByTree.setFont(LABEL_FONT);
585 .setText(MessageManager.getString("label.sort_with_new_tree"));
586 sortByTree.setToolTipText(MessageManager.getString(
587 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
588 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
589 editingTab.add(autoCalculateConsCheck);
590 editingTab.add(padGaps);
591 editingTab.add(sortByTree);
596 * Initialises the Output tab
600 private JPanel initOutputTab()
602 JPanel outputTab = new JPanel();
603 outputTab.setLayout(null);
605 JLabel epsLabel = new JLabel(
606 MessageManager.formatMessage("label.rendering_style", "EPS"));
607 epsLabel.setFont(LABEL_FONT);
608 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
609 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
610 epsRendering.setFont(LABEL_FONT);
611 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
612 JLabel htmlLabel = new JLabel(
613 MessageManager.formatMessage("label.rendering_style", "HTML"));
614 htmlLabel.setFont(LABEL_FONT);
615 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
616 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
617 htmlRendering.setFont(LABEL_FONT);
618 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
619 JLabel svgLabel = new JLabel(
620 MessageManager.formatMessage("label.rendering_style", "SVG"));
621 svgLabel.setFont(LABEL_FONT);
622 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
623 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
624 svgRendering.setFont(LABEL_FONT);
625 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
627 JLabel jLabel1 = new JLabel();
628 jLabel1.setFont(LABEL_FONT);
629 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
630 jLabel1.setText(MessageManager.getString("label.append_start_end"));
631 jLabel1.setFont(LABEL_FONT);
633 fastajv.setFont(LABEL_FONT);
634 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
635 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
636 blcjv.setText(MessageManager.getString("label.blc") + " ");
637 fastajv.setText(MessageManager.getString("label.fasta") + " ");
638 msfjv.setText(MessageManager.getString("label.msf") + " ");
639 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
640 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
641 msfjv.setFont(LABEL_FONT);
642 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
643 pirjv.setText(MessageManager.getString("label.pir") + " ");
644 JPanel jPanel11 = new JPanel();
645 jPanel11.setFont(LABEL_FONT);
646 TitledBorder titledBorder2 = new TitledBorder(
647 MessageManager.getString("label.file_output"));
648 jPanel11.setBorder(titledBorder2);
649 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
650 GridLayout gridLayout3 = new GridLayout();
651 jPanel11.setLayout(gridLayout3);
652 gridLayout3.setRows(8);
653 blcjv.setFont(LABEL_FONT);
654 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
655 clustaljv.setFont(LABEL_FONT);
656 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
657 pfamjv.setFont(LABEL_FONT);
658 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
659 pileupjv.setFont(LABEL_FONT);
660 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
661 pirjv.setFont(LABEL_FONT);
662 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
663 autoIdWidth.setFont(LABEL_FONT);
665 MessageManager.getString("label.automatically_set_id_width"));
666 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
667 .getString("label.adjusts_width_generated_eps_png")));
668 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
669 autoIdWidth.addActionListener(new ActionListener()
673 public void actionPerformed(ActionEvent e)
675 autoIdWidth_actionPerformed();
678 userIdWidthlabel.setFont(LABEL_FONT);
679 userIdWidthlabel.setText(
680 MessageManager.getString("label.figure_id_column_width"));
681 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
682 .getString("label.manually_specify_width_left_column")));
683 userIdWidthlabel.setToolTipText(
684 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
685 "label.manually_specify_width_left_column")));
686 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
687 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
688 userIdWidth.setText("");
689 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
690 userIdWidth.addActionListener(new ActionListener()
694 public void actionPerformed(ActionEvent e)
696 userIdWidth_actionPerformed();
699 modellerOutput.setFont(LABEL_FONT);
701 .setText(MessageManager.getString("label.use_modeller_output"));
702 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
703 embbedBioJSON.setFont(LABEL_FONT);
704 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
705 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
707 jPanel11.add(jLabel1);
709 jPanel11.add(clustaljv);
710 jPanel11.add(fastajv);
712 jPanel11.add(pfamjv);
713 jPanel11.add(pileupjv);
715 outputTab.add(autoIdWidth);
716 outputTab.add(userIdWidth);
717 outputTab.add(userIdWidthlabel);
718 outputTab.add(modellerOutput);
719 if (!Platform.isJS())
722 * JalviewJS doesn't support Lineart option or SVG output
724 outputTab.add(embbedBioJSON);
725 outputTab.add(epsLabel);
726 outputTab.add(epsRendering);
727 outputTab.add(htmlLabel);
728 outputTab.add(htmlRendering);
729 outputTab.add(svgLabel);
730 outputTab.add(svgRendering);
732 outputTab.add(jPanel11);
737 * Initialises the Connections tabbed panel.
741 private JPanel initConnectionsTab()
743 connectTab = new JPanel();
744 connectTab.setLayout(new GridBagLayout());
746 // Label for browser text box
747 JLabel browserLabel = new JLabel();
748 browserLabel.setFont(LABEL_FONT);
749 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
750 browserLabel.setText(
751 MessageManager.getString("label.default_browser_unix_windows"));
752 defaultBrowser.setFont(LABEL_FONT);
753 final String tooltip = JvSwingUtils.wrapTooltip(true,
754 MessageManager.getString("label.double_click_to_browse"));
755 defaultBrowser.setToolTipText(tooltip);
757 defaultBrowser.addMouseListener(new MouseAdapter()
760 public void mouseClicked(MouseEvent e)
762 if (e.getClickCount() > 1)
764 defaultBrowser_mouseClicked(e);
770 JPanel proxyPanel = initConnTabProxyPanel();
771 initConnTabCheckboxes();
773 // Add default Browser text box
774 connectTab.add(browserLabel,
775 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
776 GridBagConstraints.WEST, GridBagConstraints.NONE,
777 new Insets(10, 0, 5, 5), 5, 1));
778 defaultBrowser.setFont(LABEL_FONT);
780 ComboBoxModel<String> cbModel = new DefaultComboBoxModel(
781 BrowserLauncher.getInstance().getBrowserList().toArray());
782 String browserPref = Cache.getProperty("DEFAULT_BROWSER");
783 if (browserPref != null)
785 cbModel.setSelectedItem(browserPref);
787 defaultBrowser.setModel(cbModel);
789 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
790 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
791 new Insets(10, 0, 5, 10), 30, 1));
793 // Add proxy server panel
794 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
795 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
796 new Insets(10, 0, 5, 12), 4, 10));
798 // Add usage stats, version check and questionnaire checkboxes
799 connectTab.add(usagestats,
800 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
801 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
802 new Insets(0, 2, 5, 5), 70, 1));
803 connectTab.add(questionnaire,
804 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
805 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
806 new Insets(0, 2, 5, 10), 70, 1));
807 connectTab.add(versioncheck,
808 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
809 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
810 new Insets(0, 2, 5, 5), 70, 1));
812 versioncheck.setVisible(false);
814 // Add padding so the panel doesn't look ridiculous
815 JPanel spacePanel = new JPanel();
816 connectTab.add(spacePanel,
817 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
818 GridBagConstraints.WEST, GridBagConstraints.BOTH,
819 new Insets(0, 0, 0, 5), 70, 1));
825 * Initialises the Links tabbed panel.
829 private JPanel initLinksTab()
831 JPanel linkTab = new JPanel();
832 linkTab.setLayout(new GridBagLayout());
834 // Set up table for Url links
835 linkUrlTable.getTableHeader().setReorderingAllowed(false);
836 linkUrlTable.setFillsViewportHeight(true);
837 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
838 linkUrlTable.setAutoCreateRowSorter(true);
839 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
841 // adjust row height so radio buttons actually fit
842 // don't do this in the renderer, it causes the awt thread to activate
844 JRadioButton temp = new JRadioButton();
845 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
847 // Table in scrollpane so that the table is given a scrollbar
848 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
849 linkScrollPane.setBorder(null);
851 // Panel for links functionality
852 JPanel linkPanel = new JPanel(new GridBagLayout());
853 linkPanel.setBorder(new TitledBorder(
854 MessageManager.getString("label.url_linkfrom_sequence_id")));
856 // Put the Url links panel together
858 // Buttons go at top right, resizing only resizes the blank space vertically
859 JPanel buttonPanel = initLinkTabUrlButtons();
860 GridBagConstraints linkConstraints1 = new GridBagConstraints();
861 linkConstraints1.insets = new Insets(0, 0, 5, 0);
862 linkConstraints1.gridx = 0;
863 linkConstraints1.gridy = 0;
864 linkConstraints1.weightx = 1.0;
865 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
866 linkTab.add(buttonPanel, linkConstraints1);
868 // Links table goes at top left, resizing resizes the table
869 GridBagConstraints linkConstraints2 = new GridBagConstraints();
870 linkConstraints2.insets = new Insets(0, 0, 5, 5);
871 linkConstraints2.gridx = 0;
872 linkConstraints2.gridy = 1;
873 linkConstraints2.weightx = 1.0;
874 linkConstraints2.weighty = 1.0;
875 linkConstraints2.fill = GridBagConstraints.BOTH;
876 linkTab.add(linkScrollPane, linkConstraints2);
878 // Filter box and buttons goes at bottom left, resizing resizes the text box
879 JPanel filterPanel = initLinkTabFilterPanel();
880 GridBagConstraints linkConstraints3 = new GridBagConstraints();
881 linkConstraints3.insets = new Insets(0, 0, 0, 5);
882 linkConstraints3.gridx = 0;
883 linkConstraints3.gridy = 2;
884 linkConstraints3.weightx = 1.0;
885 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
886 linkTab.add(filterPanel, linkConstraints3);
891 private JPanel initLinkTabFilterPanel()
893 // Filter textbox and reset button
894 JLabel filterLabel = new JLabel(
895 MessageManager.getString("label.filter"));
896 filterLabel.setFont(LABEL_FONT);
897 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
898 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
900 filterTB.setFont(LABEL_FONT);
901 filterTB.setText("");
903 doReset.setText(MessageManager.getString("action.showall"));
904 userOnly.setText(MessageManager.getString("action.customfilter"));
906 // Panel for filter functionality
907 JPanel filterPanel = new JPanel(new GridBagLayout());
908 filterPanel.setBorder(new TitledBorder("Filter"));
909 GridBagConstraints gbc = new GridBagConstraints();
912 gbc.fill = GridBagConstraints.NONE;
913 gbc.anchor = GridBagConstraints.WEST;
915 filterPanel.add(filterLabel, gbc);
917 GridBagConstraints gbc1 = new GridBagConstraints();
920 gbc1.fill = GridBagConstraints.HORIZONTAL;
921 gbc1.anchor = GridBagConstraints.WEST;
923 filterPanel.add(filterTB, gbc1);
925 GridBagConstraints gbc2 = new GridBagConstraints();
927 gbc2.fill = GridBagConstraints.NONE;
928 gbc2.anchor = GridBagConstraints.WEST;
929 filterPanel.add(doReset, gbc2);
931 GridBagConstraints gbc3 = new GridBagConstraints();
933 gbc3.fill = GridBagConstraints.NONE;
934 gbc3.anchor = GridBagConstraints.WEST;
935 filterPanel.add(userOnly, gbc3);
940 private JPanel initLinkTabUrlButtons()
942 // Buttons for new / edit / delete Url links
943 JButton newLink = new JButton();
944 newLink.setText(MessageManager.getString("action.new"));
946 editLink.setText(MessageManager.getString("action.edit"));
948 deleteLink.setText(MessageManager.getString("action.delete"));
950 // no current selection, so initially disable delete/edit buttons
951 editLink.setEnabled(false);
952 deleteLink.setEnabled(false);
954 newLink.addActionListener(new java.awt.event.ActionListener()
957 public void actionPerformed(ActionEvent e)
959 newLink_actionPerformed(e);
963 editLink.setText(MessageManager.getString("action.edit"));
964 editLink.addActionListener(new java.awt.event.ActionListener()
967 public void actionPerformed(ActionEvent e)
969 editLink_actionPerformed(e);
973 deleteLink.setText(MessageManager.getString("action.delete"));
974 deleteLink.addActionListener(new java.awt.event.ActionListener()
977 public void actionPerformed(ActionEvent e)
979 deleteLink_actionPerformed(e);
983 JPanel buttonPanel = new JPanel(new GridBagLayout());
984 buttonPanel.setBorder(new TitledBorder("Edit links"));
985 GridBagConstraints gbc = new GridBagConstraints();
988 gbc.fill = GridBagConstraints.NONE;
989 buttonPanel.add(newLink, gbc);
991 GridBagConstraints gbc1 = new GridBagConstraints();
994 gbc1.fill = GridBagConstraints.NONE;
995 buttonPanel.add(editLink, gbc1);
997 GridBagConstraints gbc2 = new GridBagConstraints();
1000 gbc2.fill = GridBagConstraints.NONE;
1001 buttonPanel.add(deleteLink, gbc2);
1003 GridBagConstraints gbc3 = new GridBagConstraints();
1006 gbc3.fill = GridBagConstraints.HORIZONTAL;
1008 JPanel spacePanel = new JPanel();
1009 spacePanel.setBorder(null);
1010 buttonPanel.add(spacePanel, gbc3);
1016 * Initialises the proxy server panel in the Connections tab
1018 * @return the proxy server panel
1020 private JPanel initConnTabProxyPanel()
1022 // Label for server text box
1023 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1024 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1025 serverLabel.setFont(LABEL_FONT);
1026 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1027 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1028 serverLabel2.setFont(LABEL_FONT);
1030 // Proxy server and port text boxes
1031 proxyServerHttpTB.setFont(LABEL_FONT);
1032 proxyServerHttpTB.setColumns(40);
1033 proxyPortHttpTB.setFont(LABEL_FONT);
1034 proxyPortHttpTB.setColumns(4);
1035 proxyServerHttpsTB.setFont(LABEL_FONT);
1036 proxyServerHttpsTB.setColumns(40);
1037 proxyPortHttpsTB.setFont(LABEL_FONT);
1038 proxyPortHttpsTB.setColumns(4);
1039 proxyAuthUsernameTB.setFont(LABEL_FONT);
1040 proxyAuthUsernameTB.setColumns(30);
1042 // check for any change to enable applyProxyButton
1043 DocumentListener d = new DocumentListener()
1046 public void changedUpdate(DocumentEvent e)
1048 applyProxyButtonEnabled(true);
1052 public void insertUpdate(DocumentEvent e)
1054 applyProxyButtonEnabled(true);
1058 public void removeUpdate(DocumentEvent e)
1060 applyProxyButtonEnabled(true);
1063 proxyServerHttpTB.getDocument().addDocumentListener(d);
1064 proxyPortHttpTB.getDocument().addDocumentListener(d);
1065 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1066 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1067 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1068 proxyAuthPasswordPB.setFont(LABEL_FONT);
1069 proxyAuthPasswordPB.setColumns(30);
1070 proxyAuthPasswordPB.getDocument()
1071 .addDocumentListener(new DocumentListener()
1074 public void changedUpdate(DocumentEvent e)
1076 proxyAuthPasswordCheckHighlight(true);
1077 applyProxyButtonEnabled(true);
1081 public void insertUpdate(DocumentEvent e)
1083 proxyAuthPasswordCheckHighlight(true);
1084 applyProxyButtonEnabled(true);
1088 public void removeUpdate(DocumentEvent e)
1090 proxyAuthPasswordCheckHighlight(true);
1091 applyProxyButtonEnabled(true);
1096 // Label for Port text box
1097 portLabel.setFont(LABEL_FONT);
1098 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1099 portLabel.setText(MessageManager.getString("label.port") + ": ");
1100 portLabel2.setFont(LABEL_FONT);
1101 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1102 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1104 httpLabel.setText("HTTP");
1105 httpLabel.setFont(LABEL_FONT_BOLD);
1106 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1107 httpsLabel.setText("HTTPS");
1108 httpsLabel.setFont(LABEL_FONT_BOLD);
1109 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1111 proxyAuthUsernameLabel
1112 .setText(MessageManager.getString("label.username") + ": ");
1113 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1114 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1115 proxyAuthPasswordLabel
1116 .setText(MessageManager.getString("label.password") + ": ");
1117 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1118 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1119 passwordNotStoredLabel.setText(
1120 "(" + MessageManager.getString("label.not_stored") + ")");
1121 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1122 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1124 // Proxy type radio buttons
1125 noProxy.setFont(LABEL_FONT);
1126 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1127 noProxy.setText(MessageManager.getString("label.no_proxy"));
1128 systemProxy.setFont(LABEL_FONT);
1129 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1130 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1131 displayUserHostPort(Cache.startupProxyProperties[4],
1132 Cache.startupProxyProperties[0],
1133 Cache.startupProxyProperties[1]),
1134 displayUserHostPort(Cache.startupProxyProperties[6],
1135 Cache.startupProxyProperties[2],
1136 Cache.startupProxyProperties[3])));
1137 customProxy.setFont(LABEL_FONT);
1138 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1139 customProxy.setText(
1140 MessageManager.getString("label.use_proxy_server") + ":");
1141 ActionListener al = new ActionListener()
1144 public void actionPerformed(ActionEvent e)
1146 proxyType_actionPerformed();
1149 noProxy.addActionListener(al);
1150 systemProxy.addActionListener(al);
1151 customProxy.addActionListener(al);
1152 proxyType.add(noProxy);
1153 proxyType.add(systemProxy);
1154 proxyType.add(customProxy);
1156 proxyAuth.setFont(LABEL_FONT);
1157 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1158 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1159 proxyAuth.addActionListener(new ActionListener()
1162 public void actionPerformed(ActionEvent e)
1164 proxyAuth_actionPerformed();
1168 setCustomProxyEnabled();
1170 // Make proxy server panel
1171 JPanel proxyPanel = new JPanel();
1172 TitledBorder titledBorder1 = new TitledBorder(
1173 MessageManager.getString("label.proxy_servers"));
1174 proxyPanel.setBorder(titledBorder1);
1175 proxyPanel.setLayout(new GridBagLayout());
1176 GridBagConstraints gbc = new GridBagConstraints();
1177 gbc.fill = GridBagConstraints.HORIZONTAL;
1180 GridBagConstraints c = new GridBagConstraints();
1181 // Proxy type radio buttons (3)
1182 JPanel ptPanel = new JPanel();
1183 ptPanel.setLayout(new GridBagLayout());
1188 c.fill = GridBagConstraints.HORIZONTAL;
1189 ptPanel.add(noProxy, c);
1191 ptPanel.add(systemProxy, c);
1193 ptPanel.add(customProxy, c);
1196 proxyPanel.add(ptPanel, gbc);
1198 // host and port text boxes
1199 JPanel hpPanel = new JPanel();
1200 hpPanel.setLayout(new GridBagLayout());
1201 // HTTP host port row
1206 c.anchor = GridBagConstraints.LINE_START;
1207 hpPanel.add(httpLabel, c);
1211 c.anchor = GridBagConstraints.LINE_END;
1212 hpPanel.add(serverLabel, c);
1216 c.anchor = GridBagConstraints.LINE_START;
1217 hpPanel.add(proxyServerHttpTB, c);
1221 c.anchor = GridBagConstraints.LINE_END;
1222 hpPanel.add(portLabel, c);
1226 c.anchor = GridBagConstraints.LINE_START;
1227 hpPanel.add(proxyPortHttpTB, c);
1229 // HTTPS host port row
1234 c.anchor = GridBagConstraints.LINE_START;
1235 hpPanel.add(httpsLabel, c);
1238 c.anchor = GridBagConstraints.LINE_END;
1239 hpPanel.add(serverLabel2, c);
1242 c.anchor = GridBagConstraints.LINE_START;
1243 hpPanel.add(proxyServerHttpsTB, c);
1246 c.anchor = GridBagConstraints.LINE_END;
1247 hpPanel.add(portLabel2, c);
1250 c.anchor = GridBagConstraints.LINE_START;
1251 hpPanel.add(proxyPortHttpsTB, c);
1254 proxyPanel.add(hpPanel, gbc);
1256 if (!Platform.isJS())
1258 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1259 * Authentication options in Preferences.
1265 // Require authentication checkbox
1267 proxyPanel.add(proxyAuth, gbc);
1269 // username and password
1270 JPanel upPanel = new JPanel();
1271 upPanel.setLayout(new GridBagLayout());
1277 c.anchor = GridBagConstraints.LINE_END;
1278 upPanel.add(proxyAuthUsernameLabel, c);
1282 c.anchor = GridBagConstraints.LINE_START;
1283 upPanel.add(proxyAuthUsernameTB, c);
1289 c.anchor = GridBagConstraints.LINE_END;
1290 upPanel.add(proxyAuthPasswordLabel, c);
1294 c.anchor = GridBagConstraints.LINE_START;
1295 upPanel.add(proxyAuthPasswordPB, c);
1299 c.anchor = GridBagConstraints.LINE_START;
1300 upPanel.add(passwordNotStoredLabel, c);
1303 proxyPanel.add(upPanel, gbc);
1307 applyProxyButton.setText(MessageManager.getString("action.apply"));
1308 applyProxyButton.addActionListener(new ActionListener()
1311 public void actionPerformed(ActionEvent e)
1313 saveProxySettings();
1314 applyProxyButton.setEnabled(false);
1318 gbc.fill = GridBagConstraints.NONE;
1319 gbc.anchor = GridBagConstraints.LINE_END;
1320 proxyPanel.add(applyProxyButton, gbc);
1325 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1327 proxyAuthPasswordCheckHighlight(enabled, false);
1330 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1333 if (enabled && proxyType.isSelected(customProxy.getModel())
1334 && proxyAuth.isSelected()
1335 && !proxyAuthUsernameTB.getText().isEmpty()
1336 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1339 proxyAuthPasswordPB.grabFocus();
1340 proxyAuthPasswordPB.setBackground(Color.PINK);
1344 proxyAuthPasswordPB.setBackground(Color.WHITE);
1348 public void applyProxyButtonEnabled(boolean enabled)
1350 applyProxyButton.setEnabled(enabled);
1353 public void saveProxySettings()
1355 // overridden in Preferences
1358 private String displayUserHostPort(String user, String host, String port)
1360 boolean hostBlank = (host == null || host.isEmpty());
1361 boolean portBlank = (port == null || port.isEmpty());
1362 if (hostBlank && portBlank)
1364 return MessageManager.getString("label.none");
1367 StringBuilder sb = new StringBuilder();
1370 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1374 sb.append(hostBlank ? "" : host);
1380 return sb.toString();
1384 * Initialises the checkboxes in the Connections tab
1386 private void initConnTabCheckboxes()
1388 // Usage stats checkbox label
1390 MessageManager.getString("label.send_usage_statistics"));
1391 usagestats.setFont(LABEL_FONT);
1392 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1393 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1395 // Questionnaire checkbox label
1396 questionnaire.setText(
1397 MessageManager.getString("label.check_for_questionnaires"));
1398 questionnaire.setFont(LABEL_FONT);
1399 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1400 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1402 // Check for latest version checkbox label
1403 versioncheck.setText(
1404 MessageManager.getString("label.check_for_latest_version"));
1405 versioncheck.setFont(LABEL_FONT);
1406 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1407 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1411 * Initialises the parent panel which contains the tabbed sections.
1415 private JPanel initOkCancelPanel()
1417 JButton ok = new JButton();
1418 ok.setText(MessageManager.getString("action.ok"));
1419 ok.addActionListener(new ActionListener()
1422 public void actionPerformed(ActionEvent e)
1424 ok_actionPerformed(e);
1427 JButton cancel = new JButton();
1428 cancel.setText(MessageManager.getString("action.cancel"));
1429 cancel.addActionListener(new ActionListener()
1432 public void actionPerformed(ActionEvent e)
1434 cancel_actionPerformed(e);
1437 JPanel okCancelPanel = new JPanel();
1438 okCancelPanel.add(ok);
1439 okCancelPanel.add(cancel);
1440 return okCancelPanel;
1444 * Initialises the Colours tabbed panel.
1448 private JPanel initColoursTab()
1450 JPanel coloursTab = new JPanel();
1451 coloursTab.setBorder(new TitledBorder(
1452 MessageManager.getString("action.open_new_alignment")));
1453 coloursTab.setLayout(new FlowLayout());
1454 JLabel mincolourLabel = new JLabel();
1455 mincolourLabel.setFont(LABEL_FONT);
1456 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1457 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1458 minColour.setFont(LABEL_FONT);
1459 minColour.setBorder(BorderFactory.createEtchedBorder());
1460 minColour.setPreferredSize(new Dimension(40, 20));
1461 minColour.addMouseListener(new MouseAdapter()
1464 public void mousePressed(MouseEvent e)
1466 minColour_actionPerformed(minColour);
1469 JLabel maxcolourLabel = new JLabel();
1470 maxcolourLabel.setFont(LABEL_FONT);
1471 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1472 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1473 maxColour.setFont(LABEL_FONT);
1474 maxColour.setBorder(BorderFactory.createEtchedBorder());
1475 maxColour.setPreferredSize(new Dimension(40, 20));
1476 maxColour.addMouseListener(new MouseAdapter()
1479 public void mousePressed(MouseEvent e)
1481 maxColour_actionPerformed(maxColour);
1485 protColour.setFont(LABEL_FONT);
1486 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1487 JLabel protColourLabel = new JLabel();
1488 protColourLabel.setFont(LABEL_FONT);
1489 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1490 protColourLabel.setText(
1491 MessageManager.getString("label.prot_alignment_colour") + " ");
1492 JvSwingUtils.addtoLayout(coloursTab,
1494 .getString("label.default_colour_scheme_for_alignment"),
1495 protColourLabel, protColour);
1497 nucColour.setFont(LABEL_FONT);
1498 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1499 JLabel nucColourLabel = new JLabel();
1500 nucColourLabel.setFont(LABEL_FONT);
1501 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1502 nucColourLabel.setText(
1503 MessageManager.getString("label.nuc_alignment_colour") + " ");
1504 JvSwingUtils.addtoLayout(coloursTab,
1506 .getString("label.default_colour_scheme_for_alignment"),
1507 nucColourLabel, nucColour);
1509 JPanel annotationShding = new JPanel();
1510 annotationShding.setBorder(new TitledBorder(
1511 MessageManager.getString("label.annotation_shading_default")));
1512 annotationShding.setLayout(new GridLayout(1, 2));
1513 JvSwingUtils.addtoLayout(annotationShding,
1514 MessageManager.getString(
1515 "label.default_minimum_colour_annotation_shading"),
1516 mincolourLabel, minColour);
1517 JvSwingUtils.addtoLayout(annotationShding,
1518 MessageManager.getString(
1519 "label.default_maximum_colour_annotation_shading"),
1520 maxcolourLabel, maxColour);
1521 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1526 * Initialises the Overview tabbed panel.
1530 private JPanel initOverviewTab()
1532 JPanel overviewPanel = new JPanel();
1533 overviewPanel.setBorder(new TitledBorder(
1534 MessageManager.getString("label.overview_settings")));
1536 gapColour.setFont(LABEL_FONT);
1537 // fixing the border colours stops apparent colour bleed from the panel
1538 gapColour.setBorder(
1539 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1540 gapColour.setPreferredSize(new Dimension(40, 20));
1541 gapColour.addMouseListener(new MouseAdapter()
1544 public void mousePressed(MouseEvent e)
1546 gapColour_actionPerformed(gapColour);
1550 hiddenColour.setFont(LABEL_FONT);
1551 // fixing the border colours stops apparent colour bleed from the panel
1552 hiddenColour.setBorder(
1553 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1554 hiddenColour.setPreferredSize(new Dimension(40, 20));
1555 hiddenColour.addMouseListener(new MouseAdapter()
1558 public void mousePressed(MouseEvent e)
1560 hiddenColour_actionPerformed(hiddenColour);
1564 useLegacyGap = new JCheckBox(
1565 MessageManager.getString("label.ov_legacy_gap"));
1566 useLegacyGap.setFont(LABEL_FONT);
1567 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1568 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1569 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1570 gapLabel.setFont(LABEL_FONT);
1571 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1572 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1573 showHiddenAtStart = new JCheckBox(
1574 MessageManager.getString("label.ov_show_hide_default"));
1575 showHiddenAtStart.setFont(LABEL_FONT);
1576 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1577 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1578 JLabel hiddenLabel = new JLabel(
1579 MessageManager.getString("label.hidden_colour"));
1580 hiddenLabel.setFont(LABEL_FONT);
1581 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1582 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1584 useLegacyGap.addActionListener(new ActionListener()
1587 public void actionPerformed(ActionEvent e)
1589 useLegacyGaps_actionPerformed(e);
1593 overviewPanel.setLayout(new GridBagLayout());
1594 GridBagConstraints c1 = new GridBagConstraints();
1596 c1.fill = GridBagConstraints.HORIZONTAL;
1601 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1602 overviewPanel.add(useLegacyGap, c1);
1604 GridBagConstraints c2 = new GridBagConstraints();
1605 c2.fill = GridBagConstraints.HORIZONTAL;
1608 c2.insets = new Insets(0, 15, 0, 10);
1609 overviewPanel.add(gapLabel, c2);
1611 GridBagConstraints c3 = new GridBagConstraints();
1612 c3.fill = GridBagConstraints.HORIZONTAL;
1615 c3.insets = new Insets(0, 0, 0, 15);
1616 overviewPanel.add(gapColour, c3);
1618 GridBagConstraints c4 = new GridBagConstraints();
1619 c4.fill = GridBagConstraints.HORIZONTAL;
1623 overviewPanel.add(showHiddenAtStart, c4);
1625 GridBagConstraints c5 = new GridBagConstraints();
1626 c5.fill = GridBagConstraints.HORIZONTAL;
1629 c5.insets = new Insets(0, 15, 0, 10);
1630 overviewPanel.add(hiddenLabel, c5);
1632 GridBagConstraints c6 = new GridBagConstraints();
1633 c6.fill = GridBagConstraints.HORIZONTAL;
1636 c6.insets = new Insets(0, 0, 0, 15);
1637 overviewPanel.add(hiddenColour, c6);
1639 JButton resetButton = new JButton(
1640 MessageManager.getString("label.reset_to_defaults"));
1642 resetButton.addActionListener(new ActionListener()
1645 public void actionPerformed(ActionEvent e)
1647 resetOvDefaults_actionPerformed(e);
1651 GridBagConstraints c7 = new GridBagConstraints();
1652 c7.fill = GridBagConstraints.NONE;
1655 c7.insets = new Insets(10, 0, 0, 0);
1656 c7.anchor = GridBagConstraints.WEST;
1657 overviewPanel.add(resetButton, c7);
1659 // Add padding so the panel doesn't look ridiculous
1660 JPanel spacePanel = new JPanel();
1661 overviewPanel.add(spacePanel,
1662 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1663 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1664 new Insets(0, 0, 0, 5), 0, 0));
1666 return overviewPanel;
1670 * Initialises the Structure tabbed panel.
1674 private JPanel initStructureTab()
1676 structureTab = new JPanel();
1678 structureTab.setBorder(new TitledBorder(
1679 MessageManager.getString("label.structure_options")));
1680 structureTab.setLayout(null);
1681 final int width = 420;
1682 final int height = 22;
1683 final int lineSpacing = 25;
1686 structFromPdb.setFont(LABEL_FONT);
1688 .setText(MessageManager.getString("label.struct_from_pdb"));
1689 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1690 structFromPdb.addActionListener(new ActionListener()
1693 public void actionPerformed(ActionEvent e)
1695 boolean selected = structFromPdb.isSelected();
1696 // enable other options only when the first is checked
1697 addSecondaryStructure.setEnabled(selected);
1698 addTempFactor.setEnabled(selected);
1701 structureTab.add(structFromPdb);
1703 // indent checkboxes that are conditional on the first one
1704 ypos += lineSpacing;
1705 addSecondaryStructure.setFont(LABEL_FONT);
1706 addSecondaryStructure
1707 .setText(MessageManager.getString("label.autoadd_secstr"));
1708 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1709 structureTab.add(addSecondaryStructure);
1711 ypos += lineSpacing;
1712 addTempFactor.setFont(LABEL_FONT);
1713 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1714 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1715 structureTab.add(addTempFactor);
1717 ypos += lineSpacing;
1718 JLabel viewerLabel = new JLabel();
1719 viewerLabel.setFont(LABEL_FONT);
1720 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1721 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1722 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1723 structureTab.add(viewerLabel);
1726 * add all external viewers as options here - check
1727 * when selected whether the program is installed
1729 structViewer.setFont(LABEL_FONT);
1730 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1731 structViewer.addItem(ViewerType.JMOL.name());
1732 structViewer.addItem(ViewerType.CHIMERA.name());
1733 structViewer.addItem(ViewerType.CHIMERAX.name());
1734 structViewer.addItem(ViewerType.PYMOL.name());
1735 structViewer.addActionListener(new ActionListener()
1738 public void actionPerformed(ActionEvent e)
1740 structureViewer_actionPerformed(
1741 (String) structViewer.getSelectedItem());
1744 structureTab.add(structViewer);
1746 ypos += lineSpacing;
1747 structureViewerPathLabel = new JLabel();
1748 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1750 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1751 structureViewerPathLabel.setText(MessageManager
1752 .formatMessage("label.viewer_path", "Chimera(X)"));
1753 structureViewerPathLabel
1754 .setBounds(new Rectangle(10, ypos, 170, height));
1755 structureViewerPathLabel.setEnabled(false);
1756 structureTab.add(structureViewerPathLabel);
1758 structureViewerPath.setFont(LABEL_FONT);
1759 structureViewerPath.setText("");
1760 structureViewerPath.setEnabled(false);
1761 final String tooltip = JvSwingUtils.wrapTooltip(true,
1762 MessageManager.getString("label.viewer_path_tip"));
1763 structureViewerPath.setToolTipText(tooltip);
1764 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1765 structureViewerPath.addMouseListener(new MouseAdapter()
1768 public void mouseClicked(MouseEvent e)
1770 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1772 String chosen = openFileChooser();
1775 structureViewerPath.setText(chosen);
1780 structureTab.add(structureViewerPath);
1782 ypos += lineSpacing;
1783 nwMapping.setFont(LABEL_FONT);
1784 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1785 siftsMapping.setFont(LABEL_FONT);
1786 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1787 mappingMethod.add(nwMapping);
1788 mappingMethod.add(siftsMapping);
1789 JPanel mappingPanel = new JPanel();
1790 mappingPanel.setFont(LABEL_FONT);
1791 TitledBorder mmTitledBorder = new TitledBorder(
1792 MessageManager.getString("label.mapping_method"));
1793 mmTitledBorder.setTitleFont(LABEL_FONT);
1794 mappingPanel.setBorder(mmTitledBorder);
1795 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1796 // GridLayout mappingLayout = new GridLayout();
1797 mappingPanel.setLayout(new GridLayout());
1798 mappingPanel.add(nwMapping);
1799 mappingPanel.add(siftsMapping);
1800 structureTab.add(mappingPanel);
1802 ypos += lineSpacing;
1803 ypos += lineSpacing;
1804 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1805 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1806 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1807 structureTab.add(docFieldPref);
1810 * hide Chimera options in JalviewJS
1812 if (Platform.isJS())
1814 structureViewerPathLabel.setVisible(false);
1815 structureViewerPath.setVisible(false);
1816 viewerLabel.setVisible(false);
1817 structViewer.setVisible(false);
1820 return structureTab;
1824 * Action on choosing a structure viewer from combobox options.
1826 * @param selectedItem
1828 protected void structureViewer_actionPerformed(String selectedItem)
1833 * Show a dialog for the user to choose a file. Returns the chosen path, or
1838 protected String openFileChooser()
1840 String choice = null;
1841 JFileChooser chooser = new JFileChooser();
1843 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1844 // hidden executables within .app dirs
1845 if (Platform.isMac())
1847 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1851 // chooser.setFileView(new JalviewFileView());
1852 chooser.setDialogTitle(
1853 MessageManager.getString("label.open_local_file"));
1854 chooser.setToolTipText(MessageManager.getString("action.open"));
1856 int value = chooser.showOpenDialog(this);
1858 if (value == JFileChooser.APPROVE_OPTION)
1860 choice = chooser.getSelectedFile().getPath();
1866 * Validate the structure tab preferences; if invalid, set focus on this tab.
1870 protected boolean validateStructure(FocusEvent e)
1872 if (!validateStructure())
1874 e.getComponent().requestFocusInWindow();
1880 protected boolean validateStructure()
1886 * Initialises the Visual tabbed panel.
1890 private JPanel initVisualTab()
1892 JPanel visualTab = new JPanel();
1893 visualTab.setBorder(new TitledBorder(
1894 MessageManager.getString("action.open_new_alignment")));
1895 visualTab.setLayout(null);
1896 fullScreen.setFont(LABEL_FONT);
1897 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1898 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1899 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1900 quality.setEnabled(false);
1901 quality.setFont(LABEL_FONT);
1902 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1903 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1904 quality.setSelected(true);
1905 quality.setText(MessageManager.getString("label.quality"));
1906 conservation.setEnabled(false);
1907 conservation.setFont(LABEL_FONT);
1908 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1909 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1910 conservation.setSelected(true);
1911 conservation.setText(MessageManager.getString("label.conservation"));
1912 identity.setEnabled(false);
1913 identity.setFont(LABEL_FONT);
1914 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1915 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1916 identity.setSelected(true);
1917 identity.setText(MessageManager.getString("label.consensus"));
1918 showOccupancy.setFont(LABEL_FONT);
1919 showOccupancy.setEnabled(false);
1920 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1921 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1922 showOccupancy.setSelected(true);
1923 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1925 JLabel showGroupbits = new JLabel();
1926 showGroupbits.setFont(LABEL_FONT);
1927 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1928 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1930 .setText(MessageManager.getString("action.show_group") + ":");
1931 JLabel showConsensbits = new JLabel();
1932 showConsensbits.setFont(LABEL_FONT);
1933 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1934 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1936 .setText(MessageManager.getString("label.consensus") + ":");
1937 showConsensHistogram.setEnabled(false);
1938 showConsensHistogram.setFont(LABEL_FONT);
1939 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1940 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1941 showConsensHistogram.setSelected(true);
1942 showConsensHistogram
1943 .setText(MessageManager.getString("label.histogram"));
1944 showConsensLogo.setEnabled(false);
1945 showConsensLogo.setFont(LABEL_FONT);
1946 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1947 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1948 showConsensLogo.setSelected(true);
1949 showConsensLogo.setText(MessageManager.getString("label.logo"));
1950 showGroupConsensus.setEnabled(false);
1951 showGroupConsensus.setFont(LABEL_FONT);
1952 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1953 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1954 showGroupConsensus.setSelected(true);
1955 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1956 showGroupConservation.setEnabled(false);
1957 showGroupConservation.setFont(LABEL_FONT);
1958 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1959 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1960 showGroupConservation.setSelected(true);
1961 showGroupConservation
1962 .setText(MessageManager.getString("label.conservation"));
1963 showNpTooltip.setEnabled(true);
1964 showNpTooltip.setFont(LABEL_FONT);
1965 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1966 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1967 showNpTooltip.setSelected(true);
1968 showNpTooltip.setText(
1969 MessageManager.getString("label.non_positional_features"));
1970 showDbRefTooltip.setEnabled(true);
1971 showDbRefTooltip.setFont(LABEL_FONT);
1972 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1973 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1974 showDbRefTooltip.setSelected(true);
1976 .setText(MessageManager.getString("label.database_references"));
1977 annotations.setFont(LABEL_FONT);
1978 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1979 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1980 annotations.setSelected(true);
1981 annotations.setText(MessageManager.getString("label.show_annotations"));
1982 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1983 annotations.addActionListener(new ActionListener()
1986 public void actionPerformed(ActionEvent e)
1988 annotations_actionPerformed(e);
1991 identity.addActionListener(new ActionListener()
1994 public void actionPerformed(ActionEvent e)
1996 annotations_actionPerformed(e);
1999 showGroupConsensus.addActionListener(new ActionListener()
2002 public void actionPerformed(ActionEvent e)
2004 annotations_actionPerformed(e);
2007 showUnconserved.setFont(LABEL_FONT);
2008 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2009 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2010 showUnconserved.setSelected(true);
2012 .setText(MessageManager.getString("action.show_unconserved"));
2013 showUnconserved.addActionListener(new ActionListener()
2016 public void actionPerformed(ActionEvent e)
2018 showunconserved_actionPerformed(e);
2022 // TODO these are not yet added to / action from Preferences
2023 // JCheckBox shareSelections = new JCheckBox();
2024 // shareSelections.setFont(verdana11);
2025 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2026 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2027 // shareSelections.setSelected(true);
2028 // shareSelections.setText(MessageManager
2029 // .getString("label.share_selection_across_views"));
2030 // JCheckBox followHighlight = new JCheckBox();
2031 // followHighlight.setFont(verdana11);
2032 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2033 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2034 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2035 // followHighlight.setSelected(true);
2036 // followHighlight.setText(MessageManager
2037 // .getString("label.scroll_highlighted_regions"));
2039 seqLimit.setFont(LABEL_FONT);
2040 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2041 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2042 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2043 smoothFont.setFont(LABEL_FONT);
2044 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2045 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2046 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2047 scaleProteinToCdna.setFont(LABEL_FONT);
2048 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2049 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2050 scaleProteinToCdna.setText(
2051 MessageManager.getString("label.scale_protein_to_cdna"));
2052 scaleProteinToCdna.setToolTipText(
2053 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2054 JLabel gapLabel = new JLabel();
2055 gapLabel.setFont(LABEL_FONT);
2056 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2057 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2058 JLabel fontLabel = new JLabel();
2059 fontLabel.setFont(LABEL_FONT);
2060 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2061 fontLabel.setText(MessageManager.getString("label.font"));
2062 fontSizeCB.setFont(LABEL_FONT);
2063 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2064 fontStyleCB.setFont(LABEL_FONT);
2065 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2066 fontNameCB.setFont(LABEL_FONT);
2067 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2068 gapSymbolCB.setFont(LABEL_FONT);
2069 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2070 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2071 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2072 gapSymbolCB.setRenderer(dlcr);
2074 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2075 startupCheckbox.setFont(LABEL_FONT);
2076 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2077 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2078 startupCheckbox.setSelected(true);
2079 startupFileTextfield.setFont(LABEL_FONT);
2080 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2081 final String tooltip = JvSwingUtils.wrapTooltip(true,
2082 MessageManager.getString("label.double_click_to_browse"));
2083 startupFileTextfield.setToolTipText(tooltip);
2084 startupFileTextfield.addMouseListener(new MouseAdapter()
2087 public void mouseClicked(MouseEvent e)
2089 if (e.getClickCount() > 1)
2091 startupFileTextfield_mouseClicked();
2096 sortby.setFont(LABEL_FONT);
2097 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2098 JLabel sortLabel = new JLabel();
2099 sortLabel.setFont(LABEL_FONT);
2100 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2101 sortLabel.setText(MessageManager.getString("label.sort_by"));
2102 sortAnnBy.setFont(LABEL_FONT);
2103 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2104 JLabel sortAnnLabel = new JLabel();
2105 sortAnnLabel.setFont(LABEL_FONT);
2106 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2107 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2108 sortAutocalc.setFont(LABEL_FONT);
2109 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2111 JPanel annsettingsPanel = new JPanel();
2112 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2113 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2114 annsettingsPanel.setBorder(new EtchedBorder());
2115 visualTab.add(annsettingsPanel);
2116 Border jb = new EmptyBorder(1, 1, 4, 5);
2117 annotations.setBorder(jb);
2118 showOccupancy.setBorder(jb);
2119 quality.setBorder(jb);
2120 conservation.setBorder(jb);
2121 identity.setBorder(jb);
2122 showConsensbits.setBorder(jb);
2123 showGroupbits.setBorder(jb);
2124 showGroupConsensus.setBorder(jb);
2125 showGroupConservation.setBorder(jb);
2126 showConsensHistogram.setBorder(jb);
2127 showConsensLogo.setBorder(jb);
2129 JPanel autoAnnotSettings = new JPanel();
2130 annsettingsPanel.add(autoAnnotSettings);
2131 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2132 autoAnnotSettings.add(annotations);
2133 autoAnnotSettings.add(quality);
2134 // second row of autoannotation box
2135 autoAnnotSettings = new JPanel();
2136 annsettingsPanel.add(autoAnnotSettings);
2138 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2139 autoAnnotSettings.add(conservation);
2140 autoAnnotSettings.add(identity);
2141 autoAnnotSettings.add(showOccupancy);
2142 autoAnnotSettings.add(showGroupbits);
2143 autoAnnotSettings.add(showGroupConservation);
2144 autoAnnotSettings.add(showGroupConsensus);
2145 autoAnnotSettings.add(showConsensbits);
2146 autoAnnotSettings.add(showConsensHistogram);
2147 autoAnnotSettings.add(showConsensLogo);
2149 JPanel tooltipSettings = new JPanel();
2150 tooltipSettings.setBorder(new TitledBorder(
2151 MessageManager.getString("label.sequence_id_tooltip")));
2152 tooltipSettings.setBounds(173, 140, 220, 62);
2153 tooltipSettings.setLayout(new GridLayout(2, 1));
2154 tooltipSettings.add(showDbRefTooltip);
2155 tooltipSettings.add(showNpTooltip);
2156 visualTab.add(tooltipSettings);
2158 wrap.setFont(LABEL_FONT);
2159 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2160 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2161 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2162 rightAlign.setFont(LABEL_FONT);
2163 rightAlign.setForeground(Color.black);
2164 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2165 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2166 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2167 idItalics.setFont(LABEL_FONT_ITALIC);
2168 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2169 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2171 MessageManager.getString("label.sequence_name_italics"));
2172 openoverv.setFont(LABEL_FONT);
2173 openoverv.setActionCommand(
2174 MessageManager.getString("label.open_overview"));
2175 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2176 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2177 openoverv.setText(MessageManager.getString("label.open_overview"));
2178 JPanel jPanel2 = new JPanel();
2179 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2180 jPanel2.setLayout(new GridLayout(14, 1));
2181 jPanel2.add(fullScreen);
2182 jPanel2.add(openoverv);
2183 jPanel2.add(seqLimit);
2184 jPanel2.add(rightAlign);
2185 jPanel2.add(fontLabel);
2186 jPanel2.add(showUnconserved);
2187 jPanel2.add(idItalics);
2188 jPanel2.add(smoothFont);
2189 jPanel2.add(scaleProteinToCdna);
2190 jPanel2.add(gapLabel);
2192 jPanel2.add(sortLabel);
2193 jPanel2.add(sortAnnLabel);
2194 jPanel2.add(startupCheckbox);
2195 visualTab.add(jPanel2);
2196 visualTab.add(startupFileTextfield);
2197 visualTab.add(sortby);
2198 visualTab.add(sortAnnBy);
2199 visualTab.add(sortAutocalc);
2200 visualTab.add(gapSymbolCB);
2201 visualTab.add(fontNameCB);
2202 visualTab.add(fontSizeCB);
2203 visualTab.add(fontStyleCB);
2205 if (Platform.isJS())
2207 startupCheckbox.setVisible(false);
2208 startupFileTextfield.setVisible(false);
2215 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2218 protected void loadLastSavedBackupsOptions()
2220 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2221 .getSavedBackupEntry();
2222 enableBackupFiles.setSelected(
2223 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2225 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2226 .createBackupFilesPresetEntry(Cache
2227 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2228 if (backupfilesCustomEntry == null)
2230 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2231 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2233 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2234 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2235 backupfilesCustomEntry);
2237 setComboIntStringKey(backupfilesPresetsCombo,
2238 Cache.getDefault(BackupFiles.NS + "_PRESET",
2239 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2241 backupsSetOptions(savedPreset);
2243 backupsOptionsSetEnabled();
2244 updateBackupFilesExampleLabel();
2248 * Load the saved Memory settings
2250 protected void loadLastSavedMemorySettings()
2252 customiseMemorySetting.setSelected(
2253 Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2254 jvmMemoryPercentSlider
2255 .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2256 jvmMemoryMaxTextField.setText(
2257 Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2260 private boolean warnAboutSuffixReverseChange()
2262 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2263 .getSavedBackupEntry();
2264 boolean savedSuffixReverse = bfpe.reverse;
2265 int savedSuffixDigits = bfpe.digits;
2266 String savedSuffixTemplate = bfpe.suffix;
2268 boolean nowSuffixReverse = suffixReverse.isSelected();
2269 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2270 String nowSuffixTemplate = suffixTemplate.getText();
2271 return nowSuffixReverse != savedSuffixReverse
2272 && nowSuffixDigits == savedSuffixDigits
2273 && nowSuffixTemplate != null
2274 && nowSuffixTemplate.equals(savedSuffixTemplate);
2277 /* Initialises the Startup tabbed panel.
2282 private JPanel initStartupTab()
2284 JPanel startupTab = new JPanel();
2285 startupTab.setBorder(
2286 new TitledBorder(MessageManager.getString("label.memory")));
2287 startupTab.setLayout(new GridBagLayout());
2289 GridBagConstraints gbc = new GridBagConstraints();
2292 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2293 gbc.fill = GridBagConstraints.NONE;
2300 gbc.gridy = 0; // row 1
2302 JLabel memoryText = new JLabel();
2303 memoryText.setFont(LABEL_FONT_ITALIC);
2305 .setText(MessageManager.getString("label.memory_setting_text"));
2306 startupTab.add(memoryText, gbc);
2308 gbc.gridy++; // row 2
2310 JPanel exampleMemoryPanel = new JPanel();
2312 .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2313 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2314 MessageManager.getString("label.memory_example_tooltip")));
2315 JLabel exampleTextLabel = new JLabel();
2317 .setText(MessageManager.getString("label.memory_example_text"));
2318 exampleTextLabel.setForeground(Color.GRAY);
2319 exampleTextLabel.setFont(LABEL_FONT);
2320 exampleMemoryPanel.add(exampleTextLabel);
2321 exampleMemoryPanel.add(exampleMemoryLabel);
2322 exampleMemoryPanel.setBackground(Color.WHITE);
2323 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2324 startupTab.add(exampleMemoryPanel, gbc);
2326 gbc.gridy++; // row 3
2328 startupTab.add(customiseMemorySetting, gbc);
2330 gbc.gridy += 2; // row 4 with a gap
2332 startupTab.add(maxMemoryLabel, gbc);
2334 gbc.gridy += 2; // row 5
2337 startupTab.add(jvmMemoryPercentLabel, gbc);
2339 startupTab.add(jvmMemoryPercentSlider, gbc);
2341 // gbc.weightx = 0.1;
2342 startupTab.add(jvmMemoryPercentDisplay, gbc);
2343 // gbc.weightx = 1.0;
2346 gbc.gridy++; // row 6
2348 startupTab.add(jvmMemoryMaxLabel, gbc);
2350 startupTab.add(jvmMemoryMaxTextField, gbc);
2352 gbc.gridy++; // row 7
2355 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2356 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2357 sp.setBorder(BorderFactory.createEmptyBorder());
2358 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2359 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2360 startupTab.add(sp, gbc);
2362 // fill empty space to push widget to top left
2368 startupTab.add(new JPanel(), gbc);
2370 setMemoryPercentDisplay();
2371 memoryOptionsSetEnabled();
2375 private void initMemoryPanel()
2377 // Enable memory settings checkbox
2378 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2379 customiseMemorySetting.setText(
2380 MessageManager.getString("label.customise_memory_settings"));
2381 customiseMemorySetting.addActionListener(new ActionListener()
2384 public void actionPerformed(ActionEvent e)
2386 memoryOptionsSetEnabled();
2390 loadLastSavedMemorySettings();
2392 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2393 exampleMemoryLabel.setBackground(Color.WHITE);
2395 maxMemoryLabel = new JLabel(
2396 MessageManager.getString("label.maximum_memory_used"));
2397 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2399 // Maximum memory percentage slider
2400 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2401 jvmMemoryPercentLabel.setText(
2402 MessageManager.getString("label.percent_of_physical_memory"));
2403 jvmMemoryPercentSlider.setPaintLabels(true);
2404 jvmMemoryPercentSlider.setPaintTicks(true);
2405 jvmMemoryPercentSlider.setPaintTrack(true);
2406 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2407 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2408 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2411 public void stateChanged(ChangeEvent e)
2413 setMemoryPercentDisplay();
2416 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2417 setMemoryPercentDisplay();
2419 // Maximum memory cap textbox
2420 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2422 .setText(MessageManager.getString("label.maximum_memory"));
2423 initMemoryMaxTextField();
2425 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2426 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2427 exampleMemoryMessageTextArea.setEditable(false);
2428 exampleMemoryMessageTextArea.setLineWrap(true);
2429 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2430 exampleMemoryMessageTextArea.setText(" ");
2431 exampleMemoryMessageTextArea.setRows(2);
2432 exampleMemoryMessageTextArea.setColumns(40);
2434 setExampleMemoryLabel();
2437 private void initMemoryMaxTextField()
2439 jvmMemoryMaxTextField.setToolTipText(
2440 MessageManager.getString("label.maximum_memory_tooltip"));
2441 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2444 public void actionPerformed(ActionEvent arg0)
2446 validateMemoryMaxTextField();
2447 setExampleMemoryLabel();
2451 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2454 public void keyReleased(KeyEvent e)
2456 validateMemoryMaxTextField();
2457 setExampleMemoryLabel();
2461 public void keyPressed(KeyEvent e)
2465 // try and stop invalid typing
2467 public void keyTyped(KeyEvent e)
2469 char c = Character.toLowerCase(e.getKeyChar());
2470 String text = jvmMemoryMaxTextField.getText();
2471 String suffixes = "tgmkb";
2472 int pos = jvmMemoryMaxTextField.getCaretPosition();
2473 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2474 if (!((('0' <= c && c <= '9')
2475 && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2477 || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2479 && pos == text.length() // at end of text and
2480 && suffixPos == -1) // there isn't already one
2490 private boolean isMemoryMaxTextFieldValid()
2492 return MemorySetting
2493 .isValidMemoryString(jvmMemoryMaxTextField.getText());
2496 private void validateMemoryMaxTextField()
2498 if (isMemoryMaxTextFieldValid())
2500 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2504 jvmMemoryMaxTextField.setBackground(Color.PINK);
2508 private void setMemoryPercentDisplay()
2510 jvmMemoryPercentDisplay
2511 .setText(jvmMemoryPercentSlider.getValue() + "%");
2512 setExampleMemoryLabel();
2515 private void setExampleMemoryLabel()
2517 boolean selected = customiseMemorySetting.isSelected();
2518 int jvmmempc = jvmMemoryPercentSlider.getValue();
2519 String jvmmemmax = jvmMemoryMaxTextField.getText();
2522 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2523 && MemorySetting.isValidMemoryString(jvmmemmax))
2525 mem = MemorySetting.getMemorySetting(jvmmemmax,
2526 String.valueOf(jvmmempc), false, true);
2530 mem = MemorySetting.getMemorySetting(null, null, false, true);
2532 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2533 String message = MemorySetting.getAdjustmentMessage();
2534 exampleMemoryMessageTextArea.setText(
2535 MessageManager.getString("label.adjustments_for_this_computer")
2538 ? MessageManager.getString("label.none")
2542 private void memoryOptionsSetEnabled()
2544 boolean enabled = customiseMemorySetting.isSelected();
2545 // leave exampleMemoryLabel enabled always
2546 maxMemoryLabel.setEnabled(enabled);
2547 jvmMemoryPercentLabel.setEnabled(enabled);
2548 jvmMemoryPercentSlider.setEnabled(enabled);
2549 jvmMemoryPercentDisplay.setEnabled(enabled);
2550 jvmMemoryMaxLabel.setEnabled(enabled);
2551 jvmMemoryMaxTextField.setEnabled(enabled);
2552 exampleMemoryMessageTextArea.setEnabled(enabled);
2553 setExampleMemoryLabel();
2557 * Initialises the Backups tabbed panel.
2561 private JPanel initBackupsTab()
2563 JPanel backupsTab = new JPanel();
2564 backupsTab.setBorder(new TitledBorder(
2565 MessageManager.getString("label.backup_files")));
2566 backupsTab.setLayout(new GridBagLayout());
2568 GridBagConstraints gbc = new GridBagConstraints();
2571 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2572 gbc.fill = GridBagConstraints.NONE;
2574 initBackupsTabPresetsPanel();
2575 initBackupsTabSuffixPanel();
2576 initBackupsTabKeepFilesPanel();
2577 initBackupsTabFilenameExamplesPanel();
2579 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2581 .setText(MessageManager.getString("label.enable_backupfiles"));
2582 enableBackupFiles.addActionListener(new ActionListener()
2585 public void actionPerformed(ActionEvent e)
2587 // enable other options only when the first is checked
2588 backupsOptionsSetEnabled();
2592 // enable checkbox 1 col
2596 gbc.gridy = 0; // row 0
2597 backupsTab.add(enableBackupFiles, gbc);
2599 // summary of scheme box (over two rows)
2603 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2604 gbc.fill = GridBagConstraints.BOTH;
2605 backupsTab.add(exampleFilesPanel, gbc);
2607 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2608 gbc.fill = GridBagConstraints.NONE;
2610 // fill empty space on right
2613 backupsTab.add(new JPanel(), gbc);
2618 gbc.gridy++; // row 1
2619 backupsTab.add(presetsPanel, gbc);
2621 // now using whole row
2626 gbc.gridy++; // row 2
2627 backupsTab.add(keepfilesPanel, gbc);
2629 // filename strategy box
2630 gbc.gridy++; // row 3
2631 backupsTab.add(suffixPanel, gbc);
2634 gbc.gridy++; // row 4
2636 backupsTab.add(new JPanel(), gbc);
2638 backupsOptionsSetEnabled();
2642 private JPanel initBackupsTabPresetsPanel()
2645 String title = MessageManager.getString("label.schemes");
2647 presetsPanel.setLayout(new GridBagLayout());
2649 GridBagConstraints gbc = new GridBagConstraints();
2652 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2653 gbc.fill = GridBagConstraints.NONE;
2661 presetsComboLabel = new JLabel(title + ":");
2662 presetsPanel.add(presetsComboLabel, gbc);
2664 List<Object> entries = Arrays.asList(
2665 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2666 List<String> tooltips = Arrays.asList(
2667 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2668 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2671 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2673 backupfilesPresetsCombo
2674 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2678 backupfilesPresetsCombo.addActionListener(new ActionListener()
2681 public void actionPerformed(ActionEvent e)
2683 int key = getComboIntStringKey(backupfilesPresetsCombo);
2684 if (!customiseCheckbox.isSelected())
2686 backupfilesPresetsComboLastSelected = key;
2688 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2690 if (customiseCheckbox.isSelected())
2692 // got here by clicking on customiseCheckbox so don't change the
2694 backupfilesCustomOptionsSetEnabled();
2698 backupsTabUpdatePresets();
2699 backupfilesCustomOptionsSetEnabled();
2704 customiseCheckbox.setSelected(false);
2705 backupsTabUpdatePresets();
2706 backupfilesCustomOptionsSetEnabled();
2711 // dropdown list of preset schemes
2713 presetsPanel.add(backupfilesPresetsCombo, gbc);
2715 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2716 revertButton.setToolTipText(
2717 MessageManager.getString("label.cancel_changes_description"));
2718 revertButton.addActionListener(new ActionListener()
2721 public void actionPerformed(ActionEvent e)
2724 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2725 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2726 backupfilesCustomOptionsSetEnabled();
2730 revertButton.setFont(LABEL_FONT);
2732 customiseCheckbox.setFont(LABEL_FONT);
2733 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2734 customiseCheckbox.addActionListener(new ActionListener()
2737 public void actionPerformed(ActionEvent e)
2739 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2740 if (customiseCheckbox.isSelected())
2742 backupfilesPresetsComboLastSelected = currently;
2743 setComboIntStringKey(backupfilesPresetsCombo,
2744 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2748 setComboIntStringKey(backupfilesPresetsCombo,
2749 backupfilesPresetsComboLastSelected);
2752 backupfilesCustomOptionsSetEnabled();
2755 customiseCheckbox.setToolTipText(
2756 MessageManager.getString("label.customise_description"));
2758 // customise checkbox
2761 presetsPanel.add(customiseCheckbox, gbc);
2763 // "Cancel changes" button (aligned with combo box above)
2765 presetsPanel.add(revertButton, gbc);
2767 return presetsPanel;
2770 private JPanel initBackupsTabFilenameExamplesPanel()
2772 String title = MessageManager.getString("label.scheme_examples");
2773 TitledBorder tb = new TitledBorder(title);
2774 exampleFilesPanel.setBorder(tb);
2775 exampleFilesPanel.setLayout(new GridBagLayout());
2777 backupfilesExampleLabel.setEditable(false);
2778 backupfilesExampleLabel
2779 .setBackground(exampleFilesPanel.getBackground());
2781 updateBackupFilesExampleLabel();
2783 GridBagConstraints gbc = new GridBagConstraints();
2786 gbc.fill = GridBagConstraints.NONE;
2787 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2789 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2790 return exampleFilesPanel;
2793 private void backupsTabUpdatePresets()
2795 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2798 String value = entry.v;
2800 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2804 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2810 "Preset '" + value + "' [key:" + key + "] not implemented");
2813 // Custom options will now be enabled when the customiseCheckbox is checked
2814 // (performed above)
2815 // backupfilesCustomOptionsSetEnabled();
2816 updateBackupFilesExampleLabel();
2819 protected int getComboIntStringKey(
2820 JComboBox<Object> backupfilesPresetsCombo2)
2822 IntKeyStringValueEntry e;
2825 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2827 } catch (Exception ex)
2830 "Problem casting Combo entry to IntKeyStringValueEntry.");
2833 return e != null ? e.k : 0;
2836 protected void setComboIntStringKey(
2837 JComboBox<Object> backupfilesPresetsCombo2, int key)
2839 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2841 IntKeyStringValueEntry e;
2844 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2845 } catch (Exception ex)
2848 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2853 backupfilesPresetsCombo2.setSelectedIndex(i);
2857 // backupsTabUpdatePresets();
2860 private JPanel initBackupsTabSuffixPanel()
2862 suffixPanel.setBorder(new TitledBorder(
2863 MessageManager.getString("label.backup_filename_strategy")));
2864 suffixPanel.setLayout(new GridBagLayout());
2867 .setText(MessageManager.getString("label.append_to_filename"));
2868 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2869 suffixTemplateLabel.setFont(LABEL_FONT);
2871 final String tooltip = JvSwingUtils.wrapTooltip(true,
2872 MessageManager.getString("label.append_to_filename_tooltip"));
2873 suffixTemplate.setToolTipText(tooltip);
2874 suffixTemplate.addActionListener(new ActionListener()
2877 public void actionPerformed(ActionEvent e)
2879 updateBackupFilesExampleLabel();
2880 backupfilesCustomOptionsSetEnabled();
2881 backupfilesRevertButtonSetEnabled(true);
2885 suffixTemplate.addKeyListener(new KeyListener()
2888 public void keyReleased(KeyEvent e)
2890 updateBackupFilesExampleLabel();
2891 backupfilesCustomOptionsSetEnabled();
2892 backupfilesRevertButtonSetEnabled(true);
2896 public void keyPressed(KeyEvent e)
2900 // disable use of ':' or '/' or '\'
2902 public void keyTyped(KeyEvent e)
2904 char c = e.getKeyChar();
2905 if (c == ':' || c == '/' || c == '\\')
2907 // don't process ':' or '/' or '\'
2916 .setText(MessageManager.getString("label.index_digits"));
2917 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2918 suffixDigitsLabel.setFont(LABEL_FONT);
2919 ChangeListener c = new ChangeListener()
2922 public void stateChanged(ChangeEvent e)
2924 backupfilesRevertButtonSetEnabled(true);
2925 updateBackupFilesExampleLabel();
2929 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2930 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2932 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2933 MessageManager.getString("label.increment_index"));
2934 suffixReverse.addActionListener(new ActionListener()
2937 public void actionPerformed(ActionEvent e)
2939 boolean okay = true;
2940 if (warnAboutSuffixReverseChange())
2943 okay = confirmSuffixReverseChange();
2947 backupfilesRevertButtonSetEnabled(true);
2948 updateBackupFilesExampleLabel();
2952 boolean savedSuffixReverse = BackupFilesPresetEntry
2953 .getSavedBackupEntry().reverse;
2954 suffixReverse.setSelected(savedSuffixReverse);
2959 GridBagConstraints sgbc = new GridBagConstraints();
2961 // first row (template text box)
2962 sgbc.anchor = GridBagConstraints.WEST;
2966 sgbc.gridheight = 1;
2969 sgbc.fill = GridBagConstraints.NONE;
2970 suffixPanel.add(suffixTemplateLabel, sgbc);
2973 sgbc.fill = GridBagConstraints.HORIZONTAL;
2974 suffixPanel.add(suffixTemplate, sgbc);
2976 // second row (number of digits spinner)
2980 sgbc.fill = GridBagConstraints.NONE;
2981 suffixPanel.add(suffixDigitsLabel, sgbc);
2984 sgbc.fill = GridBagConstraints.HORIZONTAL;
2985 suffixPanel.add(suffixDigitsSpinner, sgbc);
2987 // third row (forward order radio selection)
2990 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2991 sgbc.fill = GridBagConstraints.HORIZONTAL;
2992 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2994 // fourth row (reverse order radio selection)
2996 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
3000 private boolean confirmSuffixReverseChange()
3002 boolean ret = false;
3003 String warningMessage = MessageManager
3004 .getString("label.warning_confirm_change_reverse");
3005 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
3007 MessageManager.getString("label.change_increment_decrement"),
3008 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
3010 ret = (confirm == JvOptionPane.YES_OPTION);
3014 private JPanel initBackupsTabKeepFilesPanel()
3016 keepfilesPanel.setBorder(
3017 new TitledBorder(MessageManager.getString("label.keep_files")));
3018 keepfilesPanel.setLayout(new GridBagLayout());
3020 backupfilesKeepAll.setLabels(
3021 MessageManager.getString("label.keep_all_backup_files"),
3022 MessageManager.getString(
3023 "label.keep_only_this_number_of_backup_files"));
3024 backupfilesKeepAll.addTrueActionListener(new ActionListener()
3027 public void actionPerformed(ActionEvent e)
3029 backupfilesRevertButtonSetEnabled(true);
3030 updateBackupFilesExampleLabel();
3033 backupfilesKeepAll.addActionListener(new ActionListener()
3036 public void actionPerformed(ActionEvent e)
3038 backupfilesRevertButtonSetEnabled(true);
3039 keepRollMaxOptionsEnabled();
3040 updateBackupFilesExampleLabel();
3044 ChangeListener c = new ChangeListener()
3047 public void stateChanged(ChangeEvent e)
3049 backupfilesRevertButtonSetEnabled(true);
3050 updateBackupFilesExampleLabel();
3054 setIntegerSpinner(backupfilesRollMaxSpinner,
3055 BackupFilesPresetEntry.ROLLMAXMIN,
3056 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3058 backupfilesConfirmDelete.setLabels(
3059 MessageManager.getString("label.always_ask"),
3060 MessageManager.getString("label.auto_delete"));
3061 backupfilesConfirmDelete.addActionListener(new ActionListener()
3064 public void actionPerformed(ActionEvent e)
3066 backupfilesRevertButtonSetEnabled(true);
3069 // update the enabled section
3070 keepRollMaxOptionsEnabled();
3072 GridBagConstraints kgbc = new GridBagConstraints();
3074 // first row (template text box)
3075 kgbc.anchor = GridBagConstraints.WEST;
3078 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3079 kgbc.gridheight = 1;
3082 kgbc.fill = GridBagConstraints.HORIZONTAL;
3083 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3089 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3090 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3093 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3094 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3096 // third row (indented)
3098 kgbc.insets = new Insets(0, 20, 0, 0);
3101 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3102 kgbc.fill = GridBagConstraints.HORIZONTAL;
3105 JPanel jp = new JPanel();
3106 jp.setLayout(new FlowLayout());
3107 oldBackupFilesLabel.setText(
3108 MessageManager.getString("label.autodelete_old_backup_files"));
3109 oldBackupFilesLabel.setFont(LABEL_FONT);
3110 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3111 jp.add(oldBackupFilesLabel);
3112 jp.add(backupfilesConfirmDelete.getTrueButton());
3113 jp.add(backupfilesConfirmDelete.getFalseButton());
3114 keepfilesPanel.add(jp, kgbc);
3116 return keepfilesPanel;
3119 protected void updateBackupFilesExampleLabel()
3121 int exampleindex = 12;
3122 String base = MessageManager.getString("label.filename") + ".fa";
3123 if (base == null || base.length() == 0)
3125 base = "file_name.fa";
3128 boolean reverse = suffixReverse.isSelected();
3129 boolean keepAll = backupfilesKeepAll.isSelected();
3131 String suffix = suffixTemplate.getText();
3134 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3135 if (suffix == null || suffix.length() == 0)
3137 backupfilesExampleLabel
3138 .setText(MessageManager.getString("label.no_backup_files"));
3139 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3143 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3144 rollMax = rollMax < 1 ? 1 : rollMax;
3146 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3151 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3152 digits = digits < 1 ? 1 : digits;
3154 int lowersurround = 2;
3155 int uppersurround = 0;
3156 StringBuilder exampleSB = new StringBuilder();
3157 boolean firstLine = true;
3163 int max = keepAll ? exampleindex : rollMax;
3164 for (int index = min; index <= max; index++)
3166 if (index == min + lowersurround && index < max - uppersurround - 1)
3168 exampleSB.append("\n...");
3171 else if (index > min + lowersurround && index < max - uppersurround)
3183 exampleSB.append("\n");
3186 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3187 base, suffix, digits));
3190 // no extra text needed
3192 else if (index == min)
3194 String newest = MessageManager.getString("label.braced_newest");
3195 if (newest != null && newest.length() > 0)
3197 exampleSB.append(" " + newest);
3200 else if (index == max)
3202 String oldest = MessageManager.getString("label.braced_oldest");
3203 if (oldest != null && oldest.length() > 0)
3205 exampleSB.append(" " + oldest);
3214 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3215 : exampleindex - rollMax + 1;
3216 int max = exampleindex;
3218 for (int index = min; index <= max; index++)
3221 if (index == min + lowersurround && index < max - uppersurround - 1)
3223 exampleSB.append("\n...");
3226 else if (index > min + lowersurround && index < max - uppersurround)
3238 exampleSB.append("\n");
3241 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3242 base, suffix, digits));
3245 // no extra text needed
3247 else if (index == min)
3249 String oldest = MessageManager.getString("label.braced_oldest");
3250 if (oldest != null && oldest.length() > 0)
3252 exampleSB.append(" " + oldest);
3255 else if (index == max)
3257 String newest = MessageManager.getString("label.braced_newest");
3258 if (newest != null && newest.length() > 0)
3260 exampleSB.append(" " + newest);
3268 // add some extra empty lines to pad out the example files box. ugh, please
3270 // me how to do this better
3271 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3272 if (remainingLines > 0)
3274 for (int i = 0; i < remainingLines; i++)
3276 exampleSB.append("\n ");
3281 backupfilesExampleLabel.setText(exampleSB.toString());
3284 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3285 boolean useExistingVal, ChangeListener c)
3292 i = ((Integer) s.getValue()).intValue();
3293 } catch (Exception e)
3296 "Exception casting the initial value of s.getValue()");
3300 setIntegerSpinner(s, min, max, i, c);
3303 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3306 // integer spinner for number of digits
3315 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3318 s.addChangeListener(c);
3322 protected static int getSpinnerInt(JSpinner s, int def)
3328 i = (Integer) s.getValue();
3329 } catch (Exception e)
3331 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3336 private void keepRollMaxOptionsEnabled()
3338 boolean enabled = backupfilesKeepAll.isEnabled()
3339 && !backupfilesKeepAll.isSelected();
3340 oldBackupFilesLabel.setEnabled(enabled);
3341 backupfilesRollMaxSpinner.setEnabled(enabled);
3342 backupfilesConfirmDelete.setEnabled(enabled);
3345 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3347 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3348 && customiseCheckbox.isSelected() && suffixTemplate.getText()
3349 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3350 keepfilesPanel.setEnabled(enabled);
3351 backupfilesKeepAll.setEnabled(enabled);
3352 oldBackupFilesLabel.setEnabled(enabled);
3353 keepRollMaxOptionsEnabled();
3356 private void backupfilesSuffixTemplateDigitsSetEnabled()
3358 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3359 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3360 suffixDigitsLabel.setEnabled(enabled);
3361 suffixDigitsSpinner.setEnabled(enabled);
3362 suffixReverse.setEnabled(enabled);
3365 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3367 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3368 && customiseCheckbox.isSelected();
3369 suffixPanel.setEnabled(enabled);
3370 suffixTemplateLabel.setEnabled(enabled);
3371 suffixTemplate.setEnabled(enabled);
3372 backupfilesSuffixTemplateDigitsSetEnabled();
3375 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3377 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3378 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3379 revertButton.setEnabled(enabled);
3382 private boolean backupfilesCustomChanged()
3384 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3385 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3386 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3387 return !custom.equals(current);
3390 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3392 String suffix = suffixTemplate.getText();
3393 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3394 boolean reverse = suffixReverse.isSelected();
3395 boolean keepAll = backupfilesKeepAll.isSelected();
3396 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3397 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3399 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3400 reverse, keepAll, rollMax, confirmDelete);
3405 protected void backupfilesCustomOptionsSetEnabled()
3407 boolean enabled = customiseCheckbox.isSelected();
3409 backupfilesRevertButtonSetEnabled(enabled);
3410 backupfilesSuffixTemplateSetEnabled(enabled);
3411 backupfilesKeepAllSetEnabled(enabled);
3414 private void backupfilesSummarySetEnabled()
3416 boolean enabled = enableBackupFiles.isSelected();
3417 backupfilesExampleLabel.setEnabled(enabled);
3418 exampleFilesPanel.setEnabled(enabled);
3421 private void backupfilesPresetsSetEnabled()
3423 boolean enabled = enableBackupFiles.isSelected();
3424 presetsPanel.setEnabled(enabled);
3425 presetsComboLabel.setEnabled(enabled);
3426 backupfilesPresetsCombo.setEnabled(enabled);
3427 customiseCheckbox.setEnabled(enabled);
3428 revertButton.setEnabled(enabled);
3431 protected void backupsOptionsSetEnabled()
3433 backupfilesPresetsSetEnabled();
3434 backupfilesSummarySetEnabled();
3435 backupfilesCustomOptionsSetEnabled();
3438 protected void backupsSetOptions(String suffix, int digits,
3439 boolean reverse, boolean keepAll, int rollMax,
3440 boolean confirmDelete)
3442 suffixTemplate.setText(suffix);
3443 suffixDigitsSpinner.setValue(digits);
3444 suffixReverse.setSelected(reverse);
3445 backupfilesKeepAll.setSelected(keepAll);
3446 backupfilesRollMaxSpinner.setValue(rollMax);
3447 backupfilesConfirmDelete.setSelected(confirmDelete);
3450 protected void backupsSetOptions(BackupFilesPresetEntry p)
3452 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3456 protected void autoIdWidth_actionPerformed()
3458 // TODO Auto-generated method stub
3462 protected void userIdWidth_actionPerformed()
3464 // TODO Auto-generated method stub
3468 protected void maxColour_actionPerformed(JPanel panel)
3472 protected void minColour_actionPerformed(JPanel panel)
3476 protected void gapColour_actionPerformed(JPanel panel)
3480 protected void hiddenColour_actionPerformed(JPanel panel)
3484 protected void showunconserved_actionPerformed(ActionEvent e)
3486 // TODO Auto-generated method stub
3490 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3494 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3504 public void ok_actionPerformed(ActionEvent e)
3514 public void cancel_actionPerformed(ActionEvent e)
3524 public void annotations_actionPerformed(ActionEvent e)
3531 public void startupFileTextfield_mouseClicked()
3535 public void newLink_actionPerformed(ActionEvent e)
3540 public void editLink_actionPerformed(ActionEvent e)
3545 public void deleteLink_actionPerformed(ActionEvent e)
3550 public void defaultBrowser_mouseClicked(MouseEvent e)
3555 public void linkURLList_keyTyped(KeyEvent e)
3560 public void setProxyAuthEnabled()
3562 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3563 proxyAuthUsernameLabel.setEnabled(enabled);
3564 proxyAuthPasswordLabel.setEnabled(enabled);
3565 passwordNotStoredLabel.setEnabled(enabled);
3566 proxyAuthUsernameTB.setEnabled(enabled);
3567 proxyAuthPasswordPB.setEnabled(enabled);
3570 public void setCustomProxyEnabled()
3572 boolean enabled = customProxy.isSelected();
3573 portLabel.setEnabled(enabled);
3574 serverLabel.setEnabled(enabled);
3575 portLabel2.setEnabled(enabled);
3576 serverLabel2.setEnabled(enabled);
3577 httpLabel.setEnabled(enabled);
3578 httpsLabel.setEnabled(enabled);
3579 proxyServerHttpTB.setEnabled(enabled);
3580 proxyPortHttpTB.setEnabled(enabled);
3581 proxyServerHttpsTB.setEnabled(enabled);
3582 proxyPortHttpsTB.setEnabled(enabled);
3583 proxyAuth.setEnabled(enabled);
3584 setProxyAuthEnabled();
3587 public void proxyType_actionPerformed()
3589 setCustomProxyEnabled();
3590 proxyAuthPasswordCheckHighlight(true);
3591 applyProxyButtonEnabled(true);
3594 public void proxyAuth_actionPerformed()
3596 setProxyAuthEnabled();
3597 proxyAuthPasswordCheckHighlight(true);
3598 applyProxyButtonEnabled(true);
3602 * Customer renderer for JTable: supports column of radio buttons
3604 public class RadioButtonRenderer extends JRadioButton
3605 implements TableCellRenderer
3607 public RadioButtonRenderer()
3609 setHorizontalAlignment(CENTER);
3610 setToolTipText(MessageManager.getString("label.urltooltip"));
3614 public Component getTableCellRendererComponent(JTable table,
3615 Object value, boolean isSelected, boolean hasFocus, int row,
3618 setSelected((boolean) value);
3620 // set colours to match rest of table
3623 setBackground(table.getSelectionBackground());
3624 setForeground(table.getSelectionForeground());
3628 setBackground(table.getBackground());
3629 setForeground(table.getForeground());
3636 * Customer cell editor for JTable: supports column of radio buttons in
3637 * conjunction with renderer
3639 public class RadioButtonEditor extends AbstractCellEditor
3640 implements TableCellEditor
3642 private JRadioButton button = new JRadioButton();
3644 public RadioButtonEditor()
3646 button.setHorizontalAlignment(SwingConstants.CENTER);
3647 this.button.addActionListener(new ActionListener()
3650 public void actionPerformed(ActionEvent e)
3652 fireEditingStopped();
3658 public Component getTableCellEditorComponent(JTable table, Object value,
3659 boolean isSelected, int row, int column)
3661 button.setSelected((boolean) value);
3666 public Object getCellEditorValue()
3668 return button.isSelected();