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.JalviewBooleanRadioButtons;
28 import jalview.gui.JvSwingUtils;
29 import jalview.gui.StructureViewer.ViewerType;
30 import jalview.io.BackupFilenameParts;
31 import jalview.io.BackupFiles;
32 import jalview.util.MessageManager;
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Component;
37 import java.awt.Dimension;
38 import java.awt.FlowLayout;
40 import java.awt.GridBagConstraints;
41 import java.awt.GridBagLayout;
42 import java.awt.GridLayout;
43 import java.awt.Insets;
44 import java.awt.Rectangle;
45 import java.awt.event.ActionEvent;
46 import java.awt.event.ActionListener;
47 import java.awt.event.FocusEvent;
48 import java.awt.event.KeyEvent;
49 import java.awt.event.KeyListener;
50 import java.awt.event.MouseAdapter;
51 import java.awt.event.MouseEvent;
52 import java.util.HashMap;
55 import javax.swing.AbstractCellEditor;
56 import javax.swing.BorderFactory;
57 import javax.swing.ButtonGroup;
58 import javax.swing.DefaultListCellRenderer;
59 import javax.swing.JButton;
60 import javax.swing.JCheckBox;
61 import javax.swing.JComboBox;
62 import javax.swing.JFileChooser;
63 import javax.swing.JLabel;
64 import javax.swing.JList;
65 import javax.swing.JPanel;
66 import javax.swing.JRadioButton;
67 import javax.swing.JScrollPane;
68 import javax.swing.JSpinner;
69 import javax.swing.JTabbedPane;
70 import javax.swing.JTable;
71 import javax.swing.JTextArea;
72 import javax.swing.JTextField;
73 import javax.swing.ListSelectionModel;
74 import javax.swing.SpinnerModel;
75 import javax.swing.SpinnerNumberModel;
76 import javax.swing.SwingConstants;
77 import javax.swing.border.Border;
78 import javax.swing.border.EmptyBorder;
79 import javax.swing.border.EtchedBorder;
80 import javax.swing.border.TitledBorder;
81 import javax.swing.event.ChangeEvent;
82 import javax.swing.event.ChangeListener;
83 import javax.swing.table.TableCellEditor;
84 import javax.swing.table.TableCellRenderer;
87 * Base class for the Preferences panel.
92 public class GPreferences extends JPanel
94 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
96 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
97 .getLabelFont(false, true);
99 private static final Font LABEL_FONT_BOLD = JvSwingUtils
100 .getLabelFont(true, false);
103 * Visual tab components
105 protected JCheckBox fullScreen = new JCheckBox();
107 protected JCheckBox openoverv = new JCheckBox();
109 protected JCheckBox seqLimit = new JCheckBox();
111 protected JCheckBox rightAlign = new JCheckBox();
113 protected JComboBox<String> fontSizeCB = new JComboBox<>();
115 protected JComboBox<String> fontStyleCB = new JComboBox<>();
117 protected JComboBox<String> fontNameCB = new JComboBox<>();
119 protected JCheckBox showOccupancy = new JCheckBox();
121 protected JCheckBox showUnconserved = new JCheckBox();
123 protected JCheckBox idItalics = new JCheckBox();
125 protected JCheckBox smoothFont = new JCheckBox();
127 protected JCheckBox scaleProteinToCdna = new JCheckBox();
129 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
131 protected JCheckBox wrap = new JCheckBox();
133 protected JComboBox<String> sortby = new JComboBox<>();
135 protected JComboBox<String> sortAnnBy = new JComboBox<>();
137 protected JComboBox<String> sortAutocalc = new JComboBox<>();
139 protected JCheckBox startupCheckbox = new JCheckBox();
141 protected JTextField startupFileTextfield = new JTextField();
143 // below are in the 'second column'
144 protected JCheckBox annotations = new JCheckBox();
146 protected JCheckBox quality = new JCheckBox();
148 protected JCheckBox conservation = new JCheckBox();
150 protected JCheckBox identity = new JCheckBox();
152 protected JCheckBox showGroupConsensus = new JCheckBox();
154 protected JCheckBox showGroupConservation = new JCheckBox();
156 protected JCheckBox showConsensHistogram = new JCheckBox();
158 protected JCheckBox showConsensLogo = new JCheckBox();
160 protected JCheckBox showDbRefTooltip = new JCheckBox();
162 protected JCheckBox showNpTooltip = new JCheckBox();
165 * Structure tab and components
167 protected JPanel structureTab;
169 protected JCheckBox structFromPdb = new JCheckBox();
171 protected JCheckBox useRnaView = new JCheckBox();
173 protected JCheckBox addSecondaryStructure = new JCheckBox();
175 protected JCheckBox addTempFactor = new JCheckBox();
177 protected JComboBox<String> structViewer = new JComboBox<>();
179 protected JTextField chimeraPath = new JTextField();
181 protected ButtonGroup mappingMethod = new ButtonGroup();
183 protected JRadioButton siftsMapping = new JRadioButton();
185 protected JRadioButton nwMapping = new JRadioButton();
188 * Colours tab components
190 protected JPanel minColour = new JPanel();
192 protected JPanel maxColour = new JPanel();
194 protected JComboBox<String> protColour = new JComboBox<>();
196 protected JComboBox<String> nucColour = new JComboBox<>();
199 * Overview tab components
201 protected JPanel gapColour = new JPanel();
203 protected JPanel hiddenColour = new JPanel();
205 protected JCheckBox useLegacyGap;
207 protected JCheckBox showHiddenAtStart;
209 protected JLabel gapLabel;
212 * Connections tab components
214 protected JTable linkUrlTable = new JTable();
216 protected JButton editLink = new JButton();
218 protected JButton deleteLink = new JButton();
220 protected JTextField filterTB = new JTextField();
222 protected JButton doReset = new JButton();
224 protected JButton userOnly = new JButton();
226 protected JLabel portLabel = new JLabel();
228 protected JLabel serverLabel = new JLabel();
230 protected JTextField proxyServerTB = new JTextField();
232 protected JTextField proxyPortTB = new JTextField();
234 protected JTextField defaultBrowser = new JTextField();
236 protected JCheckBox useProxy = new JCheckBox();
238 protected JCheckBox usagestats = new JCheckBox();
240 protected JCheckBox questionnaire = new JCheckBox();
242 protected JCheckBox versioncheck = new JCheckBox();
245 * Output tab components
247 protected JComboBox<Object> epsRendering = new JComboBox<>();
249 protected JLabel userIdWidthlabel = new JLabel();
251 protected JCheckBox autoIdWidth = new JCheckBox();
253 protected JTextField userIdWidth = new JTextField();
255 protected JCheckBox blcjv = new JCheckBox();
257 protected JCheckBox pileupjv = new JCheckBox();
259 protected JCheckBox clustaljv = new JCheckBox();
261 protected JCheckBox msfjv = new JCheckBox();
263 protected JCheckBox fastajv = new JCheckBox();
265 protected JCheckBox pfamjv = new JCheckBox();
267 protected JCheckBox pirjv = new JCheckBox();
269 protected JCheckBox modellerOutput = new JCheckBox();
271 protected JCheckBox embbedBioJSON = new JCheckBox();
274 * Editing tab components
276 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
278 protected JCheckBox padGaps = new JCheckBox();
280 protected JCheckBox sortByTree = new JCheckBox();
285 protected JPanel wsTab = new JPanel();
288 * Backups tab components
289 * a lot of these are member variables instead of local variables only so that they
290 * can be enabled/disabled easily in one go
293 protected JCheckBox enableBackupFiles = new JCheckBox();
295 protected JPanel presetsPanel = new JPanel();
297 protected JButton revertButton = new JButton();
299 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
301 protected JPanel suffixPanel = new JPanel();
303 protected JPanel keepfilesPanel = new JPanel();
305 protected JPanel exampleFilesPanel = new JPanel();
307 protected JTextField suffixTemplate = new JTextField(null, 8);
309 protected JLabel suffixTemplateLabel = new JLabel();
311 protected JLabel suffixDigitsLabel = new JLabel();
313 protected JSpinner suffixDigitsSpinner = new JSpinner();
315 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
317 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
319 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
321 protected JLabel oldBackupFilesLabel = new JLabel();
323 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
325 protected JTextArea backupfilesExampleLabel = new JTextArea();
328 * Creates a new GPreferences object.
330 public GPreferences()
335 } catch (Exception ex)
337 ex.printStackTrace();
342 * Construct the panel and its tabbed sub-panels.
346 private void jbInit() throws Exception
348 final JTabbedPane tabbedPane = new JTabbedPane();
349 this.setLayout(new BorderLayout());
350 JPanel okCancelPanel = initOkCancelPanel();
351 this.add(tabbedPane, BorderLayout.CENTER);
352 this.add(okCancelPanel, BorderLayout.SOUTH);
354 tabbedPane.add(initVisualTab(),
355 MessageManager.getString("label.visual"));
357 tabbedPane.add(initColoursTab(),
358 MessageManager.getString("label.colours"));
360 tabbedPane.add(initOverviewTab(),
361 MessageManager.getString("label.overview"));
363 tabbedPane.add(initStructureTab(),
364 MessageManager.getString("label.structure"));
366 tabbedPane.add(initConnectionsTab(),
367 MessageManager.getString("label.connections"));
369 tabbedPane.add(initBackupsTab(),
370 MessageManager.getString("label.backups"));
372 tabbedPane.add(initLinksTab(),
373 MessageManager.getString("label.urllinks"));
375 tabbedPane.add(initOutputTab(),
376 MessageManager.getString("label.output"));
378 tabbedPane.add(initEditingTab(),
379 MessageManager.getString("label.editing"));
382 * See WsPreferences for the real work of configuring this tab.
384 wsTab.setLayout(new BorderLayout());
385 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
388 * Handler to validate a tab before leaving it - currently only for
391 tabbedPane.addChangeListener(new ChangeListener()
393 private Component lastTab;
396 public void stateChanged(ChangeEvent e)
398 if (lastTab == structureTab
399 && tabbedPane.getSelectedComponent() != structureTab)
401 if (!validateStructure())
403 tabbedPane.setSelectedComponent(structureTab);
407 lastTab = tabbedPane.getSelectedComponent();
414 * Initialises the Editing tabbed panel.
418 private JPanel initEditingTab()
420 JPanel editingTab = new JPanel();
421 editingTab.setLayout(null);
422 autoCalculateConsCheck.setFont(LABEL_FONT);
423 autoCalculateConsCheck.setText(
424 MessageManager.getString("label.autocalculate_consensus"));
425 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
426 padGaps.setFont(LABEL_FONT);
428 MessageManager.getString("label.pad_gaps_when_editing"));
429 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
430 sortByTree.setFont(LABEL_FONT);
432 .setText(MessageManager.getString("label.sort_with_new_tree"));
433 sortByTree.setToolTipText(MessageManager.getString(
434 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
435 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
436 editingTab.add(autoCalculateConsCheck);
437 editingTab.add(padGaps);
438 editingTab.add(sortByTree);
443 * Initialises the Output tabbed panel.
447 private JPanel initOutputTab()
449 JPanel outputTab = new JPanel();
450 outputTab.setLayout(null);
451 JLabel epsLabel = new JLabel();
452 epsLabel.setFont(LABEL_FONT);
453 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
454 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
455 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
456 epsRendering.setFont(LABEL_FONT);
457 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
458 JLabel jLabel1 = new JLabel();
459 jLabel1.setFont(LABEL_FONT);
460 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
461 jLabel1.setText(MessageManager.getString("label.append_start_end"));
462 jLabel1.setFont(LABEL_FONT);
463 fastajv.setFont(LABEL_FONT);
464 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
465 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
466 blcjv.setText(MessageManager.getString("label.blc") + " ");
467 fastajv.setText(MessageManager.getString("label.fasta") + " ");
468 msfjv.setText(MessageManager.getString("label.msf") + " ");
469 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
470 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
471 msfjv.setFont(LABEL_FONT);
472 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
473 pirjv.setText(MessageManager.getString("label.pir") + " ");
474 JPanel jPanel11 = new JPanel();
475 jPanel11.setFont(LABEL_FONT);
476 TitledBorder titledBorder2 = new TitledBorder(
477 MessageManager.getString("label.file_output"));
478 jPanel11.setBorder(titledBorder2);
479 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
480 GridLayout gridLayout3 = new GridLayout();
481 jPanel11.setLayout(gridLayout3);
482 gridLayout3.setRows(8);
483 blcjv.setFont(LABEL_FONT);
484 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
485 clustaljv.setFont(LABEL_FONT);
486 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
487 pfamjv.setFont(LABEL_FONT);
488 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
489 pileupjv.setFont(LABEL_FONT);
490 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
491 pirjv.setFont(LABEL_FONT);
492 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
493 autoIdWidth.setFont(LABEL_FONT);
495 MessageManager.getString("label.automatically_set_id_width"));
496 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
497 .getString("label.adjusts_width_generated_eps_png")));
498 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
499 autoIdWidth.addActionListener(new ActionListener()
503 public void actionPerformed(ActionEvent e)
505 autoIdWidth_actionPerformed();
508 userIdWidthlabel.setFont(LABEL_FONT);
509 userIdWidthlabel.setText(
510 MessageManager.getString("label.figure_id_column_width"));
511 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
512 .getString("label.manually_specify_width_left_column")));
513 userIdWidthlabel.setToolTipText(
514 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
515 "label.manually_specify_width_left_column")));
516 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
517 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
518 userIdWidth.setText("");
519 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
520 userIdWidth.addActionListener(new ActionListener()
524 public void actionPerformed(ActionEvent e)
526 userIdWidth_actionPerformed();
529 modellerOutput.setFont(LABEL_FONT);
531 .setText(MessageManager.getString("label.use_modeller_output"));
532 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
533 embbedBioJSON.setFont(LABEL_FONT);
534 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
535 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
537 TitledBorder backupFilesBorder = new TitledBorder(
538 MessageManager.getString("label.backup_files"));
540 jPanel11.add(jLabel1);
542 jPanel11.add(clustaljv);
543 jPanel11.add(fastajv);
545 jPanel11.add(pfamjv);
546 jPanel11.add(pileupjv);
548 outputTab.add(autoIdWidth);
549 outputTab.add(userIdWidth);
550 outputTab.add(userIdWidthlabel);
551 outputTab.add(modellerOutput);
552 outputTab.add(embbedBioJSON);
553 outputTab.add(epsLabel);
554 outputTab.add(epsRendering);
555 outputTab.add(jPanel11);
560 * Initialises the Connections tabbed panel.
564 private JPanel initConnectionsTab()
566 JPanel connectTab = new JPanel();
567 connectTab.setLayout(new GridBagLayout());
569 // Label for browser text box
570 JLabel browserLabel = new JLabel();
571 browserLabel.setFont(LABEL_FONT);
572 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
573 browserLabel.setText(
574 MessageManager.getString("label.default_browser_unix"));
575 defaultBrowser.setFont(LABEL_FONT);
576 defaultBrowser.setText("");
577 final String tooltip = JvSwingUtils.wrapTooltip(true,
578 MessageManager.getString("label.double_click_to_browse"));
579 defaultBrowser.setToolTipText(tooltip);
580 defaultBrowser.addMouseListener(new MouseAdapter()
583 public void mouseClicked(MouseEvent e)
585 if (e.getClickCount() > 1)
587 defaultBrowser_mouseClicked(e);
592 JPanel proxyPanel = initConnTabProxyPanel();
593 initConnTabCheckboxes();
595 // Add default Browser text box
596 connectTab.add(browserLabel,
597 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
598 GridBagConstraints.WEST, GridBagConstraints.NONE,
599 new Insets(10, 0, 5, 5), 5, 1));
600 defaultBrowser.setFont(LABEL_FONT);
601 defaultBrowser.setText("");
603 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
604 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
605 new Insets(10, 0, 5, 10), 30, 1));
607 // Add proxy server panel
608 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
609 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
610 new Insets(10, 0, 5, 12), 4, 10));
612 // Add usage stats, version check and questionnaire checkboxes
613 connectTab.add(usagestats,
614 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
615 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
616 new Insets(0, 2, 5, 5), 70, 1));
617 connectTab.add(questionnaire,
618 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
619 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
620 new Insets(0, 2, 5, 10), 70, 1));
621 connectTab.add(versioncheck,
622 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
623 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
624 new Insets(0, 2, 5, 5), 70, 1));
626 // Add padding so the panel doesn't look ridiculous
627 JPanel spacePanel = new JPanel();
628 connectTab.add(spacePanel,
629 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
630 GridBagConstraints.WEST, GridBagConstraints.BOTH,
631 new Insets(0, 0, 0, 5), 70, 1));
637 * Initialises the Links tabbed panel.
641 private JPanel initLinksTab()
643 JPanel linkTab = new JPanel();
644 linkTab.setLayout(new GridBagLayout());
646 // Set up table for Url links
647 linkUrlTable.setFillsViewportHeight(true);
648 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
649 linkUrlTable.setAutoCreateRowSorter(true);
650 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
652 // adjust row height so radio buttons actually fit
653 // don't do this in the renderer, it causes the awt thread to activate
655 JRadioButton temp = new JRadioButton();
656 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
658 // Table in scrollpane so that the table is given a scrollbar
659 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
660 linkScrollPane.setBorder(null);
662 // Panel for links functionality
663 JPanel linkPanel = new JPanel(new GridBagLayout());
664 linkPanel.setBorder(new TitledBorder(
665 MessageManager.getString("label.url_linkfrom_sequence_id")));
667 // Put the Url links panel together
669 // Buttons go at top right, resizing only resizes the blank space vertically
670 JPanel buttonPanel = initLinkTabUrlButtons();
671 GridBagConstraints linkConstraints1 = new GridBagConstraints();
672 linkConstraints1.insets = new Insets(0, 0, 5, 0);
673 linkConstraints1.gridx = 0;
674 linkConstraints1.gridy = 0;
675 linkConstraints1.weightx = 1.0;
676 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
677 linkTab.add(buttonPanel, linkConstraints1);
679 // Links table goes at top left, resizing resizes the table
680 GridBagConstraints linkConstraints2 = new GridBagConstraints();
681 linkConstraints2.insets = new Insets(0, 0, 5, 5);
682 linkConstraints2.gridx = 0;
683 linkConstraints2.gridy = 1;
684 linkConstraints2.weightx = 1.0;
685 linkConstraints2.weighty = 1.0;
686 linkConstraints2.fill = GridBagConstraints.BOTH;
687 linkTab.add(linkScrollPane, linkConstraints2);
689 // Filter box and buttons goes at bottom left, resizing resizes the text box
690 JPanel filterPanel = initLinkTabFilterPanel();
691 GridBagConstraints linkConstraints3 = new GridBagConstraints();
692 linkConstraints3.insets = new Insets(0, 0, 0, 5);
693 linkConstraints3.gridx = 0;
694 linkConstraints3.gridy = 2;
695 linkConstraints3.weightx = 1.0;
696 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
697 linkTab.add(filterPanel, linkConstraints3);
702 private JPanel initLinkTabFilterPanel()
704 // Filter textbox and reset button
705 JLabel filterLabel = new JLabel(
706 MessageManager.getString("label.filter"));
707 filterLabel.setFont(LABEL_FONT);
708 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
709 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
711 filterTB.setFont(LABEL_FONT);
712 filterTB.setText("");
714 doReset.setText(MessageManager.getString("action.showall"));
715 userOnly.setText(MessageManager.getString("action.customfilter"));
717 // Panel for filter functionality
718 JPanel filterPanel = new JPanel(new GridBagLayout());
719 filterPanel.setBorder(new TitledBorder("Filter"));
720 GridBagConstraints gbc = new GridBagConstraints();
723 gbc.fill = GridBagConstraints.NONE;
724 gbc.anchor = GridBagConstraints.WEST;
726 filterPanel.add(filterLabel, gbc);
728 GridBagConstraints gbc1 = new GridBagConstraints();
731 gbc1.fill = GridBagConstraints.HORIZONTAL;
732 gbc1.anchor = GridBagConstraints.WEST;
734 filterPanel.add(filterTB, gbc1);
736 GridBagConstraints gbc2 = new GridBagConstraints();
738 gbc2.fill = GridBagConstraints.NONE;
739 gbc2.anchor = GridBagConstraints.WEST;
740 filterPanel.add(doReset, gbc2);
742 GridBagConstraints gbc3 = new GridBagConstraints();
744 gbc3.fill = GridBagConstraints.NONE;
745 gbc3.anchor = GridBagConstraints.WEST;
746 filterPanel.add(userOnly, gbc3);
751 private JPanel initLinkTabUrlButtons()
753 // Buttons for new / edit / delete Url links
754 JButton newLink = new JButton();
755 newLink.setText(MessageManager.getString("action.new"));
757 editLink.setText(MessageManager.getString("action.edit"));
759 deleteLink.setText(MessageManager.getString("action.delete"));
761 // no current selection, so initially disable delete/edit buttons
762 editLink.setEnabled(false);
763 deleteLink.setEnabled(false);
765 newLink.addActionListener(new java.awt.event.ActionListener()
768 public void actionPerformed(ActionEvent e)
770 newLink_actionPerformed(e);
774 editLink.setText(MessageManager.getString("action.edit"));
775 editLink.addActionListener(new java.awt.event.ActionListener()
778 public void actionPerformed(ActionEvent e)
780 editLink_actionPerformed(e);
784 deleteLink.setText(MessageManager.getString("action.delete"));
785 deleteLink.addActionListener(new java.awt.event.ActionListener()
788 public void actionPerformed(ActionEvent e)
790 deleteLink_actionPerformed(e);
794 JPanel buttonPanel = new JPanel(new GridBagLayout());
795 buttonPanel.setBorder(new TitledBorder("Edit links"));
796 GridBagConstraints gbc = new GridBagConstraints();
799 gbc.fill = GridBagConstraints.NONE;
800 buttonPanel.add(newLink, gbc);
802 GridBagConstraints gbc1 = new GridBagConstraints();
805 gbc1.fill = GridBagConstraints.NONE;
806 buttonPanel.add(editLink, gbc1);
808 GridBagConstraints gbc2 = new GridBagConstraints();
811 gbc2.fill = GridBagConstraints.NONE;
812 buttonPanel.add(deleteLink, gbc2);
814 GridBagConstraints gbc3 = new GridBagConstraints();
817 gbc3.fill = GridBagConstraints.HORIZONTAL;
819 JPanel spacePanel = new JPanel();
820 spacePanel.setBorder(null);
821 buttonPanel.add(spacePanel, gbc3);
827 * Initialises the proxy server panel in the Connections tab
829 * @return the proxy server panel
831 private JPanel initConnTabProxyPanel()
833 // Label for server text box
834 serverLabel.setText(MessageManager.getString("label.address"));
835 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
836 serverLabel.setFont(LABEL_FONT);
838 // Proxy server and port text boxes
839 proxyServerTB.setFont(LABEL_FONT);
840 proxyPortTB.setFont(LABEL_FONT);
842 // Label for Port text box
843 portLabel.setFont(LABEL_FONT);
844 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
845 portLabel.setText(MessageManager.getString("label.port"));
847 // Use proxy server checkbox
848 useProxy.setFont(LABEL_FONT);
849 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
850 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
851 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
852 useProxy.addActionListener(new ActionListener()
855 public void actionPerformed(ActionEvent e)
857 useProxy_actionPerformed();
861 // Make proxy server panel
862 JPanel proxyPanel = new JPanel();
863 TitledBorder titledBorder1 = new TitledBorder(
864 MessageManager.getString("label.proxy_server"));
865 proxyPanel.setBorder(titledBorder1);
866 proxyPanel.setLayout(new GridBagLayout());
867 proxyPanel.add(serverLabel,
868 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
869 GridBagConstraints.WEST, GridBagConstraints.NONE,
870 new Insets(0, 2, 2, 0), 5, 0));
871 proxyPanel.add(portLabel,
872 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
873 GridBagConstraints.WEST, GridBagConstraints.NONE,
874 new Insets(0, 0, 2, 0), 11, 0));
875 proxyPanel.add(useProxy,
876 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
877 GridBagConstraints.WEST, GridBagConstraints.NONE,
878 new Insets(0, 2, 5, 185), 2, -4));
879 proxyPanel.add(proxyPortTB,
880 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
881 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
882 new Insets(0, 2, 2, 2), 54, 1));
883 proxyPanel.add(proxyServerTB,
884 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
885 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
886 new Insets(0, 2, 2, 0), 263, 1));
892 * Initialises the checkboxes in the Connections tab
894 private void initConnTabCheckboxes()
896 // Usage stats checkbox label
898 MessageManager.getString("label.send_usage_statistics"));
899 usagestats.setFont(LABEL_FONT);
900 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
901 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
903 // Questionnaire checkbox label
904 questionnaire.setText(
905 MessageManager.getString("label.check_for_questionnaires"));
906 questionnaire.setFont(LABEL_FONT);
907 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
908 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
910 // Check for latest version checkbox label
911 versioncheck.setText(
912 MessageManager.getString("label.check_for_latest_version"));
913 versioncheck.setFont(LABEL_FONT);
914 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
915 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
919 * Initialises the parent panel which contains the tabbed sections.
923 private JPanel initOkCancelPanel()
925 JButton ok = new JButton();
926 ok.setText(MessageManager.getString("action.ok"));
927 ok.addActionListener(new ActionListener()
930 public void actionPerformed(ActionEvent e)
932 ok_actionPerformed(e);
935 JButton cancel = new JButton();
936 cancel.setText(MessageManager.getString("action.cancel"));
937 cancel.addActionListener(new ActionListener()
940 public void actionPerformed(ActionEvent e)
942 cancel_actionPerformed(e);
945 JPanel okCancelPanel = new JPanel();
946 okCancelPanel.add(ok);
947 okCancelPanel.add(cancel);
948 return okCancelPanel;
952 * Initialises the Colours tabbed panel.
956 private JPanel initColoursTab()
958 JPanel coloursTab = new JPanel();
959 coloursTab.setBorder(new TitledBorder(
960 MessageManager.getString("action.open_new_alignment")));
961 coloursTab.setLayout(new FlowLayout());
962 JLabel mincolourLabel = new JLabel();
963 mincolourLabel.setFont(LABEL_FONT);
964 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
965 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
966 minColour.setFont(LABEL_FONT);
967 minColour.setBorder(BorderFactory.createEtchedBorder());
968 minColour.setPreferredSize(new Dimension(40, 20));
969 minColour.addMouseListener(new MouseAdapter()
972 public void mousePressed(MouseEvent e)
974 minColour_actionPerformed(minColour);
977 JLabel maxcolourLabel = new JLabel();
978 maxcolourLabel.setFont(LABEL_FONT);
979 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
980 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
981 maxColour.setFont(LABEL_FONT);
982 maxColour.setBorder(BorderFactory.createEtchedBorder());
983 maxColour.setPreferredSize(new Dimension(40, 20));
984 maxColour.addMouseListener(new MouseAdapter()
987 public void mousePressed(MouseEvent e)
989 maxColour_actionPerformed(maxColour);
993 protColour.setFont(LABEL_FONT);
994 protColour.setBounds(new Rectangle(172, 225, 155, 21));
995 JLabel protColourLabel = new JLabel();
996 protColourLabel.setFont(LABEL_FONT);
997 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
998 protColourLabel.setText(
999 MessageManager.getString("label.prot_alignment_colour") + " ");
1000 JvSwingUtils.addtoLayout(coloursTab,
1002 .getString("label.default_colour_scheme_for_alignment"),
1003 protColourLabel, protColour);
1005 nucColour.setFont(LABEL_FONT);
1006 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1007 JLabel nucColourLabel = new JLabel();
1008 nucColourLabel.setFont(LABEL_FONT);
1009 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1010 nucColourLabel.setText(
1011 MessageManager.getString("label.nuc_alignment_colour") + " ");
1012 JvSwingUtils.addtoLayout(coloursTab,
1014 .getString("label.default_colour_scheme_for_alignment"),
1015 nucColourLabel, nucColour);
1017 JPanel annotationShding = new JPanel();
1018 annotationShding.setBorder(new TitledBorder(
1019 MessageManager.getString("label.annotation_shading_default")));
1020 annotationShding.setLayout(new GridLayout(1, 2));
1021 JvSwingUtils.addtoLayout(annotationShding,
1022 MessageManager.getString(
1023 "label.default_minimum_colour_annotation_shading"),
1024 mincolourLabel, minColour);
1025 JvSwingUtils.addtoLayout(annotationShding,
1026 MessageManager.getString(
1027 "label.default_maximum_colour_annotation_shading"),
1028 maxcolourLabel, maxColour);
1029 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1034 * Initialises the Overview tabbed panel.
1038 private JPanel initOverviewTab()
1040 JPanel overviewPanel = new JPanel();
1041 overviewPanel.setBorder(new TitledBorder(
1042 MessageManager.getString("label.overview_settings")));
1044 gapColour.setFont(LABEL_FONT);
1045 // fixing the border colours stops apparent colour bleed from the panel
1046 gapColour.setBorder(
1047 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1048 gapColour.setPreferredSize(new Dimension(40, 20));
1049 gapColour.addMouseListener(new MouseAdapter()
1052 public void mousePressed(MouseEvent e)
1054 gapColour_actionPerformed(gapColour);
1058 hiddenColour.setFont(LABEL_FONT);
1059 // fixing the border colours stops apparent colour bleed from the panel
1060 hiddenColour.setBorder(
1061 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1062 hiddenColour.setPreferredSize(new Dimension(40, 20));
1063 hiddenColour.addMouseListener(new MouseAdapter()
1066 public void mousePressed(MouseEvent e)
1068 hiddenColour_actionPerformed(hiddenColour);
1072 useLegacyGap = new JCheckBox(
1073 MessageManager.getString("label.ov_legacy_gap"));
1074 useLegacyGap.setFont(LABEL_FONT);
1075 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1076 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1077 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1078 gapLabel.setFont(LABEL_FONT);
1079 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1080 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1081 showHiddenAtStart = new JCheckBox(
1082 MessageManager.getString("label.ov_show_hide_default"));
1083 showHiddenAtStart.setFont(LABEL_FONT);
1084 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1085 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1086 JLabel hiddenLabel = new JLabel(
1087 MessageManager.getString("label.hidden_colour"));
1088 hiddenLabel.setFont(LABEL_FONT);
1089 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1090 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1092 useLegacyGap.addActionListener(new ActionListener()
1095 public void actionPerformed(ActionEvent e)
1097 useLegacyGaps_actionPerformed(e);
1101 overviewPanel.setLayout(new GridBagLayout());
1102 GridBagConstraints c1 = new GridBagConstraints();
1104 c1.fill = GridBagConstraints.HORIZONTAL;
1109 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1110 overviewPanel.add(useLegacyGap, c1);
1112 GridBagConstraints c2 = new GridBagConstraints();
1113 c2.fill = GridBagConstraints.HORIZONTAL;
1116 c2.insets = new Insets(0, 15, 0, 10);
1117 overviewPanel.add(gapLabel, c2);
1119 GridBagConstraints c3 = new GridBagConstraints();
1120 c3.fill = GridBagConstraints.HORIZONTAL;
1123 c3.insets = new Insets(0, 0, 0, 15);
1124 overviewPanel.add(gapColour, c3);
1126 GridBagConstraints c4 = new GridBagConstraints();
1127 c4.fill = GridBagConstraints.HORIZONTAL;
1131 overviewPanel.add(showHiddenAtStart, c4);
1133 GridBagConstraints c5 = new GridBagConstraints();
1134 c5.fill = GridBagConstraints.HORIZONTAL;
1137 c5.insets = new Insets(0, 15, 0, 10);
1138 overviewPanel.add(hiddenLabel, c5);
1140 GridBagConstraints c6 = new GridBagConstraints();
1141 c6.fill = GridBagConstraints.HORIZONTAL;
1144 c6.insets = new Insets(0, 0, 0, 15);
1145 overviewPanel.add(hiddenColour, c6);
1147 JButton resetButton = new JButton(
1148 MessageManager.getString("label.reset_to_defaults"));
1150 resetButton.addActionListener(new ActionListener()
1153 public void actionPerformed(ActionEvent e)
1155 resetOvDefaults_actionPerformed(e);
1159 GridBagConstraints c7 = new GridBagConstraints();
1160 c7.fill = GridBagConstraints.NONE;
1163 c7.insets = new Insets(10, 0, 0, 0);
1164 c7.anchor = GridBagConstraints.WEST;
1165 overviewPanel.add(resetButton, c7);
1167 // Add padding so the panel doesn't look ridiculous
1168 JPanel spacePanel = new JPanel();
1169 overviewPanel.add(spacePanel,
1170 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1171 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1172 new Insets(0, 0, 0, 5), 0, 0));
1174 return overviewPanel;
1178 * Initialises the Structure tabbed panel.
1182 private JPanel initStructureTab()
1184 structureTab = new JPanel();
1186 structureTab.setBorder(new TitledBorder(
1187 MessageManager.getString("label.structure_options")));
1188 structureTab.setLayout(null);
1189 final int width = 400;
1190 final int height = 22;
1191 final int lineSpacing = 25;
1194 structFromPdb.setFont(LABEL_FONT);
1196 .setText(MessageManager.getString("label.struct_from_pdb"));
1197 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1198 structFromPdb.addActionListener(new ActionListener()
1201 public void actionPerformed(ActionEvent e)
1203 boolean selected = structFromPdb.isSelected();
1204 // enable other options only when the first is checked
1205 useRnaView.setEnabled(selected);
1206 addSecondaryStructure.setEnabled(selected);
1207 addTempFactor.setEnabled(selected);
1210 structureTab.add(structFromPdb);
1212 // indent checkboxes that are conditional on the first one
1213 ypos += lineSpacing;
1214 useRnaView.setFont(LABEL_FONT);
1215 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1216 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1217 structureTab.add(useRnaView);
1219 ypos += lineSpacing;
1220 addSecondaryStructure.setFont(LABEL_FONT);
1221 addSecondaryStructure
1222 .setText(MessageManager.getString("label.autoadd_secstr"));
1223 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1224 structureTab.add(addSecondaryStructure);
1226 ypos += lineSpacing;
1227 addTempFactor.setFont(LABEL_FONT);
1228 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1229 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1230 structureTab.add(addTempFactor);
1232 ypos += lineSpacing;
1233 JLabel viewerLabel = new JLabel();
1234 viewerLabel.setFont(LABEL_FONT);
1235 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1236 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1237 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1238 structureTab.add(viewerLabel);
1240 structViewer.setFont(LABEL_FONT);
1241 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1242 structViewer.addItem(ViewerType.JMOL.name());
1243 structViewer.addItem(ViewerType.CHIMERA.name());
1244 structViewer.addActionListener(new ActionListener()
1247 public void actionPerformed(ActionEvent e)
1249 structureViewer_actionPerformed(
1250 (String) structViewer.getSelectedItem());
1253 structureTab.add(structViewer);
1255 ypos += lineSpacing;
1256 JLabel pathLabel = new JLabel();
1257 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1258 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1259 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1260 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1261 structureTab.add(pathLabel);
1263 chimeraPath.setFont(LABEL_FONT);
1264 chimeraPath.setText("");
1265 final String tooltip = JvSwingUtils.wrapTooltip(true,
1266 MessageManager.getString("label.chimera_path_tip"));
1267 chimeraPath.setToolTipText(tooltip);
1268 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1269 chimeraPath.addMouseListener(new MouseAdapter()
1272 public void mouseClicked(MouseEvent e)
1274 if (e.getClickCount() == 2)
1276 String chosen = openFileChooser();
1279 chimeraPath.setText(chosen);
1284 structureTab.add(chimeraPath);
1286 ypos += lineSpacing;
1287 nwMapping.setFont(LABEL_FONT);
1288 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1289 siftsMapping.setFont(LABEL_FONT);
1290 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1291 mappingMethod.add(nwMapping);
1292 mappingMethod.add(siftsMapping);
1293 JPanel mappingPanel = new JPanel();
1294 mappingPanel.setFont(LABEL_FONT);
1295 TitledBorder mmTitledBorder = new TitledBorder(
1296 MessageManager.getString("label.mapping_method"));
1297 mmTitledBorder.setTitleFont(LABEL_FONT);
1298 mappingPanel.setBorder(mmTitledBorder);
1299 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1300 // GridLayout mappingLayout = new GridLayout();
1301 mappingPanel.setLayout(new GridLayout());
1302 mappingPanel.add(nwMapping);
1303 mappingPanel.add(siftsMapping);
1304 structureTab.add(mappingPanel);
1306 ypos += lineSpacing;
1307 ypos += lineSpacing;
1308 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1309 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1310 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1311 structureTab.add(docFieldPref);
1313 return structureTab;
1317 * Action on choosing a structure viewer from combobox options.
1319 * @param selectedItem
1321 protected void structureViewer_actionPerformed(String selectedItem)
1326 * Show a dialog for the user to choose a file. Returns the chosen path, or
1331 protected String openFileChooser()
1333 String choice = null;
1334 JFileChooser chooser = new JFileChooser();
1336 // chooser.setFileView(new JalviewFileView());
1337 chooser.setDialogTitle(
1338 MessageManager.getString("label.open_local_file"));
1339 chooser.setToolTipText(MessageManager.getString("action.open"));
1341 int value = chooser.showOpenDialog(this);
1343 if (value == JFileChooser.APPROVE_OPTION)
1345 choice = chooser.getSelectedFile().getPath();
1351 * Validate the structure tab preferences; if invalid, set focus on this tab.
1355 protected boolean validateStructure(FocusEvent e)
1357 if (!validateStructure())
1359 e.getComponent().requestFocusInWindow();
1365 protected boolean validateStructure()
1371 * Initialises the Visual tabbed panel.
1375 private JPanel initVisualTab()
1377 JPanel visualTab = new JPanel();
1378 visualTab.setBorder(new TitledBorder(
1379 MessageManager.getString("action.open_new_alignment")));
1380 visualTab.setLayout(null);
1381 fullScreen.setFont(LABEL_FONT);
1382 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1383 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1384 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1385 quality.setEnabled(false);
1386 quality.setFont(LABEL_FONT);
1387 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1388 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1389 quality.setSelected(true);
1390 quality.setText(MessageManager.getString("label.quality"));
1391 conservation.setEnabled(false);
1392 conservation.setFont(LABEL_FONT);
1393 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1394 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1395 conservation.setSelected(true);
1396 conservation.setText(MessageManager.getString("label.conservation"));
1397 identity.setEnabled(false);
1398 identity.setFont(LABEL_FONT);
1399 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1400 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1401 identity.setSelected(true);
1402 identity.setText(MessageManager.getString("label.consensus"));
1403 showOccupancy.setFont(LABEL_FONT);
1404 showOccupancy.setEnabled(false);
1405 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1406 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1407 showOccupancy.setSelected(true);
1408 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1410 JLabel showGroupbits = new JLabel();
1411 showGroupbits.setFont(LABEL_FONT);
1412 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1413 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1415 .setText(MessageManager.getString("action.show_group") + ":");
1416 JLabel showConsensbits = new JLabel();
1417 showConsensbits.setFont(LABEL_FONT);
1418 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1419 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1421 .setText(MessageManager.getString("label.consensus") + ":");
1422 showConsensHistogram.setEnabled(false);
1423 showConsensHistogram.setFont(LABEL_FONT);
1424 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1425 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1426 showConsensHistogram.setSelected(true);
1427 showConsensHistogram
1428 .setText(MessageManager.getString("label.histogram"));
1429 showConsensLogo.setEnabled(false);
1430 showConsensLogo.setFont(LABEL_FONT);
1431 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1432 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1433 showConsensLogo.setSelected(true);
1434 showConsensLogo.setText(MessageManager.getString("label.logo"));
1435 showGroupConsensus.setEnabled(false);
1436 showGroupConsensus.setFont(LABEL_FONT);
1437 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1438 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1439 showGroupConsensus.setSelected(true);
1440 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1441 showGroupConservation.setEnabled(false);
1442 showGroupConservation.setFont(LABEL_FONT);
1443 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1444 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1445 showGroupConservation.setSelected(true);
1446 showGroupConservation
1447 .setText(MessageManager.getString("label.conservation"));
1448 showNpTooltip.setEnabled(true);
1449 showNpTooltip.setFont(LABEL_FONT);
1450 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1451 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1452 showNpTooltip.setSelected(true);
1453 showNpTooltip.setText(
1454 MessageManager.getString("label.non_positional_features"));
1455 showDbRefTooltip.setEnabled(true);
1456 showDbRefTooltip.setFont(LABEL_FONT);
1457 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1458 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1459 showDbRefTooltip.setSelected(true);
1461 .setText(MessageManager.getString("label.database_references"));
1462 annotations.setFont(LABEL_FONT);
1463 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1464 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1465 annotations.setSelected(true);
1466 annotations.setText(MessageManager.getString("label.show_annotations"));
1467 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1468 annotations.addActionListener(new ActionListener()
1471 public void actionPerformed(ActionEvent e)
1473 annotations_actionPerformed(e);
1476 identity.addActionListener(new ActionListener()
1479 public void actionPerformed(ActionEvent e)
1481 annotations_actionPerformed(e);
1484 showGroupConsensus.addActionListener(new ActionListener()
1487 public void actionPerformed(ActionEvent e)
1489 annotations_actionPerformed(e);
1492 showUnconserved.setFont(LABEL_FONT);
1493 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1494 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1495 showUnconserved.setSelected(true);
1497 .setText(MessageManager.getString("action.show_unconserved"));
1498 showUnconserved.addActionListener(new ActionListener()
1501 public void actionPerformed(ActionEvent e)
1503 showunconserved_actionPerformed(e);
1507 // TODO these are not yet added to / action from Preferences
1508 // JCheckBox shareSelections = new JCheckBox();
1509 // shareSelections.setFont(verdana11);
1510 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1511 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1512 // shareSelections.setSelected(true);
1513 // shareSelections.setText(MessageManager
1514 // .getString("label.share_selection_across_views"));
1515 // JCheckBox followHighlight = new JCheckBox();
1516 // followHighlight.setFont(verdana11);
1517 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1518 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1519 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1520 // followHighlight.setSelected(true);
1521 // followHighlight.setText(MessageManager
1522 // .getString("label.scroll_highlighted_regions"));
1524 seqLimit.setFont(LABEL_FONT);
1525 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1526 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1527 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1528 smoothFont.setFont(LABEL_FONT);
1529 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1530 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1531 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1532 scaleProteinToCdna.setFont(LABEL_FONT);
1533 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1534 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1535 scaleProteinToCdna.setText(
1536 MessageManager.getString("label.scale_protein_to_cdna"));
1537 scaleProteinToCdna.setToolTipText(
1538 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1539 JLabel gapLabel = new JLabel();
1540 gapLabel.setFont(LABEL_FONT);
1541 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1542 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1543 JLabel fontLabel = new JLabel();
1544 fontLabel.setFont(LABEL_FONT);
1545 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1546 fontLabel.setText(MessageManager.getString("label.font"));
1547 fontSizeCB.setFont(LABEL_FONT);
1548 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1549 fontStyleCB.setFont(LABEL_FONT);
1550 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1551 fontNameCB.setFont(LABEL_FONT);
1552 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1553 gapSymbolCB.setFont(LABEL_FONT);
1554 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1555 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1556 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1557 gapSymbolCB.setRenderer(dlcr);
1559 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1560 startupCheckbox.setFont(LABEL_FONT);
1561 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1562 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1563 startupCheckbox.setSelected(true);
1564 startupFileTextfield.setFont(LABEL_FONT);
1565 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1566 final String tooltip = JvSwingUtils.wrapTooltip(true,
1567 MessageManager.getString("label.double_click_to_browse"));
1568 startupFileTextfield.setToolTipText(tooltip);
1569 startupFileTextfield.addMouseListener(new MouseAdapter()
1572 public void mouseClicked(MouseEvent e)
1574 if (e.getClickCount() > 1)
1576 startupFileTextfield_mouseClicked();
1581 sortby.setFont(LABEL_FONT);
1582 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1583 JLabel sortLabel = new JLabel();
1584 sortLabel.setFont(LABEL_FONT);
1585 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1586 sortLabel.setText(MessageManager.getString("label.sort_by"));
1587 sortAnnBy.setFont(LABEL_FONT);
1588 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1589 JLabel sortAnnLabel = new JLabel();
1590 sortAnnLabel.setFont(LABEL_FONT);
1591 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1592 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1593 sortAutocalc.setFont(LABEL_FONT);
1594 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1596 JPanel annsettingsPanel = new JPanel();
1597 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1598 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1599 annsettingsPanel.setBorder(new EtchedBorder());
1600 visualTab.add(annsettingsPanel);
1601 Border jb = new EmptyBorder(1, 1, 4, 5);
1602 annotations.setBorder(jb);
1603 showOccupancy.setBorder(jb);
1604 quality.setBorder(jb);
1605 conservation.setBorder(jb);
1606 identity.setBorder(jb);
1607 showConsensbits.setBorder(jb);
1608 showGroupbits.setBorder(jb);
1609 showGroupConsensus.setBorder(jb);
1610 showGroupConservation.setBorder(jb);
1611 showConsensHistogram.setBorder(jb);
1612 showConsensLogo.setBorder(jb);
1614 JPanel autoAnnotSettings = new JPanel();
1615 annsettingsPanel.add(autoAnnotSettings);
1616 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1617 autoAnnotSettings.add(annotations);
1618 autoAnnotSettings.add(quality);
1619 // second row of autoannotation box
1620 autoAnnotSettings = new JPanel();
1621 annsettingsPanel.add(autoAnnotSettings);
1623 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1624 autoAnnotSettings.add(conservation);
1625 autoAnnotSettings.add(identity);
1626 autoAnnotSettings.add(showOccupancy);
1627 autoAnnotSettings.add(showGroupbits);
1628 autoAnnotSettings.add(showGroupConservation);
1629 autoAnnotSettings.add(showGroupConsensus);
1630 autoAnnotSettings.add(showConsensbits);
1631 autoAnnotSettings.add(showConsensHistogram);
1632 autoAnnotSettings.add(showConsensLogo);
1634 JPanel tooltipSettings = new JPanel();
1635 tooltipSettings.setBorder(new TitledBorder(
1636 MessageManager.getString("label.sequence_id_tooltip")));
1637 tooltipSettings.setBounds(173, 140, 220, 62);
1638 tooltipSettings.setLayout(new GridLayout(2, 1));
1639 tooltipSettings.add(showDbRefTooltip);
1640 tooltipSettings.add(showNpTooltip);
1641 visualTab.add(tooltipSettings);
1643 wrap.setFont(LABEL_FONT);
1644 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1645 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1646 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1647 rightAlign.setFont(LABEL_FONT);
1648 rightAlign.setForeground(Color.black);
1649 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1650 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1651 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1652 idItalics.setFont(LABEL_FONT_ITALIC);
1653 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1654 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1656 MessageManager.getString("label.sequence_name_italics"));
1657 openoverv.setFont(LABEL_FONT);
1658 openoverv.setActionCommand(
1659 MessageManager.getString("label.open_overview"));
1660 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1661 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1662 openoverv.setText(MessageManager.getString("label.open_overview"));
1663 JPanel jPanel2 = new JPanel();
1664 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1665 jPanel2.setLayout(new GridLayout(14, 1));
1666 jPanel2.add(fullScreen);
1667 jPanel2.add(openoverv);
1668 jPanel2.add(seqLimit);
1669 jPanel2.add(rightAlign);
1670 jPanel2.add(fontLabel);
1671 jPanel2.add(showUnconserved);
1672 jPanel2.add(idItalics);
1673 jPanel2.add(smoothFont);
1674 jPanel2.add(scaleProteinToCdna);
1675 jPanel2.add(gapLabel);
1677 jPanel2.add(sortLabel);
1678 jPanel2.add(sortAnnLabel);
1679 jPanel2.add(startupCheckbox);
1680 visualTab.add(jPanel2);
1681 visualTab.add(startupFileTextfield);
1682 visualTab.add(sortby);
1683 visualTab.add(sortAnnBy);
1684 visualTab.add(sortAutocalc);
1685 visualTab.add(gapSymbolCB);
1686 visualTab.add(fontNameCB);
1687 visualTab.add(fontSizeCB);
1688 visualTab.add(fontStyleCB);
1693 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1696 protected void loadLastSavedBackupsOptions()
1699 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1700 setComboIntStringKey(backupfilesPresetsCombo,
1701 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1702 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1703 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1705 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1706 suffixReverse.setSelected(
1707 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1709 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1710 backupfilesRollMaxSpinner
1711 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1712 backupfilesConfirmDelete.setSelected(
1713 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1715 backupsOptionsSetEnabled();
1716 updateBackupFilesExampleLabel();
1720 * Initialises the Backups tabbed panel.
1724 private JPanel initBackupsTab()
1726 JPanel backupsTab = new JPanel();
1727 backupsTab.setBorder(new TitledBorder(
1728 MessageManager.getString("label.backup_files")));
1729 backupsTab.setLayout(new GridBagLayout());
1731 GridBagConstraints gbc = new GridBagConstraints();
1734 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1735 gbc.fill = GridBagConstraints.NONE;
1737 initBackupsTabPresetsPanel();
1738 initBackupsTabSuffixPanel();
1739 initBackupsTabKeepFilesPanel();
1740 initBackupsTabFilenameExamplesPanel();
1742 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1744 .setText(MessageManager.getString("label.enable_backupfiles"));
1745 enableBackupFiles.addActionListener(new ActionListener()
1748 public void actionPerformed(ActionEvent e)
1750 boolean selected = enableBackupFiles.isSelected();
1751 // enable other options only when the first is checked
1752 backupsOptionsSetEnabled();
1757 // enable checkbox 1 col
1761 gbc.gridy = 0; // row 0
1762 backupsTab.add(enableBackupFiles, gbc);
1764 // summary of scheme box (over two rows)
1768 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1769 gbc.fill = GridBagConstraints.BOTH;
1770 backupsTab.add(exampleFilesPanel, gbc);
1772 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1773 gbc.fill = GridBagConstraints.NONE;
1775 // fill empty space on right
1778 backupsTab.add(new JPanel(), gbc);
1783 gbc.gridy++; // row 1
1784 backupsTab.add(presetsPanel, gbc);
1786 // gbc.anchor = GridBagConstraints.NORTHWEST;
1787 // now using whole row
1792 gbc.gridy++; // row 2
1793 backupsTab.add(keepfilesPanel, gbc);
1795 // filename strategy box
1796 gbc.gridy++; // row 3
1797 backupsTab.add(suffixPanel, gbc);
1800 gbc.gridy++; // row 4
1802 backupsTab.add(new JPanel(), gbc);
1804 backupsOptionsSetEnabled();
1808 private final int BACKUPFILESSCHEMECUSTOMISE = 0;
1809 private final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1810 new IntKeyStringValueEntry(1,
1811 MessageManager.getString("label.default")),
1812 new IntKeyStringValueEntry(2,
1813 MessageManager.getString("label.single_file")),
1814 new IntKeyStringValueEntry(3,
1815 MessageManager.getString("label.keep_all_versions")),
1816 new IntKeyStringValueEntry(4,
1817 MessageManager.getString("label.rolled_backups")),
1819 // new IntKeyStringValueEntry(255,
1820 // MessageManager.getString("label.previously_saved_scheme")),
1821 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1822 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1823 MessageManager.getString("label.customise")) };
1825 private final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1828 put(1, new BackupFilesPresetEntry(
1829 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1831 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1832 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1833 3, false, true, 10, true));
1834 put(4, new BackupFilesPresetEntry(
1835 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1840 private JPanel initBackupsTabPresetsPanel()
1843 String title = MessageManager.getString("label.schemes");
1844 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1845 // TitledBorder tb = new TitledBorder(title);
1846 // tb.setTitleFont(LABEL_FONT);
1847 // presetsPanel.setBorder(tb);
1849 presetsPanel.setLayout(new GridBagLayout());
1851 GridBagConstraints gbc = new GridBagConstraints();
1854 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1855 gbc.fill = GridBagConstraints.NONE;
1862 presetsPanel.add(new JLabel(title + ":"), gbc);
1864 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1866 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1869 // put "Previously saved scheme" item in italics (it's not really
1870 // selectable, as such -- it deselects itself when selected) and
1871 // "Customise" in bold
1872 backupfilesPresetsCombo
1873 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1874 backupfilesPresetsCombo.addActionListener(new ActionListener()
1877 public void actionPerformed(ActionEvent e)
1879 backupsTabUpdatePresets();
1883 // dropdown list of preset schemes
1885 presetsPanel.add(backupfilesPresetsCombo, gbc);
1887 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1888 revertButton.addActionListener(new ActionListener()
1891 public void actionPerformed(ActionEvent e)
1893 loadLastSavedBackupsOptions();
1897 revertButton.setFont(LABEL_FONT);
1899 // "Cancel changes" button (aligned with combo box above)
1902 presetsPanel.add(revertButton, gbc);
1904 return presetsPanel;
1907 private JPanel initBackupsTabFilenameExamplesPanel()
1909 String title = MessageManager
1910 .getString("label.summary_of_backups_scheme");
1911 TitledBorder tb = new TitledBorder(title);
1912 exampleFilesPanel.setBorder(tb);
1913 exampleFilesPanel.setLayout(new GridBagLayout());
1916 backupfilesExampleLabel.setEditable(false);
1917 backupfilesExampleLabel
1918 .setBackground(exampleFilesPanel.getBackground());
1920 updateBackupFilesExampleLabel();
1922 GridBagConstraints gbc = new GridBagConstraints();
1925 gbc.fill = GridBagConstraints.NONE;
1926 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1928 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1929 return exampleFilesPanel;
1932 private void backupsTabUpdatePresets()
1934 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1936 int key = entry.getKey();
1937 String value = entry.getValue();
1939 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
1940 if (key != BACKUPFILESSCHEMECUSTOMISE)
1942 if (backupfilesPresetEntriesValues.containsKey(key))
1944 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
1948 System.out.println("Preset '" + value + "' not implemented");
1952 backupfilesCustomOptionsSetEnabled();
1953 updateBackupFilesExampleLabel();
1956 protected int getComboIntStringKey(JComboBox c)
1958 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
1959 return e != null ? e.getKey() : 0;
1962 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
1965 for (int i = 0; i < c.getItemCount(); i++)
1967 IntKeyStringValueEntry e = c.getItemAt(i);
1969 String v = e.getValue();
1970 if (e.getKey() == key)
1972 c.setSelectedIndex(i);
1976 backupsTabUpdatePresets();
1979 private JPanel initBackupsTabSuffixPanel()
1981 suffixPanel.setBorder(new TitledBorder(
1982 MessageManager.getString("label.backup_filename_strategy")));
1983 suffixPanel.setLayout(new GridBagLayout());
1986 .setText(MessageManager.getString("label.append_to_filename"));
1987 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
1988 suffixTemplateLabel.setFont(LABEL_FONT);
1990 final String tooltip = JvSwingUtils.wrapTooltip(true,
1991 MessageManager.getString("label.append_to_filename_tooltip"));
1992 suffixTemplate.setToolTipText(tooltip);
1993 suffixTemplate.addActionListener(new ActionListener()
1996 public void actionPerformed(ActionEvent e)
1998 updateBackupFilesExampleLabel();
1999 backupfilesCustomOptionsSetEnabled();
2003 KeyListener kl = new KeyListener()
2006 public void keyReleased(KeyEvent e)
2008 updateBackupFilesExampleLabel();
2009 backupfilesCustomOptionsSetEnabled();
2013 public void keyPressed(KeyEvent e)
2017 // disable use of ':' or '/' or '\'
2019 public void keyTyped(KeyEvent e)
2021 char c = e.getKeyChar();
2022 if (c == ':' || c == '/' || c == '\\')
2024 // don't process ':' or '/' or '\'
2030 suffixTemplate.addKeyListener(kl);
2034 .setText(MessageManager.getString("label.index_digits"));
2035 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2036 suffixDigitsLabel.setFont(LABEL_FONT);
2039 ChangeListener c = new ChangeListener()
2042 public void stateChanged(ChangeEvent e)
2044 updateBackupFilesExampleLabel();
2048 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2050 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2051 MessageManager.getString("label.increment_index"));
2052 suffixReverse.addActionListener(new ActionListener()
2055 public void actionPerformed(ActionEvent e)
2057 updateBackupFilesExampleLabel();
2061 GridBagConstraints sgbc = new GridBagConstraints();
2063 // first row (template text box)
2064 sgbc.anchor = GridBagConstraints.WEST;
2068 sgbc.gridheight = 1;
2071 sgbc.fill = GridBagConstraints.NONE;
2072 suffixPanel.add(suffixTemplateLabel, sgbc);
2075 sgbc.fill = GridBagConstraints.HORIZONTAL;
2076 suffixPanel.add(suffixTemplate, sgbc);
2078 // second row (number of digits spinner)
2082 sgbc.fill = GridBagConstraints.NONE;
2083 suffixPanel.add(suffixDigitsLabel, sgbc);
2086 sgbc.fill = GridBagConstraints.HORIZONTAL;
2087 suffixPanel.add(suffixDigitsSpinner, sgbc);
2089 // third row (forward order radio selection)
2092 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2093 sgbc.fill = GridBagConstraints.HORIZONTAL;
2094 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2096 // fourth row (reverse order radio selection)
2098 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2102 private JPanel initBackupsTabKeepFilesPanel()
2104 keepfilesPanel.setBorder(
2105 new TitledBorder(MessageManager.getString("label.keep_files")));
2106 keepfilesPanel.setLayout(new GridBagLayout());
2108 backupfilesKeepAll.setLabels(
2109 MessageManager.getString("label.keep_all_backup_files"),
2110 MessageManager.getString(
2111 "label.keep_only_this_number_of_backup_files"));
2112 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2115 public void actionPerformed(ActionEvent e)
2117 updateBackupFilesExampleLabel();
2120 backupfilesKeepAll.addActionListener(new ActionListener()
2123 public void actionPerformed(ActionEvent e)
2125 boolean selected = backupfilesKeepAll.isSelected();
2126 keepRollMaxOptionsEnabled();
2127 updateBackupFilesExampleLabel();
2131 ChangeListener c = new ChangeListener()
2134 public void stateChanged(ChangeEvent e)
2136 updateBackupFilesExampleLabel();
2140 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2142 backupfilesConfirmDelete.setLabels(
2143 MessageManager.getString("label.confirm_delete"),
2144 MessageManager.getString("label.auto_delete"));
2145 // update the enabled section
2146 keepRollMaxOptionsEnabled();
2148 GridBagConstraints kgbc = new GridBagConstraints();
2150 // first row (template text box)
2151 kgbc.anchor = GridBagConstraints.WEST;
2154 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2155 kgbc.gridheight = 1;
2158 kgbc.fill = GridBagConstraints.HORIZONTAL;
2159 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2165 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2166 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2169 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2170 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2172 // third row (indented)
2174 kgbc.insets = new Insets(0, 20, 0, 0);
2177 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2178 kgbc.fill = GridBagConstraints.HORIZONTAL;
2181 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2183 // fourth row (indented)
2185 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2188 JPanel jp = new JPanel();
2189 jp.setLayout(new FlowLayout());
2191 .setText(MessageManager
2192 .getString("label.autodelete_old_backup_files"));
2193 oldBackupFilesLabel.setFont(LABEL_FONT);
2194 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2195 jp.add(oldBackupFilesLabel);
2196 jp.add(backupfilesConfirmDelete.getTrueButton());
2197 jp.add(backupfilesConfirmDelete.getFalseButton());
2198 keepfilesPanel.add(jp, kgbc);
2200 return keepfilesPanel;
2203 protected void updateBackupFilesExampleLabel()
2205 int exampleindex = 12;
2206 String base = MessageManager.getString("label.filename") + ".fa";
2207 if (base == null || base.length() == 0)
2209 base = "file_name.fa";
2212 boolean reverse = suffixReverse.isSelected();
2213 boolean keepAll = backupfilesKeepAll.isSelected();
2215 String suffix = suffixTemplate.getText();
2218 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2219 if (suffix == null || suffix.length() == 0)
2221 backupfilesExampleLabel
2222 .setText(MessageManager.getString("label.no_backup_files"));
2223 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2229 backupfilesRollMaxSpinner.commitEdit();
2230 rollMax = (Integer) backupfilesRollMaxSpinner.getValue();
2231 rollMax = rollMax < 1 ? 1 : rollMax;
2232 } catch (Exception e)
2235 "Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
2238 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2245 suffixDigitsSpinner.commitEdit();
2246 digits = (Integer) suffixDigitsSpinner.getValue();
2247 digits = digits < 1 ? 1 : digits;
2248 } catch (Exception e)
2251 "Failed casting (Integer) suffixTemplateSpinner.getValue()");
2254 int lowersurround = 2;
2255 int uppersurround = 0;
2256 StringBuilder exampleSB = new StringBuilder();
2257 boolean firstLine = true;
2262 int max = keepAll ? exampleindex : rollMax;
2263 for (int index = min; index <= max; index++)
2265 if (index == min + lowersurround && index < max - uppersurround - 1)
2267 exampleSB.append("\n...");
2269 else if (index > min + lowersurround && index < max - uppersurround)
2281 exampleSB.append("\n");
2283 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2284 base, suffix, digits));
2287 // no extra text needed
2289 else if (index == min)
2291 String newest = MessageManager.getString("label.braced_newest");
2292 if (newest != null && newest.length() > 0)
2294 exampleSB.append(" " + newest);
2297 else if (index == max)
2299 String oldest = MessageManager.getString("label.braced_oldest");
2300 if (oldest != null && oldest.length() > 0)
2302 exampleSB.append(" " + oldest);
2311 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2312 : exampleindex - rollMax + 1;
2313 int max = exampleindex;
2315 for (int index = min; index <= max; index++)
2318 if (index == min + lowersurround && index < max - uppersurround - 1)
2320 exampleSB.append("\n...");
2322 else if (index > min + lowersurround && index < max - uppersurround)
2334 exampleSB.append("\n");
2336 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2337 base, suffix, digits));
2340 // no extra text needed
2342 else if (index == min)
2344 String oldest = MessageManager.getString("label.braced_oldest");
2345 if (oldest != null && oldest.length() > 0)
2347 exampleSB.append(" " + oldest);
2350 else if (index == max)
2352 String newest = MessageManager.getString("label.braced_newest");
2353 if (newest != null && newest.length() > 0)
2355 exampleSB.append(" " + newest);
2363 backupfilesExampleLabel.setText(exampleSB.toString());
2366 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2367 boolean useExistingVal, ChangeListener c)
2374 i = Integer.parseInt((String) s.getValue());
2375 } catch (Exception e)
2378 "Exception casting the initial value of s.getValue()");
2382 setIntegerSpinner(s, min, max, i, c);
2385 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2388 // integer spinner for number of digits
2393 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2396 s.addChangeListener(c);
2400 protected static int getSpinnerInt(JSpinner s, int def)
2406 i = (Integer) s.getValue();
2407 } catch (Exception e)
2409 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2414 private void keepRollMaxOptionsEnabled()
2416 boolean enabled = backupfilesKeepAll.isEnabled()
2417 && !backupfilesKeepAll.isSelected();
2418 oldBackupFilesLabel.setEnabled(enabled);
2419 backupfilesRollMaxSpinner.setEnabled(enabled);
2420 backupfilesConfirmDelete.setEnabled(enabled);
2423 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2425 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2426 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2427 && suffixTemplate.getText()
2428 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2429 keepfilesPanel.setEnabled(enabled);
2430 backupfilesKeepAll.setEnabled(enabled);
2431 oldBackupFilesLabel.setEnabled(enabled);
2432 keepRollMaxOptionsEnabled();
2435 private void backupfilesSuffixTemplateDigitsSetEnabled()
2437 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2438 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2439 suffixDigitsLabel.setEnabled(enabled);
2440 suffixDigitsSpinner.setEnabled(enabled);
2441 suffixReverse.setEnabled(enabled);
2444 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2446 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2447 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2448 suffixPanel.setEnabled(enabled);
2449 suffixTemplateLabel.setEnabled(enabled);
2450 suffixTemplate.setEnabled(enabled);
2451 backupfilesSuffixTemplateDigitsSetEnabled();
2454 protected void backupfilesCustomOptionsSetEnabled()
2456 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2457 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2459 backupfilesSuffixTemplateSetEnabled(enabled);
2460 backupfilesKeepAllSetEnabled(enabled);
2463 private void backupfilesSummarySetEnabled()
2465 boolean enabled = enableBackupFiles.isSelected();
2466 backupfilesExampleLabel.setEnabled(enabled);
2467 exampleFilesPanel.setEnabled(enabled);
2470 private void backupfilesPresetsSetEnabled()
2472 boolean enabled = enableBackupFiles.isSelected();
2473 presetsPanel.setEnabled(enabled);
2474 backupfilesPresetsCombo.setEnabled(enabled);
2477 protected void backupsOptionsSetEnabled()
2479 backupfilesPresetsSetEnabled();
2480 backupfilesSummarySetEnabled();
2481 backupfilesCustomOptionsSetEnabled();
2484 protected void backupsSetOptions(String suffix, int digits,
2485 boolean reverse, boolean keepAll, int rollMax,
2486 boolean confirmDelete)
2488 suffixTemplate.setText(suffix);
2489 suffixDigitsSpinner.setValue(digits);
2490 suffixReverse.setSelected(reverse);
2491 backupfilesKeepAll.setSelected(keepAll);
2492 backupfilesRollMaxSpinner.setValue(rollMax);
2493 backupfilesConfirmDelete.setSelected(confirmDelete);
2496 protected void backupsSetOptions(BackupFilesPresetEntry p)
2498 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2502 protected void autoIdWidth_actionPerformed()
2504 // TODO Auto-generated method stub
2508 protected void userIdWidth_actionPerformed()
2510 // TODO Auto-generated method stub
2514 protected void maxColour_actionPerformed(JPanel panel)
2518 protected void minColour_actionPerformed(JPanel panel)
2522 protected void gapColour_actionPerformed(JPanel panel)
2526 protected void hiddenColour_actionPerformed(JPanel panel)
2530 protected void showunconserved_actionPerformed(ActionEvent e)
2532 // TODO Auto-generated method stub
2536 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2540 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2550 public void ok_actionPerformed(ActionEvent e)
2560 public void cancel_actionPerformed(ActionEvent e)
2570 public void annotations_actionPerformed(ActionEvent e)
2577 public void startupFileTextfield_mouseClicked()
2581 public void newLink_actionPerformed(ActionEvent e)
2586 public void editLink_actionPerformed(ActionEvent e)
2591 public void deleteLink_actionPerformed(ActionEvent e)
2596 public void defaultBrowser_mouseClicked(MouseEvent e)
2601 public void linkURLList_keyTyped(KeyEvent e)
2606 public void useProxy_actionPerformed()
2608 boolean enabled = useProxy.isSelected();
2609 portLabel.setEnabled(enabled);
2610 serverLabel.setEnabled(enabled);
2611 proxyServerTB.setEnabled(enabled);
2612 proxyPortTB.setEnabled(enabled);
2616 * Customer renderer for JTable: supports column of radio buttons
2618 public class RadioButtonRenderer extends JRadioButton
2619 implements TableCellRenderer
2621 public RadioButtonRenderer()
2623 setHorizontalAlignment(CENTER);
2624 setToolTipText(MessageManager.getString("label.urltooltip"));
2628 public Component getTableCellRendererComponent(JTable table,
2629 Object value, boolean isSelected, boolean hasFocus, int row,
2632 setSelected((boolean) value);
2634 // set colours to match rest of table
2637 setBackground(table.getSelectionBackground());
2638 setForeground(table.getSelectionForeground());
2642 setBackground(table.getBackground());
2643 setForeground(table.getForeground());
2650 * Customer cell editor for JTable: supports column of radio buttons in
2651 * conjunction with renderer
2653 public class RadioButtonEditor extends AbstractCellEditor
2654 implements TableCellEditor
2656 private JRadioButton button = new JRadioButton();
2658 public RadioButtonEditor()
2660 button.setHorizontalAlignment(SwingConstants.CENTER);
2661 this.button.addActionListener(new ActionListener()
2664 public void actionPerformed(ActionEvent e)
2666 fireEditingStopped();
2672 public Component getTableCellEditorComponent(JTable table, Object value,
2673 boolean isSelected, int row, int column)
2675 button.setSelected((boolean) value);
2680 public Object getCellEditorValue()
2682 return button.isSelected();
2688 class IntKeyStringValueEntry
2694 public IntKeyStringValueEntry(int k, String v)
2701 public String toString()
2703 return this.getValue();
2711 public String getValue()
2717 class BackupFilesPresetEntry
2729 boolean confirmDelete;
2731 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2732 boolean keepAll, int rollMax, boolean confirmDelete)
2734 this.suffix = suffix;
2735 this.digits = digits;
2736 this.reverse = reverse;
2737 this.keepAll = keepAll;
2738 this.rollMax = rollMax;
2739 this.confirmDelete = confirmDelete;
2743 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2746 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
2747 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2750 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2751 if (e.getKey() == 255)
2753 // "Previously saved scheme" item
2754 this.setFont(this.getFont().deriveFont(Font.ITALIC));
2756 else if (e.getKey() == 0)
2759 this.setFont(this.getFont().deriveFont(Font.BOLD));
2761 } catch (Exception e) {