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.fts.core.FTSDataColumnPreferences;
24 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
25 import jalview.fts.service.pdb.PDBFTSRestClient;
26 import jalview.gui.JalviewBooleanRadioButtons;
27 import jalview.gui.JvSwingUtils;
28 import jalview.gui.StructureViewer.ViewerType;
29 import jalview.io.BackupFilenameFilter;
30 import jalview.io.BackupFiles;
31 import jalview.util.MessageManager;
33 import java.awt.BorderLayout;
34 import java.awt.Color;
35 import java.awt.Component;
36 import java.awt.Dimension;
37 import java.awt.FlowLayout;
39 import java.awt.FontMetrics;
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.ArrayList;
54 import java.util.HashMap;
56 import javax.swing.AbstractCellEditor;
57 import javax.swing.BorderFactory;
58 import javax.swing.ButtonGroup;
59 import javax.swing.DefaultListCellRenderer;
60 import javax.swing.JButton;
61 import javax.swing.JCheckBox;
62 import javax.swing.JComboBox;
63 import javax.swing.JFileChooser;
64 import javax.swing.JLabel;
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();
286 protected JPanel wsTab = new JPanel();
289 * Backups tab components
290 * a lot of these are member variables instead of local variables only so that they
291 * can be enabled/disabled easily in one go
294 protected JCheckBox enableBackupFiles = new JCheckBox();
296 protected JPanel presetsPanel = new JPanel();
298 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
300 protected JPanel suffixPanel = new JPanel();
302 protected JPanel keepfilesPanel = new JPanel();
304 protected JPanel exampleFilesPanel = new JPanel();
306 protected JTextField suffixTemplate = new JTextField(null, 8);
308 protected JLabel suffixTemplateLabel = new JLabel();
310 protected JLabel suffixDigitsLabel = new JLabel();
312 protected JSpinner suffixDigitsSpinner = new JSpinner();
314 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
316 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
318 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
320 protected JLabel oldBackupFilesLabel = new JLabel();
322 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
324 protected JTextArea backupfilesExampleLabel = new JTextArea();
327 * Creates a new GPreferences object.
329 public GPreferences()
334 } catch (Exception ex)
336 ex.printStackTrace();
341 * Construct the panel and its tabbed sub-panels.
345 private void jbInit() throws Exception
347 final JTabbedPane tabbedPane = new JTabbedPane();
348 this.setLayout(new BorderLayout());
349 JPanel okCancelPanel = initOkCancelPanel();
350 this.add(tabbedPane, BorderLayout.CENTER);
351 this.add(okCancelPanel, BorderLayout.SOUTH);
353 tabbedPane.add(initVisualTab(),
354 MessageManager.getString("label.visual"));
356 tabbedPane.add(initColoursTab(),
357 MessageManager.getString("label.colours"));
359 tabbedPane.add(initOverviewTab(),
360 MessageManager.getString("label.overview"));
362 tabbedPane.add(initStructureTab(),
363 MessageManager.getString("label.structure"));
365 tabbedPane.add(initConnectionsTab(),
366 MessageManager.getString("label.connections"));
368 tabbedPane.add(initBackupsTab(),
369 MessageManager.getString("label.backups"));
371 tabbedPane.add(initLinksTab(),
372 MessageManager.getString("label.urllinks"));
374 tabbedPane.add(initOutputTab(),
375 MessageManager.getString("label.output"));
377 tabbedPane.add(initEditingTab(),
378 MessageManager.getString("label.editing"));
381 * See WsPreferences for the real work of configuring this tab.
383 wsTab.setLayout(new BorderLayout());
384 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
387 * Handler to validate a tab before leaving it - currently only for
390 tabbedPane.addChangeListener(new ChangeListener()
392 private Component lastTab;
395 public void stateChanged(ChangeEvent e)
397 if (lastTab == structureTab
398 && tabbedPane.getSelectedComponent() != structureTab)
400 if (!validateStructure())
402 tabbedPane.setSelectedComponent(structureTab);
406 lastTab = tabbedPane.getSelectedComponent();
413 * Initialises the Editing tabbed panel.
417 private JPanel initEditingTab()
419 JPanel editingTab = new JPanel();
420 editingTab.setLayout(null);
421 autoCalculateConsCheck.setFont(LABEL_FONT);
422 autoCalculateConsCheck.setText(
423 MessageManager.getString("label.autocalculate_consensus"));
424 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
425 padGaps.setFont(LABEL_FONT);
427 MessageManager.getString("label.pad_gaps_when_editing"));
428 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
429 sortByTree.setFont(LABEL_FONT);
431 .setText(MessageManager.getString("label.sort_with_new_tree"));
432 sortByTree.setToolTipText(MessageManager.getString(
433 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
434 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
435 editingTab.add(autoCalculateConsCheck);
436 editingTab.add(padGaps);
437 editingTab.add(sortByTree);
442 * Initialises the Output tabbed panel.
446 private JPanel initOutputTab()
448 JPanel outputTab = new JPanel();
449 outputTab.setLayout(null);
450 JLabel epsLabel = new JLabel();
451 epsLabel.setFont(LABEL_FONT);
452 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
453 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
454 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
455 epsRendering.setFont(LABEL_FONT);
456 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
457 JLabel jLabel1 = new JLabel();
458 jLabel1.setFont(LABEL_FONT);
459 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
460 jLabel1.setText(MessageManager.getString("label.append_start_end"));
461 jLabel1.setFont(LABEL_FONT);
462 fastajv.setFont(LABEL_FONT);
463 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
464 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
465 blcjv.setText(MessageManager.getString("label.blc") + " ");
466 fastajv.setText(MessageManager.getString("label.fasta") + " ");
467 msfjv.setText(MessageManager.getString("label.msf") + " ");
468 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
469 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
470 msfjv.setFont(LABEL_FONT);
471 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
472 pirjv.setText(MessageManager.getString("label.pir") + " ");
473 JPanel jPanel11 = new JPanel();
474 jPanel11.setFont(LABEL_FONT);
475 TitledBorder titledBorder2 = new TitledBorder(
476 MessageManager.getString("label.file_output"));
477 jPanel11.setBorder(titledBorder2);
478 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
479 GridLayout gridLayout3 = new GridLayout();
480 jPanel11.setLayout(gridLayout3);
481 gridLayout3.setRows(8);
482 blcjv.setFont(LABEL_FONT);
483 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
484 clustaljv.setFont(LABEL_FONT);
485 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
486 pfamjv.setFont(LABEL_FONT);
487 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
488 pileupjv.setFont(LABEL_FONT);
489 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
490 pirjv.setFont(LABEL_FONT);
491 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
492 autoIdWidth.setFont(LABEL_FONT);
494 MessageManager.getString("label.automatically_set_id_width"));
495 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
496 .getString("label.adjusts_width_generated_eps_png")));
497 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
498 autoIdWidth.addActionListener(new ActionListener()
502 public void actionPerformed(ActionEvent e)
504 autoIdWidth_actionPerformed();
507 userIdWidthlabel.setFont(LABEL_FONT);
508 userIdWidthlabel.setText(
509 MessageManager.getString("label.figure_id_column_width"));
510 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
511 .getString("label.manually_specify_width_left_column")));
512 userIdWidthlabel.setToolTipText(
513 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
514 "label.manually_specify_width_left_column")));
515 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
516 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
517 userIdWidth.setText("");
518 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
519 userIdWidth.addActionListener(new ActionListener()
523 public void actionPerformed(ActionEvent e)
525 userIdWidth_actionPerformed();
528 modellerOutput.setFont(LABEL_FONT);
530 .setText(MessageManager.getString("label.use_modeller_output"));
531 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
532 embbedBioJSON.setFont(LABEL_FONT);
533 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
534 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
537 TitledBorder backupFilesBorder = new TitledBorder(
539 .getString("label.backup_files"));
542 jPanel11.add(jLabel1);
544 jPanel11.add(clustaljv);
545 jPanel11.add(fastajv);
547 jPanel11.add(pfamjv);
548 jPanel11.add(pileupjv);
550 outputTab.add(autoIdWidth);
551 outputTab.add(userIdWidth);
552 outputTab.add(userIdWidthlabel);
553 outputTab.add(modellerOutput);
554 outputTab.add(embbedBioJSON);
555 outputTab.add(epsLabel);
556 outputTab.add(epsRendering);
557 outputTab.add(jPanel11);
562 * Initialises the Connections tabbed panel.
566 private JPanel initConnectionsTab()
568 JPanel connectTab = new JPanel();
569 connectTab.setLayout(new GridBagLayout());
571 // Label for browser text box
572 JLabel browserLabel = new JLabel();
573 browserLabel.setFont(LABEL_FONT);
574 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
575 browserLabel.setText(
576 MessageManager.getString("label.default_browser_unix"));
577 defaultBrowser.setFont(LABEL_FONT);
578 defaultBrowser.setText("");
579 final String tooltip = JvSwingUtils.wrapTooltip(true,
580 MessageManager.getString("label.double_click_to_browse"));
581 defaultBrowser.setToolTipText(tooltip);
582 defaultBrowser.addMouseListener(new MouseAdapter()
585 public void mouseClicked(MouseEvent e)
587 if (e.getClickCount() > 1)
589 defaultBrowser_mouseClicked(e);
594 JPanel proxyPanel = initConnTabProxyPanel();
595 initConnTabCheckboxes();
597 // Add default Browser text box
598 connectTab.add(browserLabel,
599 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
600 GridBagConstraints.WEST, GridBagConstraints.NONE,
601 new Insets(10, 0, 5, 5), 5, 1));
602 defaultBrowser.setFont(LABEL_FONT);
603 defaultBrowser.setText("");
605 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
606 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
607 new Insets(10, 0, 5, 10), 30, 1));
609 // Add proxy server panel
610 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
611 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
612 new Insets(10, 0, 5, 12), 4, 10));
614 // Add usage stats, version check and questionnaire checkboxes
615 connectTab.add(usagestats,
616 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
617 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
618 new Insets(0, 2, 5, 5), 70, 1));
619 connectTab.add(questionnaire,
620 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
621 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
622 new Insets(0, 2, 5, 10), 70, 1));
623 connectTab.add(versioncheck,
624 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
625 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
626 new Insets(0, 2, 5, 5), 70, 1));
628 // Add padding so the panel doesn't look ridiculous
629 JPanel spacePanel = new JPanel();
630 connectTab.add(spacePanel,
631 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
632 GridBagConstraints.WEST, GridBagConstraints.BOTH,
633 new Insets(0, 0, 0, 5), 70, 1));
639 * Initialises the Links tabbed panel.
643 private JPanel initLinksTab()
645 JPanel linkTab = new JPanel();
646 linkTab.setLayout(new GridBagLayout());
648 // Set up table for Url links
649 linkUrlTable.setFillsViewportHeight(true);
650 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
651 linkUrlTable.setAutoCreateRowSorter(true);
652 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
654 // adjust row height so radio buttons actually fit
655 // don't do this in the renderer, it causes the awt thread to activate
657 JRadioButton temp = new JRadioButton();
658 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
660 // Table in scrollpane so that the table is given a scrollbar
661 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
662 linkScrollPane.setBorder(null);
664 // Panel for links functionality
665 JPanel linkPanel = new JPanel(new GridBagLayout());
666 linkPanel.setBorder(new TitledBorder(
667 MessageManager.getString("label.url_linkfrom_sequence_id")));
669 // Put the Url links panel together
671 // Buttons go at top right, resizing only resizes the blank space vertically
672 JPanel buttonPanel = initLinkTabUrlButtons();
673 GridBagConstraints linkConstraints1 = new GridBagConstraints();
674 linkConstraints1.insets = new Insets(0, 0, 5, 0);
675 linkConstraints1.gridx = 0;
676 linkConstraints1.gridy = 0;
677 linkConstraints1.weightx = 1.0;
678 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
679 linkTab.add(buttonPanel, linkConstraints1);
681 // Links table goes at top left, resizing resizes the table
682 GridBagConstraints linkConstraints2 = new GridBagConstraints();
683 linkConstraints2.insets = new Insets(0, 0, 5, 5);
684 linkConstraints2.gridx = 0;
685 linkConstraints2.gridy = 1;
686 linkConstraints2.weightx = 1.0;
687 linkConstraints2.weighty = 1.0;
688 linkConstraints2.fill = GridBagConstraints.BOTH;
689 linkTab.add(linkScrollPane, linkConstraints2);
691 // Filter box and buttons goes at bottom left, resizing resizes the text box
692 JPanel filterPanel = initLinkTabFilterPanel();
693 GridBagConstraints linkConstraints3 = new GridBagConstraints();
694 linkConstraints3.insets = new Insets(0, 0, 0, 5);
695 linkConstraints3.gridx = 0;
696 linkConstraints3.gridy = 2;
697 linkConstraints3.weightx = 1.0;
698 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
699 linkTab.add(filterPanel, linkConstraints3);
704 private JPanel initLinkTabFilterPanel()
706 // Filter textbox and reset button
707 JLabel filterLabel = new JLabel(
708 MessageManager.getString("label.filter"));
709 filterLabel.setFont(LABEL_FONT);
710 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
711 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
713 filterTB.setFont(LABEL_FONT);
714 filterTB.setText("");
716 doReset.setText(MessageManager.getString("action.showall"));
717 userOnly.setText(MessageManager.getString("action.customfilter"));
719 // Panel for filter functionality
720 JPanel filterPanel = new JPanel(new GridBagLayout());
721 filterPanel.setBorder(new TitledBorder("Filter"));
722 GridBagConstraints gbc = new GridBagConstraints();
725 gbc.fill = GridBagConstraints.NONE;
726 gbc.anchor = GridBagConstraints.WEST;
728 filterPanel.add(filterLabel, gbc);
730 GridBagConstraints gbc1 = new GridBagConstraints();
733 gbc1.fill = GridBagConstraints.HORIZONTAL;
734 gbc1.anchor = GridBagConstraints.WEST;
736 filterPanel.add(filterTB, gbc1);
738 GridBagConstraints gbc2 = new GridBagConstraints();
740 gbc2.fill = GridBagConstraints.NONE;
741 gbc2.anchor = GridBagConstraints.WEST;
742 filterPanel.add(doReset, gbc2);
744 GridBagConstraints gbc3 = new GridBagConstraints();
746 gbc3.fill = GridBagConstraints.NONE;
747 gbc3.anchor = GridBagConstraints.WEST;
748 filterPanel.add(userOnly, gbc3);
753 private JPanel initLinkTabUrlButtons()
755 // Buttons for new / edit / delete Url links
756 JButton newLink = new JButton();
757 newLink.setText(MessageManager.getString("action.new"));
759 editLink.setText(MessageManager.getString("action.edit"));
761 deleteLink.setText(MessageManager.getString("action.delete"));
763 // no current selection, so initially disable delete/edit buttons
764 editLink.setEnabled(false);
765 deleteLink.setEnabled(false);
767 newLink.addActionListener(new java.awt.event.ActionListener()
770 public void actionPerformed(ActionEvent e)
772 newLink_actionPerformed(e);
776 editLink.setText(MessageManager.getString("action.edit"));
777 editLink.addActionListener(new java.awt.event.ActionListener()
780 public void actionPerformed(ActionEvent e)
782 editLink_actionPerformed(e);
786 deleteLink.setText(MessageManager.getString("action.delete"));
787 deleteLink.addActionListener(new java.awt.event.ActionListener()
790 public void actionPerformed(ActionEvent e)
792 deleteLink_actionPerformed(e);
796 JPanel buttonPanel = new JPanel(new GridBagLayout());
797 buttonPanel.setBorder(new TitledBorder("Edit links"));
798 GridBagConstraints gbc = new GridBagConstraints();
801 gbc.fill = GridBagConstraints.NONE;
802 buttonPanel.add(newLink, gbc);
804 GridBagConstraints gbc1 = new GridBagConstraints();
807 gbc1.fill = GridBagConstraints.NONE;
808 buttonPanel.add(editLink, gbc1);
810 GridBagConstraints gbc2 = new GridBagConstraints();
813 gbc2.fill = GridBagConstraints.NONE;
814 buttonPanel.add(deleteLink, gbc2);
816 GridBagConstraints gbc3 = new GridBagConstraints();
819 gbc3.fill = GridBagConstraints.HORIZONTAL;
821 JPanel spacePanel = new JPanel();
822 spacePanel.setBorder(null);
823 buttonPanel.add(spacePanel, gbc3);
829 * Initialises the proxy server panel in the Connections tab
831 * @return the proxy server panel
833 private JPanel initConnTabProxyPanel()
835 // Label for server text box
836 serverLabel.setText(MessageManager.getString("label.address"));
837 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
838 serverLabel.setFont(LABEL_FONT);
840 // Proxy server and port text boxes
841 proxyServerTB.setFont(LABEL_FONT);
842 proxyPortTB.setFont(LABEL_FONT);
844 // Label for Port text box
845 portLabel.setFont(LABEL_FONT);
846 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
847 portLabel.setText(MessageManager.getString("label.port"));
849 // Use proxy server checkbox
850 useProxy.setFont(LABEL_FONT);
851 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
852 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
853 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
854 useProxy.addActionListener(new ActionListener()
857 public void actionPerformed(ActionEvent e)
859 useProxy_actionPerformed();
863 // Make proxy server panel
864 JPanel proxyPanel = new JPanel();
865 TitledBorder titledBorder1 = new TitledBorder(
866 MessageManager.getString("label.proxy_server"));
867 proxyPanel.setBorder(titledBorder1);
868 proxyPanel.setLayout(new GridBagLayout());
869 proxyPanel.add(serverLabel,
870 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
871 GridBagConstraints.WEST, GridBagConstraints.NONE,
872 new Insets(0, 2, 2, 0), 5, 0));
873 proxyPanel.add(portLabel,
874 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
875 GridBagConstraints.WEST, GridBagConstraints.NONE,
876 new Insets(0, 0, 2, 0), 11, 0));
877 proxyPanel.add(useProxy,
878 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
879 GridBagConstraints.WEST, GridBagConstraints.NONE,
880 new Insets(0, 2, 5, 185), 2, -4));
881 proxyPanel.add(proxyPortTB,
882 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
883 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
884 new Insets(0, 2, 2, 2), 54, 1));
885 proxyPanel.add(proxyServerTB,
886 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
887 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
888 new Insets(0, 2, 2, 0), 263, 1));
894 * Initialises the checkboxes in the Connections tab
896 private void initConnTabCheckboxes()
898 // Usage stats checkbox label
900 MessageManager.getString("label.send_usage_statistics"));
901 usagestats.setFont(LABEL_FONT);
902 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
903 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
905 // Questionnaire checkbox label
906 questionnaire.setText(
907 MessageManager.getString("label.check_for_questionnaires"));
908 questionnaire.setFont(LABEL_FONT);
909 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
910 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
912 // Check for latest version checkbox label
913 versioncheck.setText(
914 MessageManager.getString("label.check_for_latest_version"));
915 versioncheck.setFont(LABEL_FONT);
916 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
917 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
921 * Initialises the parent panel which contains the tabbed sections.
925 private JPanel initOkCancelPanel()
927 JButton ok = new JButton();
928 ok.setText(MessageManager.getString("action.ok"));
929 ok.addActionListener(new ActionListener()
932 public void actionPerformed(ActionEvent e)
934 ok_actionPerformed(e);
937 JButton cancel = new JButton();
938 cancel.setText(MessageManager.getString("action.cancel"));
939 cancel.addActionListener(new ActionListener()
942 public void actionPerformed(ActionEvent e)
944 cancel_actionPerformed(e);
947 JPanel okCancelPanel = new JPanel();
948 okCancelPanel.add(ok);
949 okCancelPanel.add(cancel);
950 return okCancelPanel;
954 * Initialises the Colours tabbed panel.
958 private JPanel initColoursTab()
960 JPanel coloursTab = new JPanel();
961 coloursTab.setBorder(new TitledBorder(
962 MessageManager.getString("action.open_new_alignment")));
963 coloursTab.setLayout(new FlowLayout());
964 JLabel mincolourLabel = new JLabel();
965 mincolourLabel.setFont(LABEL_FONT);
966 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
967 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
968 minColour.setFont(LABEL_FONT);
969 minColour.setBorder(BorderFactory.createEtchedBorder());
970 minColour.setPreferredSize(new Dimension(40, 20));
971 minColour.addMouseListener(new MouseAdapter()
974 public void mousePressed(MouseEvent e)
976 minColour_actionPerformed(minColour);
979 JLabel maxcolourLabel = new JLabel();
980 maxcolourLabel.setFont(LABEL_FONT);
981 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
982 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
983 maxColour.setFont(LABEL_FONT);
984 maxColour.setBorder(BorderFactory.createEtchedBorder());
985 maxColour.setPreferredSize(new Dimension(40, 20));
986 maxColour.addMouseListener(new MouseAdapter()
989 public void mousePressed(MouseEvent e)
991 maxColour_actionPerformed(maxColour);
995 protColour.setFont(LABEL_FONT);
996 protColour.setBounds(new Rectangle(172, 225, 155, 21));
997 JLabel protColourLabel = new JLabel();
998 protColourLabel.setFont(LABEL_FONT);
999 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1000 protColourLabel.setText(
1001 MessageManager.getString("label.prot_alignment_colour") + " ");
1002 JvSwingUtils.addtoLayout(coloursTab,
1004 .getString("label.default_colour_scheme_for_alignment"),
1005 protColourLabel, protColour);
1007 nucColour.setFont(LABEL_FONT);
1008 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1009 JLabel nucColourLabel = new JLabel();
1010 nucColourLabel.setFont(LABEL_FONT);
1011 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1012 nucColourLabel.setText(
1013 MessageManager.getString("label.nuc_alignment_colour") + " ");
1014 JvSwingUtils.addtoLayout(coloursTab,
1016 .getString("label.default_colour_scheme_for_alignment"),
1017 nucColourLabel, nucColour);
1019 JPanel annotationShding = new JPanel();
1020 annotationShding.setBorder(new TitledBorder(
1021 MessageManager.getString("label.annotation_shading_default")));
1022 annotationShding.setLayout(new GridLayout(1, 2));
1023 JvSwingUtils.addtoLayout(annotationShding,
1024 MessageManager.getString(
1025 "label.default_minimum_colour_annotation_shading"),
1026 mincolourLabel, minColour);
1027 JvSwingUtils.addtoLayout(annotationShding,
1028 MessageManager.getString(
1029 "label.default_maximum_colour_annotation_shading"),
1030 maxcolourLabel, maxColour);
1031 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1036 * Initialises the Overview tabbed panel.
1040 private JPanel initOverviewTab()
1042 JPanel overviewPanel = new JPanel();
1043 overviewPanel.setBorder(new TitledBorder(
1044 MessageManager.getString("label.overview_settings")));
1046 gapColour.setFont(LABEL_FONT);
1047 // fixing the border colours stops apparent colour bleed from the panel
1048 gapColour.setBorder(
1049 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1050 gapColour.setPreferredSize(new Dimension(40, 20));
1051 gapColour.addMouseListener(new MouseAdapter()
1054 public void mousePressed(MouseEvent e)
1056 gapColour_actionPerformed(gapColour);
1060 hiddenColour.setFont(LABEL_FONT);
1061 // fixing the border colours stops apparent colour bleed from the panel
1062 hiddenColour.setBorder(
1063 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1064 hiddenColour.setPreferredSize(new Dimension(40, 20));
1065 hiddenColour.addMouseListener(new MouseAdapter()
1068 public void mousePressed(MouseEvent e)
1070 hiddenColour_actionPerformed(hiddenColour);
1074 useLegacyGap = new JCheckBox(
1075 MessageManager.getString("label.ov_legacy_gap"));
1076 useLegacyGap.setFont(LABEL_FONT);
1077 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1078 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1079 gapLabel = new JLabel(
1080 MessageManager.getString("label.gap_colour"));
1081 gapLabel.setFont(LABEL_FONT);
1082 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1083 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1084 showHiddenAtStart = new JCheckBox(
1085 MessageManager.getString("label.ov_show_hide_default"));
1086 showHiddenAtStart.setFont(LABEL_FONT);
1087 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1088 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1089 JLabel hiddenLabel = new JLabel(
1090 MessageManager.getString("label.hidden_colour"));
1091 hiddenLabel.setFont(LABEL_FONT);
1092 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1093 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1095 useLegacyGap.addActionListener(new ActionListener()
1098 public void actionPerformed(ActionEvent e)
1100 useLegacyGaps_actionPerformed(e);
1104 overviewPanel.setLayout(new GridBagLayout());
1105 GridBagConstraints c1 = new GridBagConstraints();
1107 c1.fill = GridBagConstraints.HORIZONTAL;
1112 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1113 overviewPanel.add(useLegacyGap, c1);
1115 GridBagConstraints c2 = new GridBagConstraints();
1116 c2.fill = GridBagConstraints.HORIZONTAL;
1119 c2.insets = new Insets(0, 15, 0, 10);
1120 overviewPanel.add(gapLabel, c2);
1122 GridBagConstraints c3 = new GridBagConstraints();
1123 c3.fill = GridBagConstraints.HORIZONTAL;
1126 c3.insets = new Insets(0, 0, 0, 15);
1127 overviewPanel.add(gapColour, c3);
1129 GridBagConstraints c4 = new GridBagConstraints();
1130 c4.fill = GridBagConstraints.HORIZONTAL;
1134 overviewPanel.add(showHiddenAtStart, c4);
1136 GridBagConstraints c5 = new GridBagConstraints();
1137 c5.fill = GridBagConstraints.HORIZONTAL;
1140 c5.insets = new Insets(0, 15, 0, 10);
1141 overviewPanel.add(hiddenLabel, c5);
1143 GridBagConstraints c6 = new GridBagConstraints();
1144 c6.fill = GridBagConstraints.HORIZONTAL;
1147 c6.insets = new Insets(0, 0, 0, 15);
1148 overviewPanel.add(hiddenColour, c6);
1150 JButton resetButton = new JButton(
1151 MessageManager.getString("label.reset_to_defaults"));
1153 resetButton.addActionListener(new ActionListener()
1156 public void actionPerformed(ActionEvent e)
1158 resetOvDefaults_actionPerformed(e);
1162 GridBagConstraints c7 = new GridBagConstraints();
1163 c7.fill = GridBagConstraints.NONE;
1166 c7.insets = new Insets(10, 0, 0, 0);
1167 c7.anchor = GridBagConstraints.WEST;
1168 overviewPanel.add(resetButton, c7);
1170 // Add padding so the panel doesn't look ridiculous
1171 JPanel spacePanel = new JPanel();
1172 overviewPanel.add(spacePanel,
1173 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1174 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1175 new Insets(0, 0, 0, 5), 0, 0));
1177 return overviewPanel;
1181 * Initialises the Structure tabbed panel.
1185 private JPanel initStructureTab()
1187 structureTab = new JPanel();
1189 structureTab.setBorder(new TitledBorder(
1190 MessageManager.getString("label.structure_options")));
1191 structureTab.setLayout(null);
1192 final int width = 400;
1193 final int height = 22;
1194 final int lineSpacing = 25;
1197 structFromPdb.setFont(LABEL_FONT);
1199 .setText(MessageManager.getString("label.struct_from_pdb"));
1200 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1201 structFromPdb.addActionListener(new ActionListener()
1204 public void actionPerformed(ActionEvent e)
1206 boolean selected = structFromPdb.isSelected();
1207 // enable other options only when the first is checked
1208 useRnaView.setEnabled(selected);
1209 addSecondaryStructure.setEnabled(selected);
1210 addTempFactor.setEnabled(selected);
1213 structureTab.add(structFromPdb);
1215 // indent checkboxes that are conditional on the first one
1216 ypos += lineSpacing;
1217 useRnaView.setFont(LABEL_FONT);
1218 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1219 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1220 structureTab.add(useRnaView);
1222 ypos += lineSpacing;
1223 addSecondaryStructure.setFont(LABEL_FONT);
1224 addSecondaryStructure
1225 .setText(MessageManager.getString("label.autoadd_secstr"));
1226 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1227 structureTab.add(addSecondaryStructure);
1229 ypos += lineSpacing;
1230 addTempFactor.setFont(LABEL_FONT);
1231 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1232 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1233 structureTab.add(addTempFactor);
1235 ypos += lineSpacing;
1236 JLabel viewerLabel = new JLabel();
1237 viewerLabel.setFont(LABEL_FONT);
1238 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1239 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1240 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1241 structureTab.add(viewerLabel);
1243 structViewer.setFont(LABEL_FONT);
1244 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1245 structViewer.addItem(ViewerType.JMOL.name());
1246 structViewer.addItem(ViewerType.CHIMERA.name());
1247 structViewer.addActionListener(new ActionListener()
1250 public void actionPerformed(ActionEvent e)
1252 structureViewer_actionPerformed(
1253 (String) structViewer.getSelectedItem());
1256 structureTab.add(structViewer);
1258 ypos += lineSpacing;
1259 JLabel pathLabel = new JLabel();
1260 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1261 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1262 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1263 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1264 structureTab.add(pathLabel);
1266 chimeraPath.setFont(LABEL_FONT);
1267 chimeraPath.setText("");
1268 final String tooltip = JvSwingUtils.wrapTooltip(true,
1269 MessageManager.getString("label.chimera_path_tip"));
1270 chimeraPath.setToolTipText(tooltip);
1271 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1272 chimeraPath.addMouseListener(new MouseAdapter()
1275 public void mouseClicked(MouseEvent e)
1277 if (e.getClickCount() == 2)
1279 String chosen = openFileChooser();
1282 chimeraPath.setText(chosen);
1287 structureTab.add(chimeraPath);
1289 ypos += lineSpacing;
1290 nwMapping.setFont(LABEL_FONT);
1291 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1292 siftsMapping.setFont(LABEL_FONT);
1293 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1294 mappingMethod.add(nwMapping);
1295 mappingMethod.add(siftsMapping);
1296 JPanel mappingPanel = new JPanel();
1297 mappingPanel.setFont(LABEL_FONT);
1298 TitledBorder mmTitledBorder = new TitledBorder(
1299 MessageManager.getString("label.mapping_method"));
1300 mmTitledBorder.setTitleFont(LABEL_FONT);
1301 mappingPanel.setBorder(mmTitledBorder);
1302 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1303 // GridLayout mappingLayout = new GridLayout();
1304 mappingPanel.setLayout(new GridLayout());
1305 mappingPanel.add(nwMapping);
1306 mappingPanel.add(siftsMapping);
1307 structureTab.add(mappingPanel);
1309 ypos += lineSpacing;
1310 ypos += lineSpacing;
1311 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1312 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1313 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1314 structureTab.add(docFieldPref);
1316 return structureTab;
1320 * Action on choosing a structure viewer from combobox options.
1322 * @param selectedItem
1324 protected void structureViewer_actionPerformed(String selectedItem)
1329 * Show a dialog for the user to choose a file. Returns the chosen path, or
1334 protected String openFileChooser()
1336 String choice = null;
1337 JFileChooser chooser = new JFileChooser();
1339 // chooser.setFileView(new JalviewFileView());
1340 chooser.setDialogTitle(
1341 MessageManager.getString("label.open_local_file"));
1342 chooser.setToolTipText(MessageManager.getString("action.open"));
1344 int value = chooser.showOpenDialog(this);
1346 if (value == JFileChooser.APPROVE_OPTION)
1348 choice = chooser.getSelectedFile().getPath();
1354 * Validate the structure tab preferences; if invalid, set focus on this tab.
1358 protected boolean validateStructure(FocusEvent e)
1360 if (!validateStructure())
1362 e.getComponent().requestFocusInWindow();
1368 protected boolean validateStructure()
1374 * Initialises the Visual tabbed panel.
1378 private JPanel initVisualTab()
1380 JPanel visualTab = new JPanel();
1381 visualTab.setBorder(new TitledBorder(
1382 MessageManager.getString("action.open_new_alignment")));
1383 visualTab.setLayout(null);
1384 fullScreen.setFont(LABEL_FONT);
1385 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1386 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1387 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1388 quality.setEnabled(false);
1389 quality.setFont(LABEL_FONT);
1390 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1391 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1392 quality.setSelected(true);
1393 quality.setText(MessageManager.getString("label.quality"));
1394 conservation.setEnabled(false);
1395 conservation.setFont(LABEL_FONT);
1396 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1397 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1398 conservation.setSelected(true);
1399 conservation.setText(MessageManager.getString("label.conservation"));
1400 identity.setEnabled(false);
1401 identity.setFont(LABEL_FONT);
1402 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1403 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1404 identity.setSelected(true);
1405 identity.setText(MessageManager.getString("label.consensus"));
1406 showOccupancy.setFont(LABEL_FONT);
1407 showOccupancy.setEnabled(false);
1408 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1409 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1410 showOccupancy.setSelected(true);
1411 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1413 JLabel showGroupbits = new JLabel();
1414 showGroupbits.setFont(LABEL_FONT);
1415 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1416 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1418 .setText(MessageManager.getString("action.show_group") + ":");
1419 JLabel showConsensbits = new JLabel();
1420 showConsensbits.setFont(LABEL_FONT);
1421 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1422 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1424 .setText(MessageManager.getString("label.consensus") + ":");
1425 showConsensHistogram.setEnabled(false);
1426 showConsensHistogram.setFont(LABEL_FONT);
1427 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1428 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1429 showConsensHistogram.setSelected(true);
1430 showConsensHistogram
1431 .setText(MessageManager.getString("label.histogram"));
1432 showConsensLogo.setEnabled(false);
1433 showConsensLogo.setFont(LABEL_FONT);
1434 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1435 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1436 showConsensLogo.setSelected(true);
1437 showConsensLogo.setText(MessageManager.getString("label.logo"));
1438 showGroupConsensus.setEnabled(false);
1439 showGroupConsensus.setFont(LABEL_FONT);
1440 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1441 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1442 showGroupConsensus.setSelected(true);
1443 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1444 showGroupConservation.setEnabled(false);
1445 showGroupConservation.setFont(LABEL_FONT);
1446 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1447 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1448 showGroupConservation.setSelected(true);
1449 showGroupConservation
1450 .setText(MessageManager.getString("label.conservation"));
1451 showNpTooltip.setEnabled(true);
1452 showNpTooltip.setFont(LABEL_FONT);
1453 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1454 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1455 showNpTooltip.setSelected(true);
1456 showNpTooltip.setText(
1457 MessageManager.getString("label.non_positional_features"));
1458 showDbRefTooltip.setEnabled(true);
1459 showDbRefTooltip.setFont(LABEL_FONT);
1460 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1461 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1462 showDbRefTooltip.setSelected(true);
1464 .setText(MessageManager.getString("label.database_references"));
1465 annotations.setFont(LABEL_FONT);
1466 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1467 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1468 annotations.setSelected(true);
1469 annotations.setText(MessageManager.getString("label.show_annotations"));
1470 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1471 annotations.addActionListener(new ActionListener()
1474 public void actionPerformed(ActionEvent e)
1476 annotations_actionPerformed(e);
1479 identity.addActionListener(new ActionListener()
1482 public void actionPerformed(ActionEvent e)
1484 annotations_actionPerformed(e);
1487 showGroupConsensus.addActionListener(new ActionListener()
1490 public void actionPerformed(ActionEvent e)
1492 annotations_actionPerformed(e);
1495 showUnconserved.setFont(LABEL_FONT);
1496 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1497 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1498 showUnconserved.setSelected(true);
1500 .setText(MessageManager.getString("action.show_unconserved"));
1501 showUnconserved.addActionListener(new ActionListener()
1504 public void actionPerformed(ActionEvent e)
1506 showunconserved_actionPerformed(e);
1510 // TODO these are not yet added to / action from Preferences
1511 // JCheckBox shareSelections = new JCheckBox();
1512 // shareSelections.setFont(verdana11);
1513 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1514 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1515 // shareSelections.setSelected(true);
1516 // shareSelections.setText(MessageManager
1517 // .getString("label.share_selection_across_views"));
1518 // JCheckBox followHighlight = new JCheckBox();
1519 // followHighlight.setFont(verdana11);
1520 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1521 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1522 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1523 // followHighlight.setSelected(true);
1524 // followHighlight.setText(MessageManager
1525 // .getString("label.scroll_highlighted_regions"));
1527 seqLimit.setFont(LABEL_FONT);
1528 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1529 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1530 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1531 smoothFont.setFont(LABEL_FONT);
1532 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1533 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1534 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1535 scaleProteinToCdna.setFont(LABEL_FONT);
1536 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1537 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1538 scaleProteinToCdna.setText(
1539 MessageManager.getString("label.scale_protein_to_cdna"));
1540 scaleProteinToCdna.setToolTipText(
1541 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1542 JLabel gapLabel = new JLabel();
1543 gapLabel.setFont(LABEL_FONT);
1544 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1545 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1546 JLabel fontLabel = new JLabel();
1547 fontLabel.setFont(LABEL_FONT);
1548 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1549 fontLabel.setText(MessageManager.getString("label.font"));
1550 fontSizeCB.setFont(LABEL_FONT);
1551 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1552 fontStyleCB.setFont(LABEL_FONT);
1553 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1554 fontNameCB.setFont(LABEL_FONT);
1555 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1556 gapSymbolCB.setFont(LABEL_FONT);
1557 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1558 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1559 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1560 gapSymbolCB.setRenderer(dlcr);
1562 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1563 startupCheckbox.setFont(LABEL_FONT);
1564 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1565 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1566 startupCheckbox.setSelected(true);
1567 startupFileTextfield.setFont(LABEL_FONT);
1568 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1569 final String tooltip = JvSwingUtils.wrapTooltip(true,
1570 MessageManager.getString("label.double_click_to_browse"));
1571 startupFileTextfield.setToolTipText(tooltip);
1572 startupFileTextfield.addMouseListener(new MouseAdapter()
1575 public void mouseClicked(MouseEvent e)
1577 if (e.getClickCount() > 1)
1579 startupFileTextfield_mouseClicked();
1584 sortby.setFont(LABEL_FONT);
1585 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1586 JLabel sortLabel = new JLabel();
1587 sortLabel.setFont(LABEL_FONT);
1588 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1589 sortLabel.setText(MessageManager.getString("label.sort_by"));
1590 sortAnnBy.setFont(LABEL_FONT);
1591 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1592 JLabel sortAnnLabel = new JLabel();
1593 sortAnnLabel.setFont(LABEL_FONT);
1594 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1595 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1596 sortAutocalc.setFont(LABEL_FONT);
1597 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1599 JPanel annsettingsPanel = new JPanel();
1600 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1601 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1602 annsettingsPanel.setBorder(new EtchedBorder());
1603 visualTab.add(annsettingsPanel);
1604 Border jb = new EmptyBorder(1, 1, 4, 5);
1605 annotations.setBorder(jb);
1606 showOccupancy.setBorder(jb);
1607 quality.setBorder(jb);
1608 conservation.setBorder(jb);
1609 identity.setBorder(jb);
1610 showConsensbits.setBorder(jb);
1611 showGroupbits.setBorder(jb);
1612 showGroupConsensus.setBorder(jb);
1613 showGroupConservation.setBorder(jb);
1614 showConsensHistogram.setBorder(jb);
1615 showConsensLogo.setBorder(jb);
1617 JPanel autoAnnotSettings = new JPanel();
1618 annsettingsPanel.add(autoAnnotSettings);
1619 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1620 autoAnnotSettings.add(annotations);
1621 autoAnnotSettings.add(quality);
1622 // second row of autoannotation box
1623 autoAnnotSettings = new JPanel();
1624 annsettingsPanel.add(autoAnnotSettings);
1626 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1627 autoAnnotSettings.add(conservation);
1628 autoAnnotSettings.add(identity);
1629 autoAnnotSettings.add(showOccupancy);
1630 autoAnnotSettings.add(showGroupbits);
1631 autoAnnotSettings.add(showGroupConservation);
1632 autoAnnotSettings.add(showGroupConsensus);
1633 autoAnnotSettings.add(showConsensbits);
1634 autoAnnotSettings.add(showConsensHistogram);
1635 autoAnnotSettings.add(showConsensLogo);
1637 JPanel tooltipSettings = new JPanel();
1638 tooltipSettings.setBorder(new TitledBorder(
1639 MessageManager.getString("label.sequence_id_tooltip")));
1640 tooltipSettings.setBounds(173, 140, 220, 62);
1641 tooltipSettings.setLayout(new GridLayout(2, 1));
1642 tooltipSettings.add(showDbRefTooltip);
1643 tooltipSettings.add(showNpTooltip);
1644 visualTab.add(tooltipSettings);
1646 wrap.setFont(LABEL_FONT);
1647 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1648 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1649 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1650 rightAlign.setFont(LABEL_FONT);
1651 rightAlign.setForeground(Color.black);
1652 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1653 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1654 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1655 idItalics.setFont(LABEL_FONT_ITALIC);
1656 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1657 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1659 MessageManager.getString("label.sequence_name_italics"));
1660 openoverv.setFont(LABEL_FONT);
1661 openoverv.setActionCommand(
1662 MessageManager.getString("label.open_overview"));
1663 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1664 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1665 openoverv.setText(MessageManager.getString("label.open_overview"));
1666 JPanel jPanel2 = new JPanel();
1667 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1668 jPanel2.setLayout(new GridLayout(14, 1));
1669 jPanel2.add(fullScreen);
1670 jPanel2.add(openoverv);
1671 jPanel2.add(seqLimit);
1672 jPanel2.add(rightAlign);
1673 jPanel2.add(fontLabel);
1674 jPanel2.add(showUnconserved);
1675 jPanel2.add(idItalics);
1676 jPanel2.add(smoothFont);
1677 jPanel2.add(scaleProteinToCdna);
1678 jPanel2.add(gapLabel);
1680 jPanel2.add(sortLabel);
1681 jPanel2.add(sortAnnLabel);
1682 jPanel2.add(startupCheckbox);
1683 visualTab.add(jPanel2);
1684 visualTab.add(startupFileTextfield);
1685 visualTab.add(sortby);
1686 visualTab.add(sortAnnBy);
1687 visualTab.add(sortAutocalc);
1688 visualTab.add(gapSymbolCB);
1689 visualTab.add(fontNameCB);
1690 visualTab.add(fontSizeCB);
1691 visualTab.add(fontStyleCB);
1696 * Initialises the Backups tabbed panel.
1700 private JPanel initBackupsTab()
1702 JPanel backupsTab = new JPanel();
1703 backupsTab.setBorder(new TitledBorder(MessageManager
1704 .getString("label.backup_files")));
1705 backupsTab.setLayout(new GridBagLayout());
1707 GridBagConstraints gbc = new GridBagConstraints();
1710 gbc.anchor = GridBagConstraints.NORTHWEST;
1711 gbc.fill = GridBagConstraints.NONE;
1713 initBackupsTabPresetsPanel();
1714 initBackupsTabSuffixPanel();
1715 initBackupsTabKeepFilesPanel();
1716 initBackupsTabFilenameExamplesPanel();
1719 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1720 enableBackupFiles.setText(
1721 MessageManager.getString("label.enable_backupfiles"));
1722 enableBackupFiles.addActionListener(new ActionListener()
1725 public void actionPerformed(ActionEvent e)
1727 boolean selected = enableBackupFiles.isSelected();
1728 // enable other options only when the first is checked
1729 backupsOptionsSetEnabled(selected);
1733 // enable checkbox 1 row
1737 backupsTab.add(enableBackupFiles, gbc);
1742 //gbc.anchor = GridBagConstraints.NORTHEAST;
1743 //gbc.fill = GridBagConstraints.HORIZONTAL;
1744 backupsTab.add(exampleFilesPanel, gbc);
1748 backupsTab.add(presetsPanel, gbc);
1750 gbc.anchor = GridBagConstraints.NORTHWEST;
1751 gbc.fill = GridBagConstraints.NONE;
1754 // whole suffix panel next row
1757 backupsTab.add(suffixPanel, gbc);
1761 backupsTab.add(keepfilesPanel, gbc);
1764 // whole examples panel next row
1766 backupsTab.add(exampleFilesPanel, gbc);
1771 backupsTab.add(new JPanel(), gbc);
1774 backupsOptionsSetEnabled(enableBackupFiles.isSelected());
1778 private final IntKeyStringValueEntry[] backupfilesPresetEntries =
1780 new IntKeyStringValueEntry(1, MessageManager.getString("label.default")),
1781 new IntKeyStringValueEntry(2, MessageManager.getString("label.single_file")),
1782 new IntKeyStringValueEntry(3, MessageManager.getString("label.keep_everything")),
1783 new IntKeyStringValueEntry(4, MessageManager.getString("label.rolled_backups")),
1785 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1786 new IntKeyStringValueEntry(0, MessageManager.getString("label.custom"))
1789 private final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1791 put(1, new BackupFilesPresetEntry(".v"+BackupFiles.NUM_PLACEHOLDER, 3, false, false, 4, false));
1792 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1793 put(3, new BackupFilesPresetEntry(".v"+BackupFiles.NUM_PLACEHOLDER, 3, false, true, 10, true));
1794 put(4, new BackupFilesPresetEntry("_bak."+BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9, false));
1797 private JPanel initBackupsTabPresetsPanel()
1799 presetsPanel.setBorder(new TitledBorder(
1800 MessageManager.getString("label.presets")));
1802 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1804 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1807 backupfilesPresetsCombo.addActionListener(new ActionListener()
1810 public void actionPerformed(ActionEvent e)
1812 backupsTabUpdatePresets();
1817 presetsPanel.add(backupfilesPresetsCombo);
1818 return presetsPanel;
1821 private void backupsTabUpdatePresets()
1823 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo.getSelectedItem();
1824 int key = entry.getKey();
1825 String value = entry.getValue();
1826 boolean custom = key==0;
1830 //backupsSetCustomOptions();
1833 if (backupfilesPresetEntriesValues.containsKey(key))
1835 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
1837 System.out.println("Preset '"+value+"' not implemented yet");
1841 updateBackupFilesExampleLabel();
1842 backupsCustomOptionsSetEnabled(custom);
1845 protected int getComboIntStringKey(JComboBox c)
1847 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
1848 return e!=null?e.getKey():0;
1851 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c, int key)
1853 for (int i=0; i < c.getItemCount(); i++)
1855 IntKeyStringValueEntry e = c.getItemAt(i);
1857 String v = e.getValue();
1858 if (e.getKey() == key)
1860 c.setSelectedIndex(i);
1864 backupsTabUpdatePresets();
1867 private JPanel initBackupsTabSuffixPanel()
1869 suffixPanel.setBorder(new TitledBorder(
1870 MessageManager.getString("label.suffix_format")));
1871 suffixPanel.setLayout(new GridBagLayout());
1874 .setText(MessageManager.getString("label.suffix_template"));
1875 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
1876 suffixTemplateLabel.setFont(LABEL_FONT);
1878 final String tooltip = JvSwingUtils.wrapTooltip(true, MessageManager
1879 .getString("label.suffix_template_tooltip"));
1880 suffixTemplate.setToolTipText(tooltip);
1881 suffixTemplate.addActionListener(new ActionListener()
1884 public void actionPerformed(ActionEvent e)
1886 updateBackupFilesExampleLabel();
1890 KeyListener kl = new KeyListener()
1893 public void keyReleased(KeyEvent e)
1895 updateBackupFilesExampleLabel();
1899 public void keyPressed(KeyEvent e)
1903 // disable use of ':'
1905 public void keyTyped(KeyEvent e)
1907 char c = e.getKeyChar();
1910 // don't process ':'
1916 suffixTemplate.addKeyListener(kl);
1920 .setText(MessageManager.getString("label.index_digits"));
1921 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1922 suffixDigitsLabel.setFont(LABEL_FONT);
1925 ChangeListener c = new ChangeListener()
1928 public void stateChanged(ChangeEvent e)
1930 updateBackupFilesExampleLabel();
1934 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
1936 suffixReverse.setLabels(
1937 MessageManager.getString("label.reverse_roll"),
1938 MessageManager.getString("label.increment_index"));
1939 suffixReverse.addActionListener(new ActionListener()
1942 public void actionPerformed(ActionEvent e)
1944 updateBackupFilesExampleLabel();
1948 GridBagConstraints sgbc = new GridBagConstraints();
1950 // first row (template text box)
1951 sgbc.anchor = GridBagConstraints.WEST;
1955 sgbc.gridheight = 1;
1958 sgbc.fill = GridBagConstraints.NONE;
1959 suffixPanel.add(suffixTemplateLabel,sgbc);
1962 sgbc.fill = GridBagConstraints.HORIZONTAL;
1963 suffixPanel.add(suffixTemplate, sgbc);
1965 // second row (number of digits spinner)
1969 sgbc.fill = GridBagConstraints.NONE;
1970 suffixPanel.add(suffixDigitsLabel, sgbc);
1973 sgbc.fill = GridBagConstraints.HORIZONTAL;
1974 suffixPanel.add(suffixDigitsSpinner, sgbc);
1976 // third row (forward order radio selection)
1979 sgbc.gridwidth = GridBagConstraints.REMAINDER;
1980 sgbc.fill = GridBagConstraints.HORIZONTAL;
1981 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
1983 // fourth row (reverse order radio selection)
1985 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
1989 private void backupfilesKeepAllEnabled(boolean enabled)
1991 backupfilesKeepAll.setEnabled(enabled);
1992 keepRollMaxOptionsEnabled();
1995 private JPanel initBackupsTabKeepFilesPanel()
1997 keepfilesPanel.setBorder(
1998 new TitledBorder(MessageManager.getString("label.keep_files")));
1999 keepfilesPanel.setLayout(new GridBagLayout());
2001 backupfilesKeepAll.setLabels(
2002 MessageManager.getString("label.keep_all_backup_files"),
2003 MessageManager.getString(
2004 "label.keep_only_this_number_of_backup_files"));
2005 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2008 public void actionPerformed(ActionEvent e)
2010 updateBackupFilesExampleLabel();
2013 backupfilesKeepAll.addActionListener(new ActionListener()
2016 public void actionPerformed(ActionEvent e)
2018 boolean selected = backupfilesKeepAll.isSelected();
2019 keepRollMaxOptionsEnabled();
2020 updateBackupFilesExampleLabel();
2024 ChangeListener c = new ChangeListener()
2027 public void stateChanged(ChangeEvent e)
2029 updateBackupFilesExampleLabel();
2033 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2035 backupfilesConfirmDelete.setLabels(
2036 MessageManager.getString("label.confirm_delete"),
2037 MessageManager.getString("label.auto_delete"));
2038 // update the enabled section
2039 keepRollMaxOptionsEnabled();
2041 GridBagConstraints kgbc = new GridBagConstraints();
2043 // first row (template text box)
2044 kgbc.anchor = GridBagConstraints.WEST;
2047 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2048 kgbc.gridheight = 1;
2051 kgbc.fill = GridBagConstraints.HORIZONTAL;
2052 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2058 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2059 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2062 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2063 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2065 // third row (indented)
2067 kgbc.insets = new Insets(0, 20, 0, 0);
2070 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2071 kgbc.fill = GridBagConstraints.HORIZONTAL;
2074 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2076 // fourth row (indented)
2078 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2081 JPanel jp = new JPanel();
2082 jp.setLayout(new FlowLayout());
2084 .setText(MessageManager.getString("label.old_backup_files"));
2085 oldBackupFilesLabel.setFont(LABEL_FONT);
2086 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2087 jp.add(oldBackupFilesLabel);
2088 jp.add(backupfilesConfirmDelete.getTrueButton());
2089 jp.add(backupfilesConfirmDelete.getFalseButton());
2090 keepfilesPanel.add(jp, kgbc);
2092 return keepfilesPanel;
2095 private JPanel initBackupsTabFilenameExamplesPanel()
2097 String title = MessageManager.getString("label.example_filenames");
2098 TitledBorder tb = new TitledBorder(title);
2099 //tb.setTitleFont(LABEL_FONT);
2100 exampleFilesPanel.setBorder(tb);
2101 exampleFilesPanel.setLayout(new GridBagLayout());
2103 //inordinately difficult to get this titledborder the right size for the title
2105 backupfilesExampleLabel.setEditable(false);
2106 backupfilesExampleLabel.setPreferredSize(new Dimension(280, 85));
2107 backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
2108 backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
2110 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2111 backupfilesExampleLabel
2112 .setBackground(exampleFilesPanel.getBackground());
2114 updateBackupFilesExampleLabel();
2115 exampleFilesPanel.setMinimumSize(new Dimension(280, 85));
2117 GridBagConstraints gbc = new GridBagConstraints();
2118 gbc.anchor = GridBagConstraints.EAST;
2121 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2122 return exampleFilesPanel;
2125 protected void updateBackupFilesExampleLabel()
2127 int exampleindex = 12;
2128 String base = MessageManager.getString("label.filename");
2129 if (base == null || base.length() > 0)
2131 base = "filename.fa";
2134 String suffix = suffixTemplate.getText();
2137 suffixDigitsSpinner.commitEdit();
2138 digits = (Integer) suffixDigitsSpinner.getValue();
2139 digits = digits < 1 ? 1 : digits;
2140 } catch (Exception e)
2142 System.out.println("Failed casting (Integer) suffixTemplateSpinner.getValue()");
2144 boolean reverse = suffixReverse.isSelected();
2145 boolean keepAll = backupfilesKeepAll.isSelected();
2149 backupfilesRollMaxSpinner.commitEdit();
2150 rollMax = (Integer) backupfilesRollMaxSpinner.getValue();
2151 rollMax = rollMax < 1 ? 1 : rollMax;
2152 } catch (Exception e)
2155 "Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
2158 int lowersurround = 2;
2159 int uppersurround = 0;
2160 StringBuilder exampleSB = new StringBuilder();
2161 boolean firstLine = true;
2166 int max = keepAll ? exampleindex : rollMax;
2167 for (int index = min; index <= max; index++)
2169 if (index == min + lowersurround && index < max - uppersurround - 1)
2171 exampleSB.append("\n...");
2173 else if (index > min + lowersurround && index < max - uppersurround)
2185 exampleSB.append("\n");
2187 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2188 base, suffix, digits));
2191 // no extra text needed
2193 else if (index == min)
2195 String newest = MessageManager.getString("label.braced_newest");
2196 if (newest != null && newest.length() > 0)
2198 exampleSB.append(" "+newest);
2201 else if (index == max)
2203 String oldest = MessageManager.getString("label.braced_oldest");
2204 if (oldest != null && oldest.length() > 0)
2206 exampleSB.append(" "+oldest);
2215 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2216 : exampleindex - rollMax + 1;
2217 int max = exampleindex;
2219 for (int index = min; index <= max; index++)
2222 if (index == min + lowersurround && index < max - uppersurround - 1)
2224 exampleSB.append("\n...");
2226 else if (index > min + lowersurround && index < max - uppersurround)
2238 exampleSB.append("\n");
2240 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2241 base, suffix, digits));
2244 // no extra text needed
2246 else if (index == min)
2248 String oldest = MessageManager.getString("label.braced_oldest");
2249 if (oldest != null && oldest.length() > 0)
2251 exampleSB.append(" "+oldest);
2254 else if (index == max)
2256 String newest = MessageManager.getString("label.braced_newest");
2257 if (newest != null && newest.length() > 0)
2259 exampleSB.append(" "+newest);
2267 backupfilesExampleLabel.setText(exampleSB.toString());
2270 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2271 boolean useExistingVal, ChangeListener c)
2278 i = Integer.parseInt((String) s.getValue());
2279 } catch (Exception e)
2282 "Exception casting the initial value of s.getValue()");
2286 setIntegerSpinner(s, min, max, i, c);
2289 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2292 // integer spinner for number of digits
2297 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2300 s.addChangeListener(c);
2304 protected static int getSpinnerInt(JSpinner s, int def)
2310 i = (Integer) s.getValue();
2311 } catch (Exception e)
2313 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2318 protected void keepRollMaxOptionsEnabled()
2320 keepRollMaxOptionsEnabled(backupfilesKeepAll.isEnabled());
2323 protected void keepRollMaxOptionsEnabled(boolean tryEnabled)
2325 boolean enabled = tryEnabled && !backupfilesKeepAll.isSelected();
2326 oldBackupFilesLabel.setEnabled(enabled);
2327 backupfilesRollMaxSpinner.setEnabled(enabled);
2328 backupfilesConfirmDelete.setEnabled(enabled);
2331 protected void backupsCustomOptionsSetEnabled(boolean enabled)
2333 backupsOptionsSetEnabled(enabled, false);
2336 protected void backupsOptionsSetEnabled(boolean enabled)
2338 backupsOptionsSetEnabled(enabled, true);
2341 protected void backupsOptionsSetEnabled(boolean enabled, boolean all)
2346 presetsPanel.setEnabled(enabled);
2347 exampleFilesPanel.setEnabled(enabled);
2349 backupfilesPresetsCombo.setEnabled(enabled);
2350 backupfilesExampleLabel.setEnabled(enabled);
2352 suffixPanel.setEnabled(enabled);
2353 keepfilesPanel.setEnabled(enabled);
2355 suffixTemplate.setEnabled(enabled);
2356 suffixTemplateLabel.setEnabled(enabled);
2357 suffixDigitsLabel.setEnabled(enabled);
2358 suffixDigitsSpinner.setEnabled(enabled);
2359 suffixReverse.setEnabled(enabled);
2360 oldBackupFilesLabel.setEnabled(enabled);
2361 backupfilesKeepAllEnabled(enabled);
2365 backupsTabUpdatePresets();
2369 protected void backupsSetOptions(String suffix, int digits, boolean reverse, boolean keepAll, int rollMax, boolean confirmDelete)
2371 suffixTemplate.setText(suffix);
2372 suffixDigitsSpinner.setValue(digits);
2373 suffixReverse.setSelected(reverse);
2374 backupfilesKeepAll.setSelected(keepAll);
2375 backupfilesRollMaxSpinner.setValue(rollMax);
2376 backupfilesConfirmDelete.setSelected(confirmDelete);
2379 protected void backupsSetOptions(BackupFilesPresetEntry p)
2381 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax, p.confirmDelete);
2384 protected void autoIdWidth_actionPerformed()
2386 // TODO Auto-generated method stub
2390 protected void userIdWidth_actionPerformed()
2392 // TODO Auto-generated method stub
2396 protected void maxColour_actionPerformed(JPanel panel)
2400 protected void minColour_actionPerformed(JPanel panel)
2404 protected void gapColour_actionPerformed(JPanel panel)
2408 protected void hiddenColour_actionPerformed(JPanel panel)
2412 protected void showunconserved_actionPerformed(ActionEvent e)
2414 // TODO Auto-generated method stub
2418 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2422 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2432 public void ok_actionPerformed(ActionEvent e)
2442 public void cancel_actionPerformed(ActionEvent e)
2452 public void annotations_actionPerformed(ActionEvent e)
2459 public void startupFileTextfield_mouseClicked()
2463 public void newLink_actionPerformed(ActionEvent e)
2468 public void editLink_actionPerformed(ActionEvent e)
2473 public void deleteLink_actionPerformed(ActionEvent e)
2478 public void defaultBrowser_mouseClicked(MouseEvent e)
2483 public void linkURLList_keyTyped(KeyEvent e)
2488 public void useProxy_actionPerformed()
2490 boolean enabled = useProxy.isSelected();
2491 portLabel.setEnabled(enabled);
2492 serverLabel.setEnabled(enabled);
2493 proxyServerTB.setEnabled(enabled);
2494 proxyPortTB.setEnabled(enabled);
2498 * Customer renderer for JTable: supports column of radio buttons
2500 public class RadioButtonRenderer extends JRadioButton
2501 implements TableCellRenderer
2503 public RadioButtonRenderer()
2505 setHorizontalAlignment(CENTER);
2506 setToolTipText(MessageManager.getString("label.urltooltip"));
2510 public Component getTableCellRendererComponent(JTable table,
2511 Object value, boolean isSelected, boolean hasFocus, int row,
2514 setSelected((boolean) value);
2516 // set colours to match rest of table
2519 setBackground(table.getSelectionBackground());
2520 setForeground(table.getSelectionForeground());
2524 setBackground(table.getBackground());
2525 setForeground(table.getForeground());
2532 * Customer cell editor for JTable: supports column of radio buttons in
2533 * conjunction with renderer
2535 public class RadioButtonEditor extends AbstractCellEditor
2536 implements TableCellEditor
2538 private JRadioButton button = new JRadioButton();
2540 public RadioButtonEditor()
2542 button.setHorizontalAlignment(SwingConstants.CENTER);
2543 this.button.addActionListener(new ActionListener()
2546 public void actionPerformed(ActionEvent e)
2548 fireEditingStopped();
2554 public Component getTableCellEditorComponent(JTable table, Object value,
2555 boolean isSelected, int row, int column)
2557 button.setSelected((boolean) value);
2562 public Object getCellEditorValue()
2564 return button.isSelected();
2570 class IntKeyStringValueEntry {
2573 public IntKeyStringValueEntry(int k, String v)
2579 public String toString()
2581 return this.getValue();
2587 public String getValue()
2593 class BackupFilesPresetEntry {
2599 boolean confirmDelete;
2600 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse, boolean keepAll, int rollMax, boolean confirmDelete)
2602 this.suffix = suffix;
2603 this.digits = digits;
2604 this.reverse = reverse;
2605 this.keepAll = keepAll;
2606 this.rollMax = rollMax;
2607 this.confirmDelete = confirmDelete;