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.BackupFilenameFilter;
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 JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
299 protected JPanel suffixPanel = new JPanel();
301 protected JPanel keepfilesPanel = new JPanel();
303 protected JPanel exampleFilesPanel = new JPanel();
305 protected JTextField suffixTemplate = new JTextField(null, 8);
307 protected JLabel suffixTemplateLabel = new JLabel();
309 protected JLabel suffixDigitsLabel = new JLabel();
311 protected JSpinner suffixDigitsSpinner = new JSpinner();
313 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
315 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
317 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
319 protected JLabel oldBackupFilesLabel = new JLabel();
321 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
323 protected JTextArea backupfilesExampleLabel = new JTextArea();
326 * Creates a new GPreferences object.
328 public GPreferences()
333 } catch (Exception ex)
335 ex.printStackTrace();
340 * Construct the panel and its tabbed sub-panels.
344 private void jbInit() throws Exception
346 final JTabbedPane tabbedPane = new JTabbedPane();
347 this.setLayout(new BorderLayout());
348 JPanel okCancelPanel = initOkCancelPanel();
349 this.add(tabbedPane, BorderLayout.CENTER);
350 this.add(okCancelPanel, BorderLayout.SOUTH);
352 tabbedPane.add(initVisualTab(),
353 MessageManager.getString("label.visual"));
355 tabbedPane.add(initColoursTab(),
356 MessageManager.getString("label.colours"));
358 tabbedPane.add(initOverviewTab(),
359 MessageManager.getString("label.overview"));
361 tabbedPane.add(initStructureTab(),
362 MessageManager.getString("label.structure"));
364 tabbedPane.add(initConnectionsTab(),
365 MessageManager.getString("label.connections"));
367 tabbedPane.add(initBackupsTab(),
368 MessageManager.getString("label.backups"));
370 tabbedPane.add(initLinksTab(),
371 MessageManager.getString("label.urllinks"));
373 tabbedPane.add(initOutputTab(),
374 MessageManager.getString("label.output"));
376 tabbedPane.add(initEditingTab(),
377 MessageManager.getString("label.editing"));
380 * See WsPreferences for the real work of configuring this tab.
382 wsTab.setLayout(new BorderLayout());
383 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
386 * Handler to validate a tab before leaving it - currently only for
389 tabbedPane.addChangeListener(new ChangeListener()
391 private Component lastTab;
394 public void stateChanged(ChangeEvent e)
396 if (lastTab == structureTab
397 && tabbedPane.getSelectedComponent() != structureTab)
399 if (!validateStructure())
401 tabbedPane.setSelectedComponent(structureTab);
405 lastTab = tabbedPane.getSelectedComponent();
412 * Initialises the Editing tabbed panel.
416 private JPanel initEditingTab()
418 JPanel editingTab = new JPanel();
419 editingTab.setLayout(null);
420 autoCalculateConsCheck.setFont(LABEL_FONT);
421 autoCalculateConsCheck.setText(
422 MessageManager.getString("label.autocalculate_consensus"));
423 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
424 padGaps.setFont(LABEL_FONT);
426 MessageManager.getString("label.pad_gaps_when_editing"));
427 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
428 sortByTree.setFont(LABEL_FONT);
430 .setText(MessageManager.getString("label.sort_with_new_tree"));
431 sortByTree.setToolTipText(MessageManager.getString(
432 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
433 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
434 editingTab.add(autoCalculateConsCheck);
435 editingTab.add(padGaps);
436 editingTab.add(sortByTree);
441 * Initialises the Output tabbed panel.
445 private JPanel initOutputTab()
447 JPanel outputTab = new JPanel();
448 outputTab.setLayout(null);
449 JLabel epsLabel = new JLabel();
450 epsLabel.setFont(LABEL_FONT);
451 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
452 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
453 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
454 epsRendering.setFont(LABEL_FONT);
455 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
456 JLabel jLabel1 = new JLabel();
457 jLabel1.setFont(LABEL_FONT);
458 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
459 jLabel1.setText(MessageManager.getString("label.append_start_end"));
460 jLabel1.setFont(LABEL_FONT);
461 fastajv.setFont(LABEL_FONT);
462 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
463 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
464 blcjv.setText(MessageManager.getString("label.blc") + " ");
465 fastajv.setText(MessageManager.getString("label.fasta") + " ");
466 msfjv.setText(MessageManager.getString("label.msf") + " ");
467 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
468 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
469 msfjv.setFont(LABEL_FONT);
470 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
471 pirjv.setText(MessageManager.getString("label.pir") + " ");
472 JPanel jPanel11 = new JPanel();
473 jPanel11.setFont(LABEL_FONT);
474 TitledBorder titledBorder2 = new TitledBorder(
475 MessageManager.getString("label.file_output"));
476 jPanel11.setBorder(titledBorder2);
477 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
478 GridLayout gridLayout3 = new GridLayout();
479 jPanel11.setLayout(gridLayout3);
480 gridLayout3.setRows(8);
481 blcjv.setFont(LABEL_FONT);
482 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
483 clustaljv.setFont(LABEL_FONT);
484 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
485 pfamjv.setFont(LABEL_FONT);
486 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
487 pileupjv.setFont(LABEL_FONT);
488 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
489 pirjv.setFont(LABEL_FONT);
490 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
491 autoIdWidth.setFont(LABEL_FONT);
493 MessageManager.getString("label.automatically_set_id_width"));
494 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
495 .getString("label.adjusts_width_generated_eps_png")));
496 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
497 autoIdWidth.addActionListener(new ActionListener()
501 public void actionPerformed(ActionEvent e)
503 autoIdWidth_actionPerformed();
506 userIdWidthlabel.setFont(LABEL_FONT);
507 userIdWidthlabel.setText(
508 MessageManager.getString("label.figure_id_column_width"));
509 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
510 .getString("label.manually_specify_width_left_column")));
511 userIdWidthlabel.setToolTipText(
512 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
513 "label.manually_specify_width_left_column")));
514 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
515 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
516 userIdWidth.setText("");
517 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
518 userIdWidth.addActionListener(new ActionListener()
522 public void actionPerformed(ActionEvent e)
524 userIdWidth_actionPerformed();
527 modellerOutput.setFont(LABEL_FONT);
529 .setText(MessageManager.getString("label.use_modeller_output"));
530 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
531 embbedBioJSON.setFont(LABEL_FONT);
532 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
533 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
535 TitledBorder backupFilesBorder = new TitledBorder(
536 MessageManager.getString("label.backup_files"));
538 jPanel11.add(jLabel1);
540 jPanel11.add(clustaljv);
541 jPanel11.add(fastajv);
543 jPanel11.add(pfamjv);
544 jPanel11.add(pileupjv);
546 outputTab.add(autoIdWidth);
547 outputTab.add(userIdWidth);
548 outputTab.add(userIdWidthlabel);
549 outputTab.add(modellerOutput);
550 outputTab.add(embbedBioJSON);
551 outputTab.add(epsLabel);
552 outputTab.add(epsRendering);
553 outputTab.add(jPanel11);
558 * Initialises the Connections tabbed panel.
562 private JPanel initConnectionsTab()
564 JPanel connectTab = new JPanel();
565 connectTab.setLayout(new GridBagLayout());
567 // Label for browser text box
568 JLabel browserLabel = new JLabel();
569 browserLabel.setFont(LABEL_FONT);
570 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
571 browserLabel.setText(
572 MessageManager.getString("label.default_browser_unix"));
573 defaultBrowser.setFont(LABEL_FONT);
574 defaultBrowser.setText("");
575 final String tooltip = JvSwingUtils.wrapTooltip(true,
576 MessageManager.getString("label.double_click_to_browse"));
577 defaultBrowser.setToolTipText(tooltip);
578 defaultBrowser.addMouseListener(new MouseAdapter()
581 public void mouseClicked(MouseEvent e)
583 if (e.getClickCount() > 1)
585 defaultBrowser_mouseClicked(e);
590 JPanel proxyPanel = initConnTabProxyPanel();
591 initConnTabCheckboxes();
593 // Add default Browser text box
594 connectTab.add(browserLabel,
595 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
596 GridBagConstraints.WEST, GridBagConstraints.NONE,
597 new Insets(10, 0, 5, 5), 5, 1));
598 defaultBrowser.setFont(LABEL_FONT);
599 defaultBrowser.setText("");
601 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
602 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
603 new Insets(10, 0, 5, 10), 30, 1));
605 // Add proxy server panel
606 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
607 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
608 new Insets(10, 0, 5, 12), 4, 10));
610 // Add usage stats, version check and questionnaire checkboxes
611 connectTab.add(usagestats,
612 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
613 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
614 new Insets(0, 2, 5, 5), 70, 1));
615 connectTab.add(questionnaire,
616 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
617 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
618 new Insets(0, 2, 5, 10), 70, 1));
619 connectTab.add(versioncheck,
620 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
621 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
622 new Insets(0, 2, 5, 5), 70, 1));
624 // Add padding so the panel doesn't look ridiculous
625 JPanel spacePanel = new JPanel();
626 connectTab.add(spacePanel,
627 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
628 GridBagConstraints.WEST, GridBagConstraints.BOTH,
629 new Insets(0, 0, 0, 5), 70, 1));
635 * Initialises the Links tabbed panel.
639 private JPanel initLinksTab()
641 JPanel linkTab = new JPanel();
642 linkTab.setLayout(new GridBagLayout());
644 // Set up table for Url links
645 linkUrlTable.setFillsViewportHeight(true);
646 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
647 linkUrlTable.setAutoCreateRowSorter(true);
648 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
650 // adjust row height so radio buttons actually fit
651 // don't do this in the renderer, it causes the awt thread to activate
653 JRadioButton temp = new JRadioButton();
654 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
656 // Table in scrollpane so that the table is given a scrollbar
657 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
658 linkScrollPane.setBorder(null);
660 // Panel for links functionality
661 JPanel linkPanel = new JPanel(new GridBagLayout());
662 linkPanel.setBorder(new TitledBorder(
663 MessageManager.getString("label.url_linkfrom_sequence_id")));
665 // Put the Url links panel together
667 // Buttons go at top right, resizing only resizes the blank space vertically
668 JPanel buttonPanel = initLinkTabUrlButtons();
669 GridBagConstraints linkConstraints1 = new GridBagConstraints();
670 linkConstraints1.insets = new Insets(0, 0, 5, 0);
671 linkConstraints1.gridx = 0;
672 linkConstraints1.gridy = 0;
673 linkConstraints1.weightx = 1.0;
674 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
675 linkTab.add(buttonPanel, linkConstraints1);
677 // Links table goes at top left, resizing resizes the table
678 GridBagConstraints linkConstraints2 = new GridBagConstraints();
679 linkConstraints2.insets = new Insets(0, 0, 5, 5);
680 linkConstraints2.gridx = 0;
681 linkConstraints2.gridy = 1;
682 linkConstraints2.weightx = 1.0;
683 linkConstraints2.weighty = 1.0;
684 linkConstraints2.fill = GridBagConstraints.BOTH;
685 linkTab.add(linkScrollPane, linkConstraints2);
687 // Filter box and buttons goes at bottom left, resizing resizes the text box
688 JPanel filterPanel = initLinkTabFilterPanel();
689 GridBagConstraints linkConstraints3 = new GridBagConstraints();
690 linkConstraints3.insets = new Insets(0, 0, 0, 5);
691 linkConstraints3.gridx = 0;
692 linkConstraints3.gridy = 2;
693 linkConstraints3.weightx = 1.0;
694 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
695 linkTab.add(filterPanel, linkConstraints3);
700 private JPanel initLinkTabFilterPanel()
702 // Filter textbox and reset button
703 JLabel filterLabel = new JLabel(
704 MessageManager.getString("label.filter"));
705 filterLabel.setFont(LABEL_FONT);
706 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
707 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
709 filterTB.setFont(LABEL_FONT);
710 filterTB.setText("");
712 doReset.setText(MessageManager.getString("action.showall"));
713 userOnly.setText(MessageManager.getString("action.customfilter"));
715 // Panel for filter functionality
716 JPanel filterPanel = new JPanel(new GridBagLayout());
717 filterPanel.setBorder(new TitledBorder("Filter"));
718 GridBagConstraints gbc = new GridBagConstraints();
721 gbc.fill = GridBagConstraints.NONE;
722 gbc.anchor = GridBagConstraints.WEST;
724 filterPanel.add(filterLabel, gbc);
726 GridBagConstraints gbc1 = new GridBagConstraints();
729 gbc1.fill = GridBagConstraints.HORIZONTAL;
730 gbc1.anchor = GridBagConstraints.WEST;
732 filterPanel.add(filterTB, gbc1);
734 GridBagConstraints gbc2 = new GridBagConstraints();
736 gbc2.fill = GridBagConstraints.NONE;
737 gbc2.anchor = GridBagConstraints.WEST;
738 filterPanel.add(doReset, gbc2);
740 GridBagConstraints gbc3 = new GridBagConstraints();
742 gbc3.fill = GridBagConstraints.NONE;
743 gbc3.anchor = GridBagConstraints.WEST;
744 filterPanel.add(userOnly, gbc3);
749 private JPanel initLinkTabUrlButtons()
751 // Buttons for new / edit / delete Url links
752 JButton newLink = new JButton();
753 newLink.setText(MessageManager.getString("action.new"));
755 editLink.setText(MessageManager.getString("action.edit"));
757 deleteLink.setText(MessageManager.getString("action.delete"));
759 // no current selection, so initially disable delete/edit buttons
760 editLink.setEnabled(false);
761 deleteLink.setEnabled(false);
763 newLink.addActionListener(new java.awt.event.ActionListener()
766 public void actionPerformed(ActionEvent e)
768 newLink_actionPerformed(e);
772 editLink.setText(MessageManager.getString("action.edit"));
773 editLink.addActionListener(new java.awt.event.ActionListener()
776 public void actionPerformed(ActionEvent e)
778 editLink_actionPerformed(e);
782 deleteLink.setText(MessageManager.getString("action.delete"));
783 deleteLink.addActionListener(new java.awt.event.ActionListener()
786 public void actionPerformed(ActionEvent e)
788 deleteLink_actionPerformed(e);
792 JPanel buttonPanel = new JPanel(new GridBagLayout());
793 buttonPanel.setBorder(new TitledBorder("Edit links"));
794 GridBagConstraints gbc = new GridBagConstraints();
797 gbc.fill = GridBagConstraints.NONE;
798 buttonPanel.add(newLink, gbc);
800 GridBagConstraints gbc1 = new GridBagConstraints();
803 gbc1.fill = GridBagConstraints.NONE;
804 buttonPanel.add(editLink, gbc1);
806 GridBagConstraints gbc2 = new GridBagConstraints();
809 gbc2.fill = GridBagConstraints.NONE;
810 buttonPanel.add(deleteLink, gbc2);
812 GridBagConstraints gbc3 = new GridBagConstraints();
815 gbc3.fill = GridBagConstraints.HORIZONTAL;
817 JPanel spacePanel = new JPanel();
818 spacePanel.setBorder(null);
819 buttonPanel.add(spacePanel, gbc3);
825 * Initialises the proxy server panel in the Connections tab
827 * @return the proxy server panel
829 private JPanel initConnTabProxyPanel()
831 // Label for server text box
832 serverLabel.setText(MessageManager.getString("label.address"));
833 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
834 serverLabel.setFont(LABEL_FONT);
836 // Proxy server and port text boxes
837 proxyServerTB.setFont(LABEL_FONT);
838 proxyPortTB.setFont(LABEL_FONT);
840 // Label for Port text box
841 portLabel.setFont(LABEL_FONT);
842 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
843 portLabel.setText(MessageManager.getString("label.port"));
845 // Use proxy server checkbox
846 useProxy.setFont(LABEL_FONT);
847 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
848 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
849 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
850 useProxy.addActionListener(new ActionListener()
853 public void actionPerformed(ActionEvent e)
855 useProxy_actionPerformed();
859 // Make proxy server panel
860 JPanel proxyPanel = new JPanel();
861 TitledBorder titledBorder1 = new TitledBorder(
862 MessageManager.getString("label.proxy_server"));
863 proxyPanel.setBorder(titledBorder1);
864 proxyPanel.setLayout(new GridBagLayout());
865 proxyPanel.add(serverLabel,
866 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
867 GridBagConstraints.WEST, GridBagConstraints.NONE,
868 new Insets(0, 2, 2, 0), 5, 0));
869 proxyPanel.add(portLabel,
870 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
871 GridBagConstraints.WEST, GridBagConstraints.NONE,
872 new Insets(0, 0, 2, 0), 11, 0));
873 proxyPanel.add(useProxy,
874 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
875 GridBagConstraints.WEST, GridBagConstraints.NONE,
876 new Insets(0, 2, 5, 185), 2, -4));
877 proxyPanel.add(proxyPortTB,
878 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
879 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
880 new Insets(0, 2, 2, 2), 54, 1));
881 proxyPanel.add(proxyServerTB,
882 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
883 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
884 new Insets(0, 2, 2, 0), 263, 1));
890 * Initialises the checkboxes in the Connections tab
892 private void initConnTabCheckboxes()
894 // Usage stats checkbox label
896 MessageManager.getString("label.send_usage_statistics"));
897 usagestats.setFont(LABEL_FONT);
898 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
899 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
901 // Questionnaire checkbox label
902 questionnaire.setText(
903 MessageManager.getString("label.check_for_questionnaires"));
904 questionnaire.setFont(LABEL_FONT);
905 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
906 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
908 // Check for latest version checkbox label
909 versioncheck.setText(
910 MessageManager.getString("label.check_for_latest_version"));
911 versioncheck.setFont(LABEL_FONT);
912 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
913 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
917 * Initialises the parent panel which contains the tabbed sections.
921 private JPanel initOkCancelPanel()
923 JButton ok = new JButton();
924 ok.setText(MessageManager.getString("action.ok"));
925 ok.addActionListener(new ActionListener()
928 public void actionPerformed(ActionEvent e)
930 ok_actionPerformed(e);
933 JButton cancel = new JButton();
934 cancel.setText(MessageManager.getString("action.cancel"));
935 cancel.addActionListener(new ActionListener()
938 public void actionPerformed(ActionEvent e)
940 cancel_actionPerformed(e);
943 JPanel okCancelPanel = new JPanel();
944 okCancelPanel.add(ok);
945 okCancelPanel.add(cancel);
946 return okCancelPanel;
950 * Initialises the Colours tabbed panel.
954 private JPanel initColoursTab()
956 JPanel coloursTab = new JPanel();
957 coloursTab.setBorder(new TitledBorder(
958 MessageManager.getString("action.open_new_alignment")));
959 coloursTab.setLayout(new FlowLayout());
960 JLabel mincolourLabel = new JLabel();
961 mincolourLabel.setFont(LABEL_FONT);
962 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
963 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
964 minColour.setFont(LABEL_FONT);
965 minColour.setBorder(BorderFactory.createEtchedBorder());
966 minColour.setPreferredSize(new Dimension(40, 20));
967 minColour.addMouseListener(new MouseAdapter()
970 public void mousePressed(MouseEvent e)
972 minColour_actionPerformed(minColour);
975 JLabel maxcolourLabel = new JLabel();
976 maxcolourLabel.setFont(LABEL_FONT);
977 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
978 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
979 maxColour.setFont(LABEL_FONT);
980 maxColour.setBorder(BorderFactory.createEtchedBorder());
981 maxColour.setPreferredSize(new Dimension(40, 20));
982 maxColour.addMouseListener(new MouseAdapter()
985 public void mousePressed(MouseEvent e)
987 maxColour_actionPerformed(maxColour);
991 protColour.setFont(LABEL_FONT);
992 protColour.setBounds(new Rectangle(172, 225, 155, 21));
993 JLabel protColourLabel = new JLabel();
994 protColourLabel.setFont(LABEL_FONT);
995 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
996 protColourLabel.setText(
997 MessageManager.getString("label.prot_alignment_colour") + " ");
998 JvSwingUtils.addtoLayout(coloursTab,
1000 .getString("label.default_colour_scheme_for_alignment"),
1001 protColourLabel, protColour);
1003 nucColour.setFont(LABEL_FONT);
1004 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1005 JLabel nucColourLabel = new JLabel();
1006 nucColourLabel.setFont(LABEL_FONT);
1007 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1008 nucColourLabel.setText(
1009 MessageManager.getString("label.nuc_alignment_colour") + " ");
1010 JvSwingUtils.addtoLayout(coloursTab,
1012 .getString("label.default_colour_scheme_for_alignment"),
1013 nucColourLabel, nucColour);
1015 JPanel annotationShding = new JPanel();
1016 annotationShding.setBorder(new TitledBorder(
1017 MessageManager.getString("label.annotation_shading_default")));
1018 annotationShding.setLayout(new GridLayout(1, 2));
1019 JvSwingUtils.addtoLayout(annotationShding,
1020 MessageManager.getString(
1021 "label.default_minimum_colour_annotation_shading"),
1022 mincolourLabel, minColour);
1023 JvSwingUtils.addtoLayout(annotationShding,
1024 MessageManager.getString(
1025 "label.default_maximum_colour_annotation_shading"),
1026 maxcolourLabel, maxColour);
1027 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1032 * Initialises the Overview tabbed panel.
1036 private JPanel initOverviewTab()
1038 JPanel overviewPanel = new JPanel();
1039 overviewPanel.setBorder(new TitledBorder(
1040 MessageManager.getString("label.overview_settings")));
1042 gapColour.setFont(LABEL_FONT);
1043 // fixing the border colours stops apparent colour bleed from the panel
1044 gapColour.setBorder(
1045 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1046 gapColour.setPreferredSize(new Dimension(40, 20));
1047 gapColour.addMouseListener(new MouseAdapter()
1050 public void mousePressed(MouseEvent e)
1052 gapColour_actionPerformed(gapColour);
1056 hiddenColour.setFont(LABEL_FONT);
1057 // fixing the border colours stops apparent colour bleed from the panel
1058 hiddenColour.setBorder(
1059 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1060 hiddenColour.setPreferredSize(new Dimension(40, 20));
1061 hiddenColour.addMouseListener(new MouseAdapter()
1064 public void mousePressed(MouseEvent e)
1066 hiddenColour_actionPerformed(hiddenColour);
1070 useLegacyGap = new JCheckBox(
1071 MessageManager.getString("label.ov_legacy_gap"));
1072 useLegacyGap.setFont(LABEL_FONT);
1073 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1074 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1075 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1076 gapLabel.setFont(LABEL_FONT);
1077 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1078 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1079 showHiddenAtStart = new JCheckBox(
1080 MessageManager.getString("label.ov_show_hide_default"));
1081 showHiddenAtStart.setFont(LABEL_FONT);
1082 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1083 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1084 JLabel hiddenLabel = new JLabel(
1085 MessageManager.getString("label.hidden_colour"));
1086 hiddenLabel.setFont(LABEL_FONT);
1087 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1088 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1090 useLegacyGap.addActionListener(new ActionListener()
1093 public void actionPerformed(ActionEvent e)
1095 useLegacyGaps_actionPerformed(e);
1099 overviewPanel.setLayout(new GridBagLayout());
1100 GridBagConstraints c1 = new GridBagConstraints();
1102 c1.fill = GridBagConstraints.HORIZONTAL;
1107 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1108 overviewPanel.add(useLegacyGap, c1);
1110 GridBagConstraints c2 = new GridBagConstraints();
1111 c2.fill = GridBagConstraints.HORIZONTAL;
1114 c2.insets = new Insets(0, 15, 0, 10);
1115 overviewPanel.add(gapLabel, c2);
1117 GridBagConstraints c3 = new GridBagConstraints();
1118 c3.fill = GridBagConstraints.HORIZONTAL;
1121 c3.insets = new Insets(0, 0, 0, 15);
1122 overviewPanel.add(gapColour, c3);
1124 GridBagConstraints c4 = new GridBagConstraints();
1125 c4.fill = GridBagConstraints.HORIZONTAL;
1129 overviewPanel.add(showHiddenAtStart, c4);
1131 GridBagConstraints c5 = new GridBagConstraints();
1132 c5.fill = GridBagConstraints.HORIZONTAL;
1135 c5.insets = new Insets(0, 15, 0, 10);
1136 overviewPanel.add(hiddenLabel, c5);
1138 GridBagConstraints c6 = new GridBagConstraints();
1139 c6.fill = GridBagConstraints.HORIZONTAL;
1142 c6.insets = new Insets(0, 0, 0, 15);
1143 overviewPanel.add(hiddenColour, c6);
1145 JButton resetButton = new JButton(
1146 MessageManager.getString("label.reset_to_defaults"));
1148 resetButton.addActionListener(new ActionListener()
1151 public void actionPerformed(ActionEvent e)
1153 resetOvDefaults_actionPerformed(e);
1157 GridBagConstraints c7 = new GridBagConstraints();
1158 c7.fill = GridBagConstraints.NONE;
1161 c7.insets = new Insets(10, 0, 0, 0);
1162 c7.anchor = GridBagConstraints.WEST;
1163 overviewPanel.add(resetButton, c7);
1165 // Add padding so the panel doesn't look ridiculous
1166 JPanel spacePanel = new JPanel();
1167 overviewPanel.add(spacePanel,
1168 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1169 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1170 new Insets(0, 0, 0, 5), 0, 0));
1172 return overviewPanel;
1176 * Initialises the Structure tabbed panel.
1180 private JPanel initStructureTab()
1182 structureTab = new JPanel();
1184 structureTab.setBorder(new TitledBorder(
1185 MessageManager.getString("label.structure_options")));
1186 structureTab.setLayout(null);
1187 final int width = 400;
1188 final int height = 22;
1189 final int lineSpacing = 25;
1192 structFromPdb.setFont(LABEL_FONT);
1194 .setText(MessageManager.getString("label.struct_from_pdb"));
1195 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1196 structFromPdb.addActionListener(new ActionListener()
1199 public void actionPerformed(ActionEvent e)
1201 boolean selected = structFromPdb.isSelected();
1202 // enable other options only when the first is checked
1203 useRnaView.setEnabled(selected);
1204 addSecondaryStructure.setEnabled(selected);
1205 addTempFactor.setEnabled(selected);
1208 structureTab.add(structFromPdb);
1210 // indent checkboxes that are conditional on the first one
1211 ypos += lineSpacing;
1212 useRnaView.setFont(LABEL_FONT);
1213 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1214 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1215 structureTab.add(useRnaView);
1217 ypos += lineSpacing;
1218 addSecondaryStructure.setFont(LABEL_FONT);
1219 addSecondaryStructure
1220 .setText(MessageManager.getString("label.autoadd_secstr"));
1221 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1222 structureTab.add(addSecondaryStructure);
1224 ypos += lineSpacing;
1225 addTempFactor.setFont(LABEL_FONT);
1226 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1227 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1228 structureTab.add(addTempFactor);
1230 ypos += lineSpacing;
1231 JLabel viewerLabel = new JLabel();
1232 viewerLabel.setFont(LABEL_FONT);
1233 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1234 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1235 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1236 structureTab.add(viewerLabel);
1238 structViewer.setFont(LABEL_FONT);
1239 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1240 structViewer.addItem(ViewerType.JMOL.name());
1241 structViewer.addItem(ViewerType.CHIMERA.name());
1242 structViewer.addActionListener(new ActionListener()
1245 public void actionPerformed(ActionEvent e)
1247 structureViewer_actionPerformed(
1248 (String) structViewer.getSelectedItem());
1251 structureTab.add(structViewer);
1253 ypos += lineSpacing;
1254 JLabel pathLabel = new JLabel();
1255 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1256 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1257 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1258 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1259 structureTab.add(pathLabel);
1261 chimeraPath.setFont(LABEL_FONT);
1262 chimeraPath.setText("");
1263 final String tooltip = JvSwingUtils.wrapTooltip(true,
1264 MessageManager.getString("label.chimera_path_tip"));
1265 chimeraPath.setToolTipText(tooltip);
1266 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1267 chimeraPath.addMouseListener(new MouseAdapter()
1270 public void mouseClicked(MouseEvent e)
1272 if (e.getClickCount() == 2)
1274 String chosen = openFileChooser();
1277 chimeraPath.setText(chosen);
1282 structureTab.add(chimeraPath);
1284 ypos += lineSpacing;
1285 nwMapping.setFont(LABEL_FONT);
1286 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1287 siftsMapping.setFont(LABEL_FONT);
1288 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1289 mappingMethod.add(nwMapping);
1290 mappingMethod.add(siftsMapping);
1291 JPanel mappingPanel = new JPanel();
1292 mappingPanel.setFont(LABEL_FONT);
1293 TitledBorder mmTitledBorder = new TitledBorder(
1294 MessageManager.getString("label.mapping_method"));
1295 mmTitledBorder.setTitleFont(LABEL_FONT);
1296 mappingPanel.setBorder(mmTitledBorder);
1297 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1298 // GridLayout mappingLayout = new GridLayout();
1299 mappingPanel.setLayout(new GridLayout());
1300 mappingPanel.add(nwMapping);
1301 mappingPanel.add(siftsMapping);
1302 structureTab.add(mappingPanel);
1304 ypos += lineSpacing;
1305 ypos += lineSpacing;
1306 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1307 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1308 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1309 structureTab.add(docFieldPref);
1311 return structureTab;
1315 * Action on choosing a structure viewer from combobox options.
1317 * @param selectedItem
1319 protected void structureViewer_actionPerformed(String selectedItem)
1324 * Show a dialog for the user to choose a file. Returns the chosen path, or
1329 protected String openFileChooser()
1331 String choice = null;
1332 JFileChooser chooser = new JFileChooser();
1334 // chooser.setFileView(new JalviewFileView());
1335 chooser.setDialogTitle(
1336 MessageManager.getString("label.open_local_file"));
1337 chooser.setToolTipText(MessageManager.getString("action.open"));
1339 int value = chooser.showOpenDialog(this);
1341 if (value == JFileChooser.APPROVE_OPTION)
1343 choice = chooser.getSelectedFile().getPath();
1349 * Validate the structure tab preferences; if invalid, set focus on this tab.
1353 protected boolean validateStructure(FocusEvent e)
1355 if (!validateStructure())
1357 e.getComponent().requestFocusInWindow();
1363 protected boolean validateStructure()
1369 * Initialises the Visual tabbed panel.
1373 private JPanel initVisualTab()
1375 JPanel visualTab = new JPanel();
1376 visualTab.setBorder(new TitledBorder(
1377 MessageManager.getString("action.open_new_alignment")));
1378 visualTab.setLayout(null);
1379 fullScreen.setFont(LABEL_FONT);
1380 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1381 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1382 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1383 quality.setEnabled(false);
1384 quality.setFont(LABEL_FONT);
1385 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1386 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1387 quality.setSelected(true);
1388 quality.setText(MessageManager.getString("label.quality"));
1389 conservation.setEnabled(false);
1390 conservation.setFont(LABEL_FONT);
1391 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1392 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1393 conservation.setSelected(true);
1394 conservation.setText(MessageManager.getString("label.conservation"));
1395 identity.setEnabled(false);
1396 identity.setFont(LABEL_FONT);
1397 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1398 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1399 identity.setSelected(true);
1400 identity.setText(MessageManager.getString("label.consensus"));
1401 showOccupancy.setFont(LABEL_FONT);
1402 showOccupancy.setEnabled(false);
1403 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1404 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1405 showOccupancy.setSelected(true);
1406 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1408 JLabel showGroupbits = new JLabel();
1409 showGroupbits.setFont(LABEL_FONT);
1410 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1411 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1413 .setText(MessageManager.getString("action.show_group") + ":");
1414 JLabel showConsensbits = new JLabel();
1415 showConsensbits.setFont(LABEL_FONT);
1416 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1417 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1419 .setText(MessageManager.getString("label.consensus") + ":");
1420 showConsensHistogram.setEnabled(false);
1421 showConsensHistogram.setFont(LABEL_FONT);
1422 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1423 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1424 showConsensHistogram.setSelected(true);
1425 showConsensHistogram
1426 .setText(MessageManager.getString("label.histogram"));
1427 showConsensLogo.setEnabled(false);
1428 showConsensLogo.setFont(LABEL_FONT);
1429 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1430 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1431 showConsensLogo.setSelected(true);
1432 showConsensLogo.setText(MessageManager.getString("label.logo"));
1433 showGroupConsensus.setEnabled(false);
1434 showGroupConsensus.setFont(LABEL_FONT);
1435 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1436 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1437 showGroupConsensus.setSelected(true);
1438 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1439 showGroupConservation.setEnabled(false);
1440 showGroupConservation.setFont(LABEL_FONT);
1441 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1442 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1443 showGroupConservation.setSelected(true);
1444 showGroupConservation
1445 .setText(MessageManager.getString("label.conservation"));
1446 showNpTooltip.setEnabled(true);
1447 showNpTooltip.setFont(LABEL_FONT);
1448 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1449 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1450 showNpTooltip.setSelected(true);
1451 showNpTooltip.setText(
1452 MessageManager.getString("label.non_positional_features"));
1453 showDbRefTooltip.setEnabled(true);
1454 showDbRefTooltip.setFont(LABEL_FONT);
1455 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1456 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1457 showDbRefTooltip.setSelected(true);
1459 .setText(MessageManager.getString("label.database_references"));
1460 annotations.setFont(LABEL_FONT);
1461 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1462 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1463 annotations.setSelected(true);
1464 annotations.setText(MessageManager.getString("label.show_annotations"));
1465 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1466 annotations.addActionListener(new ActionListener()
1469 public void actionPerformed(ActionEvent e)
1471 annotations_actionPerformed(e);
1474 identity.addActionListener(new ActionListener()
1477 public void actionPerformed(ActionEvent e)
1479 annotations_actionPerformed(e);
1482 showGroupConsensus.addActionListener(new ActionListener()
1485 public void actionPerformed(ActionEvent e)
1487 annotations_actionPerformed(e);
1490 showUnconserved.setFont(LABEL_FONT);
1491 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1492 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1493 showUnconserved.setSelected(true);
1495 .setText(MessageManager.getString("action.show_unconserved"));
1496 showUnconserved.addActionListener(new ActionListener()
1499 public void actionPerformed(ActionEvent e)
1501 showunconserved_actionPerformed(e);
1505 // TODO these are not yet added to / action from Preferences
1506 // JCheckBox shareSelections = new JCheckBox();
1507 // shareSelections.setFont(verdana11);
1508 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1509 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1510 // shareSelections.setSelected(true);
1511 // shareSelections.setText(MessageManager
1512 // .getString("label.share_selection_across_views"));
1513 // JCheckBox followHighlight = new JCheckBox();
1514 // followHighlight.setFont(verdana11);
1515 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1516 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1517 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1518 // followHighlight.setSelected(true);
1519 // followHighlight.setText(MessageManager
1520 // .getString("label.scroll_highlighted_regions"));
1522 seqLimit.setFont(LABEL_FONT);
1523 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1524 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1525 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1526 smoothFont.setFont(LABEL_FONT);
1527 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1528 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1529 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1530 scaleProteinToCdna.setFont(LABEL_FONT);
1531 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1532 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1533 scaleProteinToCdna.setText(
1534 MessageManager.getString("label.scale_protein_to_cdna"));
1535 scaleProteinToCdna.setToolTipText(
1536 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1537 JLabel gapLabel = new JLabel();
1538 gapLabel.setFont(LABEL_FONT);
1539 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1540 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1541 JLabel fontLabel = new JLabel();
1542 fontLabel.setFont(LABEL_FONT);
1543 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1544 fontLabel.setText(MessageManager.getString("label.font"));
1545 fontSizeCB.setFont(LABEL_FONT);
1546 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1547 fontStyleCB.setFont(LABEL_FONT);
1548 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1549 fontNameCB.setFont(LABEL_FONT);
1550 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1551 gapSymbolCB.setFont(LABEL_FONT);
1552 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1553 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1554 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1555 gapSymbolCB.setRenderer(dlcr);
1557 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1558 startupCheckbox.setFont(LABEL_FONT);
1559 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1560 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1561 startupCheckbox.setSelected(true);
1562 startupFileTextfield.setFont(LABEL_FONT);
1563 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1564 final String tooltip = JvSwingUtils.wrapTooltip(true,
1565 MessageManager.getString("label.double_click_to_browse"));
1566 startupFileTextfield.setToolTipText(tooltip);
1567 startupFileTextfield.addMouseListener(new MouseAdapter()
1570 public void mouseClicked(MouseEvent e)
1572 if (e.getClickCount() > 1)
1574 startupFileTextfield_mouseClicked();
1579 sortby.setFont(LABEL_FONT);
1580 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1581 JLabel sortLabel = new JLabel();
1582 sortLabel.setFont(LABEL_FONT);
1583 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1584 sortLabel.setText(MessageManager.getString("label.sort_by"));
1585 sortAnnBy.setFont(LABEL_FONT);
1586 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1587 JLabel sortAnnLabel = new JLabel();
1588 sortAnnLabel.setFont(LABEL_FONT);
1589 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1590 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1591 sortAutocalc.setFont(LABEL_FONT);
1592 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1594 JPanel annsettingsPanel = new JPanel();
1595 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1596 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1597 annsettingsPanel.setBorder(new EtchedBorder());
1598 visualTab.add(annsettingsPanel);
1599 Border jb = new EmptyBorder(1, 1, 4, 5);
1600 annotations.setBorder(jb);
1601 showOccupancy.setBorder(jb);
1602 quality.setBorder(jb);
1603 conservation.setBorder(jb);
1604 identity.setBorder(jb);
1605 showConsensbits.setBorder(jb);
1606 showGroupbits.setBorder(jb);
1607 showGroupConsensus.setBorder(jb);
1608 showGroupConservation.setBorder(jb);
1609 showConsensHistogram.setBorder(jb);
1610 showConsensLogo.setBorder(jb);
1612 JPanel autoAnnotSettings = new JPanel();
1613 annsettingsPanel.add(autoAnnotSettings);
1614 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1615 autoAnnotSettings.add(annotations);
1616 autoAnnotSettings.add(quality);
1617 // second row of autoannotation box
1618 autoAnnotSettings = new JPanel();
1619 annsettingsPanel.add(autoAnnotSettings);
1621 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1622 autoAnnotSettings.add(conservation);
1623 autoAnnotSettings.add(identity);
1624 autoAnnotSettings.add(showOccupancy);
1625 autoAnnotSettings.add(showGroupbits);
1626 autoAnnotSettings.add(showGroupConservation);
1627 autoAnnotSettings.add(showGroupConsensus);
1628 autoAnnotSettings.add(showConsensbits);
1629 autoAnnotSettings.add(showConsensHistogram);
1630 autoAnnotSettings.add(showConsensLogo);
1632 JPanel tooltipSettings = new JPanel();
1633 tooltipSettings.setBorder(new TitledBorder(
1634 MessageManager.getString("label.sequence_id_tooltip")));
1635 tooltipSettings.setBounds(173, 140, 220, 62);
1636 tooltipSettings.setLayout(new GridLayout(2, 1));
1637 tooltipSettings.add(showDbRefTooltip);
1638 tooltipSettings.add(showNpTooltip);
1639 visualTab.add(tooltipSettings);
1641 wrap.setFont(LABEL_FONT);
1642 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1643 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1644 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1645 rightAlign.setFont(LABEL_FONT);
1646 rightAlign.setForeground(Color.black);
1647 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1648 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1649 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1650 idItalics.setFont(LABEL_FONT_ITALIC);
1651 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1652 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1654 MessageManager.getString("label.sequence_name_italics"));
1655 openoverv.setFont(LABEL_FONT);
1656 openoverv.setActionCommand(
1657 MessageManager.getString("label.open_overview"));
1658 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1659 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1660 openoverv.setText(MessageManager.getString("label.open_overview"));
1661 JPanel jPanel2 = new JPanel();
1662 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1663 jPanel2.setLayout(new GridLayout(14, 1));
1664 jPanel2.add(fullScreen);
1665 jPanel2.add(openoverv);
1666 jPanel2.add(seqLimit);
1667 jPanel2.add(rightAlign);
1668 jPanel2.add(fontLabel);
1669 jPanel2.add(showUnconserved);
1670 jPanel2.add(idItalics);
1671 jPanel2.add(smoothFont);
1672 jPanel2.add(scaleProteinToCdna);
1673 jPanel2.add(gapLabel);
1675 jPanel2.add(sortLabel);
1676 jPanel2.add(sortAnnLabel);
1677 jPanel2.add(startupCheckbox);
1678 visualTab.add(jPanel2);
1679 visualTab.add(startupFileTextfield);
1680 visualTab.add(sortby);
1681 visualTab.add(sortAnnBy);
1682 visualTab.add(sortAutocalc);
1683 visualTab.add(gapSymbolCB);
1684 visualTab.add(fontNameCB);
1685 visualTab.add(fontSizeCB);
1686 visualTab.add(fontStyleCB);
1691 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1694 protected void loadLastSavedBackupsOptions()
1697 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1698 setComboIntStringKey(backupfilesPresetsCombo,
1699 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1700 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1701 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1703 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1704 suffixReverse.setSelected(
1705 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1707 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1708 backupfilesRollMaxSpinner
1709 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1710 backupfilesConfirmDelete.setSelected(
1711 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1713 backupsOptionsSetEnabled();
1714 updateBackupFilesExampleLabel();
1718 * Initialises the Backups tabbed panel.
1722 private JPanel initBackupsTab()
1724 JPanel backupsTab = new JPanel();
1725 backupsTab.setBorder(new TitledBorder(
1726 MessageManager.getString("label.backup_files")));
1727 backupsTab.setLayout(new GridBagLayout());
1729 GridBagConstraints gbc = new GridBagConstraints();
1732 gbc.anchor = GridBagConstraints.NORTHWEST;
1733 gbc.fill = GridBagConstraints.NONE;
1735 initBackupsTabPresetsPanel();
1736 initBackupsTabSuffixPanel();
1737 initBackupsTabKeepFilesPanel();
1738 initBackupsTabFilenameExamplesPanel();
1741 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1743 .setText(MessageManager.getString("label.enable_backupfiles"));
1744 enableBackupFiles.addActionListener(new ActionListener()
1747 public void actionPerformed(ActionEvent e)
1749 boolean selected = enableBackupFiles.isSelected();
1750 // enable other options only when the first is checked
1751 backupsOptionsSetEnabled();
1755 // enable checkbox 1 row
1759 backupsTab.add(enableBackupFiles, gbc);
1764 // gbc.anchor = GridBagConstraints.NORTHEAST;
1765 // gbc.fill = GridBagConstraints.HORIZONTAL;
1766 backupsTab.add(exampleFilesPanel, gbc);
1770 backupsTab.add(presetsPanel, gbc);
1772 gbc.anchor = GridBagConstraints.NORTHWEST;
1773 gbc.fill = GridBagConstraints.NONE;
1776 // whole suffix panel next row
1779 backupsTab.add(keepfilesPanel, gbc);
1783 backupsTab.add(suffixPanel, gbc);
1788 backupsTab.add(new JPanel(), gbc);
1790 backupsOptionsSetEnabled();
1794 private final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1795 new IntKeyStringValueEntry(1,
1796 MessageManager.getString("label.default")),
1797 new IntKeyStringValueEntry(2,
1798 MessageManager.getString("label.single_file")),
1799 new IntKeyStringValueEntry(3,
1800 MessageManager.getString("label.keep_all_versions")),
1801 new IntKeyStringValueEntry(4,
1802 MessageManager.getString("label.rolled_backups")),
1804 new IntKeyStringValueEntry(255,
1805 MessageManager.getString("label.previously_saved_scheme")),
1806 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1807 new IntKeyStringValueEntry(0,
1808 MessageManager.getString("label.customise")) };
1810 private final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1813 put(1, new BackupFilesPresetEntry(
1814 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1816 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1817 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1818 3, false, true, 10, true));
1819 put(4, new BackupFilesPresetEntry(
1820 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1825 private JPanel initBackupsTabPresetsPanel()
1827 presetsPanel.setBorder(
1828 new TitledBorder(MessageManager.getString("label.schemes")));
1830 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1832 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1835 // put "Previously saved scheme" item in italics (it's not really
1836 // selectable, as such -- it deselects itself when selected) and
1837 // "Customise" in bold
1838 backupfilesPresetsCombo
1839 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1840 backupfilesPresetsCombo.addActionListener(new ActionListener()
1843 public void actionPerformed(ActionEvent e)
1845 backupsTabUpdatePresets();
1849 presetsPanel.add(backupfilesPresetsCombo);
1850 return presetsPanel;
1853 private void backupsTabUpdatePresets()
1855 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1857 int key = entry.getKey();
1858 String value = entry.getValue();
1859 // 0 reserved for "Custom" and 255 reserved or "Previously saved scheme"
1860 boolean special = key == 0 || key == 255;
1866 // backupsSetCustomOptions();
1868 else if (key == 255)
1870 loadLastSavedBackupsOptions();
1871 // switch to "Customise" scheme? probably not
1872 // setComboIntStringKey(backupfilesPresetsCombo, 0);
1877 if (backupfilesPresetEntriesValues.containsKey(key))
1879 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
1883 System.out.println("Preset '" + value + "' not implemented");
1887 backupfilesCustomOptionsSetEnabled();
1888 updateBackupFilesExampleLabel();
1891 protected int getComboIntStringKey(JComboBox c)
1893 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
1894 return e != null ? e.getKey() : 0;
1897 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
1900 for (int i = 0; i < c.getItemCount(); i++)
1902 IntKeyStringValueEntry e = c.getItemAt(i);
1904 String v = e.getValue();
1905 if (e.getKey() == key)
1907 c.setSelectedIndex(i);
1911 backupsTabUpdatePresets();
1914 private JPanel initBackupsTabSuffixPanel()
1916 suffixPanel.setBorder(new TitledBorder(
1917 MessageManager.getString("label.backup_filenames")));
1918 suffixPanel.setLayout(new GridBagLayout());
1921 .setText(MessageManager.getString("label.append_to_filename"));
1922 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
1923 suffixTemplateLabel.setFont(LABEL_FONT);
1925 final String tooltip = JvSwingUtils.wrapTooltip(true,
1926 MessageManager.getString("label.append_to_filename_tooltip"));
1927 suffixTemplate.setToolTipText(tooltip);
1928 suffixTemplate.addActionListener(new ActionListener()
1931 public void actionPerformed(ActionEvent e)
1933 updateBackupFilesExampleLabel();
1934 backupfilesCustomOptionsSetEnabled();
1938 KeyListener kl = new KeyListener()
1941 public void keyReleased(KeyEvent e)
1943 updateBackupFilesExampleLabel();
1944 backupfilesCustomOptionsSetEnabled();
1948 public void keyPressed(KeyEvent e)
1952 // disable use of ':' or '/' or '\'
1954 public void keyTyped(KeyEvent e)
1956 char c = e.getKeyChar();
1957 if (c == ':' || c == '/' || c == '\\')
1959 // don't process ':' or '/' or '\'
1965 suffixTemplate.addKeyListener(kl);
1969 .setText(MessageManager.getString("label.index_digits"));
1970 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1971 suffixDigitsLabel.setFont(LABEL_FONT);
1974 ChangeListener c = new ChangeListener()
1977 public void stateChanged(ChangeEvent e)
1979 updateBackupFilesExampleLabel();
1983 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
1985 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
1986 MessageManager.getString("label.increment_index"));
1987 suffixReverse.addActionListener(new ActionListener()
1990 public void actionPerformed(ActionEvent e)
1992 updateBackupFilesExampleLabel();
1996 GridBagConstraints sgbc = new GridBagConstraints();
1998 // first row (template text box)
1999 sgbc.anchor = GridBagConstraints.WEST;
2003 sgbc.gridheight = 1;
2006 sgbc.fill = GridBagConstraints.NONE;
2007 suffixPanel.add(suffixTemplateLabel, sgbc);
2010 sgbc.fill = GridBagConstraints.HORIZONTAL;
2011 suffixPanel.add(suffixTemplate, sgbc);
2013 // second row (number of digits spinner)
2017 sgbc.fill = GridBagConstraints.NONE;
2018 suffixPanel.add(suffixDigitsLabel, sgbc);
2021 sgbc.fill = GridBagConstraints.HORIZONTAL;
2022 suffixPanel.add(suffixDigitsSpinner, sgbc);
2024 // third row (forward order radio selection)
2027 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2028 sgbc.fill = GridBagConstraints.HORIZONTAL;
2029 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2031 // fourth row (reverse order radio selection)
2033 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2037 private JPanel initBackupsTabKeepFilesPanel()
2039 keepfilesPanel.setBorder(
2040 new TitledBorder(MessageManager.getString("label.keep_files")));
2041 keepfilesPanel.setLayout(new GridBagLayout());
2043 backupfilesKeepAll.setLabels(
2044 MessageManager.getString("label.keep_all_backup_files"),
2045 MessageManager.getString(
2046 "label.keep_only_this_number_of_backup_files"));
2047 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2050 public void actionPerformed(ActionEvent e)
2052 updateBackupFilesExampleLabel();
2055 backupfilesKeepAll.addActionListener(new ActionListener()
2058 public void actionPerformed(ActionEvent e)
2060 boolean selected = backupfilesKeepAll.isSelected();
2061 keepRollMaxOptionsEnabled();
2062 updateBackupFilesExampleLabel();
2066 ChangeListener c = new ChangeListener()
2069 public void stateChanged(ChangeEvent e)
2071 updateBackupFilesExampleLabel();
2075 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2077 backupfilesConfirmDelete.setLabels(
2078 MessageManager.getString("label.confirm_delete"),
2079 MessageManager.getString("label.auto_delete"));
2080 // update the enabled section
2081 keepRollMaxOptionsEnabled();
2083 GridBagConstraints kgbc = new GridBagConstraints();
2085 // first row (template text box)
2086 kgbc.anchor = GridBagConstraints.WEST;
2089 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2090 kgbc.gridheight = 1;
2093 kgbc.fill = GridBagConstraints.HORIZONTAL;
2094 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2100 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2101 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2104 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2105 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2107 // third row (indented)
2109 kgbc.insets = new Insets(0, 20, 0, 0);
2112 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2113 kgbc.fill = GridBagConstraints.HORIZONTAL;
2116 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2118 // fourth row (indented)
2120 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2123 JPanel jp = new JPanel();
2124 jp.setLayout(new FlowLayout());
2126 .setText(MessageManager
2127 .getString("label.autodelete_old_backup_files"));
2128 oldBackupFilesLabel.setFont(LABEL_FONT);
2129 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2130 jp.add(oldBackupFilesLabel);
2131 jp.add(backupfilesConfirmDelete.getTrueButton());
2132 jp.add(backupfilesConfirmDelete.getFalseButton());
2133 keepfilesPanel.add(jp, kgbc);
2135 return keepfilesPanel;
2138 private JPanel initBackupsTabFilenameExamplesPanel()
2140 String title = MessageManager
2141 .getString("label.summary_of_backups_scheme");
2142 TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
2143 // tb.setTitleFont(LABEL_FONT);
2144 exampleFilesPanel.setBorder(tb);
2145 exampleFilesPanel.setLayout(new GridBagLayout());
2147 // inordinately difficult to get this titledborder the right size for the
2150 backupfilesExampleLabel.setEditable(false);
2151 backupfilesExampleLabel.setPreferredSize(new Dimension(280, 85));
2152 backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
2153 backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
2155 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2156 backupfilesExampleLabel
2157 .setBackground(exampleFilesPanel.getBackground());
2159 updateBackupFilesExampleLabel();
2160 exampleFilesPanel.setMinimumSize(new Dimension(280, 85));
2162 GridBagConstraints gbc = new GridBagConstraints();
2163 gbc.anchor = GridBagConstraints.EAST;
2166 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2167 return exampleFilesPanel;
2170 protected void updateBackupFilesExampleLabel()
2172 int exampleindex = 12;
2173 String base = MessageManager.getString("label.filename");
2174 if (base == null || base.length() == 0)
2176 base = "file_name.fa";
2179 boolean reverse = suffixReverse.isSelected();
2180 boolean keepAll = backupfilesKeepAll.isSelected();
2182 String suffix = suffixTemplate.getText();
2185 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2186 if (suffix == null || suffix.length() == 0)
2188 backupfilesExampleLabel
2189 .setText(MessageManager.getString("label.no_backup_files"));
2190 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2196 backupfilesRollMaxSpinner.commitEdit();
2197 rollMax = (Integer) backupfilesRollMaxSpinner.getValue();
2198 rollMax = rollMax < 1 ? 1 : rollMax;
2199 } catch (Exception e)
2202 "Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
2205 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2212 suffixDigitsSpinner.commitEdit();
2213 digits = (Integer) suffixDigitsSpinner.getValue();
2214 digits = digits < 1 ? 1 : digits;
2215 } catch (Exception e)
2218 "Failed casting (Integer) suffixTemplateSpinner.getValue()");
2221 int lowersurround = 2;
2222 int uppersurround = 0;
2223 StringBuilder exampleSB = new StringBuilder();
2224 boolean firstLine = true;
2229 int max = keepAll ? exampleindex : rollMax;
2230 for (int index = min; index <= max; index++)
2232 if (index == min + lowersurround && index < max - uppersurround - 1)
2234 exampleSB.append("\n...");
2236 else if (index > min + lowersurround && index < max - uppersurround)
2248 exampleSB.append("\n");
2250 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2251 base, suffix, digits));
2254 // no extra text needed
2256 else if (index == min)
2258 String newest = MessageManager.getString("label.braced_newest");
2259 if (newest != null && newest.length() > 0)
2261 exampleSB.append(" " + newest);
2264 else if (index == max)
2266 String oldest = MessageManager.getString("label.braced_oldest");
2267 if (oldest != null && oldest.length() > 0)
2269 exampleSB.append(" " + oldest);
2278 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2279 : exampleindex - rollMax + 1;
2280 int max = exampleindex;
2282 for (int index = min; index <= max; index++)
2285 if (index == min + lowersurround && index < max - uppersurround - 1)
2287 exampleSB.append("\n...");
2289 else if (index > min + lowersurround && index < max - uppersurround)
2301 exampleSB.append("\n");
2303 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2304 base, suffix, digits));
2307 // no extra text needed
2309 else if (index == min)
2311 String oldest = MessageManager.getString("label.braced_oldest");
2312 if (oldest != null && oldest.length() > 0)
2314 exampleSB.append(" " + oldest);
2317 else if (index == max)
2319 String newest = MessageManager.getString("label.braced_newest");
2320 if (newest != null && newest.length() > 0)
2322 exampleSB.append(" " + newest);
2330 backupfilesExampleLabel.setText(exampleSB.toString());
2333 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2334 boolean useExistingVal, ChangeListener c)
2341 i = Integer.parseInt((String) s.getValue());
2342 } catch (Exception e)
2345 "Exception casting the initial value of s.getValue()");
2349 setIntegerSpinner(s, min, max, i, c);
2352 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2355 // integer spinner for number of digits
2360 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2363 s.addChangeListener(c);
2367 protected static int getSpinnerInt(JSpinner s, int def)
2373 i = (Integer) s.getValue();
2374 } catch (Exception e)
2376 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2381 private void keepRollMaxOptionsEnabled()
2383 boolean enabled = backupfilesKeepAll.isEnabled()
2384 && !backupfilesKeepAll.isSelected();
2385 oldBackupFilesLabel.setEnabled(enabled);
2386 backupfilesRollMaxSpinner.setEnabled(enabled);
2387 backupfilesConfirmDelete.setEnabled(enabled);
2390 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2392 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2393 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2394 && suffixTemplate.getText()
2395 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2396 keepfilesPanel.setEnabled(enabled);
2397 backupfilesKeepAll.setEnabled(enabled);
2398 oldBackupFilesLabel.setEnabled(enabled);
2399 keepRollMaxOptionsEnabled();
2402 private void backupfilesSuffixTemplateDigitsSetEnabled()
2404 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2405 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2406 suffixDigitsLabel.setEnabled(enabled);
2407 suffixDigitsSpinner.setEnabled(enabled);
2408 suffixReverse.setEnabled(enabled);
2411 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2413 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2414 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2415 suffixPanel.setEnabled(enabled);
2416 suffixTemplateLabel.setEnabled(enabled);
2417 suffixTemplate.setEnabled(enabled);
2418 backupfilesSuffixTemplateDigitsSetEnabled();
2421 protected void backupfilesCustomOptionsSetEnabled()
2423 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2424 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2426 backupfilesSuffixTemplateSetEnabled(enabled);
2427 backupfilesKeepAllSetEnabled(enabled);
2430 private void backupfilesSummarySetEnabled()
2432 boolean enabled = enableBackupFiles.isSelected();
2433 backupfilesExampleLabel.setEnabled(enabled);
2434 exampleFilesPanel.setEnabled(enabled);
2437 private void backupfilesPresetsSetEnabled()
2439 boolean enabled = enableBackupFiles.isSelected();
2440 presetsPanel.setEnabled(enabled);
2441 backupfilesPresetsCombo.setEnabled(enabled);
2444 protected void backupsOptionsSetEnabled()
2446 backupfilesPresetsSetEnabled();
2447 backupfilesSummarySetEnabled();
2448 backupfilesCustomOptionsSetEnabled();
2451 protected void backupsSetOptions(String suffix, int digits,
2452 boolean reverse, boolean keepAll, int rollMax,
2453 boolean confirmDelete)
2455 suffixTemplate.setText(suffix);
2456 suffixDigitsSpinner.setValue(digits);
2457 suffixReverse.setSelected(reverse);
2458 backupfilesKeepAll.setSelected(keepAll);
2459 backupfilesRollMaxSpinner.setValue(rollMax);
2460 backupfilesConfirmDelete.setSelected(confirmDelete);
2463 protected void backupsSetOptions(BackupFilesPresetEntry p)
2465 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2469 protected void autoIdWidth_actionPerformed()
2471 // TODO Auto-generated method stub
2475 protected void userIdWidth_actionPerformed()
2477 // TODO Auto-generated method stub
2481 protected void maxColour_actionPerformed(JPanel panel)
2485 protected void minColour_actionPerformed(JPanel panel)
2489 protected void gapColour_actionPerformed(JPanel panel)
2493 protected void hiddenColour_actionPerformed(JPanel panel)
2497 protected void showunconserved_actionPerformed(ActionEvent e)
2499 // TODO Auto-generated method stub
2503 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2507 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2517 public void ok_actionPerformed(ActionEvent e)
2527 public void cancel_actionPerformed(ActionEvent e)
2537 public void annotations_actionPerformed(ActionEvent e)
2544 public void startupFileTextfield_mouseClicked()
2548 public void newLink_actionPerformed(ActionEvent e)
2553 public void editLink_actionPerformed(ActionEvent e)
2558 public void deleteLink_actionPerformed(ActionEvent e)
2563 public void defaultBrowser_mouseClicked(MouseEvent e)
2568 public void linkURLList_keyTyped(KeyEvent e)
2573 public void useProxy_actionPerformed()
2575 boolean enabled = useProxy.isSelected();
2576 portLabel.setEnabled(enabled);
2577 serverLabel.setEnabled(enabled);
2578 proxyServerTB.setEnabled(enabled);
2579 proxyPortTB.setEnabled(enabled);
2583 * Customer renderer for JTable: supports column of radio buttons
2585 public class RadioButtonRenderer extends JRadioButton
2586 implements TableCellRenderer
2588 public RadioButtonRenderer()
2590 setHorizontalAlignment(CENTER);
2591 setToolTipText(MessageManager.getString("label.urltooltip"));
2595 public Component getTableCellRendererComponent(JTable table,
2596 Object value, boolean isSelected, boolean hasFocus, int row,
2599 setSelected((boolean) value);
2601 // set colours to match rest of table
2604 setBackground(table.getSelectionBackground());
2605 setForeground(table.getSelectionForeground());
2609 setBackground(table.getBackground());
2610 setForeground(table.getForeground());
2617 * Customer cell editor for JTable: supports column of radio buttons in
2618 * conjunction with renderer
2620 public class RadioButtonEditor extends AbstractCellEditor
2621 implements TableCellEditor
2623 private JRadioButton button = new JRadioButton();
2625 public RadioButtonEditor()
2627 button.setHorizontalAlignment(SwingConstants.CENTER);
2628 this.button.addActionListener(new ActionListener()
2631 public void actionPerformed(ActionEvent e)
2633 fireEditingStopped();
2639 public Component getTableCellEditorComponent(JTable table, Object value,
2640 boolean isSelected, int row, int column)
2642 button.setSelected((boolean) value);
2647 public Object getCellEditorValue()
2649 return button.isSelected();
2655 class IntKeyStringValueEntry
2661 public IntKeyStringValueEntry(int k, String v)
2668 public String toString()
2670 return this.getValue();
2678 public String getValue()
2684 class BackupFilesPresetEntry
2696 boolean confirmDelete;
2698 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2699 boolean keepAll, int rollMax, boolean confirmDelete)
2701 this.suffix = suffix;
2702 this.digits = digits;
2703 this.reverse = reverse;
2704 this.keepAll = keepAll;
2705 this.rollMax = rollMax;
2706 this.confirmDelete = confirmDelete;
2710 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2713 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
2714 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2717 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2718 if (e.getKey() == 255)
2720 // "Previously saved scheme" item
2721 this.setFont(this.getFont().deriveFont(Font.ITALIC));
2723 else if (e.getKey() == 0)
2726 this.setFont(this.getFont().deriveFont(Font.BOLD));
2728 } catch (Exception e) {