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 structureDimensions = new JTextField();
185 protected JTextField chimeraPath = new JTextField();
187 protected ButtonGroup mappingMethod = new ButtonGroup();
189 protected JRadioButton siftsMapping = new JRadioButton();
191 protected JRadioButton nwMapping = new JRadioButton();
194 * Colours tab components
196 protected JPanel minColour = new JPanel();
198 protected JPanel maxColour = new JPanel();
200 protected JComboBox<String> protColour = new JComboBox<>();
202 protected JComboBox<String> nucColour = new JComboBox<>();
205 * Overview tab components
207 protected JPanel gapColour = new JPanel();
209 protected JPanel hiddenColour = new JPanel();
211 protected JCheckBox useLegacyGap;
213 protected JCheckBox showHiddenAtStart;
215 protected JLabel gapLabel;
218 * Connections tab components
220 protected JTable linkUrlTable = new JTable();
222 protected JButton editLink = new JButton();
224 protected JButton deleteLink = new JButton();
226 protected JTextField filterTB = new JTextField();
228 protected JButton doReset = new JButton();
230 protected JButton userOnly = new JButton();
232 protected JLabel portLabel = new JLabel();
234 protected JLabel serverLabel = new JLabel();
236 protected JTextField proxyServerTB = new JTextField();
238 protected JTextField proxyPortTB = new JTextField();
240 protected JTextField defaultBrowser = new JTextField();
242 protected JCheckBox useProxy = new JCheckBox();
244 protected JCheckBox usagestats = new JCheckBox();
246 protected JCheckBox questionnaire = new JCheckBox();
248 protected JCheckBox versioncheck = new JCheckBox();
251 * Output tab components
253 protected JComboBox<Object> epsRendering = new JComboBox<>();
255 protected JComboBox<Object> htmlRendering = new JComboBox<>();
257 protected JComboBox<Object> svgRendering = new JComboBox<>();
259 protected JLabel userIdWidthlabel = new JLabel();
261 protected JCheckBox autoIdWidth = new JCheckBox();
263 protected JTextField userIdWidth = new JTextField();
265 protected JCheckBox blcjv = new JCheckBox();
267 protected JCheckBox pileupjv = new JCheckBox();
269 protected JCheckBox clustaljv = new JCheckBox();
271 protected JCheckBox msfjv = new JCheckBox();
273 protected JCheckBox fastajv = new JCheckBox();
275 protected JCheckBox pfamjv = new JCheckBox();
277 protected JCheckBox pirjv = new JCheckBox();
279 protected JCheckBox modellerOutput = new JCheckBox();
281 protected JCheckBox embbedBioJSON = new JCheckBox();
284 * Editing tab components
286 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
288 protected JCheckBox padGaps = new JCheckBox();
290 protected JCheckBox sortByTree = new JCheckBox();
295 protected JPanel wsTab = new JPanel();
298 * Backups tab components
299 * a lot of these are member variables instead of local variables only so that they
300 * can be enabled/disabled easily in one go
303 protected JCheckBox enableBackupFiles = new JCheckBox();
305 protected JPanel presetsPanel = new JPanel();
307 protected JLabel presetsComboLabel = new JLabel();
309 protected JCheckBox customiseCheckbox = new JCheckBox();
311 protected JButton revertButton = new JButton();
313 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
315 private int backupfilesPresetsComboLastSelected = 0;
317 protected JPanel suffixPanel = new JPanel();
319 protected JPanel keepfilesPanel = new JPanel();
321 protected JPanel exampleFilesPanel = new JPanel();
323 protected JTextField suffixTemplate = new JTextField(null, 8);
325 protected JLabel suffixTemplateLabel = new JLabel();
327 protected JLabel suffixDigitsLabel = new JLabel();
329 protected JSpinner suffixDigitsSpinner = new JSpinner();
331 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
333 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
335 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
337 protected JLabel oldBackupFilesLabel = new JLabel();
339 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
341 protected JTextArea backupfilesExampleLabel = new JTextArea();
344 * Creates a new GPreferences object.
346 public GPreferences()
351 } catch (Exception ex)
353 ex.printStackTrace();
358 * Construct the panel and its tabbed sub-panels.
362 private void jbInit() throws Exception
364 final JTabbedPane tabbedPane = new JTabbedPane();
365 this.setLayout(new BorderLayout());
366 JPanel okCancelPanel = initOkCancelPanel();
367 this.add(tabbedPane, BorderLayout.CENTER);
368 this.add(okCancelPanel, BorderLayout.SOUTH);
370 tabbedPane.add(initVisualTab(),
371 MessageManager.getString("label.visual"));
373 tabbedPane.add(initColoursTab(),
374 MessageManager.getString("label.colours"));
376 tabbedPane.add(initOverviewTab(),
377 MessageManager.getString("label.overview"));
379 tabbedPane.add(initStructureTab(),
380 MessageManager.getString("label.structure"));
382 tabbedPane.add(initConnectionsTab(),
383 MessageManager.getString("label.connections"));
385 if (!Platform.isJS())
387 tabbedPane.add(initBackupsTab(),
388 MessageManager.getString("label.backups"));
391 tabbedPane.add(initLinksTab(),
392 MessageManager.getString("label.urllinks"));
394 tabbedPane.add(initOutputTab(),
395 MessageManager.getString("label.output"));
397 tabbedPane.add(initEditingTab(),
398 MessageManager.getString("label.editing"));
401 * See WsPreferences for the real work of configuring this tab.
403 if (!Platform.isJS())
405 wsTab.setLayout(new BorderLayout());
406 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
410 * Handler to validate a tab before leaving it - currently only for
413 tabbedPane.addChangeListener(new ChangeListener()
415 private Component lastTab;
418 public void stateChanged(ChangeEvent e)
420 if (lastTab == structureTab
421 && tabbedPane.getSelectedComponent() != structureTab)
423 if (!validateStructure())
425 tabbedPane.setSelectedComponent(structureTab);
429 lastTab = tabbedPane.getSelectedComponent();
436 * Initialises the Editing tabbed panel.
440 private JPanel initEditingTab()
442 JPanel editingTab = new JPanel();
443 editingTab.setLayout(null);
444 autoCalculateConsCheck.setFont(LABEL_FONT);
445 autoCalculateConsCheck.setText(
446 MessageManager.getString("label.autocalculate_consensus"));
447 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
448 padGaps.setFont(LABEL_FONT);
450 MessageManager.getString("label.pad_gaps_when_editing"));
451 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
452 sortByTree.setFont(LABEL_FONT);
454 .setText(MessageManager.getString("label.sort_with_new_tree"));
455 sortByTree.setToolTipText(MessageManager.getString(
456 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
457 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
458 editingTab.add(autoCalculateConsCheck);
459 editingTab.add(padGaps);
460 editingTab.add(sortByTree);
465 * Initialises the Output tab
469 private JPanel initOutputTab()
471 JPanel outputTab = new JPanel();
472 outputTab.setLayout(null);
474 JLabel epsLabel = new JLabel(
475 MessageManager.formatMessage("label.rendering_style", "EPS"));
476 epsLabel.setFont(LABEL_FONT);
477 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
478 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
479 epsRendering.setFont(LABEL_FONT);
480 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
481 JLabel htmlLabel = new JLabel(
482 MessageManager.formatMessage("label.rendering_style", "HTML"));
483 htmlLabel.setFont(LABEL_FONT);
484 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
485 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
486 htmlRendering.setFont(LABEL_FONT);
487 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
488 JLabel svgLabel = new JLabel(
489 MessageManager.formatMessage("label.rendering_style", "SVG"));
490 svgLabel.setFont(LABEL_FONT);
491 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
492 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
493 svgRendering.setFont(LABEL_FONT);
494 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
496 JLabel jLabel1 = new JLabel();
497 jLabel1.setFont(LABEL_FONT);
498 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
499 jLabel1.setText(MessageManager.getString("label.append_start_end"));
500 jLabel1.setFont(LABEL_FONT);
502 fastajv.setFont(LABEL_FONT);
503 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
504 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
505 blcjv.setText(MessageManager.getString("label.blc") + " ");
506 fastajv.setText(MessageManager.getString("label.fasta") + " ");
507 msfjv.setText(MessageManager.getString("label.msf") + " ");
508 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
509 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
510 msfjv.setFont(LABEL_FONT);
511 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
512 pirjv.setText(MessageManager.getString("label.pir") + " ");
513 JPanel jPanel11 = new JPanel();
514 jPanel11.setFont(LABEL_FONT);
515 TitledBorder titledBorder2 = new TitledBorder(
516 MessageManager.getString("label.file_output"));
517 jPanel11.setBorder(titledBorder2);
518 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
519 GridLayout gridLayout3 = new GridLayout();
520 jPanel11.setLayout(gridLayout3);
521 gridLayout3.setRows(8);
522 blcjv.setFont(LABEL_FONT);
523 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
524 clustaljv.setFont(LABEL_FONT);
525 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
526 pfamjv.setFont(LABEL_FONT);
527 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
528 pileupjv.setFont(LABEL_FONT);
529 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
530 pirjv.setFont(LABEL_FONT);
531 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
532 autoIdWidth.setFont(LABEL_FONT);
534 MessageManager.getString("label.automatically_set_id_width"));
535 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
536 .getString("label.adjusts_width_generated_eps_png")));
537 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
538 autoIdWidth.addActionListener(new ActionListener()
542 public void actionPerformed(ActionEvent e)
544 autoIdWidth_actionPerformed();
547 userIdWidthlabel.setFont(LABEL_FONT);
548 userIdWidthlabel.setText(
549 MessageManager.getString("label.figure_id_column_width"));
550 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
551 .getString("label.manually_specify_width_left_column")));
552 userIdWidthlabel.setToolTipText(
553 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
554 "label.manually_specify_width_left_column")));
555 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
556 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
557 userIdWidth.setText("");
558 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
559 userIdWidth.addActionListener(new ActionListener()
563 public void actionPerformed(ActionEvent e)
565 userIdWidth_actionPerformed();
568 modellerOutput.setFont(LABEL_FONT);
570 .setText(MessageManager.getString("label.use_modeller_output"));
571 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
572 embbedBioJSON.setFont(LABEL_FONT);
573 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
574 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
576 jPanel11.add(jLabel1);
578 jPanel11.add(clustaljv);
579 jPanel11.add(fastajv);
581 jPanel11.add(pfamjv);
582 jPanel11.add(pileupjv);
584 outputTab.add(autoIdWidth);
585 outputTab.add(userIdWidth);
586 outputTab.add(userIdWidthlabel);
587 outputTab.add(modellerOutput);
588 if (!Platform.isJS())
591 * JalviewJS doesn't support Lineart option or SVG output
593 outputTab.add(embbedBioJSON);
594 outputTab.add(epsLabel);
595 outputTab.add(epsRendering);
596 outputTab.add(htmlLabel);
597 outputTab.add(htmlRendering);
598 outputTab.add(svgLabel);
599 outputTab.add(svgRendering);
601 outputTab.add(jPanel11);
606 * Initialises the Connections tabbed panel.
610 private JPanel initConnectionsTab()
612 JPanel connectTab = new JPanel();
613 connectTab.setLayout(new GridBagLayout());
615 // Label for browser text box
616 JLabel browserLabel = new JLabel();
617 browserLabel.setFont(LABEL_FONT);
618 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
619 browserLabel.setText(
620 MessageManager.getString("label.default_browser_unix"));
621 defaultBrowser.setFont(LABEL_FONT);
622 defaultBrowser.setText("");
623 final String tooltip = JvSwingUtils.wrapTooltip(true,
624 MessageManager.getString("label.double_click_to_browse"));
625 defaultBrowser.setToolTipText(tooltip);
626 defaultBrowser.addMouseListener(new MouseAdapter()
629 public void mouseClicked(MouseEvent e)
631 if (e.getClickCount() > 1)
633 defaultBrowser_mouseClicked(e);
638 JPanel proxyPanel = initConnTabProxyPanel();
639 initConnTabCheckboxes();
641 // Add default Browser text box
642 connectTab.add(browserLabel,
643 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
644 GridBagConstraints.WEST, GridBagConstraints.NONE,
645 new Insets(10, 0, 5, 5), 5, 1));
646 defaultBrowser.setFont(LABEL_FONT);
647 defaultBrowser.setText("");
649 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
650 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
651 new Insets(10, 0, 5, 10), 30, 1));
653 // Add proxy server panel
654 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
655 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
656 new Insets(10, 0, 5, 12), 4, 10));
658 // Add usage stats, version check and questionnaire checkboxes
659 connectTab.add(usagestats,
660 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
661 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
662 new Insets(0, 2, 5, 5), 70, 1));
663 connectTab.add(questionnaire,
664 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
665 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
666 new Insets(0, 2, 5, 10), 70, 1));
667 connectTab.add(versioncheck,
668 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
669 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
670 new Insets(0, 2, 5, 5), 70, 1));
672 versioncheck.setVisible(false);
674 // Add padding so the panel doesn't look ridiculous
675 JPanel spacePanel = new JPanel();
676 connectTab.add(spacePanel,
677 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
678 GridBagConstraints.WEST, GridBagConstraints.BOTH,
679 new Insets(0, 0, 0, 5), 70, 1));
685 * Initialises the Links tabbed panel.
689 private JPanel initLinksTab()
691 JPanel linkTab = new JPanel();
692 linkTab.setLayout(new GridBagLayout());
694 // Set up table for Url links
695 linkUrlTable.getTableHeader().setReorderingAllowed(false);
696 linkUrlTable.setFillsViewportHeight(true);
697 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
698 linkUrlTable.setAutoCreateRowSorter(true);
699 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
701 // adjust row height so radio buttons actually fit
702 // don't do this in the renderer, it causes the awt thread to activate
704 JRadioButton temp = new JRadioButton();
705 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
707 // Table in scrollpane so that the table is given a scrollbar
708 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
709 linkScrollPane.setBorder(null);
711 // Panel for links functionality
712 JPanel linkPanel = new JPanel(new GridBagLayout());
713 linkPanel.setBorder(new TitledBorder(
714 MessageManager.getString("label.url_linkfrom_sequence_id")));
716 // Put the Url links panel together
718 // Buttons go at top right, resizing only resizes the blank space vertically
719 JPanel buttonPanel = initLinkTabUrlButtons();
720 GridBagConstraints linkConstraints1 = new GridBagConstraints();
721 linkConstraints1.insets = new Insets(0, 0, 5, 0);
722 linkConstraints1.gridx = 0;
723 linkConstraints1.gridy = 0;
724 linkConstraints1.weightx = 1.0;
725 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
726 linkTab.add(buttonPanel, linkConstraints1);
728 // Links table goes at top left, resizing resizes the table
729 GridBagConstraints linkConstraints2 = new GridBagConstraints();
730 linkConstraints2.insets = new Insets(0, 0, 5, 5);
731 linkConstraints2.gridx = 0;
732 linkConstraints2.gridy = 1;
733 linkConstraints2.weightx = 1.0;
734 linkConstraints2.weighty = 1.0;
735 linkConstraints2.fill = GridBagConstraints.BOTH;
736 linkTab.add(linkScrollPane, linkConstraints2);
738 // Filter box and buttons goes at bottom left, resizing resizes the text box
739 JPanel filterPanel = initLinkTabFilterPanel();
740 GridBagConstraints linkConstraints3 = new GridBagConstraints();
741 linkConstraints3.insets = new Insets(0, 0, 0, 5);
742 linkConstraints3.gridx = 0;
743 linkConstraints3.gridy = 2;
744 linkConstraints3.weightx = 1.0;
745 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
746 linkTab.add(filterPanel, linkConstraints3);
751 private JPanel initLinkTabFilterPanel()
753 // Filter textbox and reset button
754 JLabel filterLabel = new JLabel(
755 MessageManager.getString("label.filter"));
756 filterLabel.setFont(LABEL_FONT);
757 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
758 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
760 filterTB.setFont(LABEL_FONT);
761 filterTB.setText("");
763 doReset.setText(MessageManager.getString("action.showall"));
764 userOnly.setText(MessageManager.getString("action.customfilter"));
766 // Panel for filter functionality
767 JPanel filterPanel = new JPanel(new GridBagLayout());
768 filterPanel.setBorder(new TitledBorder("Filter"));
769 GridBagConstraints gbc = new GridBagConstraints();
772 gbc.fill = GridBagConstraints.NONE;
773 gbc.anchor = GridBagConstraints.WEST;
775 filterPanel.add(filterLabel, gbc);
777 GridBagConstraints gbc1 = new GridBagConstraints();
780 gbc1.fill = GridBagConstraints.HORIZONTAL;
781 gbc1.anchor = GridBagConstraints.WEST;
783 filterPanel.add(filterTB, gbc1);
785 GridBagConstraints gbc2 = new GridBagConstraints();
787 gbc2.fill = GridBagConstraints.NONE;
788 gbc2.anchor = GridBagConstraints.WEST;
789 filterPanel.add(doReset, gbc2);
791 GridBagConstraints gbc3 = new GridBagConstraints();
793 gbc3.fill = GridBagConstraints.NONE;
794 gbc3.anchor = GridBagConstraints.WEST;
795 filterPanel.add(userOnly, gbc3);
800 private JPanel initLinkTabUrlButtons()
802 // Buttons for new / edit / delete Url links
803 JButton newLink = new JButton();
804 newLink.setText(MessageManager.getString("action.new"));
806 editLink.setText(MessageManager.getString("action.edit"));
808 deleteLink.setText(MessageManager.getString("action.delete"));
810 // no current selection, so initially disable delete/edit buttons
811 editLink.setEnabled(false);
812 deleteLink.setEnabled(false);
814 newLink.addActionListener(new java.awt.event.ActionListener()
817 public void actionPerformed(ActionEvent e)
819 newLink_actionPerformed(e);
823 editLink.setText(MessageManager.getString("action.edit"));
824 editLink.addActionListener(new java.awt.event.ActionListener()
827 public void actionPerformed(ActionEvent e)
829 editLink_actionPerformed(e);
833 deleteLink.setText(MessageManager.getString("action.delete"));
834 deleteLink.addActionListener(new java.awt.event.ActionListener()
837 public void actionPerformed(ActionEvent e)
839 deleteLink_actionPerformed(e);
843 JPanel buttonPanel = new JPanel(new GridBagLayout());
844 buttonPanel.setBorder(new TitledBorder("Edit links"));
845 GridBagConstraints gbc = new GridBagConstraints();
848 gbc.fill = GridBagConstraints.NONE;
849 buttonPanel.add(newLink, gbc);
851 GridBagConstraints gbc1 = new GridBagConstraints();
854 gbc1.fill = GridBagConstraints.NONE;
855 buttonPanel.add(editLink, gbc1);
857 GridBagConstraints gbc2 = new GridBagConstraints();
860 gbc2.fill = GridBagConstraints.NONE;
861 buttonPanel.add(deleteLink, gbc2);
863 GridBagConstraints gbc3 = new GridBagConstraints();
866 gbc3.fill = GridBagConstraints.HORIZONTAL;
868 JPanel spacePanel = new JPanel();
869 spacePanel.setBorder(null);
870 buttonPanel.add(spacePanel, gbc3);
876 * Initialises the proxy server panel in the Connections tab
878 * @return the proxy server panel
880 private JPanel initConnTabProxyPanel()
882 // Label for server text box
883 serverLabel.setText(MessageManager.getString("label.address"));
884 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
885 serverLabel.setFont(LABEL_FONT);
887 // Proxy server and port text boxes
888 proxyServerTB.setFont(LABEL_FONT);
889 proxyPortTB.setFont(LABEL_FONT);
891 // Label for Port text box
892 portLabel.setFont(LABEL_FONT);
893 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
894 portLabel.setText(MessageManager.getString("label.port"));
896 // Use proxy server checkbox
897 useProxy.setFont(LABEL_FONT);
898 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
899 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
900 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
901 useProxy.addActionListener(new ActionListener()
904 public void actionPerformed(ActionEvent e)
906 useProxy_actionPerformed();
910 // Make proxy server panel
911 JPanel proxyPanel = new JPanel();
912 TitledBorder titledBorder1 = new TitledBorder(
913 MessageManager.getString("label.proxy_server"));
914 proxyPanel.setBorder(titledBorder1);
915 proxyPanel.setLayout(new GridBagLayout());
916 proxyPanel.add(serverLabel,
917 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
918 GridBagConstraints.WEST, GridBagConstraints.NONE,
919 new Insets(0, 2, 2, 0), 5, 0));
920 proxyPanel.add(portLabel,
921 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
922 GridBagConstraints.WEST, GridBagConstraints.NONE,
923 new Insets(0, 0, 2, 0), 11, 0));
924 proxyPanel.add(useProxy,
925 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
926 GridBagConstraints.WEST, GridBagConstraints.NONE,
927 new Insets(0, 2, 5, 185), 2, -4));
928 proxyPanel.add(proxyPortTB,
929 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
930 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
931 new Insets(0, 2, 2, 2), 54, 1));
932 proxyPanel.add(proxyServerTB,
933 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
934 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
935 new Insets(0, 2, 2, 0), 263, 1));
941 * Initialises the checkboxes in the Connections tab
943 private void initConnTabCheckboxes()
945 // Usage stats checkbox label
947 MessageManager.getString("label.send_usage_statistics"));
948 usagestats.setFont(LABEL_FONT);
949 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
950 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
952 // Questionnaire checkbox label
953 questionnaire.setText(
954 MessageManager.getString("label.check_for_questionnaires"));
955 questionnaire.setFont(LABEL_FONT);
956 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
957 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
959 // Check for latest version checkbox label
960 versioncheck.setText(
961 MessageManager.getString("label.check_for_latest_version"));
962 versioncheck.setFont(LABEL_FONT);
963 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
964 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
968 * Initialises the parent panel which contains the tabbed sections.
972 private JPanel initOkCancelPanel()
974 JButton ok = new JButton();
975 ok.setText(MessageManager.getString("action.ok"));
976 ok.addActionListener(new ActionListener()
979 public void actionPerformed(ActionEvent e)
981 ok_actionPerformed(e);
984 JButton cancel = new JButton();
985 cancel.setText(MessageManager.getString("action.cancel"));
986 cancel.addActionListener(new ActionListener()
989 public void actionPerformed(ActionEvent e)
991 cancel_actionPerformed(e);
994 JPanel okCancelPanel = new JPanel();
995 okCancelPanel.add(ok);
996 okCancelPanel.add(cancel);
997 return okCancelPanel;
1001 * Initialises the Colours tabbed panel.
1005 private JPanel initColoursTab()
1007 JPanel coloursTab = new JPanel();
1008 coloursTab.setBorder(new TitledBorder(
1009 MessageManager.getString("action.open_new_alignment")));
1010 coloursTab.setLayout(new FlowLayout());
1011 JLabel mincolourLabel = new JLabel();
1012 mincolourLabel.setFont(LABEL_FONT);
1013 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1014 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1015 minColour.setFont(LABEL_FONT);
1016 minColour.setBorder(BorderFactory.createEtchedBorder());
1017 minColour.setPreferredSize(new Dimension(40, 20));
1018 minColour.addMouseListener(new MouseAdapter()
1021 public void mousePressed(MouseEvent e)
1023 minColour_actionPerformed(minColour);
1026 JLabel maxcolourLabel = new JLabel();
1027 maxcolourLabel.setFont(LABEL_FONT);
1028 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1029 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1030 maxColour.setFont(LABEL_FONT);
1031 maxColour.setBorder(BorderFactory.createEtchedBorder());
1032 maxColour.setPreferredSize(new Dimension(40, 20));
1033 maxColour.addMouseListener(new MouseAdapter()
1036 public void mousePressed(MouseEvent e)
1038 maxColour_actionPerformed(maxColour);
1042 protColour.setFont(LABEL_FONT);
1043 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1044 JLabel protColourLabel = new JLabel();
1045 protColourLabel.setFont(LABEL_FONT);
1046 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1047 protColourLabel.setText(
1048 MessageManager.getString("label.prot_alignment_colour") + " ");
1049 JvSwingUtils.addtoLayout(coloursTab,
1051 .getString("label.default_colour_scheme_for_alignment"),
1052 protColourLabel, protColour);
1054 nucColour.setFont(LABEL_FONT);
1055 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1056 JLabel nucColourLabel = new JLabel();
1057 nucColourLabel.setFont(LABEL_FONT);
1058 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1059 nucColourLabel.setText(
1060 MessageManager.getString("label.nuc_alignment_colour") + " ");
1061 JvSwingUtils.addtoLayout(coloursTab,
1063 .getString("label.default_colour_scheme_for_alignment"),
1064 nucColourLabel, nucColour);
1066 JPanel annotationShding = new JPanel();
1067 annotationShding.setBorder(new TitledBorder(
1068 MessageManager.getString("label.annotation_shading_default")));
1069 annotationShding.setLayout(new GridLayout(1, 2));
1070 JvSwingUtils.addtoLayout(annotationShding,
1071 MessageManager.getString(
1072 "label.default_minimum_colour_annotation_shading"),
1073 mincolourLabel, minColour);
1074 JvSwingUtils.addtoLayout(annotationShding,
1075 MessageManager.getString(
1076 "label.default_maximum_colour_annotation_shading"),
1077 maxcolourLabel, maxColour);
1078 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1083 * Initialises the Overview tabbed panel.
1087 private JPanel initOverviewTab()
1089 JPanel overviewPanel = new JPanel();
1090 overviewPanel.setBorder(new TitledBorder(
1091 MessageManager.getString("label.overview_settings")));
1093 gapColour.setFont(LABEL_FONT);
1094 // fixing the border colours stops apparent colour bleed from the panel
1095 gapColour.setBorder(
1096 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1097 gapColour.setPreferredSize(new Dimension(40, 20));
1098 gapColour.addMouseListener(new MouseAdapter()
1101 public void mousePressed(MouseEvent e)
1103 gapColour_actionPerformed(gapColour);
1107 hiddenColour.setFont(LABEL_FONT);
1108 // fixing the border colours stops apparent colour bleed from the panel
1109 hiddenColour.setBorder(
1110 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1111 hiddenColour.setPreferredSize(new Dimension(40, 20));
1112 hiddenColour.addMouseListener(new MouseAdapter()
1115 public void mousePressed(MouseEvent e)
1117 hiddenColour_actionPerformed(hiddenColour);
1121 useLegacyGap = new JCheckBox(
1122 MessageManager.getString("label.ov_legacy_gap"));
1123 useLegacyGap.setFont(LABEL_FONT);
1124 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1125 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1126 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1127 gapLabel.setFont(LABEL_FONT);
1128 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1129 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1130 showHiddenAtStart = new JCheckBox(
1131 MessageManager.getString("label.ov_show_hide_default"));
1132 showHiddenAtStart.setFont(LABEL_FONT);
1133 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1134 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1135 JLabel hiddenLabel = new JLabel(
1136 MessageManager.getString("label.hidden_colour"));
1137 hiddenLabel.setFont(LABEL_FONT);
1138 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1139 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1141 useLegacyGap.addActionListener(new ActionListener()
1144 public void actionPerformed(ActionEvent e)
1146 useLegacyGaps_actionPerformed(e);
1150 overviewPanel.setLayout(new GridBagLayout());
1151 GridBagConstraints c1 = new GridBagConstraints();
1153 c1.fill = GridBagConstraints.HORIZONTAL;
1158 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1159 overviewPanel.add(useLegacyGap, c1);
1161 GridBagConstraints c2 = new GridBagConstraints();
1162 c2.fill = GridBagConstraints.HORIZONTAL;
1165 c2.insets = new Insets(0, 15, 0, 10);
1166 overviewPanel.add(gapLabel, c2);
1168 GridBagConstraints c3 = new GridBagConstraints();
1169 c3.fill = GridBagConstraints.HORIZONTAL;
1172 c3.insets = new Insets(0, 0, 0, 15);
1173 overviewPanel.add(gapColour, c3);
1175 GridBagConstraints c4 = new GridBagConstraints();
1176 c4.fill = GridBagConstraints.HORIZONTAL;
1180 overviewPanel.add(showHiddenAtStart, c4);
1182 GridBagConstraints c5 = new GridBagConstraints();
1183 c5.fill = GridBagConstraints.HORIZONTAL;
1186 c5.insets = new Insets(0, 15, 0, 10);
1187 overviewPanel.add(hiddenLabel, c5);
1189 GridBagConstraints c6 = new GridBagConstraints();
1190 c6.fill = GridBagConstraints.HORIZONTAL;
1193 c6.insets = new Insets(0, 0, 0, 15);
1194 overviewPanel.add(hiddenColour, c6);
1196 JButton resetButton = new JButton(
1197 MessageManager.getString("label.reset_to_defaults"));
1199 resetButton.addActionListener(new ActionListener()
1202 public void actionPerformed(ActionEvent e)
1204 resetOvDefaults_actionPerformed(e);
1208 GridBagConstraints c7 = new GridBagConstraints();
1209 c7.fill = GridBagConstraints.NONE;
1212 c7.insets = new Insets(10, 0, 0, 0);
1213 c7.anchor = GridBagConstraints.WEST;
1214 overviewPanel.add(resetButton, c7);
1216 // Add padding so the panel doesn't look ridiculous
1217 JPanel spacePanel = new JPanel();
1218 overviewPanel.add(spacePanel,
1219 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1220 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1221 new Insets(0, 0, 0, 5), 0, 0));
1223 return overviewPanel;
1227 * Initialises the Structure tabbed panel.
1231 private JPanel initStructureTab()
1233 structureTab = new JPanel();
1235 structureTab.setBorder(new TitledBorder(
1236 MessageManager.getString("label.structure_options")));
1237 structureTab.setLayout(null);
1238 final int width = 400;
1239 final int height = 22;
1240 final int lineSpacing = 25;
1243 structFromPdb.setFont(LABEL_FONT);
1245 .setText(MessageManager.getString("label.struct_from_pdb"));
1246 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1247 structFromPdb.addActionListener(new ActionListener()
1250 public void actionPerformed(ActionEvent e)
1252 boolean selected = structFromPdb.isSelected();
1253 // enable other options only when the first is checked
1254 useRnaView.setEnabled(selected);
1255 addSecondaryStructure.setEnabled(selected);
1256 addTempFactor.setEnabled(selected);
1259 structureTab.add(structFromPdb);
1261 // indent checkboxes that are conditional on the first one
1262 ypos += lineSpacing;
1263 useRnaView.setFont(LABEL_FONT);
1264 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1265 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1266 structureTab.add(useRnaView);
1268 ypos += lineSpacing;
1269 addSecondaryStructure.setFont(LABEL_FONT);
1270 addSecondaryStructure
1271 .setText(MessageManager.getString("label.autoadd_secstr"));
1272 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1273 structureTab.add(addSecondaryStructure);
1275 ypos += lineSpacing;
1276 addTempFactor.setFont(LABEL_FONT);
1277 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1278 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1279 structureTab.add(addTempFactor);
1281 ypos += lineSpacing;
1282 JLabel viewerLabel = new JLabel();
1283 viewerLabel.setFont(LABEL_FONT);
1284 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1285 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1286 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1287 structureTab.add(viewerLabel);
1289 structViewer.setFont(LABEL_FONT);
1290 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1291 structViewer.addItem(ViewerType.JMOL.name());
1292 structViewer.addItem(ViewerType.CHIMERA.name());
1293 structViewer.addActionListener(new ActionListener()
1297 public void actionPerformed(ActionEvent e)
1299 structureViewer_actionPerformed(
1300 (String) structViewer.getSelectedItem());
1303 structureTab.add(structViewer);
1306 ypos += lineSpacing;
1307 JLabel dimLabel = new JLabel();
1308 dimLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1309 dimLabel.setHorizontalAlignment(SwingConstants.LEFT);
1311 MessageManager.getString("label.structure_dimensions"));
1312 dimLabel.setBounds(new Rectangle(10, ypos, 140, height));
1313 structureTab.add(dimLabel);
1315 structureDimensions.setFont(LABEL_FONT);
1316 structureDimensions.setBounds(new Rectangle(160, ypos, 120, height));
1317 structureTab.add(structureDimensions);
1319 ypos += lineSpacing;
1320 JLabel pathLabel = new JLabel();
1321 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1322 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1323 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1324 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1325 structureTab.add(pathLabel);
1327 chimeraPath.setFont(LABEL_FONT);
1328 chimeraPath.setText("");
1329 final String tooltip = JvSwingUtils.wrapTooltip(true,
1330 MessageManager.getString("label.chimera_path_tip"));
1331 chimeraPath.setToolTipText(tooltip);
1332 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1333 chimeraPath.addMouseListener(new MouseAdapter()
1336 public void mouseClicked(MouseEvent e)
1338 if (e.getClickCount() == 2)
1340 String chosen = openFileChooser();
1343 chimeraPath.setText(chosen);
1348 structureTab.add(chimeraPath);
1350 ypos += lineSpacing;
1351 nwMapping.setFont(LABEL_FONT);
1352 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1353 siftsMapping.setFont(LABEL_FONT);
1354 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1355 mappingMethod.add(nwMapping);
1356 mappingMethod.add(siftsMapping);
1357 JPanel mappingPanel = new JPanel();
1358 mappingPanel.setFont(LABEL_FONT);
1359 TitledBorder mmTitledBorder = new TitledBorder(
1360 MessageManager.getString("label.mapping_method"));
1361 mmTitledBorder.setTitleFont(LABEL_FONT);
1362 mappingPanel.setBorder(mmTitledBorder);
1363 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1364 // GridLayout mappingLayout = new GridLayout();
1365 mappingPanel.setLayout(new GridLayout());
1366 mappingPanel.add(nwMapping);
1367 mappingPanel.add(siftsMapping);
1368 structureTab.add(mappingPanel);
1370 ypos += lineSpacing;
1371 ypos += lineSpacing;
1372 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1373 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1374 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1375 structureTab.add(docFieldPref);
1378 * hide Chimera options in JalviewJS
1380 if (Platform.isJS())
1382 pathLabel.setVisible(false);
1383 chimeraPath.setVisible(false);
1384 viewerLabel.setVisible(false);
1385 structViewer.setVisible(false);
1388 return structureTab;
1392 * Action on choosing a structure viewer from combobox options.
1394 * @param selectedItem
1396 protected void structureViewer_actionPerformed(String selectedItem)
1401 * Show a dialog for the user to choose a file. Returns the chosen path, or
1406 protected String openFileChooser()
1408 String choice = null;
1409 JFileChooser chooser = new JFileChooser();
1411 // chooser.setFileView(new JalviewFileView());
1412 chooser.setDialogTitle(
1413 MessageManager.getString("label.open_local_file"));
1414 chooser.setToolTipText(MessageManager.getString("action.open"));
1416 int value = chooser.showOpenDialog(this);
1418 if (value == JFileChooser.APPROVE_OPTION)
1420 choice = chooser.getSelectedFile().getPath();
1426 * Validate the structure tab preferences; if invalid, set focus on this tab.
1430 protected boolean validateStructure(FocusEvent e)
1432 if (!validateStructure())
1434 e.getComponent().requestFocusInWindow();
1440 protected boolean validateStructure()
1446 * Initialises the Visual tabbed panel.
1450 private JPanel initVisualTab()
1452 JPanel visualTab = new JPanel();
1453 visualTab.setBorder(new TitledBorder(
1454 MessageManager.getString("action.open_new_alignment")));
1455 visualTab.setLayout(null);
1456 fullScreen.setFont(LABEL_FONT);
1457 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1458 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1459 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1460 quality.setEnabled(false);
1461 quality.setFont(LABEL_FONT);
1462 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1463 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1464 quality.setSelected(true);
1465 quality.setText(MessageManager.getString("label.quality"));
1466 conservation.setEnabled(false);
1467 conservation.setFont(LABEL_FONT);
1468 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1469 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1470 conservation.setSelected(true);
1471 conservation.setText(MessageManager.getString("label.conservation"));
1472 identity.setEnabled(false);
1473 identity.setFont(LABEL_FONT);
1474 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1475 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1476 identity.setSelected(true);
1477 identity.setText(MessageManager.getString("label.consensus"));
1478 showOccupancy.setFont(LABEL_FONT);
1479 showOccupancy.setEnabled(false);
1480 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1481 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1482 showOccupancy.setSelected(true);
1483 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1485 JLabel showGroupbits = new JLabel();
1486 showGroupbits.setFont(LABEL_FONT);
1487 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1488 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1490 .setText(MessageManager.getString("action.show_group") + ":");
1491 JLabel showConsensbits = new JLabel();
1492 showConsensbits.setFont(LABEL_FONT);
1493 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1494 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1496 .setText(MessageManager.getString("label.consensus") + ":");
1497 showConsensHistogram.setEnabled(false);
1498 showConsensHistogram.setFont(LABEL_FONT);
1499 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1500 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1501 showConsensHistogram.setSelected(true);
1502 showConsensHistogram
1503 .setText(MessageManager.getString("label.histogram"));
1504 showConsensLogo.setEnabled(false);
1505 showConsensLogo.setFont(LABEL_FONT);
1506 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1507 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1508 showConsensLogo.setSelected(true);
1509 showConsensLogo.setText(MessageManager.getString("label.logo"));
1510 showGroupConsensus.setEnabled(false);
1511 showGroupConsensus.setFont(LABEL_FONT);
1512 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1513 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1514 showGroupConsensus.setSelected(true);
1515 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1516 showGroupConservation.setEnabled(false);
1517 showGroupConservation.setFont(LABEL_FONT);
1518 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1519 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1520 showGroupConservation.setSelected(true);
1521 showGroupConservation
1522 .setText(MessageManager.getString("label.conservation"));
1523 showNpTooltip.setEnabled(true);
1524 showNpTooltip.setFont(LABEL_FONT);
1525 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1526 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1527 showNpTooltip.setSelected(true);
1528 showNpTooltip.setText(
1529 MessageManager.getString("label.non_positional_features"));
1530 showDbRefTooltip.setEnabled(true);
1531 showDbRefTooltip.setFont(LABEL_FONT);
1532 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1533 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1534 showDbRefTooltip.setSelected(true);
1536 .setText(MessageManager.getString("label.database_references"));
1537 annotations.setFont(LABEL_FONT);
1538 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1539 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1540 annotations.setSelected(true);
1541 annotations.setText(MessageManager.getString("label.show_annotations"));
1542 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1543 annotations.addActionListener(new ActionListener()
1546 public void actionPerformed(ActionEvent e)
1548 annotations_actionPerformed(e);
1551 identity.addActionListener(new ActionListener()
1554 public void actionPerformed(ActionEvent e)
1556 annotations_actionPerformed(e);
1559 showGroupConsensus.addActionListener(new ActionListener()
1562 public void actionPerformed(ActionEvent e)
1564 annotations_actionPerformed(e);
1567 showUnconserved.setFont(LABEL_FONT);
1568 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1569 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1570 showUnconserved.setSelected(true);
1572 .setText(MessageManager.getString("action.show_unconserved"));
1573 showUnconserved.addActionListener(new ActionListener()
1576 public void actionPerformed(ActionEvent e)
1578 showunconserved_actionPerformed(e);
1582 // TODO these are not yet added to / action from Preferences
1583 // JCheckBox shareSelections = new JCheckBox();
1584 // shareSelections.setFont(verdana11);
1585 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1586 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1587 // shareSelections.setSelected(true);
1588 // shareSelections.setText(MessageManager
1589 // .getString("label.share_selection_across_views"));
1590 // JCheckBox followHighlight = new JCheckBox();
1591 // followHighlight.setFont(verdana11);
1592 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1593 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1594 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1595 // followHighlight.setSelected(true);
1596 // followHighlight.setText(MessageManager
1597 // .getString("label.scroll_highlighted_regions"));
1599 seqLimit.setFont(LABEL_FONT);
1600 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1601 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1602 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1603 smoothFont.setFont(LABEL_FONT);
1604 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1605 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1606 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1607 scaleProteinToCdna.setFont(LABEL_FONT);
1608 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1609 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1610 scaleProteinToCdna.setText(
1611 MessageManager.getString("label.scale_protein_to_cdna"));
1612 scaleProteinToCdna.setToolTipText(
1613 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1614 JLabel gapLabel = new JLabel();
1615 gapLabel.setFont(LABEL_FONT);
1616 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1617 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1618 JLabel fontLabel = new JLabel();
1619 fontLabel.setFont(LABEL_FONT);
1620 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1621 fontLabel.setText(MessageManager.getString("label.font"));
1622 fontSizeCB.setFont(LABEL_FONT);
1623 fontSizeCB.setBounds(new Rectangle(320, 115, 65, 23)); // BH 2019.09.24 y
1624 // added 3 pixels for
1626 fontStyleCB.setFont(LABEL_FONT);
1627 fontStyleCB.setBounds(new Rectangle(382, 115, 80, 23)); // BH 2019.09.24 y
1630 fontNameCB.setFont(LABEL_FONT);
1631 fontNameCB.setBounds(new Rectangle(172, 115, 147, 23)); // BH 2019.09.24 y
1634 gapSymbolCB.setFont(LABEL_FONT);
1635 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1636 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1637 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1638 gapSymbolCB.setRenderer(dlcr);
1640 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1641 startupCheckbox.setFont(LABEL_FONT);
1642 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1643 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1644 startupCheckbox.setSelected(true);
1645 startupFileTextfield.setFont(LABEL_FONT);
1646 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1647 final String tooltip = JvSwingUtils.wrapTooltip(true,
1648 MessageManager.getString("label.double_click_to_browse"));
1649 startupFileTextfield.setToolTipText(tooltip);
1650 startupFileTextfield.addMouseListener(new MouseAdapter()
1653 public void mouseClicked(MouseEvent e)
1655 if (e.getClickCount() > 1)
1657 startupFileTextfield_mouseClicked();
1662 sortby.setFont(LABEL_FONT);
1663 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1664 JLabel sortLabel = new JLabel();
1665 sortLabel.setFont(LABEL_FONT);
1666 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1667 sortLabel.setText(MessageManager.getString("label.sort_by"));
1668 sortAnnBy.setFont(LABEL_FONT);
1669 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1670 JLabel sortAnnLabel = new JLabel();
1671 sortAnnLabel.setFont(LABEL_FONT);
1672 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1673 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1674 sortAutocalc.setFont(LABEL_FONT);
1675 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1677 JPanel annsettingsPanel = new JPanel();
1678 annsettingsPanel.setBounds(new Rectangle(173, 13, 330, 100)); // BH
1690 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1691 annsettingsPanel.setBorder(new EtchedBorder());
1692 visualTab.add(annsettingsPanel);
1693 Border jb = new EmptyBorder(1, 1, 4, 5);
1694 annotations.setBorder(jb);
1695 showOccupancy.setBorder(jb);
1696 quality.setBorder(jb);
1697 conservation.setBorder(jb);
1698 identity.setBorder(jb);
1699 showConsensbits.setBorder(jb);
1700 showGroupbits.setBorder(jb);
1701 showGroupConsensus.setBorder(jb);
1702 showGroupConservation.setBorder(jb);
1703 showConsensHistogram.setBorder(jb);
1704 showConsensLogo.setBorder(jb);
1706 JPanel autoAnnotSettings = new JPanel();
1707 annsettingsPanel.add(autoAnnotSettings);
1708 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1709 autoAnnotSettings.add(annotations);
1710 autoAnnotSettings.add(quality);
1711 // second row of autoannotation box
1712 autoAnnotSettings = new JPanel();
1713 annsettingsPanel.add(autoAnnotSettings);
1715 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1716 autoAnnotSettings.add(conservation);
1717 autoAnnotSettings.add(identity);
1718 autoAnnotSettings.add(showOccupancy);
1719 autoAnnotSettings.add(showGroupbits);
1720 autoAnnotSettings.add(showGroupConservation);
1721 autoAnnotSettings.add(showGroupConsensus);
1722 autoAnnotSettings.add(showConsensbits);
1723 autoAnnotSettings.add(showConsensHistogram);
1724 autoAnnotSettings.add(showConsensLogo);
1726 JPanel tooltipSettings = new JPanel();
1727 tooltipSettings.setBorder(new TitledBorder(
1728 MessageManager.getString("label.sequence_id_tooltip")));
1729 tooltipSettings.setBounds(173, 140, 220, 62);
1730 tooltipSettings.setLayout(new GridLayout(2, 1));
1731 tooltipSettings.add(showDbRefTooltip);
1732 tooltipSettings.add(showNpTooltip);
1733 visualTab.add(tooltipSettings);
1735 wrap.setFont(LABEL_FONT);
1736 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1737 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1738 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1739 rightAlign.setFont(LABEL_FONT);
1740 rightAlign.setForeground(Color.black);
1741 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1742 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1743 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1744 idItalics.setFont(LABEL_FONT_ITALIC);
1745 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1746 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1748 MessageManager.getString("label.sequence_name_italics"));
1749 openoverv.setFont(LABEL_FONT);
1750 openoverv.setActionCommand(
1751 MessageManager.getString("label.open_overview"));
1752 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1753 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1754 openoverv.setText(MessageManager.getString("label.open_overview"));
1755 JPanel jPanel2 = new JPanel();
1756 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1757 jPanel2.setLayout(new GridLayout(14, 1));
1758 jPanel2.add(fullScreen);
1759 jPanel2.add(openoverv);
1760 jPanel2.add(seqLimit);
1761 jPanel2.add(rightAlign);
1762 jPanel2.add(fontLabel);
1763 jPanel2.add(showUnconserved);
1764 jPanel2.add(idItalics);
1765 jPanel2.add(smoothFont);
1766 jPanel2.add(scaleProteinToCdna);
1767 jPanel2.add(gapLabel);
1769 jPanel2.add(sortLabel);
1770 jPanel2.add(sortAnnLabel);
1771 jPanel2.add(startupCheckbox);
1772 visualTab.add(jPanel2);
1773 visualTab.add(startupFileTextfield);
1774 visualTab.add(sortby);
1775 visualTab.add(sortAnnBy);
1776 visualTab.add(sortAutocalc);
1777 visualTab.add(gapSymbolCB);
1778 visualTab.add(fontNameCB);
1779 visualTab.add(fontSizeCB);
1780 visualTab.add(fontStyleCB);
1782 if (Platform.isJS())
1784 startupCheckbox.setVisible(false);
1785 startupFileTextfield.setVisible(false);
1792 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1795 protected void loadLastSavedBackupsOptions()
1797 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1798 .getSavedBackupEntry();
1800 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1802 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1803 .createBackupFilesPresetEntry(Cache
1804 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1805 if (backupfilesCustomEntry == null)
1807 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1808 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1810 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1811 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1812 backupfilesCustomEntry);
1814 setComboIntStringKey(backupfilesPresetsCombo,
1815 Cache.getDefault(BackupFiles.NS + "_PRESET",
1816 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1818 backupsSetOptions(savedPreset);
1820 backupsOptionsSetEnabled();
1821 updateBackupFilesExampleLabel();
1824 private boolean warnAboutSuffixReverseChange()
1826 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1827 .getSavedBackupEntry();
1828 boolean savedSuffixReverse = bfpe.reverse;
1829 int savedSuffixDigits = bfpe.digits;
1830 String savedSuffixTemplate = bfpe.suffix;
1832 boolean nowSuffixReverse = suffixReverse.isSelected();
1833 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1834 String nowSuffixTemplate = suffixTemplate.getText();
1835 return nowSuffixReverse != savedSuffixReverse
1836 && nowSuffixDigits == savedSuffixDigits
1837 && nowSuffixTemplate != null
1838 && nowSuffixTemplate.equals(savedSuffixTemplate);
1842 * Initialises the Backups tabbed panel.
1846 private JPanel initBackupsTab()
1848 JPanel backupsTab = new JPanel();
1849 backupsTab.setBorder(new TitledBorder(
1850 MessageManager.getString("label.backup_files")));
1851 backupsTab.setLayout(new GridBagLayout());
1853 GridBagConstraints gbc = new GridBagConstraints();
1856 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1857 gbc.fill = GridBagConstraints.NONE;
1859 initBackupsTabPresetsPanel();
1860 initBackupsTabSuffixPanel();
1861 initBackupsTabKeepFilesPanel();
1862 initBackupsTabFilenameExamplesPanel();
1864 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1866 .setText(MessageManager.getString("label.enable_backupfiles"));
1867 enableBackupFiles.addActionListener(new ActionListener()
1870 public void actionPerformed(ActionEvent e)
1872 // enable other options only when the first is checked
1873 backupsOptionsSetEnabled();
1878 // enable checkbox 1 col
1882 gbc.gridy = 0; // row 0
1883 backupsTab.add(enableBackupFiles, gbc);
1885 // summary of scheme box (over two rows)
1889 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1890 gbc.fill = GridBagConstraints.BOTH;
1891 backupsTab.add(exampleFilesPanel, gbc);
1893 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1894 gbc.fill = GridBagConstraints.NONE;
1896 // fill empty space on right
1899 backupsTab.add(new JPanel(), gbc);
1904 gbc.gridy++; // row 1
1905 backupsTab.add(presetsPanel, gbc);
1907 // now using whole row
1912 gbc.gridy++; // row 2
1913 backupsTab.add(keepfilesPanel, gbc);
1915 // filename strategy box
1916 gbc.gridy++; // row 3
1917 backupsTab.add(suffixPanel, gbc);
1920 gbc.gridy++; // row 4
1922 backupsTab.add(new JPanel(), gbc);
1924 backupsOptionsSetEnabled();
1928 private JPanel initBackupsTabPresetsPanel()
1931 String title = MessageManager.getString("label.schemes");
1933 presetsPanel.setLayout(new GridBagLayout());
1935 GridBagConstraints gbc = new GridBagConstraints();
1938 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1939 gbc.fill = GridBagConstraints.NONE;
1947 presetsComboLabel = new JLabel(title + ":");
1948 presetsPanel.add(presetsComboLabel, gbc);
1950 List<Object> entries = Arrays
1951 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
1952 List<String> tooltips = Arrays.asList(
1953 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
1954 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
1957 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1959 backupfilesPresetsCombo
1960 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1964 backupfilesPresetsCombo.addActionListener(new ActionListener()
1967 public void actionPerformed(ActionEvent e)
1969 int key = getComboIntStringKey(backupfilesPresetsCombo);
1970 if (!customiseCheckbox.isSelected())
1972 backupfilesPresetsComboLastSelected = key;
1974 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1976 if (customiseCheckbox.isSelected())
1978 // got here by clicking on customiseCheckbox so don't change the values
1979 backupfilesCustomOptionsSetEnabled();
1983 backupsTabUpdatePresets();
1984 backupfilesCustomOptionsSetEnabled();
1989 customiseCheckbox.setSelected(false);
1990 backupsTabUpdatePresets();
1991 backupfilesCustomOptionsSetEnabled();
1996 // dropdown list of preset schemes
1998 presetsPanel.add(backupfilesPresetsCombo, gbc);
2000 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2001 revertButton.setToolTipText(
2002 MessageManager.getString("label.cancel_changes_description"));
2003 revertButton.addActionListener(new ActionListener()
2006 public void actionPerformed(ActionEvent e)
2009 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2010 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2011 backupfilesCustomOptionsSetEnabled();
2015 revertButton.setFont(LABEL_FONT);
2017 customiseCheckbox.setFont(LABEL_FONT);
2018 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2019 customiseCheckbox.addActionListener(new ActionListener()
2022 public void actionPerformed(ActionEvent e)
2024 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2025 if (customiseCheckbox.isSelected())
2027 backupfilesPresetsComboLastSelected = currently;
2028 setComboIntStringKey(backupfilesPresetsCombo,
2029 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2033 setComboIntStringKey(backupfilesPresetsCombo,
2034 backupfilesPresetsComboLastSelected);
2037 backupfilesCustomOptionsSetEnabled();
2040 customiseCheckbox.setToolTipText(
2041 MessageManager.getString("label.customise_description"));
2043 // customise checkbox
2046 presetsPanel.add(customiseCheckbox, gbc);
2048 // "Cancel changes" button (aligned with combo box above)
2050 presetsPanel.add(revertButton, gbc);
2052 return presetsPanel;
2055 private JPanel initBackupsTabFilenameExamplesPanel()
2057 String title = MessageManager
2058 .getString("label.scheme_examples");
2059 TitledBorder tb = new TitledBorder(title);
2060 exampleFilesPanel.setBorder(tb);
2061 exampleFilesPanel.setLayout(new GridBagLayout());
2064 backupfilesExampleLabel.setEditable(false);
2065 backupfilesExampleLabel
2066 .setBackground(exampleFilesPanel.getBackground());
2068 updateBackupFilesExampleLabel();
2070 GridBagConstraints gbc = new GridBagConstraints();
2073 gbc.fill = GridBagConstraints.NONE;
2074 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2076 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2077 return exampleFilesPanel;
2080 private void backupsTabUpdatePresets()
2082 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2085 String value = entry.v;
2087 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2091 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2097 "Preset '" + value + "' [key:" + key + "] not implemented");
2100 // Custom options will now be enabled when the customiseCheckbox is checked
2101 // (performed above)
2102 // backupfilesCustomOptionsSetEnabled();
2103 updateBackupFilesExampleLabel();
2106 protected int getComboIntStringKey(
2107 JComboBox<Object> backupfilesPresetsCombo2)
2109 IntKeyStringValueEntry e;
2112 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2114 } catch (Exception ex)
2117 "Problem casting Combo entry to IntKeyStringValueEntry.");
2120 return e != null ? e.k : 0;
2123 protected void setComboIntStringKey(
2124 JComboBox<Object> backupfilesPresetsCombo2,
2127 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2129 IntKeyStringValueEntry e;
2132 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2133 } catch (Exception ex)
2136 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2141 backupfilesPresetsCombo2.setSelectedIndex(i);
2145 // backupsTabUpdatePresets();
2148 private JPanel initBackupsTabSuffixPanel()
2150 suffixPanel.setBorder(new TitledBorder(
2151 MessageManager.getString("label.backup_filename_strategy")));
2152 suffixPanel.setLayout(new GridBagLayout());
2155 .setText(MessageManager.getString("label.append_to_filename"));
2156 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2157 suffixTemplateLabel.setFont(LABEL_FONT);
2159 final String tooltip = JvSwingUtils.wrapTooltip(true,
2160 MessageManager.getString("label.append_to_filename_tooltip"));
2161 suffixTemplate.setToolTipText(tooltip);
2162 suffixTemplate.addActionListener(new ActionListener()
2165 public void actionPerformed(ActionEvent e)
2167 updateBackupFilesExampleLabel();
2168 backupfilesCustomOptionsSetEnabled();
2169 backupfilesRevertButtonSetEnabled(true);
2173 suffixTemplate.addKeyListener(new KeyListener()
2176 public void keyReleased(KeyEvent e)
2178 updateBackupFilesExampleLabel();
2179 backupfilesCustomOptionsSetEnabled();
2180 backupfilesRevertButtonSetEnabled(true);
2184 public void keyPressed(KeyEvent e)
2188 // disable use of ':' or '/' or '\'
2190 public void keyTyped(KeyEvent e)
2192 char c = e.getKeyChar();
2193 if (c == ':' || c == '/' || c == '\\')
2195 // don't process ':' or '/' or '\'
2204 .setText(MessageManager.getString("label.index_digits"));
2205 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2206 suffixDigitsLabel.setFont(LABEL_FONT);
2207 ChangeListener c = new ChangeListener()
2210 public void stateChanged(ChangeEvent e)
2212 backupfilesRevertButtonSetEnabled(true);
2213 updateBackupFilesExampleLabel();
2217 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2218 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2220 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2221 MessageManager.getString("label.increment_index"));
2222 suffixReverse.addActionListener(new ActionListener()
2225 public void actionPerformed(ActionEvent e)
2227 boolean okay = true;
2228 if (warnAboutSuffixReverseChange())
2231 okay = confirmSuffixReverseChange();
2235 backupfilesRevertButtonSetEnabled(true);
2236 updateBackupFilesExampleLabel();
2240 boolean savedSuffixReverse = BackupFilesPresetEntry
2241 .getSavedBackupEntry().reverse;
2242 suffixReverse.setSelected(savedSuffixReverse);
2247 GridBagConstraints sgbc = new GridBagConstraints();
2249 // first row (template text box)
2250 sgbc.anchor = GridBagConstraints.WEST;
2254 sgbc.gridheight = 1;
2257 sgbc.fill = GridBagConstraints.NONE;
2258 suffixPanel.add(suffixTemplateLabel, sgbc);
2261 sgbc.fill = GridBagConstraints.HORIZONTAL;
2262 suffixPanel.add(suffixTemplate, sgbc);
2264 // second row (number of digits spinner)
2268 sgbc.fill = GridBagConstraints.NONE;
2269 suffixPanel.add(suffixDigitsLabel, sgbc);
2272 sgbc.fill = GridBagConstraints.HORIZONTAL;
2273 suffixPanel.add(suffixDigitsSpinner, sgbc);
2275 // third row (forward order radio selection)
2278 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2279 sgbc.fill = GridBagConstraints.HORIZONTAL;
2280 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2282 // fourth row (reverse order radio selection)
2284 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2288 private boolean confirmSuffixReverseChange()
2290 boolean ret = false;
2291 String warningMessage = MessageManager
2292 .getString("label.warning_confirm_change_reverse");
2293 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
2295 MessageManager.getString("label.change_increment_decrement"),
2296 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2298 ret = (confirm == JvOptionPane.YES_OPTION);
2302 private JPanel initBackupsTabKeepFilesPanel()
2304 keepfilesPanel.setBorder(
2305 new TitledBorder(MessageManager.getString("label.keep_files")));
2306 keepfilesPanel.setLayout(new GridBagLayout());
2308 backupfilesKeepAll.setLabels(
2309 MessageManager.getString("label.keep_all_backup_files"),
2310 MessageManager.getString(
2311 "label.keep_only_this_number_of_backup_files"));
2312 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2315 public void actionPerformed(ActionEvent e)
2317 backupfilesRevertButtonSetEnabled(true);
2318 updateBackupFilesExampleLabel();
2321 backupfilesKeepAll.addActionListener(new ActionListener()
2324 public void actionPerformed(ActionEvent e)
2326 backupfilesRevertButtonSetEnabled(true);
2327 keepRollMaxOptionsEnabled();
2328 updateBackupFilesExampleLabel();
2332 ChangeListener c = new ChangeListener()
2335 public void stateChanged(ChangeEvent e)
2337 backupfilesRevertButtonSetEnabled(true);
2338 updateBackupFilesExampleLabel();
2342 setIntegerSpinner(backupfilesRollMaxSpinner,
2343 BackupFilesPresetEntry.ROLLMAXMIN,
2344 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2346 backupfilesConfirmDelete.setLabels(
2347 MessageManager.getString("label.always_ask"),
2348 MessageManager.getString("label.auto_delete"));
2349 backupfilesConfirmDelete.addActionListener(new ActionListener()
2352 public void actionPerformed(ActionEvent e)
2354 backupfilesRevertButtonSetEnabled(true);
2357 // update the enabled section
2358 keepRollMaxOptionsEnabled();
2360 GridBagConstraints kgbc = new GridBagConstraints();
2362 // first row (template text box)
2363 kgbc.anchor = GridBagConstraints.WEST;
2366 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2367 kgbc.gridheight = 1;
2370 kgbc.fill = GridBagConstraints.HORIZONTAL;
2371 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2377 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2378 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2381 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2382 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2384 // third row (indented)
2386 kgbc.insets = new Insets(0, 20, 0, 0);
2389 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2390 kgbc.fill = GridBagConstraints.HORIZONTAL;
2393 JPanel jp = new JPanel();
2394 jp.setLayout(new FlowLayout());
2396 .setText(MessageManager
2397 .getString("label.autodelete_old_backup_files"));
2398 oldBackupFilesLabel.setFont(LABEL_FONT);
2399 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2400 jp.add(oldBackupFilesLabel);
2401 jp.add(backupfilesConfirmDelete.getTrueButton());
2402 jp.add(backupfilesConfirmDelete.getFalseButton());
2403 keepfilesPanel.add(jp, kgbc);
2405 return keepfilesPanel;
2408 protected void updateBackupFilesExampleLabel()
2410 int exampleindex = 12;
2411 String base = MessageManager.getString("label.filename") + ".fa";
2412 if (base == null || base.length() == 0)
2414 base = "file_name.fa";
2417 boolean reverse = suffixReverse.isSelected();
2418 boolean keepAll = backupfilesKeepAll.isSelected();
2420 String suffix = suffixTemplate.getText();
2423 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2424 if (suffix == null || suffix.length() == 0)
2426 backupfilesExampleLabel
2427 .setText(MessageManager.getString("label.no_backup_files"));
2428 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2432 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2433 rollMax = rollMax < 1 ? 1 : rollMax;
2435 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2440 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2441 digits = digits < 1 ? 1 : digits;
2443 int lowersurround = 2;
2444 int uppersurround = 0;
2445 StringBuilder exampleSB = new StringBuilder();
2446 boolean firstLine = true;
2452 int max = keepAll ? exampleindex : rollMax;
2453 for (int index = min; index <= max; index++)
2455 if (index == min + lowersurround && index < max - uppersurround - 1)
2457 exampleSB.append("\n...");
2460 else if (index > min + lowersurround && index < max - uppersurround)
2472 exampleSB.append("\n");
2475 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2476 base, suffix, digits));
2479 // no extra text needed
2481 else if (index == min)
2483 String newest = MessageManager.getString("label.braced_newest");
2484 if (newest != null && newest.length() > 0)
2486 exampleSB.append(" " + newest);
2489 else if (index == max)
2491 String oldest = MessageManager.getString("label.braced_oldest");
2492 if (oldest != null && oldest.length() > 0)
2494 exampleSB.append(" " + oldest);
2503 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2504 : exampleindex - rollMax + 1;
2505 int max = exampleindex;
2507 for (int index = min; index <= max; index++)
2510 if (index == min + lowersurround && index < max - uppersurround - 1)
2512 exampleSB.append("\n...");
2515 else if (index > min + lowersurround && index < max - uppersurround)
2527 exampleSB.append("\n");
2530 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2531 base, suffix, digits));
2534 // no extra text needed
2536 else if (index == min)
2538 String oldest = MessageManager.getString("label.braced_oldest");
2539 if (oldest != null && oldest.length() > 0)
2541 exampleSB.append(" " + oldest);
2544 else if (index == max)
2546 String newest = MessageManager.getString("label.braced_newest");
2547 if (newest != null && newest.length() > 0)
2549 exampleSB.append(" " + newest);
2557 // add some extra empty lines to pad out the example files box. ugh, please tell
2558 // me how to do this better
2559 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2560 if (remainingLines > 0)
2562 for (int i = 0; i < remainingLines; i++)
2564 exampleSB.append("\n ");
2569 backupfilesExampleLabel.setText(exampleSB.toString());
2572 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2573 boolean useExistingVal, ChangeListener c)
2580 i = ((Integer) s.getValue()).intValue();
2581 } catch (Exception e)
2584 "Exception casting the initial value of s.getValue()");
2588 setIntegerSpinner(s, min, max, i, c);
2591 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2594 // integer spinner for number of digits
2603 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2606 s.addChangeListener(c);
2610 protected static int getSpinnerInt(JSpinner s, int def)
2616 i = (Integer) s.getValue();
2617 } catch (Exception e)
2619 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2624 private void keepRollMaxOptionsEnabled()
2626 boolean enabled = backupfilesKeepAll.isEnabled()
2627 && !backupfilesKeepAll.isSelected();
2628 oldBackupFilesLabel.setEnabled(enabled);
2629 backupfilesRollMaxSpinner.setEnabled(enabled);
2630 backupfilesConfirmDelete.setEnabled(enabled);
2633 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2635 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2636 && customiseCheckbox.isSelected()
2637 && suffixTemplate.getText()
2638 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2639 keepfilesPanel.setEnabled(enabled);
2640 backupfilesKeepAll.setEnabled(enabled);
2641 oldBackupFilesLabel.setEnabled(enabled);
2642 keepRollMaxOptionsEnabled();
2645 private void backupfilesSuffixTemplateDigitsSetEnabled()
2647 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2648 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2649 suffixDigitsLabel.setEnabled(enabled);
2650 suffixDigitsSpinner.setEnabled(enabled);
2651 suffixReverse.setEnabled(enabled);
2654 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2656 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2657 && customiseCheckbox.isSelected();
2658 suffixPanel.setEnabled(enabled);
2659 suffixTemplateLabel.setEnabled(enabled);
2660 suffixTemplate.setEnabled(enabled);
2661 backupfilesSuffixTemplateDigitsSetEnabled();
2664 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2666 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2667 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2668 revertButton.setEnabled(enabled);
2671 private boolean backupfilesCustomChanged()
2673 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2674 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2675 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2676 return !custom.equals(current);
2679 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2681 String suffix = suffixTemplate.getText();
2682 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2683 boolean reverse = suffixReverse.isSelected();
2684 boolean keepAll = backupfilesKeepAll.isSelected();
2685 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2686 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2688 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2689 reverse, keepAll, rollMax, confirmDelete);
2694 protected void backupfilesCustomOptionsSetEnabled()
2696 boolean enabled = customiseCheckbox.isSelected();
2698 backupfilesRevertButtonSetEnabled(enabled);
2699 backupfilesSuffixTemplateSetEnabled(enabled);
2700 backupfilesKeepAllSetEnabled(enabled);
2703 private void backupfilesSummarySetEnabled()
2705 boolean enabled = enableBackupFiles.isSelected();
2706 backupfilesExampleLabel.setEnabled(enabled);
2707 exampleFilesPanel.setEnabled(enabled);
2710 private void backupfilesPresetsSetEnabled()
2712 boolean enabled = enableBackupFiles.isSelected();
2713 presetsPanel.setEnabled(enabled);
2714 presetsComboLabel.setEnabled(enabled);
2715 backupfilesPresetsCombo.setEnabled(enabled);
2716 customiseCheckbox.setEnabled(enabled);
2717 revertButton.setEnabled(enabled);
2720 protected void backupsOptionsSetEnabled()
2722 backupfilesPresetsSetEnabled();
2723 backupfilesSummarySetEnabled();
2724 backupfilesCustomOptionsSetEnabled();
2727 protected void backupsSetOptions(String suffix, int digits,
2728 boolean reverse, boolean keepAll, int rollMax,
2729 boolean confirmDelete)
2731 suffixTemplate.setText(suffix);
2732 suffixDigitsSpinner.setValue(digits);
2733 suffixReverse.setSelected(reverse);
2734 backupfilesKeepAll.setSelected(keepAll);
2735 backupfilesRollMaxSpinner.setValue(rollMax);
2736 backupfilesConfirmDelete.setSelected(confirmDelete);
2739 protected void backupsSetOptions(BackupFilesPresetEntry p)
2741 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2745 protected void autoIdWidth_actionPerformed()
2747 // TODO Auto-generated method stub
2751 protected void userIdWidth_actionPerformed()
2753 // TODO Auto-generated method stub
2757 protected void maxColour_actionPerformed(JPanel panel)
2761 protected void minColour_actionPerformed(JPanel panel)
2765 protected void gapColour_actionPerformed(JPanel panel)
2769 protected void hiddenColour_actionPerformed(JPanel panel)
2773 protected void showunconserved_actionPerformed(ActionEvent e)
2775 // TODO Auto-generated method stub
2779 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2783 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2793 public void ok_actionPerformed(ActionEvent e)
2803 public void cancel_actionPerformed(ActionEvent e)
2813 public void annotations_actionPerformed(ActionEvent e)
2820 public void startupFileTextfield_mouseClicked()
2824 public void newLink_actionPerformed(ActionEvent e)
2829 public void editLink_actionPerformed(ActionEvent e)
2834 public void deleteLink_actionPerformed(ActionEvent e)
2839 public void defaultBrowser_mouseClicked(MouseEvent e)
2844 public void linkURLList_keyTyped(KeyEvent e)
2849 public void useProxy_actionPerformed()
2851 boolean enabled = useProxy.isSelected();
2852 portLabel.setEnabled(enabled);
2853 serverLabel.setEnabled(enabled);
2854 proxyServerTB.setEnabled(enabled);
2855 proxyPortTB.setEnabled(enabled);
2859 * Customer renderer for JTable: supports column of radio buttons
2861 public class RadioButtonRenderer extends JRadioButton
2862 implements TableCellRenderer
2864 public RadioButtonRenderer()
2866 setHorizontalAlignment(CENTER);
2867 setToolTipText(MessageManager.getString("label.urltooltip"));
2871 public Component getTableCellRendererComponent(JTable table,
2872 Object value, boolean isSelected, boolean hasFocus, int row,
2875 setSelected((boolean) value);
2877 // set colours to match rest of table
2880 setBackground(table.getSelectionBackground());
2881 setForeground(table.getSelectionForeground());
2885 setBackground(table.getBackground());
2886 setForeground(table.getForeground());
2893 * Customer cell editor for JTable: supports column of radio buttons in
2894 * conjunction with renderer
2896 public class RadioButtonEditor extends AbstractCellEditor
2897 implements TableCellEditor
2899 private JRadioButton button = new JRadioButton();
2901 public RadioButtonEditor()
2903 button.setHorizontalAlignment(SwingConstants.CENTER);
2904 this.button.addActionListener(new ActionListener()
2907 public void actionPerformed(ActionEvent e)
2909 fireEditingStopped();
2915 public Component getTableCellEditorComponent(JTable table, Object value,
2916 boolean isSelected, int row, int column)
2918 button.setSelected((boolean) value);
2923 public Object getCellEditorValue()
2925 return button.isSelected();