2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import jalview.bin.Cache;
24 import jalview.fts.core.FTSDataColumnPreferences;
25 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
26 import jalview.fts.service.pdb.PDBFTSRestClient;
27 import jalview.gui.Desktop;
28 import jalview.gui.JalviewBooleanRadioButtons;
29 import jalview.gui.JvOptionPane;
30 import jalview.gui.JvSwingUtils;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.BackupFilenameParts;
33 import jalview.io.BackupFiles;
34 import jalview.util.MessageManager;
36 import java.awt.BorderLayout;
37 import java.awt.Color;
38 import java.awt.Component;
39 import java.awt.Dimension;
40 import java.awt.FlowLayout;
42 import java.awt.GridBagConstraints;
43 import java.awt.GridBagLayout;
44 import java.awt.GridLayout;
45 import java.awt.Insets;
46 import java.awt.Rectangle;
47 import java.awt.event.ActionEvent;
48 import java.awt.event.ActionListener;
49 import java.awt.event.FocusEvent;
50 import java.awt.event.KeyEvent;
51 import java.awt.event.KeyListener;
52 import java.awt.event.MouseAdapter;
53 import java.awt.event.MouseEvent;
54 import java.util.HashMap;
57 import javax.swing.AbstractCellEditor;
58 import javax.swing.BorderFactory;
59 import javax.swing.ButtonGroup;
60 import javax.swing.DefaultListCellRenderer;
61 import javax.swing.JButton;
62 import javax.swing.JCheckBox;
63 import javax.swing.JComboBox;
64 import javax.swing.JFileChooser;
65 import javax.swing.JLabel;
66 import javax.swing.JList;
67 import javax.swing.JPanel;
68 import javax.swing.JRadioButton;
69 import javax.swing.JScrollPane;
70 import javax.swing.JSpinner;
71 import javax.swing.JTabbedPane;
72 import javax.swing.JTable;
73 import javax.swing.JTextArea;
74 import javax.swing.JTextField;
75 import javax.swing.ListSelectionModel;
76 import javax.swing.SpinnerModel;
77 import javax.swing.SpinnerNumberModel;
78 import javax.swing.SwingConstants;
79 import javax.swing.border.Border;
80 import javax.swing.border.EmptyBorder;
81 import javax.swing.border.EtchedBorder;
82 import javax.swing.border.TitledBorder;
83 import javax.swing.event.ChangeEvent;
84 import javax.swing.event.ChangeListener;
85 import javax.swing.table.TableCellEditor;
86 import javax.swing.table.TableCellRenderer;
89 * Base class for the Preferences panel.
94 public class GPreferences extends JPanel
96 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
98 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
99 .getLabelFont(false, true);
101 private static final Font LABEL_FONT_BOLD = JvSwingUtils
102 .getLabelFont(true, false);
105 * Visual tab components
107 protected JCheckBox fullScreen = new JCheckBox();
109 protected JCheckBox openoverv = new JCheckBox();
111 protected JCheckBox seqLimit = new JCheckBox();
113 protected JCheckBox rightAlign = new JCheckBox();
115 protected JComboBox<String> fontSizeCB = new JComboBox<>();
117 protected JComboBox<String> fontStyleCB = new JComboBox<>();
119 protected JComboBox<String> fontNameCB = new JComboBox<>();
121 protected JCheckBox showOccupancy = new JCheckBox();
123 protected JCheckBox showUnconserved = new JCheckBox();
125 protected JCheckBox idItalics = new JCheckBox();
127 protected JCheckBox smoothFont = new JCheckBox();
129 protected JCheckBox scaleProteinToCdna = new JCheckBox();
131 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
133 protected JCheckBox wrap = new JCheckBox();
135 protected JComboBox<String> sortby = new JComboBox<>();
137 protected JComboBox<String> sortAnnBy = new JComboBox<>();
139 protected JComboBox<String> sortAutocalc = new JComboBox<>();
141 protected JCheckBox startupCheckbox = new JCheckBox();
143 protected JTextField startupFileTextfield = new JTextField();
145 // below are in the 'second column'
146 protected JCheckBox annotations = new JCheckBox();
148 protected JCheckBox quality = new JCheckBox();
150 protected JCheckBox conservation = new JCheckBox();
152 protected JCheckBox identity = new JCheckBox();
154 protected JCheckBox showGroupConsensus = new JCheckBox();
156 protected JCheckBox showGroupConservation = new JCheckBox();
158 protected JCheckBox showConsensHistogram = new JCheckBox();
160 protected JCheckBox showConsensLogo = new JCheckBox();
162 protected JCheckBox showDbRefTooltip = new JCheckBox();
164 protected JCheckBox showNpTooltip = new JCheckBox();
167 * Structure tab and components
169 protected JPanel structureTab;
171 protected JCheckBox structFromPdb = new JCheckBox();
173 protected JCheckBox useRnaView = new JCheckBox();
175 protected JCheckBox addSecondaryStructure = new JCheckBox();
177 protected JCheckBox addTempFactor = new JCheckBox();
179 protected JComboBox<String> structViewer = new JComboBox<>();
181 protected JTextField chimeraPath = new JTextField();
183 protected ButtonGroup mappingMethod = new ButtonGroup();
185 protected JRadioButton siftsMapping = new JRadioButton();
187 protected JRadioButton nwMapping = new JRadioButton();
190 * Colours tab components
192 protected JPanel minColour = new JPanel();
194 protected JPanel maxColour = new JPanel();
196 protected JComboBox<String> protColour = new JComboBox<>();
198 protected JComboBox<String> nucColour = new JComboBox<>();
201 * Overview tab components
203 protected JPanel gapColour = new JPanel();
205 protected JPanel hiddenColour = new JPanel();
207 protected JCheckBox useLegacyGap;
209 protected JCheckBox showHiddenAtStart;
211 protected JLabel gapLabel;
214 * Connections tab components
216 protected JTable linkUrlTable = new JTable();
218 protected JButton editLink = new JButton();
220 protected JButton deleteLink = new JButton();
222 protected JTextField filterTB = new JTextField();
224 protected JButton doReset = new JButton();
226 protected JButton userOnly = new JButton();
228 protected JLabel portLabel = new JLabel();
230 protected JLabel serverLabel = new JLabel();
232 protected JTextField proxyServerTB = new JTextField();
234 protected JTextField proxyPortTB = new JTextField();
236 protected JTextField defaultBrowser = new JTextField();
238 protected JCheckBox useProxy = new JCheckBox();
240 protected JCheckBox usagestats = new JCheckBox();
242 protected JCheckBox questionnaire = new JCheckBox();
244 protected JCheckBox versioncheck = new JCheckBox();
247 * Output tab components
249 protected JComboBox<Object> epsRendering = new JComboBox<>();
251 protected JLabel userIdWidthlabel = new JLabel();
253 protected JCheckBox autoIdWidth = new JCheckBox();
255 protected JTextField userIdWidth = new JTextField();
257 protected JCheckBox blcjv = new JCheckBox();
259 protected JCheckBox pileupjv = new JCheckBox();
261 protected JCheckBox clustaljv = new JCheckBox();
263 protected JCheckBox msfjv = new JCheckBox();
265 protected JCheckBox fastajv = new JCheckBox();
267 protected JCheckBox pfamjv = new JCheckBox();
269 protected JCheckBox pirjv = new JCheckBox();
271 protected JCheckBox modellerOutput = new JCheckBox();
273 protected JCheckBox embbedBioJSON = new JCheckBox();
276 * Editing tab components
278 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
280 protected JCheckBox padGaps = new JCheckBox();
282 protected JCheckBox sortByTree = new JCheckBox();
287 protected JPanel wsTab = new JPanel();
290 * Backups tab components
291 * a lot of these are member variables instead of local variables only so that they
292 * can be enabled/disabled easily in one go
295 protected JCheckBox enableBackupFiles = new JCheckBox();
297 protected JPanel presetsPanel = new JPanel();
299 protected JButton revertButton = new JButton();
301 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
303 protected JPanel suffixPanel = new JPanel();
305 protected JPanel keepfilesPanel = new JPanel();
307 protected JPanel exampleFilesPanel = new JPanel();
309 protected JTextField suffixTemplate = new JTextField(null, 8);
311 protected JLabel suffixTemplateLabel = new JLabel();
313 protected JLabel suffixDigitsLabel = new JLabel();
315 protected JSpinner suffixDigitsSpinner = new JSpinner();
317 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
319 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
321 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
323 protected JLabel oldBackupFilesLabel = new JLabel();
325 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
327 protected JTextArea backupfilesExampleLabel = new JTextArea();
330 * Creates a new GPreferences object.
332 public GPreferences()
337 } catch (Exception ex)
339 ex.printStackTrace();
344 * Construct the panel and its tabbed sub-panels.
348 private void jbInit() throws Exception
350 final JTabbedPane tabbedPane = new JTabbedPane();
351 this.setLayout(new BorderLayout());
352 JPanel okCancelPanel = initOkCancelPanel();
353 this.add(tabbedPane, BorderLayout.CENTER);
354 this.add(okCancelPanel, BorderLayout.SOUTH);
356 tabbedPane.add(initVisualTab(),
357 MessageManager.getString("label.visual"));
359 tabbedPane.add(initColoursTab(),
360 MessageManager.getString("label.colours"));
362 tabbedPane.add(initOverviewTab(),
363 MessageManager.getString("label.overview"));
365 tabbedPane.add(initStructureTab(),
366 MessageManager.getString("label.structure"));
368 tabbedPane.add(initConnectionsTab(),
369 MessageManager.getString("label.connections"));
371 tabbedPane.add(initBackupsTab(),
372 MessageManager.getString("label.backups"));
374 tabbedPane.add(initLinksTab(),
375 MessageManager.getString("label.urllinks"));
377 tabbedPane.add(initOutputTab(),
378 MessageManager.getString("label.output"));
380 tabbedPane.add(initEditingTab(),
381 MessageManager.getString("label.editing"));
384 * See WsPreferences for the real work of configuring this tab.
386 wsTab.setLayout(new BorderLayout());
387 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
390 * Handler to validate a tab before leaving it - currently only for
393 tabbedPane.addChangeListener(new ChangeListener()
395 private Component lastTab;
398 public void stateChanged(ChangeEvent e)
400 if (lastTab == structureTab
401 && tabbedPane.getSelectedComponent() != structureTab)
403 if (!validateStructure())
405 tabbedPane.setSelectedComponent(structureTab);
409 lastTab = tabbedPane.getSelectedComponent();
416 * Initialises the Editing tabbed panel.
420 private JPanel initEditingTab()
422 JPanel editingTab = new JPanel();
423 editingTab.setLayout(null);
424 autoCalculateConsCheck.setFont(LABEL_FONT);
425 autoCalculateConsCheck.setText(
426 MessageManager.getString("label.autocalculate_consensus"));
427 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
428 padGaps.setFont(LABEL_FONT);
430 MessageManager.getString("label.pad_gaps_when_editing"));
431 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
432 sortByTree.setFont(LABEL_FONT);
434 .setText(MessageManager.getString("label.sort_with_new_tree"));
435 sortByTree.setToolTipText(MessageManager.getString(
436 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
437 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
438 editingTab.add(autoCalculateConsCheck);
439 editingTab.add(padGaps);
440 editingTab.add(sortByTree);
445 * Initialises the Output tabbed panel.
449 private JPanel initOutputTab()
451 JPanel outputTab = new JPanel();
452 outputTab.setLayout(null);
453 JLabel epsLabel = new JLabel();
454 epsLabel.setFont(LABEL_FONT);
455 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
456 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
457 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
458 epsRendering.setFont(LABEL_FONT);
459 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
460 JLabel jLabel1 = new JLabel();
461 jLabel1.setFont(LABEL_FONT);
462 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
463 jLabel1.setText(MessageManager.getString("label.append_start_end"));
464 jLabel1.setFont(LABEL_FONT);
465 fastajv.setFont(LABEL_FONT);
466 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
467 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
468 blcjv.setText(MessageManager.getString("label.blc") + " ");
469 fastajv.setText(MessageManager.getString("label.fasta") + " ");
470 msfjv.setText(MessageManager.getString("label.msf") + " ");
471 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
472 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
473 msfjv.setFont(LABEL_FONT);
474 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
475 pirjv.setText(MessageManager.getString("label.pir") + " ");
476 JPanel jPanel11 = new JPanel();
477 jPanel11.setFont(LABEL_FONT);
478 TitledBorder titledBorder2 = new TitledBorder(
479 MessageManager.getString("label.file_output"));
480 jPanel11.setBorder(titledBorder2);
481 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
482 GridLayout gridLayout3 = new GridLayout();
483 jPanel11.setLayout(gridLayout3);
484 gridLayout3.setRows(8);
485 blcjv.setFont(LABEL_FONT);
486 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
487 clustaljv.setFont(LABEL_FONT);
488 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
489 pfamjv.setFont(LABEL_FONT);
490 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
491 pileupjv.setFont(LABEL_FONT);
492 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
493 pirjv.setFont(LABEL_FONT);
494 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
495 autoIdWidth.setFont(LABEL_FONT);
497 MessageManager.getString("label.automatically_set_id_width"));
498 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
499 .getString("label.adjusts_width_generated_eps_png")));
500 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
501 autoIdWidth.addActionListener(new ActionListener()
505 public void actionPerformed(ActionEvent e)
507 autoIdWidth_actionPerformed();
510 userIdWidthlabel.setFont(LABEL_FONT);
511 userIdWidthlabel.setText(
512 MessageManager.getString("label.figure_id_column_width"));
513 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
514 .getString("label.manually_specify_width_left_column")));
515 userIdWidthlabel.setToolTipText(
516 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
517 "label.manually_specify_width_left_column")));
518 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
519 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
520 userIdWidth.setText("");
521 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
522 userIdWidth.addActionListener(new ActionListener()
526 public void actionPerformed(ActionEvent e)
528 userIdWidth_actionPerformed();
531 modellerOutput.setFont(LABEL_FONT);
533 .setText(MessageManager.getString("label.use_modeller_output"));
534 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
535 embbedBioJSON.setFont(LABEL_FONT);
536 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
537 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
539 jPanel11.add(jLabel1);
541 jPanel11.add(clustaljv);
542 jPanel11.add(fastajv);
544 jPanel11.add(pfamjv);
545 jPanel11.add(pileupjv);
547 outputTab.add(autoIdWidth);
548 outputTab.add(userIdWidth);
549 outputTab.add(userIdWidthlabel);
550 outputTab.add(modellerOutput);
551 outputTab.add(embbedBioJSON);
552 outputTab.add(epsLabel);
553 outputTab.add(epsRendering);
554 outputTab.add(jPanel11);
559 * Initialises the Connections tabbed panel.
563 private JPanel initConnectionsTab()
565 JPanel connectTab = new JPanel();
566 connectTab.setLayout(new GridBagLayout());
568 // Label for browser text box
569 JLabel browserLabel = new JLabel();
570 browserLabel.setFont(LABEL_FONT);
571 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
572 browserLabel.setText(
573 MessageManager.getString("label.default_browser_unix"));
574 defaultBrowser.setFont(LABEL_FONT);
575 defaultBrowser.setText("");
576 final String tooltip = JvSwingUtils.wrapTooltip(true,
577 MessageManager.getString("label.double_click_to_browse"));
578 defaultBrowser.setToolTipText(tooltip);
579 defaultBrowser.addMouseListener(new MouseAdapter()
582 public void mouseClicked(MouseEvent e)
584 if (e.getClickCount() > 1)
586 defaultBrowser_mouseClicked(e);
591 JPanel proxyPanel = initConnTabProxyPanel();
592 initConnTabCheckboxes();
594 // Add default Browser text box
595 connectTab.add(browserLabel,
596 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
597 GridBagConstraints.WEST, GridBagConstraints.NONE,
598 new Insets(10, 0, 5, 5), 5, 1));
599 defaultBrowser.setFont(LABEL_FONT);
600 defaultBrowser.setText("");
602 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
603 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
604 new Insets(10, 0, 5, 10), 30, 1));
606 // Add proxy server panel
607 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
608 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
609 new Insets(10, 0, 5, 12), 4, 10));
611 // Add usage stats, version check and questionnaire checkboxes
612 connectTab.add(usagestats,
613 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
614 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
615 new Insets(0, 2, 5, 5), 70, 1));
616 connectTab.add(questionnaire,
617 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
618 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
619 new Insets(0, 2, 5, 10), 70, 1));
620 connectTab.add(versioncheck,
621 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
622 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
623 new Insets(0, 2, 5, 5), 70, 1));
625 // Add padding so the panel doesn't look ridiculous
626 JPanel spacePanel = new JPanel();
627 connectTab.add(spacePanel,
628 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
629 GridBagConstraints.WEST, GridBagConstraints.BOTH,
630 new Insets(0, 0, 0, 5), 70, 1));
636 * Initialises the Links tabbed panel.
640 private JPanel initLinksTab()
642 JPanel linkTab = new JPanel();
643 linkTab.setLayout(new GridBagLayout());
645 // Set up table for Url links
646 linkUrlTable.setFillsViewportHeight(true);
647 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
648 linkUrlTable.setAutoCreateRowSorter(true);
649 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
651 // adjust row height so radio buttons actually fit
652 // don't do this in the renderer, it causes the awt thread to activate
654 JRadioButton temp = new JRadioButton();
655 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
657 // Table in scrollpane so that the table is given a scrollbar
658 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
659 linkScrollPane.setBorder(null);
661 // Panel for links functionality
662 JPanel linkPanel = new JPanel(new GridBagLayout());
663 linkPanel.setBorder(new TitledBorder(
664 MessageManager.getString("label.url_linkfrom_sequence_id")));
666 // Put the Url links panel together
668 // Buttons go at top right, resizing only resizes the blank space vertically
669 JPanel buttonPanel = initLinkTabUrlButtons();
670 GridBagConstraints linkConstraints1 = new GridBagConstraints();
671 linkConstraints1.insets = new Insets(0, 0, 5, 0);
672 linkConstraints1.gridx = 0;
673 linkConstraints1.gridy = 0;
674 linkConstraints1.weightx = 1.0;
675 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
676 linkTab.add(buttonPanel, linkConstraints1);
678 // Links table goes at top left, resizing resizes the table
679 GridBagConstraints linkConstraints2 = new GridBagConstraints();
680 linkConstraints2.insets = new Insets(0, 0, 5, 5);
681 linkConstraints2.gridx = 0;
682 linkConstraints2.gridy = 1;
683 linkConstraints2.weightx = 1.0;
684 linkConstraints2.weighty = 1.0;
685 linkConstraints2.fill = GridBagConstraints.BOTH;
686 linkTab.add(linkScrollPane, linkConstraints2);
688 // Filter box and buttons goes at bottom left, resizing resizes the text box
689 JPanel filterPanel = initLinkTabFilterPanel();
690 GridBagConstraints linkConstraints3 = new GridBagConstraints();
691 linkConstraints3.insets = new Insets(0, 0, 0, 5);
692 linkConstraints3.gridx = 0;
693 linkConstraints3.gridy = 2;
694 linkConstraints3.weightx = 1.0;
695 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
696 linkTab.add(filterPanel, linkConstraints3);
701 private JPanel initLinkTabFilterPanel()
703 // Filter textbox and reset button
704 JLabel filterLabel = new JLabel(
705 MessageManager.getString("label.filter"));
706 filterLabel.setFont(LABEL_FONT);
707 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
708 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
710 filterTB.setFont(LABEL_FONT);
711 filterTB.setText("");
713 doReset.setText(MessageManager.getString("action.showall"));
714 userOnly.setText(MessageManager.getString("action.customfilter"));
716 // Panel for filter functionality
717 JPanel filterPanel = new JPanel(new GridBagLayout());
718 filterPanel.setBorder(new TitledBorder("Filter"));
719 GridBagConstraints gbc = new GridBagConstraints();
722 gbc.fill = GridBagConstraints.NONE;
723 gbc.anchor = GridBagConstraints.WEST;
725 filterPanel.add(filterLabel, gbc);
727 GridBagConstraints gbc1 = new GridBagConstraints();
730 gbc1.fill = GridBagConstraints.HORIZONTAL;
731 gbc1.anchor = GridBagConstraints.WEST;
733 filterPanel.add(filterTB, gbc1);
735 GridBagConstraints gbc2 = new GridBagConstraints();
737 gbc2.fill = GridBagConstraints.NONE;
738 gbc2.anchor = GridBagConstraints.WEST;
739 filterPanel.add(doReset, gbc2);
741 GridBagConstraints gbc3 = new GridBagConstraints();
743 gbc3.fill = GridBagConstraints.NONE;
744 gbc3.anchor = GridBagConstraints.WEST;
745 filterPanel.add(userOnly, gbc3);
750 private JPanel initLinkTabUrlButtons()
752 // Buttons for new / edit / delete Url links
753 JButton newLink = new JButton();
754 newLink.setText(MessageManager.getString("action.new"));
756 editLink.setText(MessageManager.getString("action.edit"));
758 deleteLink.setText(MessageManager.getString("action.delete"));
760 // no current selection, so initially disable delete/edit buttons
761 editLink.setEnabled(false);
762 deleteLink.setEnabled(false);
764 newLink.addActionListener(new java.awt.event.ActionListener()
767 public void actionPerformed(ActionEvent e)
769 newLink_actionPerformed(e);
773 editLink.setText(MessageManager.getString("action.edit"));
774 editLink.addActionListener(new java.awt.event.ActionListener()
777 public void actionPerformed(ActionEvent e)
779 editLink_actionPerformed(e);
783 deleteLink.setText(MessageManager.getString("action.delete"));
784 deleteLink.addActionListener(new java.awt.event.ActionListener()
787 public void actionPerformed(ActionEvent e)
789 deleteLink_actionPerformed(e);
793 JPanel buttonPanel = new JPanel(new GridBagLayout());
794 buttonPanel.setBorder(new TitledBorder("Edit links"));
795 GridBagConstraints gbc = new GridBagConstraints();
798 gbc.fill = GridBagConstraints.NONE;
799 buttonPanel.add(newLink, gbc);
801 GridBagConstraints gbc1 = new GridBagConstraints();
804 gbc1.fill = GridBagConstraints.NONE;
805 buttonPanel.add(editLink, gbc1);
807 GridBagConstraints gbc2 = new GridBagConstraints();
810 gbc2.fill = GridBagConstraints.NONE;
811 buttonPanel.add(deleteLink, gbc2);
813 GridBagConstraints gbc3 = new GridBagConstraints();
816 gbc3.fill = GridBagConstraints.HORIZONTAL;
818 JPanel spacePanel = new JPanel();
819 spacePanel.setBorder(null);
820 buttonPanel.add(spacePanel, gbc3);
826 * Initialises the proxy server panel in the Connections tab
828 * @return the proxy server panel
830 private JPanel initConnTabProxyPanel()
832 // Label for server text box
833 serverLabel.setText(MessageManager.getString("label.address"));
834 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
835 serverLabel.setFont(LABEL_FONT);
837 // Proxy server and port text boxes
838 proxyServerTB.setFont(LABEL_FONT);
839 proxyPortTB.setFont(LABEL_FONT);
841 // Label for Port text box
842 portLabel.setFont(LABEL_FONT);
843 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
844 portLabel.setText(MessageManager.getString("label.port"));
846 // Use proxy server checkbox
847 useProxy.setFont(LABEL_FONT);
848 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
849 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
850 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
851 useProxy.addActionListener(new ActionListener()
854 public void actionPerformed(ActionEvent e)
856 useProxy_actionPerformed();
860 // Make proxy server panel
861 JPanel proxyPanel = new JPanel();
862 TitledBorder titledBorder1 = new TitledBorder(
863 MessageManager.getString("label.proxy_server"));
864 proxyPanel.setBorder(titledBorder1);
865 proxyPanel.setLayout(new GridBagLayout());
866 proxyPanel.add(serverLabel,
867 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
868 GridBagConstraints.WEST, GridBagConstraints.NONE,
869 new Insets(0, 2, 2, 0), 5, 0));
870 proxyPanel.add(portLabel,
871 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
872 GridBagConstraints.WEST, GridBagConstraints.NONE,
873 new Insets(0, 0, 2, 0), 11, 0));
874 proxyPanel.add(useProxy,
875 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
876 GridBagConstraints.WEST, GridBagConstraints.NONE,
877 new Insets(0, 2, 5, 185), 2, -4));
878 proxyPanel.add(proxyPortTB,
879 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
880 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
881 new Insets(0, 2, 2, 2), 54, 1));
882 proxyPanel.add(proxyServerTB,
883 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
884 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
885 new Insets(0, 2, 2, 0), 263, 1));
891 * Initialises the checkboxes in the Connections tab
893 private void initConnTabCheckboxes()
895 // Usage stats checkbox label
897 MessageManager.getString("label.send_usage_statistics"));
898 usagestats.setFont(LABEL_FONT);
899 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
900 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
902 // Questionnaire checkbox label
903 questionnaire.setText(
904 MessageManager.getString("label.check_for_questionnaires"));
905 questionnaire.setFont(LABEL_FONT);
906 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
907 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
909 // Check for latest version checkbox label
910 versioncheck.setText(
911 MessageManager.getString("label.check_for_latest_version"));
912 versioncheck.setFont(LABEL_FONT);
913 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
914 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
918 * Initialises the parent panel which contains the tabbed sections.
922 private JPanel initOkCancelPanel()
924 JButton ok = new JButton();
925 ok.setText(MessageManager.getString("action.ok"));
926 ok.addActionListener(new ActionListener()
929 public void actionPerformed(ActionEvent e)
931 ok_actionPerformed(e);
934 JButton cancel = new JButton();
935 cancel.setText(MessageManager.getString("action.cancel"));
936 cancel.addActionListener(new ActionListener()
939 public void actionPerformed(ActionEvent e)
941 cancel_actionPerformed(e);
944 JPanel okCancelPanel = new JPanel();
945 okCancelPanel.add(ok);
946 okCancelPanel.add(cancel);
947 return okCancelPanel;
951 * Initialises the Colours tabbed panel.
955 private JPanel initColoursTab()
957 JPanel coloursTab = new JPanel();
958 coloursTab.setBorder(new TitledBorder(
959 MessageManager.getString("action.open_new_alignment")));
960 coloursTab.setLayout(new FlowLayout());
961 JLabel mincolourLabel = new JLabel();
962 mincolourLabel.setFont(LABEL_FONT);
963 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
964 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
965 minColour.setFont(LABEL_FONT);
966 minColour.setBorder(BorderFactory.createEtchedBorder());
967 minColour.setPreferredSize(new Dimension(40, 20));
968 minColour.addMouseListener(new MouseAdapter()
971 public void mousePressed(MouseEvent e)
973 minColour_actionPerformed(minColour);
976 JLabel maxcolourLabel = new JLabel();
977 maxcolourLabel.setFont(LABEL_FONT);
978 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
979 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
980 maxColour.setFont(LABEL_FONT);
981 maxColour.setBorder(BorderFactory.createEtchedBorder());
982 maxColour.setPreferredSize(new Dimension(40, 20));
983 maxColour.addMouseListener(new MouseAdapter()
986 public void mousePressed(MouseEvent e)
988 maxColour_actionPerformed(maxColour);
992 protColour.setFont(LABEL_FONT);
993 protColour.setBounds(new Rectangle(172, 225, 155, 21));
994 JLabel protColourLabel = new JLabel();
995 protColourLabel.setFont(LABEL_FONT);
996 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
997 protColourLabel.setText(
998 MessageManager.getString("label.prot_alignment_colour") + " ");
999 JvSwingUtils.addtoLayout(coloursTab,
1001 .getString("label.default_colour_scheme_for_alignment"),
1002 protColourLabel, protColour);
1004 nucColour.setFont(LABEL_FONT);
1005 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1006 JLabel nucColourLabel = new JLabel();
1007 nucColourLabel.setFont(LABEL_FONT);
1008 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1009 nucColourLabel.setText(
1010 MessageManager.getString("label.nuc_alignment_colour") + " ");
1011 JvSwingUtils.addtoLayout(coloursTab,
1013 .getString("label.default_colour_scheme_for_alignment"),
1014 nucColourLabel, nucColour);
1016 JPanel annotationShding = new JPanel();
1017 annotationShding.setBorder(new TitledBorder(
1018 MessageManager.getString("label.annotation_shading_default")));
1019 annotationShding.setLayout(new GridLayout(1, 2));
1020 JvSwingUtils.addtoLayout(annotationShding,
1021 MessageManager.getString(
1022 "label.default_minimum_colour_annotation_shading"),
1023 mincolourLabel, minColour);
1024 JvSwingUtils.addtoLayout(annotationShding,
1025 MessageManager.getString(
1026 "label.default_maximum_colour_annotation_shading"),
1027 maxcolourLabel, maxColour);
1028 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1033 * Initialises the Overview tabbed panel.
1037 private JPanel initOverviewTab()
1039 JPanel overviewPanel = new JPanel();
1040 overviewPanel.setBorder(new TitledBorder(
1041 MessageManager.getString("label.overview_settings")));
1043 gapColour.setFont(LABEL_FONT);
1044 // fixing the border colours stops apparent colour bleed from the panel
1045 gapColour.setBorder(
1046 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1047 gapColour.setPreferredSize(new Dimension(40, 20));
1048 gapColour.addMouseListener(new MouseAdapter()
1051 public void mousePressed(MouseEvent e)
1053 gapColour_actionPerformed(gapColour);
1057 hiddenColour.setFont(LABEL_FONT);
1058 // fixing the border colours stops apparent colour bleed from the panel
1059 hiddenColour.setBorder(
1060 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1061 hiddenColour.setPreferredSize(new Dimension(40, 20));
1062 hiddenColour.addMouseListener(new MouseAdapter()
1065 public void mousePressed(MouseEvent e)
1067 hiddenColour_actionPerformed(hiddenColour);
1071 useLegacyGap = new JCheckBox(
1072 MessageManager.getString("label.ov_legacy_gap"));
1073 useLegacyGap.setFont(LABEL_FONT);
1074 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1075 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1076 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1077 gapLabel.setFont(LABEL_FONT);
1078 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1079 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1080 showHiddenAtStart = new JCheckBox(
1081 MessageManager.getString("label.ov_show_hide_default"));
1082 showHiddenAtStart.setFont(LABEL_FONT);
1083 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1084 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1085 JLabel hiddenLabel = new JLabel(
1086 MessageManager.getString("label.hidden_colour"));
1087 hiddenLabel.setFont(LABEL_FONT);
1088 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1089 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1091 useLegacyGap.addActionListener(new ActionListener()
1094 public void actionPerformed(ActionEvent e)
1096 useLegacyGaps_actionPerformed(e);
1100 overviewPanel.setLayout(new GridBagLayout());
1101 GridBagConstraints c1 = new GridBagConstraints();
1103 c1.fill = GridBagConstraints.HORIZONTAL;
1108 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1109 overviewPanel.add(useLegacyGap, c1);
1111 GridBagConstraints c2 = new GridBagConstraints();
1112 c2.fill = GridBagConstraints.HORIZONTAL;
1115 c2.insets = new Insets(0, 15, 0, 10);
1116 overviewPanel.add(gapLabel, c2);
1118 GridBagConstraints c3 = new GridBagConstraints();
1119 c3.fill = GridBagConstraints.HORIZONTAL;
1122 c3.insets = new Insets(0, 0, 0, 15);
1123 overviewPanel.add(gapColour, c3);
1125 GridBagConstraints c4 = new GridBagConstraints();
1126 c4.fill = GridBagConstraints.HORIZONTAL;
1130 overviewPanel.add(showHiddenAtStart, c4);
1132 GridBagConstraints c5 = new GridBagConstraints();
1133 c5.fill = GridBagConstraints.HORIZONTAL;
1136 c5.insets = new Insets(0, 15, 0, 10);
1137 overviewPanel.add(hiddenLabel, c5);
1139 GridBagConstraints c6 = new GridBagConstraints();
1140 c6.fill = GridBagConstraints.HORIZONTAL;
1143 c6.insets = new Insets(0, 0, 0, 15);
1144 overviewPanel.add(hiddenColour, c6);
1146 JButton resetButton = new JButton(
1147 MessageManager.getString("label.reset_to_defaults"));
1149 resetButton.addActionListener(new ActionListener()
1152 public void actionPerformed(ActionEvent e)
1154 resetOvDefaults_actionPerformed(e);
1158 GridBagConstraints c7 = new GridBagConstraints();
1159 c7.fill = GridBagConstraints.NONE;
1162 c7.insets = new Insets(10, 0, 0, 0);
1163 c7.anchor = GridBagConstraints.WEST;
1164 overviewPanel.add(resetButton, c7);
1166 // Add padding so the panel doesn't look ridiculous
1167 JPanel spacePanel = new JPanel();
1168 overviewPanel.add(spacePanel,
1169 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1170 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1171 new Insets(0, 0, 0, 5), 0, 0));
1173 return overviewPanel;
1177 * Initialises the Structure tabbed panel.
1181 private JPanel initStructureTab()
1183 structureTab = new JPanel();
1185 structureTab.setBorder(new TitledBorder(
1186 MessageManager.getString("label.structure_options")));
1187 structureTab.setLayout(null);
1188 final int width = 400;
1189 final int height = 22;
1190 final int lineSpacing = 25;
1193 structFromPdb.setFont(LABEL_FONT);
1195 .setText(MessageManager.getString("label.struct_from_pdb"));
1196 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1197 structFromPdb.addActionListener(new ActionListener()
1200 public void actionPerformed(ActionEvent e)
1202 boolean selected = structFromPdb.isSelected();
1203 // enable other options only when the first is checked
1204 useRnaView.setEnabled(selected);
1205 addSecondaryStructure.setEnabled(selected);
1206 addTempFactor.setEnabled(selected);
1209 structureTab.add(structFromPdb);
1211 // indent checkboxes that are conditional on the first one
1212 ypos += lineSpacing;
1213 useRnaView.setFont(LABEL_FONT);
1214 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1215 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1216 structureTab.add(useRnaView);
1218 ypos += lineSpacing;
1219 addSecondaryStructure.setFont(LABEL_FONT);
1220 addSecondaryStructure
1221 .setText(MessageManager.getString("label.autoadd_secstr"));
1222 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1223 structureTab.add(addSecondaryStructure);
1225 ypos += lineSpacing;
1226 addTempFactor.setFont(LABEL_FONT);
1227 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1228 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1229 structureTab.add(addTempFactor);
1231 ypos += lineSpacing;
1232 JLabel viewerLabel = new JLabel();
1233 viewerLabel.setFont(LABEL_FONT);
1234 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1235 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1236 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1237 structureTab.add(viewerLabel);
1239 structViewer.setFont(LABEL_FONT);
1240 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1241 structViewer.addItem(ViewerType.JMOL.name());
1242 structViewer.addItem(ViewerType.CHIMERA.name());
1243 structViewer.addActionListener(new ActionListener()
1246 public void actionPerformed(ActionEvent e)
1248 structureViewer_actionPerformed(
1249 (String) structViewer.getSelectedItem());
1252 structureTab.add(structViewer);
1254 ypos += lineSpacing;
1255 JLabel pathLabel = new JLabel();
1256 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1257 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1258 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1259 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1260 structureTab.add(pathLabel);
1262 chimeraPath.setFont(LABEL_FONT);
1263 chimeraPath.setText("");
1264 final String tooltip = JvSwingUtils.wrapTooltip(true,
1265 MessageManager.getString("label.chimera_path_tip"));
1266 chimeraPath.setToolTipText(tooltip);
1267 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1268 chimeraPath.addMouseListener(new MouseAdapter()
1271 public void mouseClicked(MouseEvent e)
1273 if (e.getClickCount() == 2)
1275 String chosen = openFileChooser();
1278 chimeraPath.setText(chosen);
1283 structureTab.add(chimeraPath);
1285 ypos += lineSpacing;
1286 nwMapping.setFont(LABEL_FONT);
1287 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1288 siftsMapping.setFont(LABEL_FONT);
1289 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1290 mappingMethod.add(nwMapping);
1291 mappingMethod.add(siftsMapping);
1292 JPanel mappingPanel = new JPanel();
1293 mappingPanel.setFont(LABEL_FONT);
1294 TitledBorder mmTitledBorder = new TitledBorder(
1295 MessageManager.getString("label.mapping_method"));
1296 mmTitledBorder.setTitleFont(LABEL_FONT);
1297 mappingPanel.setBorder(mmTitledBorder);
1298 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1299 // GridLayout mappingLayout = new GridLayout();
1300 mappingPanel.setLayout(new GridLayout());
1301 mappingPanel.add(nwMapping);
1302 mappingPanel.add(siftsMapping);
1303 structureTab.add(mappingPanel);
1305 ypos += lineSpacing;
1306 ypos += lineSpacing;
1307 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1308 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1309 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1310 structureTab.add(docFieldPref);
1312 return structureTab;
1316 * Action on choosing a structure viewer from combobox options.
1318 * @param selectedItem
1320 protected void structureViewer_actionPerformed(String selectedItem)
1325 * Show a dialog for the user to choose a file. Returns the chosen path, or
1330 protected String openFileChooser()
1332 String choice = null;
1333 JFileChooser chooser = new JFileChooser();
1335 // chooser.setFileView(new JalviewFileView());
1336 chooser.setDialogTitle(
1337 MessageManager.getString("label.open_local_file"));
1338 chooser.setToolTipText(MessageManager.getString("action.open"));
1340 int value = chooser.showOpenDialog(this);
1342 if (value == JFileChooser.APPROVE_OPTION)
1344 choice = chooser.getSelectedFile().getPath();
1350 * Validate the structure tab preferences; if invalid, set focus on this tab.
1354 protected boolean validateStructure(FocusEvent e)
1356 if (!validateStructure())
1358 e.getComponent().requestFocusInWindow();
1364 protected boolean validateStructure()
1370 * Initialises the Visual tabbed panel.
1374 private JPanel initVisualTab()
1376 JPanel visualTab = new JPanel();
1377 visualTab.setBorder(new TitledBorder(
1378 MessageManager.getString("action.open_new_alignment")));
1379 visualTab.setLayout(null);
1380 fullScreen.setFont(LABEL_FONT);
1381 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1382 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1383 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1384 quality.setEnabled(false);
1385 quality.setFont(LABEL_FONT);
1386 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1387 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1388 quality.setSelected(true);
1389 quality.setText(MessageManager.getString("label.quality"));
1390 conservation.setEnabled(false);
1391 conservation.setFont(LABEL_FONT);
1392 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1393 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1394 conservation.setSelected(true);
1395 conservation.setText(MessageManager.getString("label.conservation"));
1396 identity.setEnabled(false);
1397 identity.setFont(LABEL_FONT);
1398 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1399 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1400 identity.setSelected(true);
1401 identity.setText(MessageManager.getString("label.consensus"));
1402 showOccupancy.setFont(LABEL_FONT);
1403 showOccupancy.setEnabled(false);
1404 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1405 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1406 showOccupancy.setSelected(true);
1407 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1409 JLabel showGroupbits = new JLabel();
1410 showGroupbits.setFont(LABEL_FONT);
1411 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1412 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1414 .setText(MessageManager.getString("action.show_group") + ":");
1415 JLabel showConsensbits = new JLabel();
1416 showConsensbits.setFont(LABEL_FONT);
1417 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1418 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1420 .setText(MessageManager.getString("label.consensus") + ":");
1421 showConsensHistogram.setEnabled(false);
1422 showConsensHistogram.setFont(LABEL_FONT);
1423 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1424 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1425 showConsensHistogram.setSelected(true);
1426 showConsensHistogram
1427 .setText(MessageManager.getString("label.histogram"));
1428 showConsensLogo.setEnabled(false);
1429 showConsensLogo.setFont(LABEL_FONT);
1430 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1431 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1432 showConsensLogo.setSelected(true);
1433 showConsensLogo.setText(MessageManager.getString("label.logo"));
1434 showGroupConsensus.setEnabled(false);
1435 showGroupConsensus.setFont(LABEL_FONT);
1436 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1437 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1438 showGroupConsensus.setSelected(true);
1439 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1440 showGroupConservation.setEnabled(false);
1441 showGroupConservation.setFont(LABEL_FONT);
1442 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1443 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1444 showGroupConservation.setSelected(true);
1445 showGroupConservation
1446 .setText(MessageManager.getString("label.conservation"));
1447 showNpTooltip.setEnabled(true);
1448 showNpTooltip.setFont(LABEL_FONT);
1449 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1450 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1451 showNpTooltip.setSelected(true);
1452 showNpTooltip.setText(
1453 MessageManager.getString("label.non_positional_features"));
1454 showDbRefTooltip.setEnabled(true);
1455 showDbRefTooltip.setFont(LABEL_FONT);
1456 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1457 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1458 showDbRefTooltip.setSelected(true);
1460 .setText(MessageManager.getString("label.database_references"));
1461 annotations.setFont(LABEL_FONT);
1462 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1463 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1464 annotations.setSelected(true);
1465 annotations.setText(MessageManager.getString("label.show_annotations"));
1466 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1467 annotations.addActionListener(new ActionListener()
1470 public void actionPerformed(ActionEvent e)
1472 annotations_actionPerformed(e);
1475 identity.addActionListener(new ActionListener()
1478 public void actionPerformed(ActionEvent e)
1480 annotations_actionPerformed(e);
1483 showGroupConsensus.addActionListener(new ActionListener()
1486 public void actionPerformed(ActionEvent e)
1488 annotations_actionPerformed(e);
1491 showUnconserved.setFont(LABEL_FONT);
1492 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1493 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1494 showUnconserved.setSelected(true);
1496 .setText(MessageManager.getString("action.show_unconserved"));
1497 showUnconserved.addActionListener(new ActionListener()
1500 public void actionPerformed(ActionEvent e)
1502 showunconserved_actionPerformed(e);
1506 // TODO these are not yet added to / action from Preferences
1507 // JCheckBox shareSelections = new JCheckBox();
1508 // shareSelections.setFont(verdana11);
1509 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1510 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1511 // shareSelections.setSelected(true);
1512 // shareSelections.setText(MessageManager
1513 // .getString("label.share_selection_across_views"));
1514 // JCheckBox followHighlight = new JCheckBox();
1515 // followHighlight.setFont(verdana11);
1516 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1517 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1518 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1519 // followHighlight.setSelected(true);
1520 // followHighlight.setText(MessageManager
1521 // .getString("label.scroll_highlighted_regions"));
1523 seqLimit.setFont(LABEL_FONT);
1524 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1525 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1526 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1527 smoothFont.setFont(LABEL_FONT);
1528 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1529 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1530 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1531 scaleProteinToCdna.setFont(LABEL_FONT);
1532 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1533 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1534 scaleProteinToCdna.setText(
1535 MessageManager.getString("label.scale_protein_to_cdna"));
1536 scaleProteinToCdna.setToolTipText(
1537 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1538 JLabel gapLabel = new JLabel();
1539 gapLabel.setFont(LABEL_FONT);
1540 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1541 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1542 JLabel fontLabel = new JLabel();
1543 fontLabel.setFont(LABEL_FONT);
1544 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1545 fontLabel.setText(MessageManager.getString("label.font"));
1546 fontSizeCB.setFont(LABEL_FONT);
1547 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1548 fontStyleCB.setFont(LABEL_FONT);
1549 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1550 fontNameCB.setFont(LABEL_FONT);
1551 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1552 gapSymbolCB.setFont(LABEL_FONT);
1553 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1554 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1555 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1556 gapSymbolCB.setRenderer(dlcr);
1558 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1559 startupCheckbox.setFont(LABEL_FONT);
1560 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1561 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1562 startupCheckbox.setSelected(true);
1563 startupFileTextfield.setFont(LABEL_FONT);
1564 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1565 final String tooltip = JvSwingUtils.wrapTooltip(true,
1566 MessageManager.getString("label.double_click_to_browse"));
1567 startupFileTextfield.setToolTipText(tooltip);
1568 startupFileTextfield.addMouseListener(new MouseAdapter()
1571 public void mouseClicked(MouseEvent e)
1573 if (e.getClickCount() > 1)
1575 startupFileTextfield_mouseClicked();
1580 sortby.setFont(LABEL_FONT);
1581 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1582 JLabel sortLabel = new JLabel();
1583 sortLabel.setFont(LABEL_FONT);
1584 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1585 sortLabel.setText(MessageManager.getString("label.sort_by"));
1586 sortAnnBy.setFont(LABEL_FONT);
1587 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1588 JLabel sortAnnLabel = new JLabel();
1589 sortAnnLabel.setFont(LABEL_FONT);
1590 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1591 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1592 sortAutocalc.setFont(LABEL_FONT);
1593 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1595 JPanel annsettingsPanel = new JPanel();
1596 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1597 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1598 annsettingsPanel.setBorder(new EtchedBorder());
1599 visualTab.add(annsettingsPanel);
1600 Border jb = new EmptyBorder(1, 1, 4, 5);
1601 annotations.setBorder(jb);
1602 showOccupancy.setBorder(jb);
1603 quality.setBorder(jb);
1604 conservation.setBorder(jb);
1605 identity.setBorder(jb);
1606 showConsensbits.setBorder(jb);
1607 showGroupbits.setBorder(jb);
1608 showGroupConsensus.setBorder(jb);
1609 showGroupConservation.setBorder(jb);
1610 showConsensHistogram.setBorder(jb);
1611 showConsensLogo.setBorder(jb);
1613 JPanel autoAnnotSettings = new JPanel();
1614 annsettingsPanel.add(autoAnnotSettings);
1615 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1616 autoAnnotSettings.add(annotations);
1617 autoAnnotSettings.add(quality);
1618 // second row of autoannotation box
1619 autoAnnotSettings = new JPanel();
1620 annsettingsPanel.add(autoAnnotSettings);
1622 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1623 autoAnnotSettings.add(conservation);
1624 autoAnnotSettings.add(identity);
1625 autoAnnotSettings.add(showOccupancy);
1626 autoAnnotSettings.add(showGroupbits);
1627 autoAnnotSettings.add(showGroupConservation);
1628 autoAnnotSettings.add(showGroupConsensus);
1629 autoAnnotSettings.add(showConsensbits);
1630 autoAnnotSettings.add(showConsensHistogram);
1631 autoAnnotSettings.add(showConsensLogo);
1633 JPanel tooltipSettings = new JPanel();
1634 tooltipSettings.setBorder(new TitledBorder(
1635 MessageManager.getString("label.sequence_id_tooltip")));
1636 tooltipSettings.setBounds(173, 140, 220, 62);
1637 tooltipSettings.setLayout(new GridLayout(2, 1));
1638 tooltipSettings.add(showDbRefTooltip);
1639 tooltipSettings.add(showNpTooltip);
1640 visualTab.add(tooltipSettings);
1642 wrap.setFont(LABEL_FONT);
1643 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1644 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1645 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1646 rightAlign.setFont(LABEL_FONT);
1647 rightAlign.setForeground(Color.black);
1648 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1649 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1650 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1651 idItalics.setFont(LABEL_FONT_ITALIC);
1652 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1653 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1655 MessageManager.getString("label.sequence_name_italics"));
1656 openoverv.setFont(LABEL_FONT);
1657 openoverv.setActionCommand(
1658 MessageManager.getString("label.open_overview"));
1659 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1660 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1661 openoverv.setText(MessageManager.getString("label.open_overview"));
1662 JPanel jPanel2 = new JPanel();
1663 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1664 jPanel2.setLayout(new GridLayout(14, 1));
1665 jPanel2.add(fullScreen);
1666 jPanel2.add(openoverv);
1667 jPanel2.add(seqLimit);
1668 jPanel2.add(rightAlign);
1669 jPanel2.add(fontLabel);
1670 jPanel2.add(showUnconserved);
1671 jPanel2.add(idItalics);
1672 jPanel2.add(smoothFont);
1673 jPanel2.add(scaleProteinToCdna);
1674 jPanel2.add(gapLabel);
1676 jPanel2.add(sortLabel);
1677 jPanel2.add(sortAnnLabel);
1678 jPanel2.add(startupCheckbox);
1679 visualTab.add(jPanel2);
1680 visualTab.add(startupFileTextfield);
1681 visualTab.add(sortby);
1682 visualTab.add(sortAnnBy);
1683 visualTab.add(sortAutocalc);
1684 visualTab.add(gapSymbolCB);
1685 visualTab.add(fontNameCB);
1686 visualTab.add(fontSizeCB);
1687 visualTab.add(fontStyleCB);
1692 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1695 protected void loadLastSavedBackupsOptions()
1698 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1699 setComboIntStringKey(backupfilesPresetsCombo,
1700 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1701 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1702 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1704 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1705 suffixReverse.setSelected(
1706 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1708 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1709 backupfilesRollMaxSpinner
1710 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1711 backupfilesConfirmDelete.setSelected(
1712 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1714 backupsOptionsSetEnabled();
1715 updateBackupFilesExampleLabel();
1718 private boolean warnAboutSuffixReverseChange()
1720 boolean savedSuffixReverse = Cache.getDefault(BackupFiles.REVERSE_ORDER,
1722 int savedSuffixDigits = Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3);
1723 String savedSuffixTemplate = Cache.getDefault(BackupFiles.SUFFIX,
1724 ".bak" + BackupFiles.NUM_PLACEHOLDER);
1726 boolean nowSuffixReverse = suffixReverse.isSelected();
1727 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1728 String nowSuffixTemplate = suffixTemplate.getText();
1729 return nowSuffixReverse != savedSuffixReverse
1730 && nowSuffixDigits == savedSuffixDigits
1731 && nowSuffixTemplate != null
1732 && nowSuffixTemplate.equals(savedSuffixTemplate);
1736 * Initialises the Backups tabbed panel.
1740 private JPanel initBackupsTab()
1742 JPanel backupsTab = new JPanel();
1743 backupsTab.setBorder(new TitledBorder(
1744 MessageManager.getString("label.backup_files")));
1745 backupsTab.setLayout(new GridBagLayout());
1747 GridBagConstraints gbc = new GridBagConstraints();
1750 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1751 gbc.fill = GridBagConstraints.NONE;
1753 initBackupsTabPresetsPanel();
1754 initBackupsTabSuffixPanel();
1755 initBackupsTabKeepFilesPanel();
1756 initBackupsTabFilenameExamplesPanel();
1758 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1760 .setText(MessageManager.getString("label.enable_backupfiles"));
1761 enableBackupFiles.addActionListener(new ActionListener()
1764 public void actionPerformed(ActionEvent e)
1766 // enable other options only when the first is checked
1767 backupsOptionsSetEnabled();
1772 // enable checkbox 1 col
1776 gbc.gridy = 0; // row 0
1777 backupsTab.add(enableBackupFiles, gbc);
1779 // summary of scheme box (over two rows)
1783 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1784 gbc.fill = GridBagConstraints.BOTH;
1785 backupsTab.add(exampleFilesPanel, gbc);
1787 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1788 gbc.fill = GridBagConstraints.NONE;
1790 // fill empty space on right
1793 backupsTab.add(new JPanel(), gbc);
1798 gbc.gridy++; // row 1
1799 backupsTab.add(presetsPanel, gbc);
1801 // gbc.anchor = GridBagConstraints.NORTHWEST;
1802 // now using whole row
1807 gbc.gridy++; // row 2
1808 backupsTab.add(keepfilesPanel, gbc);
1810 // filename strategy box
1811 gbc.gridy++; // row 3
1812 backupsTab.add(suffixPanel, gbc);
1815 gbc.gridy++; // row 4
1817 backupsTab.add(new JPanel(), gbc);
1819 backupsOptionsSetEnabled();
1823 protected static final int BACKUPFILESSCHEMECUSTOMISE = 0;
1825 private static final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1826 new IntKeyStringValueEntry(1,
1827 MessageManager.getString("label.default")),
1828 new IntKeyStringValueEntry(2,
1829 MessageManager.getString("label.single_file")),
1830 new IntKeyStringValueEntry(3,
1831 MessageManager.getString("label.keep_all_versions")),
1832 new IntKeyStringValueEntry(4,
1833 MessageManager.getString("label.rolled_backups")),
1835 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1836 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1837 MessageManager.getString("label.customise")) };
1839 private static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1844 private static final long serialVersionUID = 125L;
1847 put(1, new BackupFilesPresetEntry(
1848 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1850 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1851 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1852 3, false, true, 10, true));
1853 put(4, new BackupFilesPresetEntry(
1854 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1859 private JPanel initBackupsTabPresetsPanel()
1862 String title = MessageManager.getString("label.schemes");
1863 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1864 // TitledBorder tb = new TitledBorder(title);
1865 // tb.setTitleFont(LABEL_FONT);
1866 // presetsPanel.setBorder(tb);
1868 presetsPanel.setLayout(new GridBagLayout());
1870 GridBagConstraints gbc = new GridBagConstraints();
1873 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1874 gbc.fill = GridBagConstraints.NONE;
1881 presetsPanel.add(new JLabel(title + ":"), gbc);
1883 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1885 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1888 // put "Previously saved scheme" item in italics (it's not really
1889 // selectable, as such -- it deselects itself when selected) and
1890 // "Customise" in bold
1891 backupfilesPresetsCombo
1892 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1893 backupfilesPresetsCombo.addActionListener(new ActionListener()
1896 public void actionPerformed(ActionEvent e)
1898 backupsTabUpdatePresets();
1902 // dropdown list of preset schemes
1904 presetsPanel.add(backupfilesPresetsCombo, gbc);
1906 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1907 revertButton.addActionListener(new ActionListener()
1910 public void actionPerformed(ActionEvent e)
1912 loadLastSavedBackupsOptions();
1916 revertButton.setFont(LABEL_FONT);
1918 // "Cancel changes" button (aligned with combo box above)
1921 presetsPanel.add(revertButton, gbc);
1923 return presetsPanel;
1926 private JPanel initBackupsTabFilenameExamplesPanel()
1928 String title = MessageManager
1929 .getString("label.summary_of_backups_scheme");
1930 TitledBorder tb = new TitledBorder(title);
1931 exampleFilesPanel.setBorder(tb);
1932 exampleFilesPanel.setLayout(new GridBagLayout());
1935 backupfilesExampleLabel.setEditable(false);
1936 backupfilesExampleLabel
1937 .setBackground(exampleFilesPanel.getBackground());
1939 updateBackupFilesExampleLabel();
1941 GridBagConstraints gbc = new GridBagConstraints();
1944 gbc.fill = GridBagConstraints.NONE;
1945 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1947 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1948 return exampleFilesPanel;
1951 private void backupsTabUpdatePresets()
1953 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1955 int key = entry.getKey();
1956 String value = entry.getValue();
1958 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
1959 if (key != BACKUPFILESSCHEMECUSTOMISE)
1961 if (backupfilesPresetEntriesValues.containsKey(key))
1963 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
1967 System.out.println("Preset '" + value + "' not implemented");
1971 backupfilesCustomOptionsSetEnabled();
1972 updateBackupFilesExampleLabel();
1975 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
1977 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
1978 return e != null ? e.getKey() : 0;
1981 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
1984 for (int i = 0; i < c.getItemCount(); i++)
1986 IntKeyStringValueEntry e = c.getItemAt(i);
1987 if (e.getKey() == key)
1989 c.setSelectedIndex(i);
1993 backupsTabUpdatePresets();
1996 private JPanel initBackupsTabSuffixPanel()
1998 suffixPanel.setBorder(new TitledBorder(
1999 MessageManager.getString("label.backup_filename_strategy")));
2000 suffixPanel.setLayout(new GridBagLayout());
2003 .setText(MessageManager.getString("label.append_to_filename"));
2004 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2005 suffixTemplateLabel.setFont(LABEL_FONT);
2007 final String tooltip = JvSwingUtils.wrapTooltip(true,
2008 MessageManager.getString("label.append_to_filename_tooltip"));
2009 suffixTemplate.setToolTipText(tooltip);
2010 suffixTemplate.addActionListener(new ActionListener()
2013 public void actionPerformed(ActionEvent e)
2015 updateBackupFilesExampleLabel();
2016 backupfilesCustomOptionsSetEnabled();
2020 KeyListener kl = new KeyListener()
2023 public void keyReleased(KeyEvent e)
2025 updateBackupFilesExampleLabel();
2026 backupfilesCustomOptionsSetEnabled();
2030 public void keyPressed(KeyEvent e)
2034 // disable use of ':' or '/' or '\'
2036 public void keyTyped(KeyEvent e)
2038 char c = e.getKeyChar();
2039 if (c == ':' || c == '/' || c == '\\')
2041 // don't process ':' or '/' or '\'
2047 suffixTemplate.addKeyListener(kl);
2051 .setText(MessageManager.getString("label.index_digits"));
2052 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2053 suffixDigitsLabel.setFont(LABEL_FONT);
2056 ChangeListener c = new ChangeListener()
2059 public void stateChanged(ChangeEvent e)
2061 updateBackupFilesExampleLabel();
2065 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2067 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2068 MessageManager.getString("label.increment_index"));
2069 suffixReverse.addActionListener(new ActionListener()
2072 public void actionPerformed(ActionEvent e)
2074 boolean okay = true;
2075 if (warnAboutSuffixReverseChange())
2078 okay = confirmSuffixReverseChange();
2082 updateBackupFilesExampleLabel();
2086 boolean savedSuffixReverse = Cache
2087 .getDefault(BackupFiles.REVERSE_ORDER, false);
2088 suffixReverse.setSelected(savedSuffixReverse);
2093 GridBagConstraints sgbc = new GridBagConstraints();
2095 // first row (template text box)
2096 sgbc.anchor = GridBagConstraints.WEST;
2100 sgbc.gridheight = 1;
2103 sgbc.fill = GridBagConstraints.NONE;
2104 suffixPanel.add(suffixTemplateLabel, sgbc);
2107 sgbc.fill = GridBagConstraints.HORIZONTAL;
2108 suffixPanel.add(suffixTemplate, sgbc);
2110 // second row (number of digits spinner)
2114 sgbc.fill = GridBagConstraints.NONE;
2115 suffixPanel.add(suffixDigitsLabel, sgbc);
2118 sgbc.fill = GridBagConstraints.HORIZONTAL;
2119 suffixPanel.add(suffixDigitsSpinner, sgbc);
2121 // third row (forward order radio selection)
2124 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2125 sgbc.fill = GridBagConstraints.HORIZONTAL;
2126 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2128 // fourth row (reverse order radio selection)
2130 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2134 private boolean confirmSuffixReverseChange()
2136 boolean ret = false;
2137 String warningMessage = MessageManager
2138 .getString("label.warning_confirm_change_reverse");
2139 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2141 MessageManager.getString("label.change_increment_decrement"),
2142 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2144 ret = (confirm == JvOptionPane.YES_OPTION);
2148 private JPanel initBackupsTabKeepFilesPanel()
2150 keepfilesPanel.setBorder(
2151 new TitledBorder(MessageManager.getString("label.keep_files")));
2152 keepfilesPanel.setLayout(new GridBagLayout());
2154 backupfilesKeepAll.setLabels(
2155 MessageManager.getString("label.keep_all_backup_files"),
2156 MessageManager.getString(
2157 "label.keep_only_this_number_of_backup_files"));
2158 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2161 public void actionPerformed(ActionEvent e)
2163 updateBackupFilesExampleLabel();
2166 backupfilesKeepAll.addActionListener(new ActionListener()
2169 public void actionPerformed(ActionEvent e)
2171 keepRollMaxOptionsEnabled();
2172 updateBackupFilesExampleLabel();
2176 ChangeListener c = new ChangeListener()
2179 public void stateChanged(ChangeEvent e)
2181 updateBackupFilesExampleLabel();
2185 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2187 backupfilesConfirmDelete.setLabels(
2188 MessageManager.getString("label.confirm_delete"),
2189 MessageManager.getString("label.auto_delete"));
2190 // update the enabled section
2191 keepRollMaxOptionsEnabled();
2193 GridBagConstraints kgbc = new GridBagConstraints();
2195 // first row (template text box)
2196 kgbc.anchor = GridBagConstraints.WEST;
2199 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2200 kgbc.gridheight = 1;
2203 kgbc.fill = GridBagConstraints.HORIZONTAL;
2204 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2210 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2211 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2214 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2215 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2217 // third row (indented)
2219 kgbc.insets = new Insets(0, 20, 0, 0);
2222 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2223 kgbc.fill = GridBagConstraints.HORIZONTAL;
2226 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2228 // fourth row (indented)
2230 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2233 JPanel jp = new JPanel();
2234 jp.setLayout(new FlowLayout());
2236 .setText(MessageManager
2237 .getString("label.autodelete_old_backup_files"));
2238 oldBackupFilesLabel.setFont(LABEL_FONT);
2239 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2240 jp.add(oldBackupFilesLabel);
2241 jp.add(backupfilesConfirmDelete.getTrueButton());
2242 jp.add(backupfilesConfirmDelete.getFalseButton());
2243 keepfilesPanel.add(jp, kgbc);
2245 return keepfilesPanel;
2248 protected void updateBackupFilesExampleLabel()
2250 int exampleindex = 12;
2251 String base = MessageManager.getString("label.filename") + ".fa";
2252 if (base == null || base.length() == 0)
2254 base = "file_name.fa";
2257 boolean reverse = suffixReverse.isSelected();
2258 boolean keepAll = backupfilesKeepAll.isSelected();
2260 String suffix = suffixTemplate.getText();
2263 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2264 if (suffix == null || suffix.length() == 0)
2266 backupfilesExampleLabel
2267 .setText(MessageManager.getString("label.no_backup_files"));
2268 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2272 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2273 rollMax = rollMax < 1 ? 1 : rollMax;
2275 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2280 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2281 digits = digits < 1 ? 1 : digits;
2283 int lowersurround = 2;
2284 int uppersurround = 0;
2285 StringBuilder exampleSB = new StringBuilder();
2286 boolean firstLine = true;
2291 int max = keepAll ? exampleindex : rollMax;
2292 for (int index = min; index <= max; index++)
2294 if (index == min + lowersurround && index < max - uppersurround - 1)
2296 exampleSB.append("\n...");
2298 else if (index > min + lowersurround && index < max - uppersurround)
2310 exampleSB.append("\n");
2312 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2313 base, suffix, digits));
2316 // no extra text needed
2318 else if (index == min)
2320 String newest = MessageManager.getString("label.braced_newest");
2321 if (newest != null && newest.length() > 0)
2323 exampleSB.append(" " + newest);
2326 else if (index == max)
2328 String oldest = MessageManager.getString("label.braced_oldest");
2329 if (oldest != null && oldest.length() > 0)
2331 exampleSB.append(" " + oldest);
2340 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2341 : exampleindex - rollMax + 1;
2342 int max = exampleindex;
2344 for (int index = min; index <= max; index++)
2347 if (index == min + lowersurround && index < max - uppersurround - 1)
2349 exampleSB.append("\n...");
2351 else if (index > min + lowersurround && index < max - uppersurround)
2363 exampleSB.append("\n");
2365 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2366 base, suffix, digits));
2369 // no extra text needed
2371 else if (index == min)
2373 String oldest = MessageManager.getString("label.braced_oldest");
2374 if (oldest != null && oldest.length() > 0)
2376 exampleSB.append(" " + oldest);
2379 else if (index == max)
2381 String newest = MessageManager.getString("label.braced_newest");
2382 if (newest != null && newest.length() > 0)
2384 exampleSB.append(" " + newest);
2392 backupfilesExampleLabel.setText(exampleSB.toString());
2395 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2396 boolean useExistingVal, ChangeListener c)
2403 i = Integer.parseInt((String) s.getValue());
2404 } catch (Exception e)
2407 "Exception casting the initial value of s.getValue()");
2411 setIntegerSpinner(s, min, max, i, c);
2414 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2417 // integer spinner for number of digits
2422 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2425 s.addChangeListener(c);
2429 protected static int getSpinnerInt(JSpinner s, int def)
2435 i = (Integer) s.getValue();
2436 } catch (Exception e)
2438 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2443 private void keepRollMaxOptionsEnabled()
2445 boolean enabled = backupfilesKeepAll.isEnabled()
2446 && !backupfilesKeepAll.isSelected();
2447 oldBackupFilesLabel.setEnabled(enabled);
2448 backupfilesRollMaxSpinner.setEnabled(enabled);
2449 backupfilesConfirmDelete.setEnabled(enabled);
2452 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2454 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2455 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2456 && suffixTemplate.getText()
2457 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2458 keepfilesPanel.setEnabled(enabled);
2459 backupfilesKeepAll.setEnabled(enabled);
2460 oldBackupFilesLabel.setEnabled(enabled);
2461 keepRollMaxOptionsEnabled();
2464 private void backupfilesSuffixTemplateDigitsSetEnabled()
2466 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2467 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2468 suffixDigitsLabel.setEnabled(enabled);
2469 suffixDigitsSpinner.setEnabled(enabled);
2470 suffixReverse.setEnabled(enabled);
2473 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2475 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2476 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2477 suffixPanel.setEnabled(enabled);
2478 suffixTemplateLabel.setEnabled(enabled);
2479 suffixTemplate.setEnabled(enabled);
2480 backupfilesSuffixTemplateDigitsSetEnabled();
2483 protected void backupfilesCustomOptionsSetEnabled()
2485 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2486 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2488 backupfilesSuffixTemplateSetEnabled(enabled);
2489 backupfilesKeepAllSetEnabled(enabled);
2492 private void backupfilesSummarySetEnabled()
2494 boolean enabled = enableBackupFiles.isSelected();
2495 backupfilesExampleLabel.setEnabled(enabled);
2496 exampleFilesPanel.setEnabled(enabled);
2499 private void backupfilesPresetsSetEnabled()
2501 boolean enabled = enableBackupFiles.isSelected();
2502 presetsPanel.setEnabled(enabled);
2503 backupfilesPresetsCombo.setEnabled(enabled);
2506 protected void backupsOptionsSetEnabled()
2508 backupfilesPresetsSetEnabled();
2509 backupfilesSummarySetEnabled();
2510 backupfilesCustomOptionsSetEnabled();
2513 protected void backupsSetOptions(String suffix, int digits,
2514 boolean reverse, boolean keepAll, int rollMax,
2515 boolean confirmDelete)
2517 suffixTemplate.setText(suffix);
2518 suffixDigitsSpinner.setValue(digits);
2519 suffixReverse.setSelected(reverse);
2520 backupfilesKeepAll.setSelected(keepAll);
2521 backupfilesRollMaxSpinner.setValue(rollMax);
2522 backupfilesConfirmDelete.setSelected(confirmDelete);
2525 protected void backupsSetOptions(BackupFilesPresetEntry p)
2527 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2531 protected void autoIdWidth_actionPerformed()
2533 // TODO Auto-generated method stub
2537 protected void userIdWidth_actionPerformed()
2539 // TODO Auto-generated method stub
2543 protected void maxColour_actionPerformed(JPanel panel)
2547 protected void minColour_actionPerformed(JPanel panel)
2551 protected void gapColour_actionPerformed(JPanel panel)
2555 protected void hiddenColour_actionPerformed(JPanel panel)
2559 protected void showunconserved_actionPerformed(ActionEvent e)
2561 // TODO Auto-generated method stub
2565 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2569 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2579 public void ok_actionPerformed(ActionEvent e)
2589 public void cancel_actionPerformed(ActionEvent e)
2599 public void annotations_actionPerformed(ActionEvent e)
2606 public void startupFileTextfield_mouseClicked()
2610 public void newLink_actionPerformed(ActionEvent e)
2615 public void editLink_actionPerformed(ActionEvent e)
2620 public void deleteLink_actionPerformed(ActionEvent e)
2625 public void defaultBrowser_mouseClicked(MouseEvent e)
2630 public void linkURLList_keyTyped(KeyEvent e)
2635 public void useProxy_actionPerformed()
2637 boolean enabled = useProxy.isSelected();
2638 portLabel.setEnabled(enabled);
2639 serverLabel.setEnabled(enabled);
2640 proxyServerTB.setEnabled(enabled);
2641 proxyPortTB.setEnabled(enabled);
2645 * Customer renderer for JTable: supports column of radio buttons
2647 public class RadioButtonRenderer extends JRadioButton
2648 implements TableCellRenderer
2650 public RadioButtonRenderer()
2652 setHorizontalAlignment(CENTER);
2653 setToolTipText(MessageManager.getString("label.urltooltip"));
2657 public Component getTableCellRendererComponent(JTable table,
2658 Object value, boolean isSelected, boolean hasFocus, int row,
2661 setSelected((boolean) value);
2663 // set colours to match rest of table
2666 setBackground(table.getSelectionBackground());
2667 setForeground(table.getSelectionForeground());
2671 setBackground(table.getBackground());
2672 setForeground(table.getForeground());
2679 * Customer cell editor for JTable: supports column of radio buttons in
2680 * conjunction with renderer
2682 public class RadioButtonEditor extends AbstractCellEditor
2683 implements TableCellEditor
2685 private JRadioButton button = new JRadioButton();
2687 public RadioButtonEditor()
2689 button.setHorizontalAlignment(SwingConstants.CENTER);
2690 this.button.addActionListener(new ActionListener()
2693 public void actionPerformed(ActionEvent e)
2695 fireEditingStopped();
2701 public Component getTableCellEditorComponent(JTable table, Object value,
2702 boolean isSelected, int row, int column)
2704 button.setSelected((boolean) value);
2709 public Object getCellEditorValue()
2711 return button.isSelected();
2717 class IntKeyStringValueEntry
2723 public IntKeyStringValueEntry(int k, String v)
2730 public String toString()
2732 return this.getValue();
2740 public String getValue()
2746 class BackupFilesPresetEntry
2758 boolean confirmDelete;
2760 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2761 boolean keepAll, int rollMax, boolean confirmDelete)
2763 this.suffix = suffix;
2764 this.digits = digits;
2765 this.reverse = reverse;
2766 this.keepAll = keepAll;
2767 this.rollMax = rollMax;
2768 this.confirmDelete = confirmDelete;
2772 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2777 private static final long serialVersionUID = 88L;
2780 public Component getListCellRendererComponent(JList list, Object value,
2781 int index, boolean isSelected, boolean cellHasFocus)
2783 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2786 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2787 if (e.getKey() == GPreferences.BACKUPFILESSCHEMECUSTOMISE)
2790 this.setFont(this.getFont().deriveFont(Font.BOLD));
2792 } catch (Exception e) {