2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.util.Arrays;
42 import java.util.List;
44 import javax.swing.AbstractCellEditor;
45 import javax.swing.BorderFactory;
46 import javax.swing.ButtonGroup;
47 import javax.swing.DefaultListCellRenderer;
48 import javax.swing.JButton;
49 import javax.swing.JCheckBox;
50 import javax.swing.JComboBox;
51 import javax.swing.JFileChooser;
52 import javax.swing.JLabel;
53 import javax.swing.JPanel;
54 import javax.swing.JRadioButton;
55 import javax.swing.JScrollPane;
56 import javax.swing.JSpinner;
57 import javax.swing.JTabbedPane;
58 import javax.swing.JTable;
59 import javax.swing.JTextArea;
60 import javax.swing.JTextField;
61 import javax.swing.ListSelectionModel;
62 import javax.swing.SpinnerModel;
63 import javax.swing.SpinnerNumberModel;
64 import javax.swing.SwingConstants;
65 import javax.swing.border.Border;
66 import javax.swing.border.EmptyBorder;
67 import javax.swing.border.EtchedBorder;
68 import javax.swing.border.TitledBorder;
69 import javax.swing.event.ChangeEvent;
70 import javax.swing.event.ChangeListener;
71 import javax.swing.table.TableCellEditor;
72 import javax.swing.table.TableCellRenderer;
74 import jalview.bin.Cache;
75 import jalview.fts.core.FTSDataColumnPreferences;
76 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
77 import jalview.fts.service.pdb.PDBFTSRestClient;
78 import jalview.gui.Desktop;
79 import jalview.gui.JalviewBooleanRadioButtons;
80 import jalview.gui.JvOptionPane;
81 import jalview.gui.JvSwingUtils;
82 import jalview.gui.StructureViewer.ViewerType;
83 import jalview.io.BackupFilenameParts;
84 import jalview.io.BackupFiles;
85 import jalview.io.BackupFilesPresetEntry;
86 import jalview.io.IntKeyStringValueEntry;
87 import jalview.util.MessageManager;
88 import jalview.util.Platform;
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 JLabel structureViewerPathLabel;
185 protected JTextField structureViewerPath = 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 = 420;
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, 220, height));
1287 structureTab.add(viewerLabel);
1290 * add all external viewers as options here - check
1291 * when selected whether the program is installed
1293 structViewer.setFont(LABEL_FONT);
1294 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1295 structViewer.addItem(ViewerType.JMOL.name());
1296 structViewer.addItem(ViewerType.CHIMERA.name());
1297 structViewer.addItem(ViewerType.CHIMERAX.name());
1298 structViewer.addItem(ViewerType.PYMOL.name());
1299 structViewer.addActionListener(new ActionListener()
1302 public void actionPerformed(ActionEvent e)
1304 structureViewer_actionPerformed(
1305 (String) structViewer.getSelectedItem());
1308 structureTab.add(structViewer);
1310 ypos += lineSpacing;
1311 structureViewerPathLabel = new JLabel();
1312 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
1313 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1314 structureViewerPathLabel.setText(MessageManager
1315 .formatMessage("label.viewer_path", "Chimera(X)"));
1316 structureViewerPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
1317 structureViewerPathLabel.setEnabled(false);
1318 structureTab.add(structureViewerPathLabel);
1320 structureViewerPath.setFont(LABEL_FONT);
1321 structureViewerPath.setText("");
1322 structureViewerPath.setEnabled(false);
1323 final String tooltip = JvSwingUtils.wrapTooltip(true,
1324 MessageManager.getString("label.viewer_path_tip"));
1325 structureViewerPath.setToolTipText(tooltip);
1326 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1327 structureViewerPath.addMouseListener(new MouseAdapter()
1330 public void mouseClicked(MouseEvent e)
1332 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1334 String chosen = openFileChooser();
1337 structureViewerPath.setText(chosen);
1342 structureTab.add(structureViewerPath);
1344 ypos += lineSpacing;
1345 nwMapping.setFont(LABEL_FONT);
1346 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1347 siftsMapping.setFont(LABEL_FONT);
1348 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1349 mappingMethod.add(nwMapping);
1350 mappingMethod.add(siftsMapping);
1351 JPanel mappingPanel = new JPanel();
1352 mappingPanel.setFont(LABEL_FONT);
1353 TitledBorder mmTitledBorder = new TitledBorder(
1354 MessageManager.getString("label.mapping_method"));
1355 mmTitledBorder.setTitleFont(LABEL_FONT);
1356 mappingPanel.setBorder(mmTitledBorder);
1357 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1358 // GridLayout mappingLayout = new GridLayout();
1359 mappingPanel.setLayout(new GridLayout());
1360 mappingPanel.add(nwMapping);
1361 mappingPanel.add(siftsMapping);
1362 structureTab.add(mappingPanel);
1364 ypos += lineSpacing;
1365 ypos += lineSpacing;
1366 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1367 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1368 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1369 structureTab.add(docFieldPref);
1372 * hide Chimera options in JalviewJS
1374 if (Platform.isJS())
1376 structureViewerPathLabel.setVisible(false);
1377 structureViewerPath.setVisible(false);
1378 viewerLabel.setVisible(false);
1379 structViewer.setVisible(false);
1382 return structureTab;
1386 * Action on choosing a structure viewer from combobox options.
1388 * @param selectedItem
1390 protected void structureViewer_actionPerformed(String selectedItem)
1395 * Show a dialog for the user to choose a file. Returns the chosen path, or
1400 protected String openFileChooser()
1402 String choice = null;
1403 JFileChooser chooser = new JFileChooser();
1405 // chooser.setFileView(new JalviewFileView());
1406 chooser.setDialogTitle(
1407 MessageManager.getString("label.open_local_file"));
1408 chooser.setToolTipText(MessageManager.getString("action.open"));
1410 int value = chooser.showOpenDialog(this);
1412 if (value == JFileChooser.APPROVE_OPTION)
1414 choice = chooser.getSelectedFile().getPath();
1420 * Validate the structure tab preferences; if invalid, set focus on this tab.
1424 protected boolean validateStructure(FocusEvent e)
1426 if (!validateStructure())
1428 e.getComponent().requestFocusInWindow();
1434 protected boolean validateStructure()
1440 * Initialises the Visual tabbed panel.
1444 private JPanel initVisualTab()
1446 JPanel visualTab = new JPanel();
1447 visualTab.setBorder(new TitledBorder(
1448 MessageManager.getString("action.open_new_alignment")));
1449 visualTab.setLayout(null);
1450 fullScreen.setFont(LABEL_FONT);
1451 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1452 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1453 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1454 quality.setEnabled(false);
1455 quality.setFont(LABEL_FONT);
1456 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1457 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1458 quality.setSelected(true);
1459 quality.setText(MessageManager.getString("label.quality"));
1460 conservation.setEnabled(false);
1461 conservation.setFont(LABEL_FONT);
1462 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1463 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1464 conservation.setSelected(true);
1465 conservation.setText(MessageManager.getString("label.conservation"));
1466 identity.setEnabled(false);
1467 identity.setFont(LABEL_FONT);
1468 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1469 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1470 identity.setSelected(true);
1471 identity.setText(MessageManager.getString("label.consensus"));
1472 showOccupancy.setFont(LABEL_FONT);
1473 showOccupancy.setEnabled(false);
1474 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1475 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1476 showOccupancy.setSelected(true);
1477 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1479 JLabel showGroupbits = new JLabel();
1480 showGroupbits.setFont(LABEL_FONT);
1481 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1482 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1484 .setText(MessageManager.getString("action.show_group") + ":");
1485 JLabel showConsensbits = new JLabel();
1486 showConsensbits.setFont(LABEL_FONT);
1487 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1488 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1490 .setText(MessageManager.getString("label.consensus") + ":");
1491 showConsensHistogram.setEnabled(false);
1492 showConsensHistogram.setFont(LABEL_FONT);
1493 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1494 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1495 showConsensHistogram.setSelected(true);
1496 showConsensHistogram
1497 .setText(MessageManager.getString("label.histogram"));
1498 showConsensLogo.setEnabled(false);
1499 showConsensLogo.setFont(LABEL_FONT);
1500 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1501 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1502 showConsensLogo.setSelected(true);
1503 showConsensLogo.setText(MessageManager.getString("label.logo"));
1504 showGroupConsensus.setEnabled(false);
1505 showGroupConsensus.setFont(LABEL_FONT);
1506 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1507 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1508 showGroupConsensus.setSelected(true);
1509 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1510 showGroupConservation.setEnabled(false);
1511 showGroupConservation.setFont(LABEL_FONT);
1512 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1513 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1514 showGroupConservation.setSelected(true);
1515 showGroupConservation
1516 .setText(MessageManager.getString("label.conservation"));
1517 showNpTooltip.setEnabled(true);
1518 showNpTooltip.setFont(LABEL_FONT);
1519 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1520 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1521 showNpTooltip.setSelected(true);
1522 showNpTooltip.setText(
1523 MessageManager.getString("label.non_positional_features"));
1524 showDbRefTooltip.setEnabled(true);
1525 showDbRefTooltip.setFont(LABEL_FONT);
1526 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1527 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1528 showDbRefTooltip.setSelected(true);
1530 .setText(MessageManager.getString("label.database_references"));
1531 annotations.setFont(LABEL_FONT);
1532 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1533 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1534 annotations.setSelected(true);
1535 annotations.setText(MessageManager.getString("label.show_annotations"));
1536 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1537 annotations.addActionListener(new ActionListener()
1540 public void actionPerformed(ActionEvent e)
1542 annotations_actionPerformed(e);
1545 identity.addActionListener(new ActionListener()
1548 public void actionPerformed(ActionEvent e)
1550 annotations_actionPerformed(e);
1553 showGroupConsensus.addActionListener(new ActionListener()
1556 public void actionPerformed(ActionEvent e)
1558 annotations_actionPerformed(e);
1561 showUnconserved.setFont(LABEL_FONT);
1562 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1563 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1564 showUnconserved.setSelected(true);
1566 .setText(MessageManager.getString("action.show_unconserved"));
1567 showUnconserved.addActionListener(new ActionListener()
1570 public void actionPerformed(ActionEvent e)
1572 showunconserved_actionPerformed(e);
1576 // TODO these are not yet added to / action from Preferences
1577 // JCheckBox shareSelections = new JCheckBox();
1578 // shareSelections.setFont(verdana11);
1579 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1580 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1581 // shareSelections.setSelected(true);
1582 // shareSelections.setText(MessageManager
1583 // .getString("label.share_selection_across_views"));
1584 // JCheckBox followHighlight = new JCheckBox();
1585 // followHighlight.setFont(verdana11);
1586 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1587 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1588 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1589 // followHighlight.setSelected(true);
1590 // followHighlight.setText(MessageManager
1591 // .getString("label.scroll_highlighted_regions"));
1593 seqLimit.setFont(LABEL_FONT);
1594 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1595 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1596 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1597 smoothFont.setFont(LABEL_FONT);
1598 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1599 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1600 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1601 scaleProteinToCdna.setFont(LABEL_FONT);
1602 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1603 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1604 scaleProteinToCdna.setText(
1605 MessageManager.getString("label.scale_protein_to_cdna"));
1606 scaleProteinToCdna.setToolTipText(
1607 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1608 JLabel gapLabel = new JLabel();
1609 gapLabel.setFont(LABEL_FONT);
1610 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1611 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1612 JLabel fontLabel = new JLabel();
1613 fontLabel.setFont(LABEL_FONT);
1614 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1615 fontLabel.setText(MessageManager.getString("label.font"));
1616 fontSizeCB.setFont(LABEL_FONT);
1617 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1618 fontStyleCB.setFont(LABEL_FONT);
1619 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1620 fontNameCB.setFont(LABEL_FONT);
1621 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1622 gapSymbolCB.setFont(LABEL_FONT);
1623 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1624 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1625 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1626 gapSymbolCB.setRenderer(dlcr);
1628 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1629 startupCheckbox.setFont(LABEL_FONT);
1630 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1631 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1632 startupCheckbox.setSelected(true);
1633 startupFileTextfield.setFont(LABEL_FONT);
1634 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1635 final String tooltip = JvSwingUtils.wrapTooltip(true,
1636 MessageManager.getString("label.double_click_to_browse"));
1637 startupFileTextfield.setToolTipText(tooltip);
1638 startupFileTextfield.addMouseListener(new MouseAdapter()
1641 public void mouseClicked(MouseEvent e)
1643 if (e.getClickCount() > 1)
1645 startupFileTextfield_mouseClicked();
1650 sortby.setFont(LABEL_FONT);
1651 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1652 JLabel sortLabel = new JLabel();
1653 sortLabel.setFont(LABEL_FONT);
1654 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1655 sortLabel.setText(MessageManager.getString("label.sort_by"));
1656 sortAnnBy.setFont(LABEL_FONT);
1657 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1658 JLabel sortAnnLabel = new JLabel();
1659 sortAnnLabel.setFont(LABEL_FONT);
1660 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1661 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1662 sortAutocalc.setFont(LABEL_FONT);
1663 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1665 JPanel annsettingsPanel = new JPanel();
1666 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1667 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1668 annsettingsPanel.setBorder(new EtchedBorder());
1669 visualTab.add(annsettingsPanel);
1670 Border jb = new EmptyBorder(1, 1, 4, 5);
1671 annotations.setBorder(jb);
1672 showOccupancy.setBorder(jb);
1673 quality.setBorder(jb);
1674 conservation.setBorder(jb);
1675 identity.setBorder(jb);
1676 showConsensbits.setBorder(jb);
1677 showGroupbits.setBorder(jb);
1678 showGroupConsensus.setBorder(jb);
1679 showGroupConservation.setBorder(jb);
1680 showConsensHistogram.setBorder(jb);
1681 showConsensLogo.setBorder(jb);
1683 JPanel autoAnnotSettings = new JPanel();
1684 annsettingsPanel.add(autoAnnotSettings);
1685 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1686 autoAnnotSettings.add(annotations);
1687 autoAnnotSettings.add(quality);
1688 // second row of autoannotation box
1689 autoAnnotSettings = new JPanel();
1690 annsettingsPanel.add(autoAnnotSettings);
1692 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1693 autoAnnotSettings.add(conservation);
1694 autoAnnotSettings.add(identity);
1695 autoAnnotSettings.add(showOccupancy);
1696 autoAnnotSettings.add(showGroupbits);
1697 autoAnnotSettings.add(showGroupConservation);
1698 autoAnnotSettings.add(showGroupConsensus);
1699 autoAnnotSettings.add(showConsensbits);
1700 autoAnnotSettings.add(showConsensHistogram);
1701 autoAnnotSettings.add(showConsensLogo);
1703 JPanel tooltipSettings = new JPanel();
1704 tooltipSettings.setBorder(new TitledBorder(
1705 MessageManager.getString("label.sequence_id_tooltip")));
1706 tooltipSettings.setBounds(173, 140, 220, 62);
1707 tooltipSettings.setLayout(new GridLayout(2, 1));
1708 tooltipSettings.add(showDbRefTooltip);
1709 tooltipSettings.add(showNpTooltip);
1710 visualTab.add(tooltipSettings);
1712 wrap.setFont(LABEL_FONT);
1713 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1714 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1715 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1716 rightAlign.setFont(LABEL_FONT);
1717 rightAlign.setForeground(Color.black);
1718 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1719 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1720 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1721 idItalics.setFont(LABEL_FONT_ITALIC);
1722 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1723 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1725 MessageManager.getString("label.sequence_name_italics"));
1726 openoverv.setFont(LABEL_FONT);
1727 openoverv.setActionCommand(
1728 MessageManager.getString("label.open_overview"));
1729 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1730 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1731 openoverv.setText(MessageManager.getString("label.open_overview"));
1732 JPanel jPanel2 = new JPanel();
1733 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1734 jPanel2.setLayout(new GridLayout(14, 1));
1735 jPanel2.add(fullScreen);
1736 jPanel2.add(openoverv);
1737 jPanel2.add(seqLimit);
1738 jPanel2.add(rightAlign);
1739 jPanel2.add(fontLabel);
1740 jPanel2.add(showUnconserved);
1741 jPanel2.add(idItalics);
1742 jPanel2.add(smoothFont);
1743 jPanel2.add(scaleProteinToCdna);
1744 jPanel2.add(gapLabel);
1746 jPanel2.add(sortLabel);
1747 jPanel2.add(sortAnnLabel);
1748 jPanel2.add(startupCheckbox);
1749 visualTab.add(jPanel2);
1750 visualTab.add(startupFileTextfield);
1751 visualTab.add(sortby);
1752 visualTab.add(sortAnnBy);
1753 visualTab.add(sortAutocalc);
1754 visualTab.add(gapSymbolCB);
1755 visualTab.add(fontNameCB);
1756 visualTab.add(fontSizeCB);
1757 visualTab.add(fontStyleCB);
1759 if (Platform.isJS())
1761 startupCheckbox.setVisible(false);
1762 startupFileTextfield.setVisible(false);
1769 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1772 protected void loadLastSavedBackupsOptions()
1774 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1775 .getSavedBackupEntry();
1777 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1779 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1780 .createBackupFilesPresetEntry(Cache
1781 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1782 if (backupfilesCustomEntry == null)
1784 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1785 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1787 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1788 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1789 backupfilesCustomEntry);
1791 setComboIntStringKey(backupfilesPresetsCombo,
1792 Cache.getDefault(BackupFiles.NS + "_PRESET",
1793 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1795 backupsSetOptions(savedPreset);
1797 backupsOptionsSetEnabled();
1798 updateBackupFilesExampleLabel();
1801 private boolean warnAboutSuffixReverseChange()
1803 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1804 .getSavedBackupEntry();
1805 boolean savedSuffixReverse = bfpe.reverse;
1806 int savedSuffixDigits = bfpe.digits;
1807 String savedSuffixTemplate = bfpe.suffix;
1809 boolean nowSuffixReverse = suffixReverse.isSelected();
1810 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1811 String nowSuffixTemplate = suffixTemplate.getText();
1812 return nowSuffixReverse != savedSuffixReverse
1813 && nowSuffixDigits == savedSuffixDigits
1814 && nowSuffixTemplate != null
1815 && nowSuffixTemplate.equals(savedSuffixTemplate);
1819 * Initialises the Backups tabbed panel.
1823 private JPanel initBackupsTab()
1825 JPanel backupsTab = new JPanel();
1826 backupsTab.setBorder(new TitledBorder(
1827 MessageManager.getString("label.backup_files")));
1828 backupsTab.setLayout(new GridBagLayout());
1830 GridBagConstraints gbc = new GridBagConstraints();
1833 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1834 gbc.fill = GridBagConstraints.NONE;
1836 initBackupsTabPresetsPanel();
1837 initBackupsTabSuffixPanel();
1838 initBackupsTabKeepFilesPanel();
1839 initBackupsTabFilenameExamplesPanel();
1841 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1843 .setText(MessageManager.getString("label.enable_backupfiles"));
1844 enableBackupFiles.addActionListener(new ActionListener()
1847 public void actionPerformed(ActionEvent e)
1849 // enable other options only when the first is checked
1850 backupsOptionsSetEnabled();
1855 // enable checkbox 1 col
1859 gbc.gridy = 0; // row 0
1860 backupsTab.add(enableBackupFiles, gbc);
1862 // summary of scheme box (over two rows)
1866 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1867 gbc.fill = GridBagConstraints.BOTH;
1868 backupsTab.add(exampleFilesPanel, gbc);
1870 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1871 gbc.fill = GridBagConstraints.NONE;
1873 // fill empty space on right
1876 backupsTab.add(new JPanel(), gbc);
1881 gbc.gridy++; // row 1
1882 backupsTab.add(presetsPanel, gbc);
1884 // now using whole row
1889 gbc.gridy++; // row 2
1890 backupsTab.add(keepfilesPanel, gbc);
1892 // filename strategy box
1893 gbc.gridy++; // row 3
1894 backupsTab.add(suffixPanel, gbc);
1897 gbc.gridy++; // row 4
1899 backupsTab.add(new JPanel(), gbc);
1901 backupsOptionsSetEnabled();
1905 private JPanel initBackupsTabPresetsPanel()
1908 String title = MessageManager.getString("label.schemes");
1910 presetsPanel.setLayout(new GridBagLayout());
1912 GridBagConstraints gbc = new GridBagConstraints();
1915 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1916 gbc.fill = GridBagConstraints.NONE;
1924 presetsComboLabel = new JLabel(title + ":");
1925 presetsPanel.add(presetsComboLabel, gbc);
1927 List<Object> entries = Arrays
1928 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
1929 List<String> tooltips = Arrays.asList(
1930 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
1931 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
1934 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1936 backupfilesPresetsCombo
1937 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1941 backupfilesPresetsCombo.addActionListener(new ActionListener()
1944 public void actionPerformed(ActionEvent e)
1946 int key = getComboIntStringKey(backupfilesPresetsCombo);
1947 if (!customiseCheckbox.isSelected())
1949 backupfilesPresetsComboLastSelected = key;
1951 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1953 if (customiseCheckbox.isSelected())
1955 // got here by clicking on customiseCheckbox so don't change the values
1956 backupfilesCustomOptionsSetEnabled();
1960 backupsTabUpdatePresets();
1961 backupfilesCustomOptionsSetEnabled();
1966 customiseCheckbox.setSelected(false);
1967 backupsTabUpdatePresets();
1968 backupfilesCustomOptionsSetEnabled();
1973 // dropdown list of preset schemes
1975 presetsPanel.add(backupfilesPresetsCombo, gbc);
1977 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1978 revertButton.setToolTipText(
1979 MessageManager.getString("label.cancel_changes_description"));
1980 revertButton.addActionListener(new ActionListener()
1983 public void actionPerformed(ActionEvent e)
1986 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
1987 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
1988 backupfilesCustomOptionsSetEnabled();
1992 revertButton.setFont(LABEL_FONT);
1994 customiseCheckbox.setFont(LABEL_FONT);
1995 customiseCheckbox.setText(MessageManager.getString("label.customise"));
1996 customiseCheckbox.addActionListener(new ActionListener()
1999 public void actionPerformed(ActionEvent e)
2001 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2002 if (customiseCheckbox.isSelected())
2004 backupfilesPresetsComboLastSelected = currently;
2005 setComboIntStringKey(backupfilesPresetsCombo,
2006 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2010 setComboIntStringKey(backupfilesPresetsCombo,
2011 backupfilesPresetsComboLastSelected);
2014 backupfilesCustomOptionsSetEnabled();
2017 customiseCheckbox.setToolTipText(
2018 MessageManager.getString("label.customise_description"));
2020 // customise checkbox
2023 presetsPanel.add(customiseCheckbox, gbc);
2025 // "Cancel changes" button (aligned with combo box above)
2027 presetsPanel.add(revertButton, gbc);
2029 return presetsPanel;
2032 private JPanel initBackupsTabFilenameExamplesPanel()
2034 String title = MessageManager
2035 .getString("label.scheme_examples");
2036 TitledBorder tb = new TitledBorder(title);
2037 exampleFilesPanel.setBorder(tb);
2038 exampleFilesPanel.setLayout(new GridBagLayout());
2041 backupfilesExampleLabel.setEditable(false);
2042 backupfilesExampleLabel
2043 .setBackground(exampleFilesPanel.getBackground());
2045 updateBackupFilesExampleLabel();
2047 GridBagConstraints gbc = new GridBagConstraints();
2050 gbc.fill = GridBagConstraints.NONE;
2051 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2053 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2054 return exampleFilesPanel;
2057 private void backupsTabUpdatePresets()
2059 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2062 String value = entry.v;
2064 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2068 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2074 "Preset '" + value + "' [key:" + key + "] not implemented");
2077 // Custom options will now be enabled when the customiseCheckbox is checked
2078 // (performed above)
2079 // backupfilesCustomOptionsSetEnabled();
2080 updateBackupFilesExampleLabel();
2083 protected int getComboIntStringKey(
2084 JComboBox<Object> backupfilesPresetsCombo2)
2086 IntKeyStringValueEntry e;
2089 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2091 } catch (Exception ex)
2094 "Problem casting Combo entry to IntKeyStringValueEntry.");
2097 return e != null ? e.k : 0;
2100 protected void setComboIntStringKey(
2101 JComboBox<Object> backupfilesPresetsCombo2,
2104 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2106 IntKeyStringValueEntry e;
2109 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2110 } catch (Exception ex)
2113 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2118 backupfilesPresetsCombo2.setSelectedIndex(i);
2122 // backupsTabUpdatePresets();
2125 private JPanel initBackupsTabSuffixPanel()
2127 suffixPanel.setBorder(new TitledBorder(
2128 MessageManager.getString("label.backup_filename_strategy")));
2129 suffixPanel.setLayout(new GridBagLayout());
2132 .setText(MessageManager.getString("label.append_to_filename"));
2133 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2134 suffixTemplateLabel.setFont(LABEL_FONT);
2136 final String tooltip = JvSwingUtils.wrapTooltip(true,
2137 MessageManager.getString("label.append_to_filename_tooltip"));
2138 suffixTemplate.setToolTipText(tooltip);
2139 suffixTemplate.addActionListener(new ActionListener()
2142 public void actionPerformed(ActionEvent e)
2144 updateBackupFilesExampleLabel();
2145 backupfilesCustomOptionsSetEnabled();
2146 backupfilesRevertButtonSetEnabled(true);
2150 suffixTemplate.addKeyListener(new KeyListener()
2153 public void keyReleased(KeyEvent e)
2155 updateBackupFilesExampleLabel();
2156 backupfilesCustomOptionsSetEnabled();
2157 backupfilesRevertButtonSetEnabled(true);
2161 public void keyPressed(KeyEvent e)
2165 // disable use of ':' or '/' or '\'
2167 public void keyTyped(KeyEvent e)
2169 char c = e.getKeyChar();
2170 if (c == ':' || c == '/' || c == '\\')
2172 // don't process ':' or '/' or '\'
2181 .setText(MessageManager.getString("label.index_digits"));
2182 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2183 suffixDigitsLabel.setFont(LABEL_FONT);
2184 ChangeListener c = new ChangeListener()
2187 public void stateChanged(ChangeEvent e)
2189 backupfilesRevertButtonSetEnabled(true);
2190 updateBackupFilesExampleLabel();
2194 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2195 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2197 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2198 MessageManager.getString("label.increment_index"));
2199 suffixReverse.addActionListener(new ActionListener()
2202 public void actionPerformed(ActionEvent e)
2204 boolean okay = true;
2205 if (warnAboutSuffixReverseChange())
2208 okay = confirmSuffixReverseChange();
2212 backupfilesRevertButtonSetEnabled(true);
2213 updateBackupFilesExampleLabel();
2217 boolean savedSuffixReverse = BackupFilesPresetEntry
2218 .getSavedBackupEntry().reverse;
2219 suffixReverse.setSelected(savedSuffixReverse);
2224 GridBagConstraints sgbc = new GridBagConstraints();
2226 // first row (template text box)
2227 sgbc.anchor = GridBagConstraints.WEST;
2231 sgbc.gridheight = 1;
2234 sgbc.fill = GridBagConstraints.NONE;
2235 suffixPanel.add(suffixTemplateLabel, sgbc);
2238 sgbc.fill = GridBagConstraints.HORIZONTAL;
2239 suffixPanel.add(suffixTemplate, sgbc);
2241 // second row (number of digits spinner)
2245 sgbc.fill = GridBagConstraints.NONE;
2246 suffixPanel.add(suffixDigitsLabel, sgbc);
2249 sgbc.fill = GridBagConstraints.HORIZONTAL;
2250 suffixPanel.add(suffixDigitsSpinner, sgbc);
2252 // third row (forward order radio selection)
2255 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2256 sgbc.fill = GridBagConstraints.HORIZONTAL;
2257 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2259 // fourth row (reverse order radio selection)
2261 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2265 private boolean confirmSuffixReverseChange()
2267 boolean ret = false;
2268 String warningMessage = MessageManager
2269 .getString("label.warning_confirm_change_reverse");
2270 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2272 MessageManager.getString("label.change_increment_decrement"),
2273 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2275 ret = (confirm == JvOptionPane.YES_OPTION);
2279 private JPanel initBackupsTabKeepFilesPanel()
2281 keepfilesPanel.setBorder(
2282 new TitledBorder(MessageManager.getString("label.keep_files")));
2283 keepfilesPanel.setLayout(new GridBagLayout());
2285 backupfilesKeepAll.setLabels(
2286 MessageManager.getString("label.keep_all_backup_files"),
2287 MessageManager.getString(
2288 "label.keep_only_this_number_of_backup_files"));
2289 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2292 public void actionPerformed(ActionEvent e)
2294 backupfilesRevertButtonSetEnabled(true);
2295 updateBackupFilesExampleLabel();
2298 backupfilesKeepAll.addActionListener(new ActionListener()
2301 public void actionPerformed(ActionEvent e)
2303 backupfilesRevertButtonSetEnabled(true);
2304 keepRollMaxOptionsEnabled();
2305 updateBackupFilesExampleLabel();
2309 ChangeListener c = new ChangeListener()
2312 public void stateChanged(ChangeEvent e)
2314 backupfilesRevertButtonSetEnabled(true);
2315 updateBackupFilesExampleLabel();
2319 setIntegerSpinner(backupfilesRollMaxSpinner,
2320 BackupFilesPresetEntry.ROLLMAXMIN,
2321 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2323 backupfilesConfirmDelete.setLabels(
2324 MessageManager.getString("label.always_ask"),
2325 MessageManager.getString("label.auto_delete"));
2326 backupfilesConfirmDelete.addActionListener(new ActionListener()
2329 public void actionPerformed(ActionEvent e)
2331 backupfilesRevertButtonSetEnabled(true);
2334 // update the enabled section
2335 keepRollMaxOptionsEnabled();
2337 GridBagConstraints kgbc = new GridBagConstraints();
2339 // first row (template text box)
2340 kgbc.anchor = GridBagConstraints.WEST;
2343 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2344 kgbc.gridheight = 1;
2347 kgbc.fill = GridBagConstraints.HORIZONTAL;
2348 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2354 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2355 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2358 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2359 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2361 // third row (indented)
2363 kgbc.insets = new Insets(0, 20, 0, 0);
2366 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2367 kgbc.fill = GridBagConstraints.HORIZONTAL;
2370 JPanel jp = new JPanel();
2371 jp.setLayout(new FlowLayout());
2373 .setText(MessageManager
2374 .getString("label.autodelete_old_backup_files"));
2375 oldBackupFilesLabel.setFont(LABEL_FONT);
2376 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2377 jp.add(oldBackupFilesLabel);
2378 jp.add(backupfilesConfirmDelete.getTrueButton());
2379 jp.add(backupfilesConfirmDelete.getFalseButton());
2380 keepfilesPanel.add(jp, kgbc);
2382 return keepfilesPanel;
2385 protected void updateBackupFilesExampleLabel()
2387 int exampleindex = 12;
2388 String base = MessageManager.getString("label.filename") + ".fa";
2389 if (base == null || base.length() == 0)
2391 base = "file_name.fa";
2394 boolean reverse = suffixReverse.isSelected();
2395 boolean keepAll = backupfilesKeepAll.isSelected();
2397 String suffix = suffixTemplate.getText();
2400 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2401 if (suffix == null || suffix.length() == 0)
2403 backupfilesExampleLabel
2404 .setText(MessageManager.getString("label.no_backup_files"));
2405 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2409 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2410 rollMax = rollMax < 1 ? 1 : rollMax;
2412 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2417 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2418 digits = digits < 1 ? 1 : digits;
2420 int lowersurround = 2;
2421 int uppersurround = 0;
2422 StringBuilder exampleSB = new StringBuilder();
2423 boolean firstLine = true;
2429 int max = keepAll ? exampleindex : rollMax;
2430 for (int index = min; index <= max; index++)
2432 if (index == min + lowersurround && index < max - uppersurround - 1)
2434 exampleSB.append("\n...");
2437 else if (index > min + lowersurround && index < max - uppersurround)
2449 exampleSB.append("\n");
2452 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2453 base, suffix, digits));
2456 // no extra text needed
2458 else if (index == min)
2460 String newest = MessageManager.getString("label.braced_newest");
2461 if (newest != null && newest.length() > 0)
2463 exampleSB.append(" " + newest);
2466 else if (index == max)
2468 String oldest = MessageManager.getString("label.braced_oldest");
2469 if (oldest != null && oldest.length() > 0)
2471 exampleSB.append(" " + oldest);
2480 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2481 : exampleindex - rollMax + 1;
2482 int max = exampleindex;
2484 for (int index = min; index <= max; index++)
2487 if (index == min + lowersurround && index < max - uppersurround - 1)
2489 exampleSB.append("\n...");
2492 else if (index > min + lowersurround && index < max - uppersurround)
2504 exampleSB.append("\n");
2507 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2508 base, suffix, digits));
2511 // no extra text needed
2513 else if (index == min)
2515 String oldest = MessageManager.getString("label.braced_oldest");
2516 if (oldest != null && oldest.length() > 0)
2518 exampleSB.append(" " + oldest);
2521 else if (index == max)
2523 String newest = MessageManager.getString("label.braced_newest");
2524 if (newest != null && newest.length() > 0)
2526 exampleSB.append(" " + newest);
2534 // add some extra empty lines to pad out the example files box. ugh, please tell
2535 // me how to do this better
2536 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2537 if (remainingLines > 0)
2539 for (int i = 0; i < remainingLines; i++)
2541 exampleSB.append("\n ");
2546 backupfilesExampleLabel.setText(exampleSB.toString());
2549 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2550 boolean useExistingVal, ChangeListener c)
2557 i = ((Integer) s.getValue()).intValue();
2558 } catch (Exception e)
2561 "Exception casting the initial value of s.getValue()");
2565 setIntegerSpinner(s, min, max, i, c);
2568 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2571 // integer spinner for number of digits
2580 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2583 s.addChangeListener(c);
2587 protected static int getSpinnerInt(JSpinner s, int def)
2593 i = (Integer) s.getValue();
2594 } catch (Exception e)
2596 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2601 private void keepRollMaxOptionsEnabled()
2603 boolean enabled = backupfilesKeepAll.isEnabled()
2604 && !backupfilesKeepAll.isSelected();
2605 oldBackupFilesLabel.setEnabled(enabled);
2606 backupfilesRollMaxSpinner.setEnabled(enabled);
2607 backupfilesConfirmDelete.setEnabled(enabled);
2610 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2612 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2613 && customiseCheckbox.isSelected()
2614 && suffixTemplate.getText()
2615 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2616 keepfilesPanel.setEnabled(enabled);
2617 backupfilesKeepAll.setEnabled(enabled);
2618 oldBackupFilesLabel.setEnabled(enabled);
2619 keepRollMaxOptionsEnabled();
2622 private void backupfilesSuffixTemplateDigitsSetEnabled()
2624 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2625 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2626 suffixDigitsLabel.setEnabled(enabled);
2627 suffixDigitsSpinner.setEnabled(enabled);
2628 suffixReverse.setEnabled(enabled);
2631 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2633 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2634 && customiseCheckbox.isSelected();
2635 suffixPanel.setEnabled(enabled);
2636 suffixTemplateLabel.setEnabled(enabled);
2637 suffixTemplate.setEnabled(enabled);
2638 backupfilesSuffixTemplateDigitsSetEnabled();
2641 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2643 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2644 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2645 revertButton.setEnabled(enabled);
2648 private boolean backupfilesCustomChanged()
2650 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2651 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2652 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2653 return !custom.equals(current);
2656 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2658 String suffix = suffixTemplate.getText();
2659 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2660 boolean reverse = suffixReverse.isSelected();
2661 boolean keepAll = backupfilesKeepAll.isSelected();
2662 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2663 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2665 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2666 reverse, keepAll, rollMax, confirmDelete);
2671 protected void backupfilesCustomOptionsSetEnabled()
2673 boolean enabled = customiseCheckbox.isSelected();
2675 backupfilesRevertButtonSetEnabled(enabled);
2676 backupfilesSuffixTemplateSetEnabled(enabled);
2677 backupfilesKeepAllSetEnabled(enabled);
2680 private void backupfilesSummarySetEnabled()
2682 boolean enabled = enableBackupFiles.isSelected();
2683 backupfilesExampleLabel.setEnabled(enabled);
2684 exampleFilesPanel.setEnabled(enabled);
2687 private void backupfilesPresetsSetEnabled()
2689 boolean enabled = enableBackupFiles.isSelected();
2690 presetsPanel.setEnabled(enabled);
2691 presetsComboLabel.setEnabled(enabled);
2692 backupfilesPresetsCombo.setEnabled(enabled);
2693 customiseCheckbox.setEnabled(enabled);
2694 revertButton.setEnabled(enabled);
2697 protected void backupsOptionsSetEnabled()
2699 backupfilesPresetsSetEnabled();
2700 backupfilesSummarySetEnabled();
2701 backupfilesCustomOptionsSetEnabled();
2704 protected void backupsSetOptions(String suffix, int digits,
2705 boolean reverse, boolean keepAll, int rollMax,
2706 boolean confirmDelete)
2708 suffixTemplate.setText(suffix);
2709 suffixDigitsSpinner.setValue(digits);
2710 suffixReverse.setSelected(reverse);
2711 backupfilesKeepAll.setSelected(keepAll);
2712 backupfilesRollMaxSpinner.setValue(rollMax);
2713 backupfilesConfirmDelete.setSelected(confirmDelete);
2716 protected void backupsSetOptions(BackupFilesPresetEntry p)
2718 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2722 protected void autoIdWidth_actionPerformed()
2724 // TODO Auto-generated method stub
2728 protected void userIdWidth_actionPerformed()
2730 // TODO Auto-generated method stub
2734 protected void maxColour_actionPerformed(JPanel panel)
2738 protected void minColour_actionPerformed(JPanel panel)
2742 protected void gapColour_actionPerformed(JPanel panel)
2746 protected void hiddenColour_actionPerformed(JPanel panel)
2750 protected void showunconserved_actionPerformed(ActionEvent e)
2752 // TODO Auto-generated method stub
2756 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2760 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2770 public void ok_actionPerformed(ActionEvent e)
2780 public void cancel_actionPerformed(ActionEvent e)
2790 public void annotations_actionPerformed(ActionEvent e)
2797 public void startupFileTextfield_mouseClicked()
2801 public void newLink_actionPerformed(ActionEvent e)
2806 public void editLink_actionPerformed(ActionEvent e)
2811 public void deleteLink_actionPerformed(ActionEvent e)
2816 public void defaultBrowser_mouseClicked(MouseEvent e)
2821 public void linkURLList_keyTyped(KeyEvent e)
2826 public void useProxy_actionPerformed()
2828 boolean enabled = useProxy.isSelected();
2829 portLabel.setEnabled(enabled);
2830 serverLabel.setEnabled(enabled);
2831 proxyServerTB.setEnabled(enabled);
2832 proxyPortTB.setEnabled(enabled);
2836 * Customer renderer for JTable: supports column of radio buttons
2838 public class RadioButtonRenderer extends JRadioButton
2839 implements TableCellRenderer
2841 public RadioButtonRenderer()
2843 setHorizontalAlignment(CENTER);
2844 setToolTipText(MessageManager.getString("label.urltooltip"));
2848 public Component getTableCellRendererComponent(JTable table,
2849 Object value, boolean isSelected, boolean hasFocus, int row,
2852 setSelected((boolean) value);
2854 // set colours to match rest of table
2857 setBackground(table.getSelectionBackground());
2858 setForeground(table.getSelectionForeground());
2862 setBackground(table.getBackground());
2863 setForeground(table.getForeground());
2870 * Customer cell editor for JTable: supports column of radio buttons in
2871 * conjunction with renderer
2873 public class RadioButtonEditor extends AbstractCellEditor
2874 implements TableCellEditor
2876 private JRadioButton button = new JRadioButton();
2878 public RadioButtonEditor()
2880 button.setHorizontalAlignment(SwingConstants.CENTER);
2881 this.button.addActionListener(new ActionListener()
2884 public void actionPerformed(ActionEvent e)
2886 fireEditingStopped();
2892 public Component getTableCellEditorComponent(JTable table, Object value,
2893 boolean isSelected, int row, int column)
2895 button.setSelected((boolean) value);
2900 public Object getCellEditorValue()
2902 return button.isSelected();