2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import jalview.bin.Cache;
24 import jalview.fts.core.FTSDataColumnPreferences;
25 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
26 import jalview.fts.service.pdb.PDBFTSRestClient;
27 import jalview.gui.Desktop;
28 import jalview.gui.JalviewBooleanRadioButtons;
29 import jalview.gui.JvOptionPane;
30 import jalview.gui.JvSwingUtils;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.BackupFilenameParts;
33 import jalview.io.BackupFiles;
34 import jalview.io.BackupFilesPresetEntry;
35 import jalview.io.IntKeyStringValueEntry;
36 import jalview.util.MessageManager;
37 import jalview.util.Platform;
39 import java.awt.BorderLayout;
40 import java.awt.Color;
41 import java.awt.Component;
42 import java.awt.Dimension;
43 import java.awt.FlowLayout;
45 import java.awt.GridBagConstraints;
46 import java.awt.GridBagLayout;
47 import java.awt.GridLayout;
48 import java.awt.Insets;
49 import java.awt.Rectangle;
50 import java.awt.event.ActionEvent;
51 import java.awt.event.ActionListener;
52 import java.awt.event.FocusEvent;
53 import java.awt.event.KeyEvent;
54 import java.awt.event.KeyListener;
55 import java.awt.event.MouseAdapter;
56 import java.awt.event.MouseEvent;
57 import java.util.Arrays;
58 import java.util.List;
60 import javax.swing.AbstractCellEditor;
61 import javax.swing.BorderFactory;
62 import javax.swing.ButtonGroup;
63 import javax.swing.DefaultListCellRenderer;
64 import javax.swing.JButton;
65 import javax.swing.JCheckBox;
66 import javax.swing.JComboBox;
67 import javax.swing.JFileChooser;
68 import javax.swing.JLabel;
69 import javax.swing.JPanel;
70 import javax.swing.JRadioButton;
71 import javax.swing.JScrollPane;
72 import javax.swing.JSpinner;
73 import javax.swing.JTabbedPane;
74 import javax.swing.JTable;
75 import javax.swing.JTextArea;
76 import javax.swing.JTextField;
77 import javax.swing.ListSelectionModel;
78 import javax.swing.SpinnerModel;
79 import javax.swing.SpinnerNumberModel;
80 import javax.swing.SwingConstants;
81 import javax.swing.border.Border;
82 import javax.swing.border.EmptyBorder;
83 import javax.swing.border.EtchedBorder;
84 import javax.swing.border.TitledBorder;
85 import javax.swing.event.ChangeEvent;
86 import javax.swing.event.ChangeListener;
87 import javax.swing.table.TableCellEditor;
88 import javax.swing.table.TableCellRenderer;
91 * Base class for the Preferences panel.
96 public class GPreferences extends JPanel
98 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
100 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
101 .getLabelFont(false, true);
103 private static final Font LABEL_FONT_BOLD = JvSwingUtils
104 .getLabelFont(true, false);
107 * Visual tab components
109 protected JCheckBox fullScreen = new JCheckBox();
111 protected JCheckBox openoverv = new JCheckBox();
113 protected JCheckBox seqLimit = new JCheckBox();
115 protected JCheckBox rightAlign = new JCheckBox();
117 protected JComboBox<String> fontSizeCB = new JComboBox<>();
119 protected JComboBox<String> fontStyleCB = new JComboBox<>();
121 protected JComboBox<String> fontNameCB = new JComboBox<>();
123 protected JCheckBox showOccupancy = new JCheckBox();
125 protected JCheckBox showUnconserved = new JCheckBox();
127 protected JCheckBox idItalics = new JCheckBox();
129 protected JCheckBox smoothFont = new JCheckBox();
131 protected JCheckBox scaleProteinToCdna = new JCheckBox();
133 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
135 protected JCheckBox wrap = new JCheckBox();
137 protected JComboBox<String> sortby = new JComboBox<>();
139 protected JComboBox<String> sortAnnBy = new JComboBox<>();
141 protected JComboBox<String> sortAutocalc = new JComboBox<>();
143 protected JCheckBox startupCheckbox = new JCheckBox();
145 protected JTextField startupFileTextfield = new JTextField();
147 // below are in the 'second column'
148 protected JCheckBox annotations = new JCheckBox();
150 protected JCheckBox quality = new JCheckBox();
152 protected JCheckBox conservation = new JCheckBox();
154 protected JCheckBox identity = new JCheckBox();
156 protected JCheckBox showGroupConsensus = new JCheckBox();
158 protected JCheckBox showGroupConservation = new JCheckBox();
160 protected JCheckBox showConsensHistogram = new JCheckBox();
162 protected JCheckBox showConsensLogo = new JCheckBox();
164 protected JCheckBox showDbRefTooltip = new JCheckBox();
166 protected JCheckBox showNpTooltip = new JCheckBox();
169 * Structure tab and components
171 protected JPanel structureTab;
173 protected JCheckBox structFromPdb = new JCheckBox();
175 protected JCheckBox useRnaView = new JCheckBox();
177 protected JCheckBox addSecondaryStructure = new JCheckBox();
179 protected JCheckBox addTempFactor = new JCheckBox();
181 protected JComboBox<String> structViewer = new JComboBox<>();
183 protected JTextField chimeraPath = new JTextField();
185 protected ButtonGroup mappingMethod = new ButtonGroup();
187 protected JRadioButton siftsMapping = new JRadioButton();
189 protected JRadioButton nwMapping = new JRadioButton();
192 * Colours tab components
194 protected JPanel minColour = new JPanel();
196 protected JPanel maxColour = new JPanel();
198 protected JComboBox<String> protColour = new JComboBox<>();
200 protected JComboBox<String> nucColour = new JComboBox<>();
203 * Overview tab components
205 protected JPanel gapColour = new JPanel();
207 protected JPanel hiddenColour = new JPanel();
209 protected JCheckBox useLegacyGap;
211 protected JCheckBox showHiddenAtStart;
213 protected JLabel gapLabel;
216 * Connections tab components
218 protected JTable linkUrlTable = new JTable();
220 protected JButton editLink = new JButton();
222 protected JButton deleteLink = new JButton();
224 protected JTextField filterTB = new JTextField();
226 protected JButton doReset = new JButton();
228 protected JButton userOnly = new JButton();
230 protected JLabel portLabel = new JLabel();
232 protected JLabel serverLabel = new JLabel();
234 protected JTextField proxyServerTB = new JTextField();
236 protected JTextField proxyPortTB = new JTextField();
238 protected JTextField defaultBrowser = new JTextField();
240 protected JCheckBox useProxy = new JCheckBox();
242 protected JCheckBox usagestats = new JCheckBox();
244 protected JCheckBox questionnaire = new JCheckBox();
246 protected JCheckBox versioncheck = new JCheckBox();
249 * Output tab components
251 protected JComboBox<Object> epsRendering = new JComboBox<>();
253 protected JComboBox<Object> htmlRendering = new JComboBox<>();
255 protected JComboBox<Object> svgRendering = new JComboBox<>();
257 protected JLabel userIdWidthlabel = new JLabel();
259 protected JCheckBox autoIdWidth = new JCheckBox();
261 protected JTextField userIdWidth = new JTextField();
263 protected JCheckBox blcjv = new JCheckBox();
265 protected JCheckBox pileupjv = new JCheckBox();
267 protected JCheckBox clustaljv = new JCheckBox();
269 protected JCheckBox msfjv = new JCheckBox();
271 protected JCheckBox fastajv = new JCheckBox();
273 protected JCheckBox pfamjv = new JCheckBox();
275 protected JCheckBox pirjv = new JCheckBox();
277 protected JCheckBox modellerOutput = new JCheckBox();
279 protected JCheckBox embbedBioJSON = new JCheckBox();
282 * Editing tab components
284 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
286 protected JCheckBox padGaps = new JCheckBox();
288 protected JCheckBox sortByTree = new JCheckBox();
293 protected JPanel wsTab = new JPanel();
296 * Backups tab components
297 * a lot of these are member variables instead of local variables only so that they
298 * can be enabled/disabled easily in one go
301 protected JCheckBox enableBackupFiles = new JCheckBox();
303 protected JPanel presetsPanel = new JPanel();
305 protected JLabel presetsComboLabel = new JLabel();
307 protected JCheckBox customiseCheckbox = new JCheckBox();
309 protected JButton revertButton = new JButton();
311 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
313 private int backupfilesPresetsComboLastSelected = 0;
315 protected JPanel suffixPanel = new JPanel();
317 protected JPanel keepfilesPanel = new JPanel();
319 protected JPanel exampleFilesPanel = new JPanel();
321 protected JTextField suffixTemplate = new JTextField(null, 8);
323 protected JLabel suffixTemplateLabel = new JLabel();
325 protected JLabel suffixDigitsLabel = new JLabel();
327 protected JSpinner suffixDigitsSpinner = new JSpinner();
329 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
331 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
333 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
335 protected JLabel oldBackupFilesLabel = new JLabel();
337 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
339 protected JTextArea backupfilesExampleLabel = new JTextArea();
342 * Creates a new GPreferences object.
344 public GPreferences()
349 } catch (Exception ex)
351 ex.printStackTrace();
356 * Construct the panel and its tabbed sub-panels.
360 private void jbInit() throws Exception
362 final JTabbedPane tabbedPane = new JTabbedPane();
363 this.setLayout(new BorderLayout());
364 JPanel okCancelPanel = initOkCancelPanel();
365 this.add(tabbedPane, BorderLayout.CENTER);
366 this.add(okCancelPanel, BorderLayout.SOUTH);
368 tabbedPane.add(initVisualTab(),
369 MessageManager.getString("label.visual"));
371 tabbedPane.add(initColoursTab(),
372 MessageManager.getString("label.colours"));
374 tabbedPane.add(initOverviewTab(),
375 MessageManager.getString("label.overview"));
377 tabbedPane.add(initStructureTab(),
378 MessageManager.getString("label.structure"));
380 tabbedPane.add(initConnectionsTab(),
381 MessageManager.getString("label.connections"));
383 if (!Platform.isJS())
385 tabbedPane.add(initBackupsTab(),
386 MessageManager.getString("label.backups"));
389 tabbedPane.add(initLinksTab(),
390 MessageManager.getString("label.urllinks"));
392 tabbedPane.add(initOutputTab(),
393 MessageManager.getString("label.output"));
395 tabbedPane.add(initEditingTab(),
396 MessageManager.getString("label.editing"));
399 * See WsPreferences for the real work of configuring this tab.
401 if (!Platform.isJS())
403 wsTab.setLayout(new BorderLayout());
404 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
408 * Handler to validate a tab before leaving it - currently only for
411 tabbedPane.addChangeListener(new ChangeListener()
413 private Component lastTab;
416 public void stateChanged(ChangeEvent e)
418 if (lastTab == structureTab
419 && tabbedPane.getSelectedComponent() != structureTab)
421 if (!validateStructure())
423 tabbedPane.setSelectedComponent(structureTab);
427 lastTab = tabbedPane.getSelectedComponent();
434 * Initialises the Editing tabbed panel.
438 private JPanel initEditingTab()
440 JPanel editingTab = new JPanel();
441 editingTab.setLayout(null);
442 autoCalculateConsCheck.setFont(LABEL_FONT);
443 autoCalculateConsCheck.setText(
444 MessageManager.getString("label.autocalculate_consensus"));
445 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
446 padGaps.setFont(LABEL_FONT);
448 MessageManager.getString("label.pad_gaps_when_editing"));
449 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
450 sortByTree.setFont(LABEL_FONT);
452 .setText(MessageManager.getString("label.sort_with_new_tree"));
453 sortByTree.setToolTipText(MessageManager.getString(
454 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
455 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
456 editingTab.add(autoCalculateConsCheck);
457 editingTab.add(padGaps);
458 editingTab.add(sortByTree);
463 * Initialises the Output tab
467 private JPanel initOutputTab()
469 JPanel outputTab = new JPanel();
470 outputTab.setLayout(null);
472 JLabel epsLabel = new JLabel(
473 MessageManager.formatMessage("label.rendering_style", "EPS"));
474 epsLabel.setFont(LABEL_FONT);
475 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
476 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
477 epsRendering.setFont(LABEL_FONT);
478 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
479 JLabel htmlLabel = new JLabel(
480 MessageManager.formatMessage("label.rendering_style", "HTML"));
481 htmlLabel.setFont(LABEL_FONT);
482 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
483 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
484 htmlRendering.setFont(LABEL_FONT);
485 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
486 JLabel svgLabel = new JLabel(
487 MessageManager.formatMessage("label.rendering_style", "SVG"));
488 svgLabel.setFont(LABEL_FONT);
489 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
490 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
491 svgRendering.setFont(LABEL_FONT);
492 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
494 JLabel jLabel1 = new JLabel();
495 jLabel1.setFont(LABEL_FONT);
496 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
497 jLabel1.setText(MessageManager.getString("label.append_start_end"));
498 jLabel1.setFont(LABEL_FONT);
500 fastajv.setFont(LABEL_FONT);
501 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
502 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
503 blcjv.setText(MessageManager.getString("label.blc") + " ");
504 fastajv.setText(MessageManager.getString("label.fasta") + " ");
505 msfjv.setText(MessageManager.getString("label.msf") + " ");
506 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
507 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
508 msfjv.setFont(LABEL_FONT);
509 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
510 pirjv.setText(MessageManager.getString("label.pir") + " ");
511 JPanel jPanel11 = new JPanel();
512 jPanel11.setFont(LABEL_FONT);
513 TitledBorder titledBorder2 = new TitledBorder(
514 MessageManager.getString("label.file_output"));
515 jPanel11.setBorder(titledBorder2);
516 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
517 GridLayout gridLayout3 = new GridLayout();
518 jPanel11.setLayout(gridLayout3);
519 gridLayout3.setRows(8);
520 blcjv.setFont(LABEL_FONT);
521 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
522 clustaljv.setFont(LABEL_FONT);
523 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
524 pfamjv.setFont(LABEL_FONT);
525 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
526 pileupjv.setFont(LABEL_FONT);
527 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
528 pirjv.setFont(LABEL_FONT);
529 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
530 autoIdWidth.setFont(LABEL_FONT);
532 MessageManager.getString("label.automatically_set_id_width"));
533 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
534 .getString("label.adjusts_width_generated_eps_png")));
535 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
536 autoIdWidth.addActionListener(new ActionListener()
540 public void actionPerformed(ActionEvent e)
542 autoIdWidth_actionPerformed();
545 userIdWidthlabel.setFont(LABEL_FONT);
546 userIdWidthlabel.setText(
547 MessageManager.getString("label.figure_id_column_width"));
548 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
549 .getString("label.manually_specify_width_left_column")));
550 userIdWidthlabel.setToolTipText(
551 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
552 "label.manually_specify_width_left_column")));
553 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
554 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
555 userIdWidth.setText("");
556 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
557 userIdWidth.addActionListener(new ActionListener()
561 public void actionPerformed(ActionEvent e)
563 userIdWidth_actionPerformed();
566 modellerOutput.setFont(LABEL_FONT);
568 .setText(MessageManager.getString("label.use_modeller_output"));
569 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
570 embbedBioJSON.setFont(LABEL_FONT);
571 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
572 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
574 jPanel11.add(jLabel1);
576 jPanel11.add(clustaljv);
577 jPanel11.add(fastajv);
579 jPanel11.add(pfamjv);
580 jPanel11.add(pileupjv);
582 outputTab.add(autoIdWidth);
583 outputTab.add(userIdWidth);
584 outputTab.add(userIdWidthlabel);
585 outputTab.add(modellerOutput);
586 if (!Platform.isJS())
589 * JalviewJS doesn't support Lineart option or SVG output
591 outputTab.add(embbedBioJSON);
592 outputTab.add(epsLabel);
593 outputTab.add(epsRendering);
594 outputTab.add(htmlLabel);
595 outputTab.add(htmlRendering);
596 outputTab.add(svgLabel);
597 outputTab.add(svgRendering);
599 outputTab.add(jPanel11);
604 * Initialises the Connections tabbed panel.
608 private JPanel initConnectionsTab()
610 JPanel connectTab = new JPanel();
611 connectTab.setLayout(new GridBagLayout());
613 // Label for browser text box
614 JLabel browserLabel = new JLabel();
615 browserLabel.setFont(LABEL_FONT);
616 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
617 browserLabel.setText(
618 MessageManager.getString("label.default_browser_unix"));
619 defaultBrowser.setFont(LABEL_FONT);
620 defaultBrowser.setText("");
621 final String tooltip = JvSwingUtils.wrapTooltip(true,
622 MessageManager.getString("label.double_click_to_browse"));
623 defaultBrowser.setToolTipText(tooltip);
624 defaultBrowser.addMouseListener(new MouseAdapter()
627 public void mouseClicked(MouseEvent e)
629 if (e.getClickCount() > 1)
631 defaultBrowser_mouseClicked(e);
636 JPanel proxyPanel = initConnTabProxyPanel();
637 initConnTabCheckboxes();
639 // Add default Browser text box
640 connectTab.add(browserLabel,
641 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
642 GridBagConstraints.WEST, GridBagConstraints.NONE,
643 new Insets(10, 0, 5, 5), 5, 1));
644 defaultBrowser.setFont(LABEL_FONT);
645 defaultBrowser.setText("");
647 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
648 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
649 new Insets(10, 0, 5, 10), 30, 1));
651 // Add proxy server panel
652 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
653 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
654 new Insets(10, 0, 5, 12), 4, 10));
656 // Add usage stats, version check and questionnaire checkboxes
657 connectTab.add(usagestats,
658 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
659 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
660 new Insets(0, 2, 5, 5), 70, 1));
661 connectTab.add(questionnaire,
662 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
663 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
664 new Insets(0, 2, 5, 10), 70, 1));
665 connectTab.add(versioncheck,
666 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
667 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
668 new Insets(0, 2, 5, 5), 70, 1));
670 versioncheck.setVisible(false);
672 // Add padding so the panel doesn't look ridiculous
673 JPanel spacePanel = new JPanel();
674 connectTab.add(spacePanel,
675 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
676 GridBagConstraints.WEST, GridBagConstraints.BOTH,
677 new Insets(0, 0, 0, 5), 70, 1));
683 * Initialises the Links tabbed panel.
687 private JPanel initLinksTab()
689 JPanel linkTab = new JPanel();
690 linkTab.setLayout(new GridBagLayout());
692 // Set up table for Url links
693 linkUrlTable.getTableHeader().setReorderingAllowed(false);
694 linkUrlTable.setFillsViewportHeight(true);
695 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
696 linkUrlTable.setAutoCreateRowSorter(true);
697 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
699 // adjust row height so radio buttons actually fit
700 // don't do this in the renderer, it causes the awt thread to activate
702 JRadioButton temp = new JRadioButton();
703 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
705 // Table in scrollpane so that the table is given a scrollbar
706 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
707 linkScrollPane.setBorder(null);
709 // Panel for links functionality
710 JPanel linkPanel = new JPanel(new GridBagLayout());
711 linkPanel.setBorder(new TitledBorder(
712 MessageManager.getString("label.url_linkfrom_sequence_id")));
714 // Put the Url links panel together
716 // Buttons go at top right, resizing only resizes the blank space vertically
717 JPanel buttonPanel = initLinkTabUrlButtons();
718 GridBagConstraints linkConstraints1 = new GridBagConstraints();
719 linkConstraints1.insets = new Insets(0, 0, 5, 0);
720 linkConstraints1.gridx = 0;
721 linkConstraints1.gridy = 0;
722 linkConstraints1.weightx = 1.0;
723 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
724 linkTab.add(buttonPanel, linkConstraints1);
726 // Links table goes at top left, resizing resizes the table
727 GridBagConstraints linkConstraints2 = new GridBagConstraints();
728 linkConstraints2.insets = new Insets(0, 0, 5, 5);
729 linkConstraints2.gridx = 0;
730 linkConstraints2.gridy = 1;
731 linkConstraints2.weightx = 1.0;
732 linkConstraints2.weighty = 1.0;
733 linkConstraints2.fill = GridBagConstraints.BOTH;
734 linkTab.add(linkScrollPane, linkConstraints2);
736 // Filter box and buttons goes at bottom left, resizing resizes the text box
737 JPanel filterPanel = initLinkTabFilterPanel();
738 GridBagConstraints linkConstraints3 = new GridBagConstraints();
739 linkConstraints3.insets = new Insets(0, 0, 0, 5);
740 linkConstraints3.gridx = 0;
741 linkConstraints3.gridy = 2;
742 linkConstraints3.weightx = 1.0;
743 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
744 linkTab.add(filterPanel, linkConstraints3);
749 private JPanel initLinkTabFilterPanel()
751 // Filter textbox and reset button
752 JLabel filterLabel = new JLabel(
753 MessageManager.getString("label.filter"));
754 filterLabel.setFont(LABEL_FONT);
755 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
756 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
758 filterTB.setFont(LABEL_FONT);
759 filterTB.setText("");
761 doReset.setText(MessageManager.getString("action.showall"));
762 userOnly.setText(MessageManager.getString("action.customfilter"));
764 // Panel for filter functionality
765 JPanel filterPanel = new JPanel(new GridBagLayout());
766 filterPanel.setBorder(new TitledBorder("Filter"));
767 GridBagConstraints gbc = new GridBagConstraints();
770 gbc.fill = GridBagConstraints.NONE;
771 gbc.anchor = GridBagConstraints.WEST;
773 filterPanel.add(filterLabel, gbc);
775 GridBagConstraints gbc1 = new GridBagConstraints();
778 gbc1.fill = GridBagConstraints.HORIZONTAL;
779 gbc1.anchor = GridBagConstraints.WEST;
781 filterPanel.add(filterTB, gbc1);
783 GridBagConstraints gbc2 = new GridBagConstraints();
785 gbc2.fill = GridBagConstraints.NONE;
786 gbc2.anchor = GridBagConstraints.WEST;
787 filterPanel.add(doReset, gbc2);
789 GridBagConstraints gbc3 = new GridBagConstraints();
791 gbc3.fill = GridBagConstraints.NONE;
792 gbc3.anchor = GridBagConstraints.WEST;
793 filterPanel.add(userOnly, gbc3);
798 private JPanel initLinkTabUrlButtons()
800 // Buttons for new / edit / delete Url links
801 JButton newLink = new JButton();
802 newLink.setText(MessageManager.getString("action.new"));
804 editLink.setText(MessageManager.getString("action.edit"));
806 deleteLink.setText(MessageManager.getString("action.delete"));
808 // no current selection, so initially disable delete/edit buttons
809 editLink.setEnabled(false);
810 deleteLink.setEnabled(false);
812 newLink.addActionListener(new java.awt.event.ActionListener()
815 public void actionPerformed(ActionEvent e)
817 newLink_actionPerformed(e);
821 editLink.setText(MessageManager.getString("action.edit"));
822 editLink.addActionListener(new java.awt.event.ActionListener()
825 public void actionPerformed(ActionEvent e)
827 editLink_actionPerformed(e);
831 deleteLink.setText(MessageManager.getString("action.delete"));
832 deleteLink.addActionListener(new java.awt.event.ActionListener()
835 public void actionPerformed(ActionEvent e)
837 deleteLink_actionPerformed(e);
841 JPanel buttonPanel = new JPanel(new GridBagLayout());
842 buttonPanel.setBorder(new TitledBorder("Edit links"));
843 GridBagConstraints gbc = new GridBagConstraints();
846 gbc.fill = GridBagConstraints.NONE;
847 buttonPanel.add(newLink, gbc);
849 GridBagConstraints gbc1 = new GridBagConstraints();
852 gbc1.fill = GridBagConstraints.NONE;
853 buttonPanel.add(editLink, gbc1);
855 GridBagConstraints gbc2 = new GridBagConstraints();
858 gbc2.fill = GridBagConstraints.NONE;
859 buttonPanel.add(deleteLink, gbc2);
861 GridBagConstraints gbc3 = new GridBagConstraints();
864 gbc3.fill = GridBagConstraints.HORIZONTAL;
866 JPanel spacePanel = new JPanel();
867 spacePanel.setBorder(null);
868 buttonPanel.add(spacePanel, gbc3);
874 * Initialises the proxy server panel in the Connections tab
876 * @return the proxy server panel
878 private JPanel initConnTabProxyPanel()
880 // Label for server text box
881 serverLabel.setText(MessageManager.getString("label.address"));
882 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
883 serverLabel.setFont(LABEL_FONT);
885 // Proxy server and port text boxes
886 proxyServerTB.setFont(LABEL_FONT);
887 proxyPortTB.setFont(LABEL_FONT);
889 // Label for Port text box
890 portLabel.setFont(LABEL_FONT);
891 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
892 portLabel.setText(MessageManager.getString("label.port"));
894 // Use proxy server checkbox
895 useProxy.setFont(LABEL_FONT);
896 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
897 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
898 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
899 useProxy.addActionListener(new ActionListener()
902 public void actionPerformed(ActionEvent e)
904 useProxy_actionPerformed();
908 // Make proxy server panel
909 JPanel proxyPanel = new JPanel();
910 TitledBorder titledBorder1 = new TitledBorder(
911 MessageManager.getString("label.proxy_server"));
912 proxyPanel.setBorder(titledBorder1);
913 proxyPanel.setLayout(new GridBagLayout());
914 proxyPanel.add(serverLabel,
915 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
916 GridBagConstraints.WEST, GridBagConstraints.NONE,
917 new Insets(0, 2, 2, 0), 5, 0));
918 proxyPanel.add(portLabel,
919 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
920 GridBagConstraints.WEST, GridBagConstraints.NONE,
921 new Insets(0, 0, 2, 0), 11, 0));
922 proxyPanel.add(useProxy,
923 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
924 GridBagConstraints.WEST, GridBagConstraints.NONE,
925 new Insets(0, 2, 5, 185), 2, -4));
926 proxyPanel.add(proxyPortTB,
927 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
928 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
929 new Insets(0, 2, 2, 2), 54, 1));
930 proxyPanel.add(proxyServerTB,
931 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
932 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
933 new Insets(0, 2, 2, 0), 263, 1));
939 * Initialises the checkboxes in the Connections tab
941 private void initConnTabCheckboxes()
943 // Usage stats checkbox label
945 MessageManager.getString("label.send_usage_statistics"));
946 usagestats.setFont(LABEL_FONT);
947 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
948 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
950 // Questionnaire checkbox label
951 questionnaire.setText(
952 MessageManager.getString("label.check_for_questionnaires"));
953 questionnaire.setFont(LABEL_FONT);
954 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
955 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
957 // Check for latest version checkbox label
958 versioncheck.setText(
959 MessageManager.getString("label.check_for_latest_version"));
960 versioncheck.setFont(LABEL_FONT);
961 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
962 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
966 * Initialises the parent panel which contains the tabbed sections.
970 private JPanel initOkCancelPanel()
972 JButton ok = new JButton();
973 ok.setText(MessageManager.getString("action.ok"));
974 ok.addActionListener(new ActionListener()
977 public void actionPerformed(ActionEvent e)
979 ok_actionPerformed(e);
982 JButton cancel = new JButton();
983 cancel.setText(MessageManager.getString("action.cancel"));
984 cancel.addActionListener(new ActionListener()
987 public void actionPerformed(ActionEvent e)
989 cancel_actionPerformed(e);
992 JPanel okCancelPanel = new JPanel();
993 okCancelPanel.add(ok);
994 okCancelPanel.add(cancel);
995 return okCancelPanel;
999 * Initialises the Colours tabbed panel.
1003 private JPanel initColoursTab()
1005 JPanel coloursTab = new JPanel();
1006 coloursTab.setBorder(new TitledBorder(
1007 MessageManager.getString("action.open_new_alignment")));
1008 coloursTab.setLayout(new FlowLayout());
1009 JLabel mincolourLabel = new JLabel();
1010 mincolourLabel.setFont(LABEL_FONT);
1011 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1012 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1013 minColour.setFont(LABEL_FONT);
1014 minColour.setBorder(BorderFactory.createEtchedBorder());
1015 minColour.setPreferredSize(new Dimension(40, 20));
1016 minColour.addMouseListener(new MouseAdapter()
1019 public void mousePressed(MouseEvent e)
1021 minColour_actionPerformed(minColour);
1024 JLabel maxcolourLabel = new JLabel();
1025 maxcolourLabel.setFont(LABEL_FONT);
1026 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1027 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1028 maxColour.setFont(LABEL_FONT);
1029 maxColour.setBorder(BorderFactory.createEtchedBorder());
1030 maxColour.setPreferredSize(new Dimension(40, 20));
1031 maxColour.addMouseListener(new MouseAdapter()
1034 public void mousePressed(MouseEvent e)
1036 maxColour_actionPerformed(maxColour);
1040 protColour.setFont(LABEL_FONT);
1041 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1042 JLabel protColourLabel = new JLabel();
1043 protColourLabel.setFont(LABEL_FONT);
1044 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1045 protColourLabel.setText(
1046 MessageManager.getString("label.prot_alignment_colour") + " ");
1047 JvSwingUtils.addtoLayout(coloursTab,
1049 .getString("label.default_colour_scheme_for_alignment"),
1050 protColourLabel, protColour);
1052 nucColour.setFont(LABEL_FONT);
1053 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1054 JLabel nucColourLabel = new JLabel();
1055 nucColourLabel.setFont(LABEL_FONT);
1056 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1057 nucColourLabel.setText(
1058 MessageManager.getString("label.nuc_alignment_colour") + " ");
1059 JvSwingUtils.addtoLayout(coloursTab,
1061 .getString("label.default_colour_scheme_for_alignment"),
1062 nucColourLabel, nucColour);
1064 JPanel annotationShding = new JPanel();
1065 annotationShding.setBorder(new TitledBorder(
1066 MessageManager.getString("label.annotation_shading_default")));
1067 annotationShding.setLayout(new GridLayout(1, 2));
1068 JvSwingUtils.addtoLayout(annotationShding,
1069 MessageManager.getString(
1070 "label.default_minimum_colour_annotation_shading"),
1071 mincolourLabel, minColour);
1072 JvSwingUtils.addtoLayout(annotationShding,
1073 MessageManager.getString(
1074 "label.default_maximum_colour_annotation_shading"),
1075 maxcolourLabel, maxColour);
1076 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1081 * Initialises the Overview tabbed panel.
1085 private JPanel initOverviewTab()
1087 JPanel overviewPanel = new JPanel();
1088 overviewPanel.setBorder(new TitledBorder(
1089 MessageManager.getString("label.overview_settings")));
1091 gapColour.setFont(LABEL_FONT);
1092 // fixing the border colours stops apparent colour bleed from the panel
1093 gapColour.setBorder(
1094 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1095 gapColour.setPreferredSize(new Dimension(40, 20));
1096 gapColour.addMouseListener(new MouseAdapter()
1099 public void mousePressed(MouseEvent e)
1101 gapColour_actionPerformed(gapColour);
1105 hiddenColour.setFont(LABEL_FONT);
1106 // fixing the border colours stops apparent colour bleed from the panel
1107 hiddenColour.setBorder(
1108 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1109 hiddenColour.setPreferredSize(new Dimension(40, 20));
1110 hiddenColour.addMouseListener(new MouseAdapter()
1113 public void mousePressed(MouseEvent e)
1115 hiddenColour_actionPerformed(hiddenColour);
1119 useLegacyGap = new JCheckBox(
1120 MessageManager.getString("label.ov_legacy_gap"));
1121 useLegacyGap.setFont(LABEL_FONT);
1122 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1123 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1124 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1125 gapLabel.setFont(LABEL_FONT);
1126 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1127 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1128 showHiddenAtStart = new JCheckBox(
1129 MessageManager.getString("label.ov_show_hide_default"));
1130 showHiddenAtStart.setFont(LABEL_FONT);
1131 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1132 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1133 JLabel hiddenLabel = new JLabel(
1134 MessageManager.getString("label.hidden_colour"));
1135 hiddenLabel.setFont(LABEL_FONT);
1136 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1137 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1139 useLegacyGap.addActionListener(new ActionListener()
1142 public void actionPerformed(ActionEvent e)
1144 useLegacyGaps_actionPerformed(e);
1148 overviewPanel.setLayout(new GridBagLayout());
1149 GridBagConstraints c1 = new GridBagConstraints();
1151 c1.fill = GridBagConstraints.HORIZONTAL;
1156 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1157 overviewPanel.add(useLegacyGap, c1);
1159 GridBagConstraints c2 = new GridBagConstraints();
1160 c2.fill = GridBagConstraints.HORIZONTAL;
1163 c2.insets = new Insets(0, 15, 0, 10);
1164 overviewPanel.add(gapLabel, c2);
1166 GridBagConstraints c3 = new GridBagConstraints();
1167 c3.fill = GridBagConstraints.HORIZONTAL;
1170 c3.insets = new Insets(0, 0, 0, 15);
1171 overviewPanel.add(gapColour, c3);
1173 GridBagConstraints c4 = new GridBagConstraints();
1174 c4.fill = GridBagConstraints.HORIZONTAL;
1178 overviewPanel.add(showHiddenAtStart, c4);
1180 GridBagConstraints c5 = new GridBagConstraints();
1181 c5.fill = GridBagConstraints.HORIZONTAL;
1184 c5.insets = new Insets(0, 15, 0, 10);
1185 overviewPanel.add(hiddenLabel, c5);
1187 GridBagConstraints c6 = new GridBagConstraints();
1188 c6.fill = GridBagConstraints.HORIZONTAL;
1191 c6.insets = new Insets(0, 0, 0, 15);
1192 overviewPanel.add(hiddenColour, c6);
1194 JButton resetButton = new JButton(
1195 MessageManager.getString("label.reset_to_defaults"));
1197 resetButton.addActionListener(new ActionListener()
1200 public void actionPerformed(ActionEvent e)
1202 resetOvDefaults_actionPerformed(e);
1206 GridBagConstraints c7 = new GridBagConstraints();
1207 c7.fill = GridBagConstraints.NONE;
1210 c7.insets = new Insets(10, 0, 0, 0);
1211 c7.anchor = GridBagConstraints.WEST;
1212 overviewPanel.add(resetButton, c7);
1214 // Add padding so the panel doesn't look ridiculous
1215 JPanel spacePanel = new JPanel();
1216 overviewPanel.add(spacePanel,
1217 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1218 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1219 new Insets(0, 0, 0, 5), 0, 0));
1221 return overviewPanel;
1225 * Initialises the Structure tabbed panel.
1229 private JPanel initStructureTab()
1231 structureTab = new JPanel();
1233 structureTab.setBorder(new TitledBorder(
1234 MessageManager.getString("label.structure_options")));
1235 structureTab.setLayout(null);
1236 final int width = 400;
1237 final int height = 22;
1238 final int lineSpacing = 25;
1241 structFromPdb.setFont(LABEL_FONT);
1243 .setText(MessageManager.getString("label.struct_from_pdb"));
1244 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1245 structFromPdb.addActionListener(new ActionListener()
1248 public void actionPerformed(ActionEvent e)
1250 boolean selected = structFromPdb.isSelected();
1251 // enable other options only when the first is checked
1252 useRnaView.setEnabled(selected);
1253 addSecondaryStructure.setEnabled(selected);
1254 addTempFactor.setEnabled(selected);
1257 structureTab.add(structFromPdb);
1259 // indent checkboxes that are conditional on the first one
1260 ypos += lineSpacing;
1261 useRnaView.setFont(LABEL_FONT);
1262 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1263 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1264 structureTab.add(useRnaView);
1266 ypos += lineSpacing;
1267 addSecondaryStructure.setFont(LABEL_FONT);
1268 addSecondaryStructure
1269 .setText(MessageManager.getString("label.autoadd_secstr"));
1270 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1271 structureTab.add(addSecondaryStructure);
1273 ypos += lineSpacing;
1274 addTempFactor.setFont(LABEL_FONT);
1275 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1276 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1277 structureTab.add(addTempFactor);
1279 ypos += lineSpacing;
1280 JLabel viewerLabel = new JLabel();
1281 viewerLabel.setFont(LABEL_FONT);
1282 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1283 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1284 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1285 structureTab.add(viewerLabel);
1287 structViewer.setFont(LABEL_FONT);
1288 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1289 structViewer.addItem(ViewerType.JMOL.name());
1290 structViewer.addItem(ViewerType.CHIMERA.name());
1291 structViewer.addActionListener(new ActionListener()
1294 public void actionPerformed(ActionEvent e)
1296 structureViewer_actionPerformed(
1297 (String) structViewer.getSelectedItem());
1300 structureTab.add(structViewer);
1302 ypos += lineSpacing;
1303 JLabel pathLabel = new JLabel();
1304 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1305 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1306 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1307 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1308 structureTab.add(pathLabel);
1310 chimeraPath.setFont(LABEL_FONT);
1311 chimeraPath.setText("");
1312 final String tooltip = JvSwingUtils.wrapTooltip(true,
1313 MessageManager.getString("label.chimera_path_tip"));
1314 chimeraPath.setToolTipText(tooltip);
1315 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1316 chimeraPath.addMouseListener(new MouseAdapter()
1319 public void mouseClicked(MouseEvent e)
1321 if (e.getClickCount() == 2)
1323 String chosen = openFileChooser();
1326 chimeraPath.setText(chosen);
1331 structureTab.add(chimeraPath);
1333 ypos += lineSpacing;
1334 nwMapping.setFont(LABEL_FONT);
1335 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1336 siftsMapping.setFont(LABEL_FONT);
1337 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1338 mappingMethod.add(nwMapping);
1339 mappingMethod.add(siftsMapping);
1340 JPanel mappingPanel = new JPanel();
1341 mappingPanel.setFont(LABEL_FONT);
1342 TitledBorder mmTitledBorder = new TitledBorder(
1343 MessageManager.getString("label.mapping_method"));
1344 mmTitledBorder.setTitleFont(LABEL_FONT);
1345 mappingPanel.setBorder(mmTitledBorder);
1346 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1347 // GridLayout mappingLayout = new GridLayout();
1348 mappingPanel.setLayout(new GridLayout());
1349 mappingPanel.add(nwMapping);
1350 mappingPanel.add(siftsMapping);
1351 structureTab.add(mappingPanel);
1353 ypos += lineSpacing;
1354 ypos += lineSpacing;
1355 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1356 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1357 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1358 structureTab.add(docFieldPref);
1361 * hide Chimera options in JalviewJS
1363 if (Platform.isJS())
1365 pathLabel.setVisible(false);
1366 chimeraPath.setVisible(false);
1367 viewerLabel.setVisible(false);
1368 structViewer.setVisible(false);
1371 return structureTab;
1375 * Action on choosing a structure viewer from combobox options.
1377 * @param selectedItem
1379 protected void structureViewer_actionPerformed(String selectedItem)
1384 * Show a dialog for the user to choose a file. Returns the chosen path, or
1389 protected String openFileChooser()
1391 String choice = null;
1392 JFileChooser chooser = new JFileChooser();
1394 // chooser.setFileView(new JalviewFileView());
1395 chooser.setDialogTitle(
1396 MessageManager.getString("label.open_local_file"));
1397 chooser.setToolTipText(MessageManager.getString("action.open"));
1399 int value = chooser.showOpenDialog(this);
1401 if (value == JFileChooser.APPROVE_OPTION)
1403 choice = chooser.getSelectedFile().getPath();
1409 * Validate the structure tab preferences; if invalid, set focus on this tab.
1413 protected boolean validateStructure(FocusEvent e)
1415 if (!validateStructure())
1417 e.getComponent().requestFocusInWindow();
1423 protected boolean validateStructure()
1429 * Initialises the Visual tabbed panel.
1433 private JPanel initVisualTab()
1435 JPanel visualTab = new JPanel();
1436 visualTab.setBorder(new TitledBorder(
1437 MessageManager.getString("action.open_new_alignment")));
1438 visualTab.setLayout(null);
1439 fullScreen.setFont(LABEL_FONT);
1440 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1441 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1442 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1443 quality.setEnabled(false);
1444 quality.setFont(LABEL_FONT);
1445 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1446 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1447 quality.setSelected(true);
1448 quality.setText(MessageManager.getString("label.quality"));
1449 conservation.setEnabled(false);
1450 conservation.setFont(LABEL_FONT);
1451 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1452 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1453 conservation.setSelected(true);
1454 conservation.setText(MessageManager.getString("label.conservation"));
1455 identity.setEnabled(false);
1456 identity.setFont(LABEL_FONT);
1457 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1458 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1459 identity.setSelected(true);
1460 identity.setText(MessageManager.getString("label.consensus"));
1461 showOccupancy.setFont(LABEL_FONT);
1462 showOccupancy.setEnabled(false);
1463 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1464 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1465 showOccupancy.setSelected(true);
1466 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1468 JLabel showGroupbits = new JLabel();
1469 showGroupbits.setFont(LABEL_FONT);
1470 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1471 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1473 .setText(MessageManager.getString("action.show_group") + ":");
1474 JLabel showConsensbits = new JLabel();
1475 showConsensbits.setFont(LABEL_FONT);
1476 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1477 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1479 .setText(MessageManager.getString("label.consensus") + ":");
1480 showConsensHistogram.setEnabled(false);
1481 showConsensHistogram.setFont(LABEL_FONT);
1482 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1483 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1484 showConsensHistogram.setSelected(true);
1485 showConsensHistogram
1486 .setText(MessageManager.getString("label.histogram"));
1487 showConsensLogo.setEnabled(false);
1488 showConsensLogo.setFont(LABEL_FONT);
1489 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1490 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1491 showConsensLogo.setSelected(true);
1492 showConsensLogo.setText(MessageManager.getString("label.logo"));
1493 showGroupConsensus.setEnabled(false);
1494 showGroupConsensus.setFont(LABEL_FONT);
1495 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1496 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1497 showGroupConsensus.setSelected(true);
1498 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1499 showGroupConservation.setEnabled(false);
1500 showGroupConservation.setFont(LABEL_FONT);
1501 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1502 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1503 showGroupConservation.setSelected(true);
1504 showGroupConservation
1505 .setText(MessageManager.getString("label.conservation"));
1506 showNpTooltip.setEnabled(true);
1507 showNpTooltip.setFont(LABEL_FONT);
1508 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1509 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1510 showNpTooltip.setSelected(true);
1511 showNpTooltip.setText(
1512 MessageManager.getString("label.non_positional_features"));
1513 showDbRefTooltip.setEnabled(true);
1514 showDbRefTooltip.setFont(LABEL_FONT);
1515 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1516 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1517 showDbRefTooltip.setSelected(true);
1519 .setText(MessageManager.getString("label.database_references"));
1520 annotations.setFont(LABEL_FONT);
1521 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1522 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1523 annotations.setSelected(true);
1524 annotations.setText(MessageManager.getString("label.show_annotations"));
1525 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1526 annotations.addActionListener(new ActionListener()
1529 public void actionPerformed(ActionEvent e)
1531 annotations_actionPerformed(e);
1534 identity.addActionListener(new ActionListener()
1537 public void actionPerformed(ActionEvent e)
1539 annotations_actionPerformed(e);
1542 showGroupConsensus.addActionListener(new ActionListener()
1545 public void actionPerformed(ActionEvent e)
1547 annotations_actionPerformed(e);
1550 showUnconserved.setFont(LABEL_FONT);
1551 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1552 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1553 showUnconserved.setSelected(true);
1555 .setText(MessageManager.getString("action.show_unconserved"));
1556 showUnconserved.addActionListener(new ActionListener()
1559 public void actionPerformed(ActionEvent e)
1561 showunconserved_actionPerformed(e);
1565 // TODO these are not yet added to / action from Preferences
1566 // JCheckBox shareSelections = new JCheckBox();
1567 // shareSelections.setFont(verdana11);
1568 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1569 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1570 // shareSelections.setSelected(true);
1571 // shareSelections.setText(MessageManager
1572 // .getString("label.share_selection_across_views"));
1573 // JCheckBox followHighlight = new JCheckBox();
1574 // followHighlight.setFont(verdana11);
1575 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1576 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1577 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1578 // followHighlight.setSelected(true);
1579 // followHighlight.setText(MessageManager
1580 // .getString("label.scroll_highlighted_regions"));
1582 seqLimit.setFont(LABEL_FONT);
1583 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1584 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1585 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1586 smoothFont.setFont(LABEL_FONT);
1587 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1588 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1589 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1590 scaleProteinToCdna.setFont(LABEL_FONT);
1591 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1592 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1593 scaleProteinToCdna.setText(
1594 MessageManager.getString("label.scale_protein_to_cdna"));
1595 scaleProteinToCdna.setToolTipText(
1596 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1597 JLabel gapLabel = new JLabel();
1598 gapLabel.setFont(LABEL_FONT);
1599 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1600 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1601 JLabel fontLabel = new JLabel();
1602 fontLabel.setFont(LABEL_FONT);
1603 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1604 fontLabel.setText(MessageManager.getString("label.font"));
1605 fontSizeCB.setFont(LABEL_FONT);
1606 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1607 fontStyleCB.setFont(LABEL_FONT);
1608 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1609 fontNameCB.setFont(LABEL_FONT);
1610 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1611 gapSymbolCB.setFont(LABEL_FONT);
1612 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1613 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1614 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1615 gapSymbolCB.setRenderer(dlcr);
1617 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1618 startupCheckbox.setFont(LABEL_FONT);
1619 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1620 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1621 startupCheckbox.setSelected(true);
1622 startupFileTextfield.setFont(LABEL_FONT);
1623 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1624 final String tooltip = JvSwingUtils.wrapTooltip(true,
1625 MessageManager.getString("label.double_click_to_browse"));
1626 startupFileTextfield.setToolTipText(tooltip);
1627 startupFileTextfield.addMouseListener(new MouseAdapter()
1630 public void mouseClicked(MouseEvent e)
1632 if (e.getClickCount() > 1)
1634 startupFileTextfield_mouseClicked();
1639 sortby.setFont(LABEL_FONT);
1640 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1641 JLabel sortLabel = new JLabel();
1642 sortLabel.setFont(LABEL_FONT);
1643 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1644 sortLabel.setText(MessageManager.getString("label.sort_by"));
1645 sortAnnBy.setFont(LABEL_FONT);
1646 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1647 JLabel sortAnnLabel = new JLabel();
1648 sortAnnLabel.setFont(LABEL_FONT);
1649 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1650 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1651 sortAutocalc.setFont(LABEL_FONT);
1652 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1654 JPanel annsettingsPanel = new JPanel();
1655 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1656 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1657 annsettingsPanel.setBorder(new EtchedBorder());
1658 visualTab.add(annsettingsPanel);
1659 Border jb = new EmptyBorder(1, 1, 4, 5);
1660 annotations.setBorder(jb);
1661 showOccupancy.setBorder(jb);
1662 quality.setBorder(jb);
1663 conservation.setBorder(jb);
1664 identity.setBorder(jb);
1665 showConsensbits.setBorder(jb);
1666 showGroupbits.setBorder(jb);
1667 showGroupConsensus.setBorder(jb);
1668 showGroupConservation.setBorder(jb);
1669 showConsensHistogram.setBorder(jb);
1670 showConsensLogo.setBorder(jb);
1672 JPanel autoAnnotSettings = new JPanel();
1673 annsettingsPanel.add(autoAnnotSettings);
1674 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1675 autoAnnotSettings.add(annotations);
1676 autoAnnotSettings.add(quality);
1677 // second row of autoannotation box
1678 autoAnnotSettings = new JPanel();
1679 annsettingsPanel.add(autoAnnotSettings);
1681 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1682 autoAnnotSettings.add(conservation);
1683 autoAnnotSettings.add(identity);
1684 autoAnnotSettings.add(showOccupancy);
1685 autoAnnotSettings.add(showGroupbits);
1686 autoAnnotSettings.add(showGroupConservation);
1687 autoAnnotSettings.add(showGroupConsensus);
1688 autoAnnotSettings.add(showConsensbits);
1689 autoAnnotSettings.add(showConsensHistogram);
1690 autoAnnotSettings.add(showConsensLogo);
1692 JPanel tooltipSettings = new JPanel();
1693 tooltipSettings.setBorder(new TitledBorder(
1694 MessageManager.getString("label.sequence_id_tooltip")));
1695 tooltipSettings.setBounds(173, 140, 220, 62);
1696 tooltipSettings.setLayout(new GridLayout(2, 1));
1697 tooltipSettings.add(showDbRefTooltip);
1698 tooltipSettings.add(showNpTooltip);
1699 visualTab.add(tooltipSettings);
1701 wrap.setFont(LABEL_FONT);
1702 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1703 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1704 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1705 rightAlign.setFont(LABEL_FONT);
1706 rightAlign.setForeground(Color.black);
1707 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1708 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1709 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1710 idItalics.setFont(LABEL_FONT_ITALIC);
1711 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1712 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1714 MessageManager.getString("label.sequence_name_italics"));
1715 openoverv.setFont(LABEL_FONT);
1716 openoverv.setActionCommand(
1717 MessageManager.getString("label.open_overview"));
1718 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1719 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1720 openoverv.setText(MessageManager.getString("label.open_overview"));
1721 JPanel jPanel2 = new JPanel();
1722 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1723 jPanel2.setLayout(new GridLayout(14, 1));
1724 jPanel2.add(fullScreen);
1725 jPanel2.add(openoverv);
1726 jPanel2.add(seqLimit);
1727 jPanel2.add(rightAlign);
1728 jPanel2.add(fontLabel);
1729 jPanel2.add(showUnconserved);
1730 jPanel2.add(idItalics);
1731 jPanel2.add(smoothFont);
1732 jPanel2.add(scaleProteinToCdna);
1733 jPanel2.add(gapLabel);
1735 jPanel2.add(sortLabel);
1736 jPanel2.add(sortAnnLabel);
1737 jPanel2.add(startupCheckbox);
1738 visualTab.add(jPanel2);
1739 visualTab.add(startupFileTextfield);
1740 visualTab.add(sortby);
1741 visualTab.add(sortAnnBy);
1742 visualTab.add(sortAutocalc);
1743 visualTab.add(gapSymbolCB);
1744 visualTab.add(fontNameCB);
1745 visualTab.add(fontSizeCB);
1746 visualTab.add(fontStyleCB);
1748 if (Platform.isJS())
1750 startupCheckbox.setVisible(false);
1751 startupFileTextfield.setVisible(false);
1758 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1761 protected void loadLastSavedBackupsOptions()
1763 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1764 .getSavedBackupEntry();
1766 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1768 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1769 .createBackupFilesPresetEntry(Cache
1770 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1771 if (backupfilesCustomEntry == null)
1773 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1774 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1776 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1777 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1778 backupfilesCustomEntry);
1780 setComboIntStringKey(backupfilesPresetsCombo,
1781 Cache.getDefault(BackupFiles.NS + "_PRESET",
1782 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1784 backupsSetOptions(savedPreset);
1786 backupsOptionsSetEnabled();
1787 updateBackupFilesExampleLabel();
1790 private boolean warnAboutSuffixReverseChange()
1792 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1793 .getSavedBackupEntry();
1794 boolean savedSuffixReverse = bfpe.reverse;
1795 int savedSuffixDigits = bfpe.digits;
1796 String savedSuffixTemplate = bfpe.suffix;
1798 boolean nowSuffixReverse = suffixReverse.isSelected();
1799 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1800 String nowSuffixTemplate = suffixTemplate.getText();
1801 return nowSuffixReverse != savedSuffixReverse
1802 && nowSuffixDigits == savedSuffixDigits
1803 && nowSuffixTemplate != null
1804 && nowSuffixTemplate.equals(savedSuffixTemplate);
1808 * Initialises the Backups tabbed panel.
1812 private JPanel initBackupsTab()
1814 JPanel backupsTab = new JPanel();
1815 backupsTab.setBorder(new TitledBorder(
1816 MessageManager.getString("label.backup_files")));
1817 backupsTab.setLayout(new GridBagLayout());
1819 GridBagConstraints gbc = new GridBagConstraints();
1822 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1823 gbc.fill = GridBagConstraints.NONE;
1825 initBackupsTabPresetsPanel();
1826 initBackupsTabSuffixPanel();
1827 initBackupsTabKeepFilesPanel();
1828 initBackupsTabFilenameExamplesPanel();
1830 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1832 .setText(MessageManager.getString("label.enable_backupfiles"));
1833 enableBackupFiles.addActionListener(new ActionListener()
1836 public void actionPerformed(ActionEvent e)
1838 // enable other options only when the first is checked
1839 backupsOptionsSetEnabled();
1844 // enable checkbox 1 col
1848 gbc.gridy = 0; // row 0
1849 backupsTab.add(enableBackupFiles, gbc);
1851 // summary of scheme box (over two rows)
1855 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1856 gbc.fill = GridBagConstraints.BOTH;
1857 backupsTab.add(exampleFilesPanel, gbc);
1859 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1860 gbc.fill = GridBagConstraints.NONE;
1862 // fill empty space on right
1865 backupsTab.add(new JPanel(), gbc);
1870 gbc.gridy++; // row 1
1871 backupsTab.add(presetsPanel, gbc);
1873 // now using whole row
1878 gbc.gridy++; // row 2
1879 backupsTab.add(keepfilesPanel, gbc);
1881 // filename strategy box
1882 gbc.gridy++; // row 3
1883 backupsTab.add(suffixPanel, gbc);
1886 gbc.gridy++; // row 4
1888 backupsTab.add(new JPanel(), gbc);
1890 backupsOptionsSetEnabled();
1894 private JPanel initBackupsTabPresetsPanel()
1897 String title = MessageManager.getString("label.schemes");
1899 presetsPanel.setLayout(new GridBagLayout());
1901 GridBagConstraints gbc = new GridBagConstraints();
1904 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1905 gbc.fill = GridBagConstraints.NONE;
1913 presetsComboLabel = new JLabel(title + ":");
1914 presetsPanel.add(presetsComboLabel, gbc);
1916 List<Object> entries = Arrays
1917 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
1918 List<String> tooltips = Arrays.asList(
1919 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
1920 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
1923 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1925 backupfilesPresetsCombo
1926 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1930 backupfilesPresetsCombo.addActionListener(new ActionListener()
1933 public void actionPerformed(ActionEvent e)
1935 int key = getComboIntStringKey(backupfilesPresetsCombo);
1936 if (!customiseCheckbox.isSelected())
1938 backupfilesPresetsComboLastSelected = key;
1940 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1942 if (customiseCheckbox.isSelected())
1944 // got here by clicking on customiseCheckbox so don't change the values
1945 backupfilesCustomOptionsSetEnabled();
1949 backupsTabUpdatePresets();
1950 backupfilesCustomOptionsSetEnabled();
1955 customiseCheckbox.setSelected(false);
1956 backupsTabUpdatePresets();
1957 backupfilesCustomOptionsSetEnabled();
1962 // dropdown list of preset schemes
1964 presetsPanel.add(backupfilesPresetsCombo, gbc);
1966 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1967 revertButton.setToolTipText(
1968 MessageManager.getString("label.cancel_changes_description"));
1969 revertButton.addActionListener(new ActionListener()
1972 public void actionPerformed(ActionEvent e)
1975 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
1976 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
1977 backupfilesCustomOptionsSetEnabled();
1981 revertButton.setFont(LABEL_FONT);
1983 customiseCheckbox.setFont(LABEL_FONT);
1984 customiseCheckbox.setText(MessageManager.getString("label.customise"));
1985 customiseCheckbox.addActionListener(new ActionListener()
1988 public void actionPerformed(ActionEvent e)
1990 int currently = getComboIntStringKey(backupfilesPresetsCombo);
1991 if (customiseCheckbox.isSelected())
1993 backupfilesPresetsComboLastSelected = currently;
1994 setComboIntStringKey(backupfilesPresetsCombo,
1995 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
1999 setComboIntStringKey(backupfilesPresetsCombo,
2000 backupfilesPresetsComboLastSelected);
2003 backupfilesCustomOptionsSetEnabled();
2006 customiseCheckbox.setToolTipText(
2007 MessageManager.getString("label.customise_description"));
2009 // customise checkbox
2012 presetsPanel.add(customiseCheckbox, gbc);
2014 // "Cancel changes" button (aligned with combo box above)
2016 presetsPanel.add(revertButton, gbc);
2018 return presetsPanel;
2021 private JPanel initBackupsTabFilenameExamplesPanel()
2023 String title = MessageManager
2024 .getString("label.scheme_examples");
2025 TitledBorder tb = new TitledBorder(title);
2026 exampleFilesPanel.setBorder(tb);
2027 exampleFilesPanel.setLayout(new GridBagLayout());
2030 backupfilesExampleLabel.setEditable(false);
2031 backupfilesExampleLabel
2032 .setBackground(exampleFilesPanel.getBackground());
2034 updateBackupFilesExampleLabel();
2036 GridBagConstraints gbc = new GridBagConstraints();
2039 gbc.fill = GridBagConstraints.NONE;
2040 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2042 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2043 return exampleFilesPanel;
2046 private void backupsTabUpdatePresets()
2048 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2051 String value = entry.v;
2053 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2057 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2063 "Preset '" + value + "' [key:" + key + "] not implemented");
2066 // Custom options will now be enabled when the customiseCheckbox is checked
2067 // (performed above)
2068 // backupfilesCustomOptionsSetEnabled();
2069 updateBackupFilesExampleLabel();
2072 protected int getComboIntStringKey(
2073 JComboBox<Object> backupfilesPresetsCombo2)
2075 IntKeyStringValueEntry e;
2078 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2080 } catch (Exception ex)
2083 "Problem casting Combo entry to IntKeyStringValueEntry.");
2086 return e != null ? e.k : 0;
2089 protected void setComboIntStringKey(
2090 JComboBox<Object> backupfilesPresetsCombo2,
2093 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2095 IntKeyStringValueEntry e;
2098 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2099 } catch (Exception ex)
2102 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2107 backupfilesPresetsCombo2.setSelectedIndex(i);
2111 // backupsTabUpdatePresets();
2114 private JPanel initBackupsTabSuffixPanel()
2116 suffixPanel.setBorder(new TitledBorder(
2117 MessageManager.getString("label.backup_filename_strategy")));
2118 suffixPanel.setLayout(new GridBagLayout());
2121 .setText(MessageManager.getString("label.append_to_filename"));
2122 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2123 suffixTemplateLabel.setFont(LABEL_FONT);
2125 final String tooltip = JvSwingUtils.wrapTooltip(true,
2126 MessageManager.getString("label.append_to_filename_tooltip"));
2127 suffixTemplate.setToolTipText(tooltip);
2128 suffixTemplate.addActionListener(new ActionListener()
2131 public void actionPerformed(ActionEvent e)
2133 updateBackupFilesExampleLabel();
2134 backupfilesCustomOptionsSetEnabled();
2135 backupfilesRevertButtonSetEnabled(true);
2139 suffixTemplate.addKeyListener(new KeyListener()
2142 public void keyReleased(KeyEvent e)
2144 updateBackupFilesExampleLabel();
2145 backupfilesCustomOptionsSetEnabled();
2146 backupfilesRevertButtonSetEnabled(true);
2150 public void keyPressed(KeyEvent e)
2154 // disable use of ':' or '/' or '\'
2156 public void keyTyped(KeyEvent e)
2158 char c = e.getKeyChar();
2159 if (c == ':' || c == '/' || c == '\\')
2161 // don't process ':' or '/' or '\'
2170 .setText(MessageManager.getString("label.index_digits"));
2171 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2172 suffixDigitsLabel.setFont(LABEL_FONT);
2173 ChangeListener c = new ChangeListener()
2176 public void stateChanged(ChangeEvent e)
2178 backupfilesRevertButtonSetEnabled(true);
2179 updateBackupFilesExampleLabel();
2183 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2184 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2186 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2187 MessageManager.getString("label.increment_index"));
2188 suffixReverse.addActionListener(new ActionListener()
2191 public void actionPerformed(ActionEvent e)
2193 boolean okay = true;
2194 if (warnAboutSuffixReverseChange())
2197 okay = confirmSuffixReverseChange();
2201 backupfilesRevertButtonSetEnabled(true);
2202 updateBackupFilesExampleLabel();
2206 boolean savedSuffixReverse = BackupFilesPresetEntry
2207 .getSavedBackupEntry().reverse;
2208 suffixReverse.setSelected(savedSuffixReverse);
2213 GridBagConstraints sgbc = new GridBagConstraints();
2215 // first row (template text box)
2216 sgbc.anchor = GridBagConstraints.WEST;
2220 sgbc.gridheight = 1;
2223 sgbc.fill = GridBagConstraints.NONE;
2224 suffixPanel.add(suffixTemplateLabel, sgbc);
2227 sgbc.fill = GridBagConstraints.HORIZONTAL;
2228 suffixPanel.add(suffixTemplate, sgbc);
2230 // second row (number of digits spinner)
2234 sgbc.fill = GridBagConstraints.NONE;
2235 suffixPanel.add(suffixDigitsLabel, sgbc);
2238 sgbc.fill = GridBagConstraints.HORIZONTAL;
2239 suffixPanel.add(suffixDigitsSpinner, sgbc);
2241 // third row (forward order radio selection)
2244 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2245 sgbc.fill = GridBagConstraints.HORIZONTAL;
2246 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2248 // fourth row (reverse order radio selection)
2250 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2254 private boolean confirmSuffixReverseChange()
2256 boolean ret = false;
2257 String warningMessage = MessageManager
2258 .getString("label.warning_confirm_change_reverse");
2259 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2261 MessageManager.getString("label.change_increment_decrement"),
2262 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2264 ret = (confirm == JvOptionPane.YES_OPTION);
2268 private JPanel initBackupsTabKeepFilesPanel()
2270 keepfilesPanel.setBorder(
2271 new TitledBorder(MessageManager.getString("label.keep_files")));
2272 keepfilesPanel.setLayout(new GridBagLayout());
2274 backupfilesKeepAll.setLabels(
2275 MessageManager.getString("label.keep_all_backup_files"),
2276 MessageManager.getString(
2277 "label.keep_only_this_number_of_backup_files"));
2278 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2281 public void actionPerformed(ActionEvent e)
2283 backupfilesRevertButtonSetEnabled(true);
2284 updateBackupFilesExampleLabel();
2287 backupfilesKeepAll.addActionListener(new ActionListener()
2290 public void actionPerformed(ActionEvent e)
2292 backupfilesRevertButtonSetEnabled(true);
2293 keepRollMaxOptionsEnabled();
2294 updateBackupFilesExampleLabel();
2298 ChangeListener c = new ChangeListener()
2301 public void stateChanged(ChangeEvent e)
2303 backupfilesRevertButtonSetEnabled(true);
2304 updateBackupFilesExampleLabel();
2308 setIntegerSpinner(backupfilesRollMaxSpinner,
2309 BackupFilesPresetEntry.ROLLMAXMIN,
2310 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2312 backupfilesConfirmDelete.setLabels(
2313 MessageManager.getString("label.always_ask"),
2314 MessageManager.getString("label.auto_delete"));
2315 backupfilesConfirmDelete.addActionListener(new ActionListener()
2318 public void actionPerformed(ActionEvent e)
2320 backupfilesRevertButtonSetEnabled(true);
2323 // update the enabled section
2324 keepRollMaxOptionsEnabled();
2326 GridBagConstraints kgbc = new GridBagConstraints();
2328 // first row (template text box)
2329 kgbc.anchor = GridBagConstraints.WEST;
2332 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2333 kgbc.gridheight = 1;
2336 kgbc.fill = GridBagConstraints.HORIZONTAL;
2337 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2343 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2344 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2347 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2348 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2350 // third row (indented)
2352 kgbc.insets = new Insets(0, 20, 0, 0);
2355 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2356 kgbc.fill = GridBagConstraints.HORIZONTAL;
2359 JPanel jp = new JPanel();
2360 jp.setLayout(new FlowLayout());
2362 .setText(MessageManager
2363 .getString("label.autodelete_old_backup_files"));
2364 oldBackupFilesLabel.setFont(LABEL_FONT);
2365 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2366 jp.add(oldBackupFilesLabel);
2367 jp.add(backupfilesConfirmDelete.getTrueButton());
2368 jp.add(backupfilesConfirmDelete.getFalseButton());
2369 keepfilesPanel.add(jp, kgbc);
2371 return keepfilesPanel;
2374 protected void updateBackupFilesExampleLabel()
2376 int exampleindex = 12;
2377 String base = MessageManager.getString("label.filename") + ".fa";
2378 if (base == null || base.length() == 0)
2380 base = "file_name.fa";
2383 boolean reverse = suffixReverse.isSelected();
2384 boolean keepAll = backupfilesKeepAll.isSelected();
2386 String suffix = suffixTemplate.getText();
2389 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2390 if (suffix == null || suffix.length() == 0)
2392 backupfilesExampleLabel
2393 .setText(MessageManager.getString("label.no_backup_files"));
2394 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2398 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2399 rollMax = rollMax < 1 ? 1 : rollMax;
2401 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2406 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2407 digits = digits < 1 ? 1 : digits;
2409 int lowersurround = 2;
2410 int uppersurround = 0;
2411 StringBuilder exampleSB = new StringBuilder();
2412 boolean firstLine = true;
2418 int max = keepAll ? exampleindex : rollMax;
2419 for (int index = min; index <= max; index++)
2421 if (index == min + lowersurround && index < max - uppersurround - 1)
2423 exampleSB.append("\n...");
2426 else if (index > min + lowersurround && index < max - uppersurround)
2438 exampleSB.append("\n");
2441 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2442 base, suffix, digits));
2445 // no extra text needed
2447 else if (index == min)
2449 String newest = MessageManager.getString("label.braced_newest");
2450 if (newest != null && newest.length() > 0)
2452 exampleSB.append(" " + newest);
2455 else if (index == max)
2457 String oldest = MessageManager.getString("label.braced_oldest");
2458 if (oldest != null && oldest.length() > 0)
2460 exampleSB.append(" " + oldest);
2469 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2470 : exampleindex - rollMax + 1;
2471 int max = exampleindex;
2473 for (int index = min; index <= max; index++)
2476 if (index == min + lowersurround && index < max - uppersurround - 1)
2478 exampleSB.append("\n...");
2481 else if (index > min + lowersurround && index < max - uppersurround)
2493 exampleSB.append("\n");
2496 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2497 base, suffix, digits));
2500 // no extra text needed
2502 else if (index == min)
2504 String oldest = MessageManager.getString("label.braced_oldest");
2505 if (oldest != null && oldest.length() > 0)
2507 exampleSB.append(" " + oldest);
2510 else if (index == max)
2512 String newest = MessageManager.getString("label.braced_newest");
2513 if (newest != null && newest.length() > 0)
2515 exampleSB.append(" " + newest);
2523 // add some extra empty lines to pad out the example files box. ugh, please tell
2524 // me how to do this better
2525 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2526 if (remainingLines > 0)
2528 for (int i = 0; i < remainingLines; i++)
2530 exampleSB.append("\n ");
2535 backupfilesExampleLabel.setText(exampleSB.toString());
2538 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2539 boolean useExistingVal, ChangeListener c)
2546 i = ((Integer) s.getValue()).intValue();
2547 } catch (Exception e)
2550 "Exception casting the initial value of s.getValue()");
2554 setIntegerSpinner(s, min, max, i, c);
2557 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2560 // integer spinner for number of digits
2569 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2572 s.addChangeListener(c);
2576 protected static int getSpinnerInt(JSpinner s, int def)
2582 i = (Integer) s.getValue();
2583 } catch (Exception e)
2585 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2590 private void keepRollMaxOptionsEnabled()
2592 boolean enabled = backupfilesKeepAll.isEnabled()
2593 && !backupfilesKeepAll.isSelected();
2594 oldBackupFilesLabel.setEnabled(enabled);
2595 backupfilesRollMaxSpinner.setEnabled(enabled);
2596 backupfilesConfirmDelete.setEnabled(enabled);
2599 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2601 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2602 && customiseCheckbox.isSelected()
2603 && suffixTemplate.getText()
2604 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2605 keepfilesPanel.setEnabled(enabled);
2606 backupfilesKeepAll.setEnabled(enabled);
2607 oldBackupFilesLabel.setEnabled(enabled);
2608 keepRollMaxOptionsEnabled();
2611 private void backupfilesSuffixTemplateDigitsSetEnabled()
2613 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2614 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2615 suffixDigitsLabel.setEnabled(enabled);
2616 suffixDigitsSpinner.setEnabled(enabled);
2617 suffixReverse.setEnabled(enabled);
2620 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2622 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2623 && customiseCheckbox.isSelected();
2624 suffixPanel.setEnabled(enabled);
2625 suffixTemplateLabel.setEnabled(enabled);
2626 suffixTemplate.setEnabled(enabled);
2627 backupfilesSuffixTemplateDigitsSetEnabled();
2630 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2632 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2633 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2634 revertButton.setEnabled(enabled);
2637 private boolean backupfilesCustomChanged()
2639 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2640 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2641 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2642 return !custom.equals(current);
2645 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2647 String suffix = suffixTemplate.getText();
2648 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2649 boolean reverse = suffixReverse.isSelected();
2650 boolean keepAll = backupfilesKeepAll.isSelected();
2651 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2652 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2654 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2655 reverse, keepAll, rollMax, confirmDelete);
2660 protected void backupfilesCustomOptionsSetEnabled()
2662 boolean enabled = customiseCheckbox.isSelected();
2664 backupfilesRevertButtonSetEnabled(enabled);
2665 backupfilesSuffixTemplateSetEnabled(enabled);
2666 backupfilesKeepAllSetEnabled(enabled);
2669 private void backupfilesSummarySetEnabled()
2671 boolean enabled = enableBackupFiles.isSelected();
2672 backupfilesExampleLabel.setEnabled(enabled);
2673 exampleFilesPanel.setEnabled(enabled);
2676 private void backupfilesPresetsSetEnabled()
2678 boolean enabled = enableBackupFiles.isSelected();
2679 presetsPanel.setEnabled(enabled);
2680 presetsComboLabel.setEnabled(enabled);
2681 backupfilesPresetsCombo.setEnabled(enabled);
2682 customiseCheckbox.setEnabled(enabled);
2683 revertButton.setEnabled(enabled);
2686 protected void backupsOptionsSetEnabled()
2688 backupfilesPresetsSetEnabled();
2689 backupfilesSummarySetEnabled();
2690 backupfilesCustomOptionsSetEnabled();
2693 protected void backupsSetOptions(String suffix, int digits,
2694 boolean reverse, boolean keepAll, int rollMax,
2695 boolean confirmDelete)
2697 suffixTemplate.setText(suffix);
2698 suffixDigitsSpinner.setValue(digits);
2699 suffixReverse.setSelected(reverse);
2700 backupfilesKeepAll.setSelected(keepAll);
2701 backupfilesRollMaxSpinner.setValue(rollMax);
2702 backupfilesConfirmDelete.setSelected(confirmDelete);
2705 protected void backupsSetOptions(BackupFilesPresetEntry p)
2707 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2711 protected void autoIdWidth_actionPerformed()
2713 // TODO Auto-generated method stub
2717 protected void userIdWidth_actionPerformed()
2719 // TODO Auto-generated method stub
2723 protected void maxColour_actionPerformed(JPanel panel)
2727 protected void minColour_actionPerformed(JPanel panel)
2731 protected void gapColour_actionPerformed(JPanel panel)
2735 protected void hiddenColour_actionPerformed(JPanel panel)
2739 protected void showunconserved_actionPerformed(ActionEvent e)
2741 // TODO Auto-generated method stub
2745 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2749 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2759 public void ok_actionPerformed(ActionEvent e)
2769 public void cancel_actionPerformed(ActionEvent e)
2779 public void annotations_actionPerformed(ActionEvent e)
2786 public void startupFileTextfield_mouseClicked()
2790 public void newLink_actionPerformed(ActionEvent e)
2795 public void editLink_actionPerformed(ActionEvent e)
2800 public void deleteLink_actionPerformed(ActionEvent e)
2805 public void defaultBrowser_mouseClicked(MouseEvent e)
2810 public void linkURLList_keyTyped(KeyEvent e)
2815 public void useProxy_actionPerformed()
2817 boolean enabled = useProxy.isSelected();
2818 portLabel.setEnabled(enabled);
2819 serverLabel.setEnabled(enabled);
2820 proxyServerTB.setEnabled(enabled);
2821 proxyPortTB.setEnabled(enabled);
2825 * Customer renderer for JTable: supports column of radio buttons
2827 public class RadioButtonRenderer extends JRadioButton
2828 implements TableCellRenderer
2830 public RadioButtonRenderer()
2832 setHorizontalAlignment(CENTER);
2833 setToolTipText(MessageManager.getString("label.urltooltip"));
2837 public Component getTableCellRendererComponent(JTable table,
2838 Object value, boolean isSelected, boolean hasFocus, int row,
2841 setSelected((boolean) value);
2843 // set colours to match rest of table
2846 setBackground(table.getSelectionBackground());
2847 setForeground(table.getSelectionForeground());
2851 setBackground(table.getBackground());
2852 setForeground(table.getForeground());
2859 * Customer cell editor for JTable: supports column of radio buttons in
2860 * conjunction with renderer
2862 public class RadioButtonEditor extends AbstractCellEditor
2863 implements TableCellEditor
2865 private JRadioButton button = new JRadioButton();
2867 public RadioButtonEditor()
2869 button.setHorizontalAlignment(SwingConstants.CENTER);
2870 this.button.addActionListener(new ActionListener()
2873 public void actionPerformed(ActionEvent e)
2875 fireEditingStopped();
2881 public Component getTableCellEditorComponent(JTable table, Object value,
2882 boolean isSelected, int row, int column)
2884 button.setSelected((boolean) value);
2889 public Object getCellEditorValue()
2891 return button.isSelected();