2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import jalview.bin.Cache;
24 import jalview.fts.core.FTSDataColumnPreferences;
25 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
26 import jalview.fts.service.pdb.PDBFTSRestClient;
27 import jalview.gui.Desktop;
28 import jalview.gui.JalviewBooleanRadioButtons;
29 import jalview.gui.JvOptionPane;
30 import jalview.gui.JvSwingUtils;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.BackupFilenameParts;
33 import jalview.io.BackupFiles;
34 import jalview.util.MessageManager;
35 import jalview.util.Platform;
37 import java.awt.BorderLayout;
38 import java.awt.Color;
39 import java.awt.Component;
40 import java.awt.Dimension;
41 import java.awt.FlowLayout;
43 import java.awt.GridBagConstraints;
44 import java.awt.GridBagLayout;
45 import java.awt.GridLayout;
46 import java.awt.Insets;
47 import java.awt.Rectangle;
48 import java.awt.event.ActionEvent;
49 import java.awt.event.ActionListener;
50 import java.awt.event.FocusEvent;
51 import java.awt.event.KeyEvent;
52 import java.awt.event.KeyListener;
53 import java.awt.event.MouseAdapter;
54 import java.awt.event.MouseEvent;
55 import java.util.HashMap;
58 import javax.swing.AbstractCellEditor;
59 import javax.swing.BorderFactory;
60 import javax.swing.ButtonGroup;
61 import javax.swing.DefaultListCellRenderer;
62 import javax.swing.JButton;
63 import javax.swing.JCheckBox;
64 import javax.swing.JComboBox;
65 import javax.swing.JFileChooser;
66 import javax.swing.JLabel;
67 import javax.swing.JList;
68 import javax.swing.JPanel;
69 import javax.swing.JRadioButton;
70 import javax.swing.JScrollPane;
71 import javax.swing.JSpinner;
72 import javax.swing.JTabbedPane;
73 import javax.swing.JTable;
74 import javax.swing.JTextArea;
75 import javax.swing.JTextField;
76 import javax.swing.ListSelectionModel;
77 import javax.swing.SpinnerModel;
78 import javax.swing.SpinnerNumberModel;
79 import javax.swing.SwingConstants;
80 import javax.swing.border.Border;
81 import javax.swing.border.EmptyBorder;
82 import javax.swing.border.EtchedBorder;
83 import javax.swing.border.TitledBorder;
84 import javax.swing.event.ChangeEvent;
85 import javax.swing.event.ChangeListener;
86 import javax.swing.table.TableCellEditor;
87 import javax.swing.table.TableCellRenderer;
90 * Base class for the Preferences panel.
95 @SuppressWarnings("serial")
96 public class GPreferences extends JPanel
98 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
100 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
101 .getLabelFont(false, true);
103 private static final Font LABEL_FONT_BOLD = JvSwingUtils
104 .getLabelFont(true, false);
107 * Visual tab components
109 protected JCheckBox fullScreen = new JCheckBox();
111 protected JCheckBox openoverv = new JCheckBox();
113 protected JCheckBox seqLimit = new JCheckBox();
115 protected JCheckBox rightAlign = new JCheckBox();
117 protected JComboBox<String> fontSizeCB = new JComboBox<>();
119 protected JComboBox<String> fontStyleCB = new JComboBox<>();
121 protected JComboBox<String> fontNameCB = new JComboBox<>();
123 protected JCheckBox showOccupancy = new JCheckBox();
125 protected JCheckBox showUnconserved = new JCheckBox();
127 protected JCheckBox idItalics = new JCheckBox();
129 protected JCheckBox smoothFont = new JCheckBox();
131 protected JCheckBox scaleProteinToCdna = new JCheckBox();
133 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
135 protected JCheckBox wrap = new JCheckBox();
137 protected JComboBox<String> sortby = new JComboBox<>();
139 protected JComboBox<String> sortAnnBy = new JComboBox<>();
141 protected JComboBox<String> sortAutocalc = new JComboBox<>();
143 protected JCheckBox startupCheckbox = new JCheckBox();
145 protected JTextField startupFileTextfield = new JTextField();
147 // below are in the 'second column'
148 protected JCheckBox annotations = new JCheckBox();
150 protected JCheckBox quality = new JCheckBox();
152 protected JCheckBox conservation = new JCheckBox();
154 protected JCheckBox identity = new JCheckBox();
156 protected JCheckBox showGroupConsensus = new JCheckBox();
158 protected JCheckBox showGroupConservation = new JCheckBox();
160 protected JCheckBox showConsensHistogram = new JCheckBox();
162 protected JCheckBox showConsensLogo = new JCheckBox();
164 protected JCheckBox showDbRefTooltip = new JCheckBox();
166 protected JCheckBox showNpTooltip = new JCheckBox();
169 * Structure tab and components
171 protected JPanel structureTab;
173 protected JCheckBox structFromPdb = new JCheckBox();
175 protected JCheckBox useRnaView = new JCheckBox();
177 protected JCheckBox addSecondaryStructure = new JCheckBox();
179 protected JCheckBox addTempFactor = new JCheckBox();
181 protected JComboBox<String> structViewer = new JComboBox<>();
183 protected JTextField chimeraPath = new JTextField();
185 protected ButtonGroup mappingMethod = new ButtonGroup();
187 protected JRadioButton siftsMapping = new JRadioButton();
189 protected JRadioButton nwMapping = new JRadioButton();
192 * Colours tab components
194 protected JPanel minColour = new JPanel();
196 protected JPanel maxColour = new JPanel();
198 protected JComboBox<String> protColour = new JComboBox<>();
200 protected JComboBox<String> nucColour = new JComboBox<>();
203 * Overview tab components
205 protected JPanel gapColour = new JPanel();
207 protected JPanel hiddenColour = new JPanel();
209 protected JCheckBox useLegacyGap;
211 protected JCheckBox showHiddenAtStart;
213 protected JLabel gapLabel;
216 * Connections tab components
218 public JTable linkUrlTable = new JTable();
220 public JButton editLink = new JButton();
222 public JButton deleteLink = new JButton();
224 public JTextField filterTB = new JTextField();
226 protected JButton doReset = new JButton();
228 protected JButton userOnly = new JButton();
230 protected JLabel portLabel = new JLabel();
232 protected JLabel serverLabel = new JLabel();
234 protected JTextField proxyServerTB = new JTextField();
236 protected JTextField proxyPortTB = new JTextField();
238 protected JTextField defaultBrowser = new JTextField();
240 protected JCheckBox useProxy = new JCheckBox();
242 protected JCheckBox usagestats = new JCheckBox();
244 protected JCheckBox questionnaire = new JCheckBox();
246 protected JCheckBox versioncheck = new JCheckBox();
249 * Output tab components
251 protected JComboBox<Object> epsRendering = new JComboBox<>();
253 protected JComboBox<Object> htmlRendering = new JComboBox<>();
255 protected JComboBox<Object> svgRendering = new JComboBox<>();
257 protected JLabel userIdWidthlabel = new JLabel();
259 protected JCheckBox autoIdWidth = new JCheckBox();
261 protected JTextField userIdWidth = new JTextField();
263 protected JCheckBox blcjv = new JCheckBox();
265 protected JCheckBox pileupjv = new JCheckBox();
267 protected JCheckBox clustaljv = new JCheckBox();
269 protected JCheckBox msfjv = new JCheckBox();
271 protected JCheckBox fastajv = new JCheckBox();
273 protected JCheckBox pfamjv = new JCheckBox();
275 protected JCheckBox pirjv = new JCheckBox();
277 protected JCheckBox modellerOutput = new JCheckBox();
279 protected JCheckBox embbedBioJSON = new JCheckBox();
282 * Editing tab components
284 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
286 protected JCheckBox padGaps = new JCheckBox();
288 protected JCheckBox sortByTree = new JCheckBox();
293 protected JPanel wsTab = new JPanel();
296 * Backups tab components
297 * a lot of these are member variables instead of local variables only so that they
298 * can be enabled/disabled easily in one go
301 protected JCheckBox enableBackupFiles = new JCheckBox();
303 protected JPanel presetsPanel = new JPanel();
305 protected JButton revertButton = new JButton();
307 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
309 protected JPanel suffixPanel = new JPanel();
311 protected JPanel keepfilesPanel = new JPanel();
313 protected JPanel exampleFilesPanel = new JPanel();
315 protected JTextField suffixTemplate = new JTextField(null, 8);
317 protected JLabel suffixTemplateLabel = new JLabel();
319 protected JLabel suffixDigitsLabel = new JLabel();
321 protected JSpinner suffixDigitsSpinner = new JSpinner();
323 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
325 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
327 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
329 protected JLabel oldBackupFilesLabel = new JLabel();
331 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
333 protected JTextArea backupfilesExampleLabel = new JTextArea();
336 * Creates a new GPreferences object.
338 public GPreferences()
343 } catch (Exception ex)
345 ex.printStackTrace();
350 * Construct the panel and its tabbed sub-panels.
354 private void jbInit() throws Exception
356 final JTabbedPane tabbedPane = new JTabbedPane();
357 this.setLayout(new BorderLayout());
358 JPanel okCancelPanel = initOkCancelPanel();
359 this.add(tabbedPane, BorderLayout.CENTER);
360 this.add(okCancelPanel, BorderLayout.SOUTH);
362 tabbedPane.add(initVisualTab(),
363 MessageManager.getString("label.visual"));
365 tabbedPane.add(initColoursTab(),
366 MessageManager.getString("label.colours"));
368 tabbedPane.add(initOverviewTab(),
369 MessageManager.getString("label.overview"));
371 tabbedPane.add(initStructureTab(),
372 MessageManager.getString("label.structure"));
374 tabbedPane.add(initConnectionsTab(),
375 MessageManager.getString("label.connections"));
377 if (!Platform.isJS())
379 tabbedPane.add(initBackupsTab(),
380 MessageManager.getString("label.backups"));
383 tabbedPane.add(initLinksTab(),
384 MessageManager.getString("label.urllinks"));
386 tabbedPane.add(initOutputTab(),
387 MessageManager.getString("label.output"));
389 tabbedPane.add(initEditingTab(),
390 MessageManager.getString("label.editing"));
393 * See WsPreferences for the real work of configuring this tab.
395 if (!Platform.isJS())
397 wsTab.setLayout(new BorderLayout());
398 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
402 * Handler to validate a tab before leaving it - currently only for
405 tabbedPane.addChangeListener(new ChangeListener()
407 private Component lastTab;
410 public void stateChanged(ChangeEvent e)
412 if (lastTab == structureTab
413 && tabbedPane.getSelectedComponent() != structureTab)
415 if (!validateStructure())
417 tabbedPane.setSelectedComponent(structureTab);
421 lastTab = tabbedPane.getSelectedComponent();
428 * Initialises the Editing tabbed panel.
432 private JPanel initEditingTab()
434 JPanel editingTab = new JPanel();
435 editingTab.setLayout(null);
436 autoCalculateConsCheck.setFont(LABEL_FONT);
437 autoCalculateConsCheck.setText(
438 MessageManager.getString("label.autocalculate_consensus"));
439 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
440 padGaps.setFont(LABEL_FONT);
442 MessageManager.getString("label.pad_gaps_when_editing"));
443 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
444 sortByTree.setFont(LABEL_FONT);
446 .setText(MessageManager.getString("label.sort_with_new_tree"));
447 sortByTree.setToolTipText(MessageManager.getString(
448 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
449 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
450 editingTab.add(autoCalculateConsCheck);
451 editingTab.add(padGaps);
452 editingTab.add(sortByTree);
457 * Initialises the Output tab
461 private JPanel initOutputTab()
463 JPanel outputTab = new JPanel();
464 outputTab.setLayout(null);
466 JLabel epsLabel = new JLabel(
467 MessageManager.formatMessage("label.rendering_style", "EPS"));
468 epsLabel.setFont(LABEL_FONT);
469 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
470 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
471 epsRendering.setFont(LABEL_FONT);
472 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
473 JLabel htmlLabel = new JLabel(
474 MessageManager.formatMessage("label.rendering_style", "HTML"));
475 htmlLabel.setFont(LABEL_FONT);
476 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
477 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
478 htmlRendering.setFont(LABEL_FONT);
479 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
480 JLabel svgLabel = new JLabel(
481 MessageManager.formatMessage("label.rendering_style", "SVG"));
482 svgLabel.setFont(LABEL_FONT);
483 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
484 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
485 svgRendering.setFont(LABEL_FONT);
486 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
488 JLabel jLabel1 = new JLabel();
489 jLabel1.setFont(LABEL_FONT);
490 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
491 jLabel1.setText(MessageManager.getString("label.append_start_end"));
492 jLabel1.setFont(LABEL_FONT);
494 fastajv.setFont(LABEL_FONT);
495 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
496 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
497 blcjv.setText(MessageManager.getString("label.blc") + " ");
498 fastajv.setText(MessageManager.getString("label.fasta") + " ");
499 msfjv.setText(MessageManager.getString("label.msf") + " ");
500 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
501 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
502 msfjv.setFont(LABEL_FONT);
503 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
504 pirjv.setText(MessageManager.getString("label.pir") + " ");
505 JPanel jPanel11 = new JPanel();
506 jPanel11.setFont(LABEL_FONT);
507 TitledBorder titledBorder2 = new TitledBorder(
508 MessageManager.getString("label.file_output"));
509 jPanel11.setBorder(titledBorder2);
510 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
511 GridLayout gridLayout3 = new GridLayout();
512 jPanel11.setLayout(gridLayout3);
513 gridLayout3.setRows(8);
514 blcjv.setFont(LABEL_FONT);
515 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
516 clustaljv.setFont(LABEL_FONT);
517 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
518 pfamjv.setFont(LABEL_FONT);
519 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
520 pileupjv.setFont(LABEL_FONT);
521 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
522 pirjv.setFont(LABEL_FONT);
523 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
524 autoIdWidth.setFont(LABEL_FONT);
526 MessageManager.getString("label.automatically_set_id_width"));
527 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
528 .getString("label.adjusts_width_generated_eps_png")));
529 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
530 autoIdWidth.addActionListener(new ActionListener()
534 public void actionPerformed(ActionEvent e)
536 autoIdWidth_actionPerformed();
539 userIdWidthlabel.setFont(LABEL_FONT);
540 userIdWidthlabel.setText(
541 MessageManager.getString("label.figure_id_column_width"));
542 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
543 .getString("label.manually_specify_width_left_column")));
544 userIdWidthlabel.setToolTipText(
545 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
546 "label.manually_specify_width_left_column")));
547 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
548 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
549 userIdWidth.setText("");
550 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
551 userIdWidth.addActionListener(new ActionListener()
555 public void actionPerformed(ActionEvent e)
557 userIdWidth_actionPerformed();
560 modellerOutput.setFont(LABEL_FONT);
562 .setText(MessageManager.getString("label.use_modeller_output"));
563 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
564 embbedBioJSON.setFont(LABEL_FONT);
565 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
566 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
568 jPanel11.add(jLabel1);
570 jPanel11.add(clustaljv);
571 jPanel11.add(fastajv);
573 jPanel11.add(pfamjv);
574 jPanel11.add(pileupjv);
576 outputTab.add(autoIdWidth);
577 outputTab.add(userIdWidth);
578 outputTab.add(userIdWidthlabel);
579 outputTab.add(modellerOutput);
580 if (!Platform.isJS())
583 * JalviewJS doesn't support Lineart option or SVG output
585 outputTab.add(embbedBioJSON);
586 outputTab.add(epsLabel);
587 outputTab.add(epsRendering);
588 outputTab.add(htmlLabel);
589 outputTab.add(htmlRendering);
590 outputTab.add(svgLabel);
591 outputTab.add(svgRendering);
593 outputTab.add(jPanel11);
598 * Initialises the Connections tabbed panel.
602 private JPanel initConnectionsTab()
604 JPanel connectTab = new JPanel();
605 connectTab.setLayout(new GridBagLayout());
607 // Label for browser text box
608 JLabel browserLabel = new JLabel();
609 browserLabel.setFont(LABEL_FONT);
610 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
611 browserLabel.setText(
612 MessageManager.getString("label.default_browser_unix"));
613 defaultBrowser.setFont(LABEL_FONT);
614 defaultBrowser.setText("");
615 final String tooltip = JvSwingUtils.wrapTooltip(true,
616 MessageManager.getString("label.double_click_to_browse"));
617 defaultBrowser.setToolTipText(tooltip);
618 defaultBrowser.addMouseListener(new MouseAdapter()
621 public void mouseClicked(MouseEvent e)
623 if (e.getClickCount() > 1)
625 defaultBrowser_mouseClicked(e);
630 JPanel proxyPanel = initConnTabProxyPanel();
631 initConnTabCheckboxes();
633 // Add default Browser text box
634 connectTab.add(browserLabel,
635 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
636 GridBagConstraints.WEST, GridBagConstraints.NONE,
637 new Insets(10, 0, 5, 5), 5, 1));
638 defaultBrowser.setFont(LABEL_FONT);
639 defaultBrowser.setText("");
641 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
642 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
643 new Insets(10, 0, 5, 10), 30, 1));
645 // Add proxy server panel
646 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
647 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
648 new Insets(10, 0, 5, 12), 4, 10));
650 // Add usage stats, version check and questionnaire checkboxes
651 connectTab.add(usagestats,
652 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
653 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
654 new Insets(0, 2, 5, 5), 70, 1));
655 connectTab.add(questionnaire,
656 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
657 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
658 new Insets(0, 2, 5, 10), 70, 1));
659 connectTab.add(versioncheck,
660 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
661 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
662 new Insets(0, 2, 5, 5), 70, 1));
664 // Add padding so the panel doesn't look ridiculous
665 JPanel spacePanel = new JPanel();
666 connectTab.add(spacePanel,
667 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
668 GridBagConstraints.WEST, GridBagConstraints.BOTH,
669 new Insets(0, 0, 0, 5), 70, 1));
675 * Initialises the Links tabbed panel.
679 private JPanel initLinksTab()
681 JPanel linkTab = new JPanel();
682 linkTab.setLayout(new GridBagLayout());
684 // Set up table for Url links
685 linkUrlTable.getTableHeader().setReorderingAllowed(false);
686 linkUrlTable.setFillsViewportHeight(true);
687 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
688 linkUrlTable.setAutoCreateRowSorter(true);
689 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
691 // adjust row height so radio buttons actually fit
692 // don't do this in the renderer, it causes the awt thread to activate
694 JRadioButton temp = new JRadioButton();
695 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
697 // Table in scrollpane so that the table is given a scrollbar
698 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
699 linkScrollPane.setBorder(null);
701 // Panel for links functionality
702 JPanel linkPanel = new JPanel(new GridBagLayout());
703 linkPanel.setBorder(new TitledBorder(
704 MessageManager.getString("label.url_linkfrom_sequence_id")));
706 // Put the Url links panel together
708 // Buttons go at top right, resizing only resizes the blank space vertically
709 JPanel buttonPanel = initLinkTabUrlButtons();
710 GridBagConstraints linkConstraints1 = new GridBagConstraints();
711 linkConstraints1.insets = new Insets(0, 0, 5, 0);
712 linkConstraints1.gridx = 0;
713 linkConstraints1.gridy = 0;
714 linkConstraints1.weightx = 1.0;
715 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
716 linkTab.add(buttonPanel, linkConstraints1);
718 // Links table goes at top left, resizing resizes the table
719 GridBagConstraints linkConstraints2 = new GridBagConstraints();
720 linkConstraints2.insets = new Insets(0, 0, 5, 5);
721 linkConstraints2.gridx = 0;
722 linkConstraints2.gridy = 1;
723 linkConstraints2.weightx = 1.0;
724 linkConstraints2.weighty = 1.0;
725 linkConstraints2.fill = GridBagConstraints.BOTH;
726 linkTab.add(linkScrollPane, linkConstraints2);
728 // Filter box and buttons goes at bottom left, resizing resizes the text box
729 JPanel filterPanel = initLinkTabFilterPanel();
730 GridBagConstraints linkConstraints3 = new GridBagConstraints();
731 linkConstraints3.insets = new Insets(0, 0, 0, 5);
732 linkConstraints3.gridx = 0;
733 linkConstraints3.gridy = 2;
734 linkConstraints3.weightx = 1.0;
735 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
736 linkTab.add(filterPanel, linkConstraints3);
741 private JPanel initLinkTabFilterPanel()
743 // Filter textbox and reset button
744 JLabel filterLabel = new JLabel(
745 MessageManager.getString("label.filter"));
746 filterLabel.setFont(LABEL_FONT);
747 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
748 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
750 filterTB.setFont(LABEL_FONT);
751 filterTB.setText("");
753 doReset.setText(MessageManager.getString("action.showall"));
754 userOnly.setText(MessageManager.getString("action.customfilter"));
756 // Panel for filter functionality
757 JPanel filterPanel = new JPanel(new GridBagLayout());
758 filterPanel.setBorder(new TitledBorder("Filter"));
759 GridBagConstraints gbc = new GridBagConstraints();
762 gbc.fill = GridBagConstraints.NONE;
763 gbc.anchor = GridBagConstraints.WEST;
765 filterPanel.add(filterLabel, gbc);
767 GridBagConstraints gbc1 = new GridBagConstraints();
770 gbc1.fill = GridBagConstraints.HORIZONTAL;
771 gbc1.anchor = GridBagConstraints.WEST;
773 filterPanel.add(filterTB, gbc1);
775 GridBagConstraints gbc2 = new GridBagConstraints();
777 gbc2.fill = GridBagConstraints.NONE;
778 gbc2.anchor = GridBagConstraints.WEST;
779 filterPanel.add(doReset, gbc2);
781 GridBagConstraints gbc3 = new GridBagConstraints();
783 gbc3.fill = GridBagConstraints.NONE;
784 gbc3.anchor = GridBagConstraints.WEST;
785 filterPanel.add(userOnly, gbc3);
790 private JPanel initLinkTabUrlButtons()
792 // Buttons for new / edit / delete Url links
793 JButton newLink = new JButton();
794 newLink.setText(MessageManager.getString("action.new"));
796 editLink.setText(MessageManager.getString("action.edit"));
798 deleteLink.setText(MessageManager.getString("action.delete"));
800 // no current selection, so initially disable delete/edit buttons
801 editLink.setEnabled(false);
802 deleteLink.setEnabled(false);
804 newLink.addActionListener(new java.awt.event.ActionListener()
807 public void actionPerformed(ActionEvent e)
809 newLink_actionPerformed(e);
813 editLink.setText(MessageManager.getString("action.edit"));
814 editLink.addActionListener(new java.awt.event.ActionListener()
817 public void actionPerformed(ActionEvent e)
819 editLink_actionPerformed(e);
823 deleteLink.setText(MessageManager.getString("action.delete"));
824 deleteLink.addActionListener(new java.awt.event.ActionListener()
827 public void actionPerformed(ActionEvent e)
829 deleteLink_actionPerformed(e);
833 JPanel buttonPanel = new JPanel(new GridBagLayout());
834 buttonPanel.setBorder(new TitledBorder("Edit links"));
835 GridBagConstraints gbc = new GridBagConstraints();
838 gbc.fill = GridBagConstraints.NONE;
839 buttonPanel.add(newLink, gbc);
841 GridBagConstraints gbc1 = new GridBagConstraints();
844 gbc1.fill = GridBagConstraints.NONE;
845 buttonPanel.add(editLink, gbc1);
847 GridBagConstraints gbc2 = new GridBagConstraints();
850 gbc2.fill = GridBagConstraints.NONE;
851 buttonPanel.add(deleteLink, gbc2);
853 GridBagConstraints gbc3 = new GridBagConstraints();
856 gbc3.fill = GridBagConstraints.HORIZONTAL;
858 JPanel spacePanel = new JPanel();
859 spacePanel.setBorder(null);
860 buttonPanel.add(spacePanel, gbc3);
866 * Initialises the proxy server panel in the Connections tab
868 * @return the proxy server panel
870 private JPanel initConnTabProxyPanel()
872 // Label for server text box
873 serverLabel.setText(MessageManager.getString("label.address"));
874 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
875 serverLabel.setFont(LABEL_FONT);
877 // Proxy server and port text boxes
878 proxyServerTB.setFont(LABEL_FONT);
879 proxyPortTB.setFont(LABEL_FONT);
881 // Label for Port text box
882 portLabel.setFont(LABEL_FONT);
883 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
884 portLabel.setText(MessageManager.getString("label.port"));
886 // Use proxy server checkbox
887 useProxy.setFont(LABEL_FONT);
888 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
889 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
890 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
891 useProxy.addActionListener(new ActionListener()
894 public void actionPerformed(ActionEvent e)
896 useProxy_actionPerformed();
900 // Make proxy server panel
901 JPanel proxyPanel = new JPanel();
902 TitledBorder titledBorder1 = new TitledBorder(
903 MessageManager.getString("label.proxy_server"));
904 proxyPanel.setBorder(titledBorder1);
905 proxyPanel.setLayout(new GridBagLayout());
906 proxyPanel.add(serverLabel,
907 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
908 GridBagConstraints.WEST, GridBagConstraints.NONE,
909 new Insets(0, 2, 2, 0), 5, 0));
910 proxyPanel.add(portLabel,
911 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
912 GridBagConstraints.WEST, GridBagConstraints.NONE,
913 new Insets(0, 0, 2, 0), 11, 0));
914 proxyPanel.add(useProxy,
915 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
916 GridBagConstraints.WEST, GridBagConstraints.NONE,
917 new Insets(0, 2, 5, 185), 2, -4));
918 proxyPanel.add(proxyPortTB,
919 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
920 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
921 new Insets(0, 2, 2, 2), 54, 1));
922 proxyPanel.add(proxyServerTB,
923 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
924 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
925 new Insets(0, 2, 2, 0), 263, 1));
931 * Initialises the checkboxes in the Connections tab
933 private void initConnTabCheckboxes()
935 // Usage stats checkbox label
937 MessageManager.getString("label.send_usage_statistics"));
938 usagestats.setFont(LABEL_FONT);
939 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
940 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
942 // Questionnaire checkbox label
943 questionnaire.setText(
944 MessageManager.getString("label.check_for_questionnaires"));
945 questionnaire.setFont(LABEL_FONT);
946 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
947 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
949 // Check for latest version checkbox label
950 versioncheck.setText(
951 MessageManager.getString("label.check_for_latest_version"));
952 versioncheck.setFont(LABEL_FONT);
953 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
954 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
958 * Initialises the parent panel which contains the tabbed sections.
962 private JPanel initOkCancelPanel()
964 JButton ok = new JButton();
965 ok.setText(MessageManager.getString("action.ok"));
966 ok.addActionListener(new ActionListener()
969 public void actionPerformed(ActionEvent e)
971 ok_actionPerformed(e);
974 JButton cancel = new JButton();
975 cancel.setText(MessageManager.getString("action.cancel"));
976 cancel.addActionListener(new ActionListener()
979 public void actionPerformed(ActionEvent e)
981 cancel_actionPerformed(e);
984 JPanel okCancelPanel = new JPanel();
985 okCancelPanel.add(ok);
986 okCancelPanel.add(cancel);
987 return okCancelPanel;
991 * Initialises the Colours tabbed panel.
995 private JPanel initColoursTab()
997 JPanel coloursTab = new JPanel();
998 coloursTab.setBorder(new TitledBorder(
999 MessageManager.getString("action.open_new_alignment")));
1000 coloursTab.setLayout(new FlowLayout());
1001 JLabel mincolourLabel = new JLabel();
1002 mincolourLabel.setFont(LABEL_FONT);
1003 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1004 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1005 minColour.setFont(LABEL_FONT);
1006 minColour.setBorder(BorderFactory.createEtchedBorder());
1007 minColour.setPreferredSize(new Dimension(40, 20));
1008 minColour.addMouseListener(new MouseAdapter()
1011 public void mousePressed(MouseEvent e)
1013 minColour_actionPerformed(minColour);
1016 JLabel maxcolourLabel = new JLabel();
1017 maxcolourLabel.setFont(LABEL_FONT);
1018 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1019 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1020 maxColour.setFont(LABEL_FONT);
1021 maxColour.setBorder(BorderFactory.createEtchedBorder());
1022 maxColour.setPreferredSize(new Dimension(40, 20));
1023 maxColour.addMouseListener(new MouseAdapter()
1026 public void mousePressed(MouseEvent e)
1028 maxColour_actionPerformed(maxColour);
1032 protColour.setFont(LABEL_FONT);
1033 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1034 JLabel protColourLabel = new JLabel();
1035 protColourLabel.setFont(LABEL_FONT);
1036 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1037 protColourLabel.setText(
1038 MessageManager.getString("label.prot_alignment_colour") + " ");
1039 JvSwingUtils.addtoLayout(coloursTab,
1041 .getString("label.default_colour_scheme_for_alignment"),
1042 protColourLabel, protColour);
1044 nucColour.setFont(LABEL_FONT);
1045 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1046 JLabel nucColourLabel = new JLabel();
1047 nucColourLabel.setFont(LABEL_FONT);
1048 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1049 nucColourLabel.setText(
1050 MessageManager.getString("label.nuc_alignment_colour") + " ");
1051 JvSwingUtils.addtoLayout(coloursTab,
1053 .getString("label.default_colour_scheme_for_alignment"),
1054 nucColourLabel, nucColour);
1056 JPanel annotationShding = new JPanel();
1057 annotationShding.setBorder(new TitledBorder(
1058 MessageManager.getString("label.annotation_shading_default")));
1059 annotationShding.setLayout(new GridLayout(1, 2));
1060 JvSwingUtils.addtoLayout(annotationShding,
1061 MessageManager.getString(
1062 "label.default_minimum_colour_annotation_shading"),
1063 mincolourLabel, minColour);
1064 JvSwingUtils.addtoLayout(annotationShding,
1065 MessageManager.getString(
1066 "label.default_maximum_colour_annotation_shading"),
1067 maxcolourLabel, maxColour);
1068 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1073 * Initialises the Overview tabbed panel.
1077 private JPanel initOverviewTab()
1079 JPanel overviewPanel = new JPanel();
1080 overviewPanel.setBorder(new TitledBorder(
1081 MessageManager.getString("label.overview_settings")));
1083 gapColour.setFont(LABEL_FONT);
1084 // fixing the border colours stops apparent colour bleed from the panel
1085 gapColour.setBorder(
1086 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1087 gapColour.setPreferredSize(new Dimension(40, 20));
1088 gapColour.addMouseListener(new MouseAdapter()
1091 public void mousePressed(MouseEvent e)
1093 gapColour_actionPerformed(gapColour);
1097 hiddenColour.setFont(LABEL_FONT);
1098 // fixing the border colours stops apparent colour bleed from the panel
1099 hiddenColour.setBorder(
1100 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1101 hiddenColour.setPreferredSize(new Dimension(40, 20));
1102 hiddenColour.addMouseListener(new MouseAdapter()
1105 public void mousePressed(MouseEvent e)
1107 hiddenColour_actionPerformed(hiddenColour);
1111 useLegacyGap = new JCheckBox(
1112 MessageManager.getString("label.ov_legacy_gap"));
1113 useLegacyGap.setFont(LABEL_FONT);
1114 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1115 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1116 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1117 gapLabel.setFont(LABEL_FONT);
1118 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1119 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1120 showHiddenAtStart = new JCheckBox(
1121 MessageManager.getString("label.ov_show_hide_default"));
1122 showHiddenAtStart.setFont(LABEL_FONT);
1123 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1124 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1125 JLabel hiddenLabel = new JLabel(
1126 MessageManager.getString("label.hidden_colour"));
1127 hiddenLabel.setFont(LABEL_FONT);
1128 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1129 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1131 useLegacyGap.addActionListener(new ActionListener()
1134 public void actionPerformed(ActionEvent e)
1136 useLegacyGaps_actionPerformed(e);
1140 overviewPanel.setLayout(new GridBagLayout());
1141 GridBagConstraints c1 = new GridBagConstraints();
1143 c1.fill = GridBagConstraints.HORIZONTAL;
1148 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1149 overviewPanel.add(useLegacyGap, c1);
1151 GridBagConstraints c2 = new GridBagConstraints();
1152 c2.fill = GridBagConstraints.HORIZONTAL;
1155 c2.insets = new Insets(0, 15, 0, 10);
1156 overviewPanel.add(gapLabel, c2);
1158 GridBagConstraints c3 = new GridBagConstraints();
1159 c3.fill = GridBagConstraints.HORIZONTAL;
1162 c3.insets = new Insets(0, 0, 0, 15);
1163 overviewPanel.add(gapColour, c3);
1165 GridBagConstraints c4 = new GridBagConstraints();
1166 c4.fill = GridBagConstraints.HORIZONTAL;
1170 overviewPanel.add(showHiddenAtStart, c4);
1172 GridBagConstraints c5 = new GridBagConstraints();
1173 c5.fill = GridBagConstraints.HORIZONTAL;
1176 c5.insets = new Insets(0, 15, 0, 10);
1177 overviewPanel.add(hiddenLabel, c5);
1179 GridBagConstraints c6 = new GridBagConstraints();
1180 c6.fill = GridBagConstraints.HORIZONTAL;
1183 c6.insets = new Insets(0, 0, 0, 15);
1184 overviewPanel.add(hiddenColour, c6);
1186 JButton resetButton = new JButton(
1187 MessageManager.getString("label.reset_to_defaults"));
1189 resetButton.addActionListener(new ActionListener()
1192 public void actionPerformed(ActionEvent e)
1194 resetOvDefaults_actionPerformed(e);
1198 GridBagConstraints c7 = new GridBagConstraints();
1199 c7.fill = GridBagConstraints.NONE;
1202 c7.insets = new Insets(10, 0, 0, 0);
1203 c7.anchor = GridBagConstraints.WEST;
1204 overviewPanel.add(resetButton, c7);
1206 // Add padding so the panel doesn't look ridiculous
1207 JPanel spacePanel = new JPanel();
1208 overviewPanel.add(spacePanel,
1209 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1210 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1211 new Insets(0, 0, 0, 5), 0, 0));
1213 return overviewPanel;
1217 * Initialises the Structure tabbed panel.
1221 private JPanel initStructureTab()
1223 structureTab = new JPanel();
1225 structureTab.setBorder(new TitledBorder(
1226 MessageManager.getString("label.structure_options")));
1227 structureTab.setLayout(null);
1228 final int width = 400;
1229 final int height = 22;
1230 final int lineSpacing = 25;
1233 structFromPdb.setFont(LABEL_FONT);
1235 .setText(MessageManager.getString("label.struct_from_pdb"));
1236 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1237 structFromPdb.addActionListener(new ActionListener()
1240 public void actionPerformed(ActionEvent e)
1242 boolean selected = structFromPdb.isSelected();
1243 // enable other options only when the first is checked
1244 useRnaView.setEnabled(selected);
1245 addSecondaryStructure.setEnabled(selected);
1246 addTempFactor.setEnabled(selected);
1249 structureTab.add(structFromPdb);
1251 // indent checkboxes that are conditional on the first one
1252 ypos += lineSpacing;
1253 useRnaView.setFont(LABEL_FONT);
1254 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1255 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1256 structureTab.add(useRnaView);
1258 ypos += lineSpacing;
1259 addSecondaryStructure.setFont(LABEL_FONT);
1260 addSecondaryStructure
1261 .setText(MessageManager.getString("label.autoadd_secstr"));
1262 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1263 structureTab.add(addSecondaryStructure);
1265 ypos += lineSpacing;
1266 addTempFactor.setFont(LABEL_FONT);
1267 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1268 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1269 structureTab.add(addTempFactor);
1271 ypos += lineSpacing;
1272 JLabel viewerLabel = new JLabel();
1273 viewerLabel.setFont(LABEL_FONT);
1274 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1275 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1276 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1277 structureTab.add(viewerLabel);
1279 structViewer.setFont(LABEL_FONT);
1280 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1281 structViewer.addItem(ViewerType.JMOL.name());
1282 structViewer.addItem(ViewerType.CHIMERA.name());
1283 structViewer.addActionListener(new ActionListener()
1286 public void actionPerformed(ActionEvent e)
1288 structureViewer_actionPerformed(
1289 (String) structViewer.getSelectedItem());
1292 structureTab.add(structViewer);
1294 ypos += lineSpacing;
1295 JLabel pathLabel = new JLabel();
1296 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1297 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1298 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1299 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1300 structureTab.add(pathLabel);
1302 chimeraPath.setFont(LABEL_FONT);
1303 chimeraPath.setText("");
1304 final String tooltip = JvSwingUtils.wrapTooltip(true,
1305 MessageManager.getString("label.chimera_path_tip"));
1306 chimeraPath.setToolTipText(tooltip);
1307 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1308 chimeraPath.addMouseListener(new MouseAdapter()
1311 public void mouseClicked(MouseEvent e)
1313 if (e.getClickCount() == 2)
1315 String chosen = openFileChooser();
1318 chimeraPath.setText(chosen);
1323 structureTab.add(chimeraPath);
1325 ypos += lineSpacing;
1326 nwMapping.setFont(LABEL_FONT);
1327 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1328 siftsMapping.setFont(LABEL_FONT);
1329 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1330 mappingMethod.add(nwMapping);
1331 mappingMethod.add(siftsMapping);
1332 JPanel mappingPanel = new JPanel();
1333 mappingPanel.setFont(LABEL_FONT);
1334 TitledBorder mmTitledBorder = new TitledBorder(
1335 MessageManager.getString("label.mapping_method"));
1336 mmTitledBorder.setTitleFont(LABEL_FONT);
1337 mappingPanel.setBorder(mmTitledBorder);
1338 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1339 // GridLayout mappingLayout = new GridLayout();
1340 mappingPanel.setLayout(new GridLayout());
1341 mappingPanel.add(nwMapping);
1342 mappingPanel.add(siftsMapping);
1343 structureTab.add(mappingPanel);
1345 ypos += lineSpacing;
1346 ypos += lineSpacing;
1347 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1348 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1349 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1350 structureTab.add(docFieldPref);
1353 * hide Chimera options in JalviewJS
1355 if (Platform.isJS())
1357 pathLabel.setVisible(false);
1358 chimeraPath.setVisible(false);
1359 viewerLabel.setVisible(false);
1360 structViewer.setVisible(false);
1363 return structureTab;
1367 * Action on choosing a structure viewer from combobox options.
1369 * @param selectedItem
1371 protected void structureViewer_actionPerformed(String selectedItem)
1376 * Show a dialog for the user to choose a file. Returns the chosen path, or
1381 protected String openFileChooser()
1383 String choice = null;
1384 JFileChooser chooser = new JFileChooser();
1386 // chooser.setFileView(new JalviewFileView());
1387 chooser.setDialogTitle(
1388 MessageManager.getString("label.open_local_file"));
1389 chooser.setToolTipText(MessageManager.getString("action.open"));
1391 int value = chooser.showOpenDialog(this);
1393 if (value == JFileChooser.APPROVE_OPTION)
1395 choice = chooser.getSelectedFile().getPath();
1401 * Validate the structure tab preferences; if invalid, set focus on this tab.
1405 protected boolean validateStructure(FocusEvent e)
1407 if (!validateStructure())
1409 e.getComponent().requestFocusInWindow();
1415 protected boolean validateStructure()
1421 * Initialises the Visual tabbed panel.
1425 private JPanel initVisualTab()
1427 JPanel visualTab = new JPanel();
1428 visualTab.setBorder(new TitledBorder(
1429 MessageManager.getString("action.open_new_alignment")));
1430 visualTab.setLayout(null);
1431 fullScreen.setFont(LABEL_FONT);
1432 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1433 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1434 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1435 quality.setEnabled(false);
1436 quality.setFont(LABEL_FONT);
1437 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1438 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1439 quality.setSelected(true);
1440 quality.setText(MessageManager.getString("label.quality"));
1441 conservation.setEnabled(false);
1442 conservation.setFont(LABEL_FONT);
1443 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1444 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1445 conservation.setSelected(true);
1446 conservation.setText(MessageManager.getString("label.conservation"));
1447 identity.setEnabled(false);
1448 identity.setFont(LABEL_FONT);
1449 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1450 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1451 identity.setSelected(true);
1452 identity.setText(MessageManager.getString("label.consensus"));
1453 showOccupancy.setFont(LABEL_FONT);
1454 showOccupancy.setEnabled(false);
1455 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1456 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1457 showOccupancy.setSelected(true);
1458 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1460 JLabel showGroupbits = new JLabel();
1461 showGroupbits.setFont(LABEL_FONT);
1462 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1463 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1465 .setText(MessageManager.getString("action.show_group") + ":");
1466 JLabel showConsensbits = new JLabel();
1467 showConsensbits.setFont(LABEL_FONT);
1468 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1469 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1471 .setText(MessageManager.getString("label.consensus") + ":");
1472 showConsensHistogram.setEnabled(false);
1473 showConsensHistogram.setFont(LABEL_FONT);
1474 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1475 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1476 showConsensHistogram.setSelected(true);
1477 showConsensHistogram
1478 .setText(MessageManager.getString("label.histogram"));
1479 showConsensLogo.setEnabled(false);
1480 showConsensLogo.setFont(LABEL_FONT);
1481 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1482 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1483 showConsensLogo.setSelected(true);
1484 showConsensLogo.setText(MessageManager.getString("label.logo"));
1485 showGroupConsensus.setEnabled(false);
1486 showGroupConsensus.setFont(LABEL_FONT);
1487 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1488 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1489 showGroupConsensus.setSelected(true);
1490 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1491 showGroupConservation.setEnabled(false);
1492 showGroupConservation.setFont(LABEL_FONT);
1493 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1494 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1495 showGroupConservation.setSelected(true);
1496 showGroupConservation
1497 .setText(MessageManager.getString("label.conservation"));
1498 showNpTooltip.setEnabled(true);
1499 showNpTooltip.setFont(LABEL_FONT);
1500 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1501 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1502 showNpTooltip.setSelected(true);
1503 showNpTooltip.setText(
1504 MessageManager.getString("label.non_positional_features"));
1505 showDbRefTooltip.setEnabled(true);
1506 showDbRefTooltip.setFont(LABEL_FONT);
1507 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1508 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1509 showDbRefTooltip.setSelected(true);
1511 .setText(MessageManager.getString("label.database_references"));
1512 annotations.setFont(LABEL_FONT);
1513 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1514 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1515 annotations.setSelected(true);
1516 annotations.setText(MessageManager.getString("label.show_annotations"));
1517 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1518 annotations.addActionListener(new ActionListener()
1521 public void actionPerformed(ActionEvent e)
1523 annotations_actionPerformed(e);
1526 identity.addActionListener(new ActionListener()
1529 public void actionPerformed(ActionEvent e)
1531 annotations_actionPerformed(e);
1534 showGroupConsensus.addActionListener(new ActionListener()
1537 public void actionPerformed(ActionEvent e)
1539 annotations_actionPerformed(e);
1542 showUnconserved.setFont(LABEL_FONT);
1543 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1544 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1545 showUnconserved.setSelected(true);
1547 .setText(MessageManager.getString("action.show_unconserved"));
1548 showUnconserved.addActionListener(new ActionListener()
1551 public void actionPerformed(ActionEvent e)
1553 showunconserved_actionPerformed(e);
1557 // TODO these are not yet added to / action from Preferences
1558 // JCheckBox shareSelections = new JCheckBox();
1559 // shareSelections.setFont(verdana11);
1560 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1561 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1562 // shareSelections.setSelected(true);
1563 // shareSelections.setText(MessageManager
1564 // .getString("label.share_selection_across_views"));
1565 // JCheckBox followHighlight = new JCheckBox();
1566 // followHighlight.setFont(verdana11);
1567 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1568 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1569 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1570 // followHighlight.setSelected(true);
1571 // followHighlight.setText(MessageManager
1572 // .getString("label.scroll_highlighted_regions"));
1574 seqLimit.setFont(LABEL_FONT);
1575 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1576 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1577 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1578 smoothFont.setFont(LABEL_FONT);
1579 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1580 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1581 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1582 scaleProteinToCdna.setFont(LABEL_FONT);
1583 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1584 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1585 scaleProteinToCdna.setText(
1586 MessageManager.getString("label.scale_protein_to_cdna"));
1587 scaleProteinToCdna.setToolTipText(
1588 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1589 JLabel gapLabel = new JLabel();
1590 gapLabel.setFont(LABEL_FONT);
1591 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1592 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1593 JLabel fontLabel = new JLabel();
1594 fontLabel.setFont(LABEL_FONT);
1595 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1596 fontLabel.setText(MessageManager.getString("label.font"));
1597 fontSizeCB.setFont(LABEL_FONT);
1598 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1599 fontStyleCB.setFont(LABEL_FONT);
1600 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1601 fontNameCB.setFont(LABEL_FONT);
1602 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1603 gapSymbolCB.setFont(LABEL_FONT);
1604 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1605 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1606 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1607 gapSymbolCB.setRenderer(dlcr);
1609 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1610 startupCheckbox.setFont(LABEL_FONT);
1611 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1612 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1613 startupCheckbox.setSelected(true);
1614 startupFileTextfield.setFont(LABEL_FONT);
1615 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1616 final String tooltip = JvSwingUtils.wrapTooltip(true,
1617 MessageManager.getString("label.double_click_to_browse"));
1618 startupFileTextfield.setToolTipText(tooltip);
1619 startupFileTextfield.addMouseListener(new MouseAdapter()
1622 public void mouseClicked(MouseEvent e)
1624 if (e.getClickCount() > 1)
1626 startupFileTextfield_mouseClicked();
1631 sortby.setFont(LABEL_FONT);
1632 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1633 JLabel sortLabel = new JLabel();
1634 sortLabel.setFont(LABEL_FONT);
1635 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1636 sortLabel.setText(MessageManager.getString("label.sort_by"));
1637 sortAnnBy.setFont(LABEL_FONT);
1638 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1639 JLabel sortAnnLabel = new JLabel();
1640 sortAnnLabel.setFont(LABEL_FONT);
1641 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1642 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1643 sortAutocalc.setFont(LABEL_FONT);
1644 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1646 JPanel annsettingsPanel = new JPanel();
1647 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1648 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1649 annsettingsPanel.setBorder(new EtchedBorder());
1650 visualTab.add(annsettingsPanel);
1651 Border jb = new EmptyBorder(1, 1, 4, 5);
1652 annotations.setBorder(jb);
1653 showOccupancy.setBorder(jb);
1654 quality.setBorder(jb);
1655 conservation.setBorder(jb);
1656 identity.setBorder(jb);
1657 showConsensbits.setBorder(jb);
1658 showGroupbits.setBorder(jb);
1659 showGroupConsensus.setBorder(jb);
1660 showGroupConservation.setBorder(jb);
1661 showConsensHistogram.setBorder(jb);
1662 showConsensLogo.setBorder(jb);
1664 JPanel autoAnnotSettings = new JPanel();
1665 annsettingsPanel.add(autoAnnotSettings);
1666 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1667 autoAnnotSettings.add(annotations);
1668 autoAnnotSettings.add(quality);
1669 // second row of autoannotation box
1670 autoAnnotSettings = new JPanel();
1671 annsettingsPanel.add(autoAnnotSettings);
1673 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1674 autoAnnotSettings.add(conservation);
1675 autoAnnotSettings.add(identity);
1676 autoAnnotSettings.add(showOccupancy);
1677 autoAnnotSettings.add(showGroupbits);
1678 autoAnnotSettings.add(showGroupConservation);
1679 autoAnnotSettings.add(showGroupConsensus);
1680 autoAnnotSettings.add(showConsensbits);
1681 autoAnnotSettings.add(showConsensHistogram);
1682 autoAnnotSettings.add(showConsensLogo);
1684 JPanel tooltipSettings = new JPanel();
1685 tooltipSettings.setBorder(new TitledBorder(
1686 MessageManager.getString("label.sequence_id_tooltip")));
1687 tooltipSettings.setBounds(173, 140, 220, 62);
1688 tooltipSettings.setLayout(new GridLayout(2, 1));
1689 tooltipSettings.add(showDbRefTooltip);
1690 tooltipSettings.add(showNpTooltip);
1691 visualTab.add(tooltipSettings);
1693 wrap.setFont(LABEL_FONT);
1694 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1695 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1696 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1697 rightAlign.setFont(LABEL_FONT);
1698 rightAlign.setForeground(Color.black);
1699 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1700 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1701 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1702 idItalics.setFont(LABEL_FONT_ITALIC);
1703 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1704 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1706 MessageManager.getString("label.sequence_name_italics"));
1707 openoverv.setFont(LABEL_FONT);
1708 openoverv.setActionCommand(
1709 MessageManager.getString("label.open_overview"));
1710 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1711 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1712 openoverv.setText(MessageManager.getString("label.open_overview"));
1713 JPanel jPanel2 = new JPanel();
1714 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1715 jPanel2.setLayout(new GridLayout(14, 1));
1716 jPanel2.add(fullScreen);
1717 jPanel2.add(openoverv);
1718 jPanel2.add(seqLimit);
1719 jPanel2.add(rightAlign);
1720 jPanel2.add(fontLabel);
1721 jPanel2.add(showUnconserved);
1722 jPanel2.add(idItalics);
1723 jPanel2.add(smoothFont);
1724 jPanel2.add(scaleProteinToCdna);
1725 jPanel2.add(gapLabel);
1727 jPanel2.add(sortLabel);
1728 jPanel2.add(sortAnnLabel);
1729 jPanel2.add(startupCheckbox);
1730 visualTab.add(jPanel2);
1731 visualTab.add(startupFileTextfield);
1732 visualTab.add(sortby);
1733 visualTab.add(sortAnnBy);
1734 visualTab.add(sortAutocalc);
1735 visualTab.add(gapSymbolCB);
1736 visualTab.add(fontNameCB);
1737 visualTab.add(fontSizeCB);
1738 visualTab.add(fontStyleCB);
1740 if (Platform.isJS())
1742 startupCheckbox.setVisible(false);
1743 startupFileTextfield.setVisible(false);
1750 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1753 protected void loadLastSavedBackupsOptions()
1756 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1757 setComboIntStringKey(backupfilesPresetsCombo,
1758 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1759 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1760 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1762 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1763 suffixReverse.setSelected(
1764 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1766 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1767 backupfilesRollMaxSpinner
1768 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1769 backupfilesConfirmDelete.setSelected(
1770 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1772 backupsOptionsSetEnabled();
1773 updateBackupFilesExampleLabel();
1776 protected boolean warnAboutSuffixReverseChange()
1778 boolean savedSuffixReverse = Cache.getDefault(BackupFiles.REVERSE_ORDER,
1780 int savedSuffixDigits = Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3);
1781 String savedSuffixTemplate = Cache.getDefault(BackupFiles.SUFFIX,
1782 ".bak" + BackupFiles.NUM_PLACEHOLDER);
1784 boolean nowSuffixReverse = suffixReverse.isSelected();
1785 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1786 String nowSuffixTemplate = suffixTemplate.getText();
1787 return nowSuffixReverse != savedSuffixReverse
1788 && nowSuffixDigits == savedSuffixDigits
1789 && nowSuffixTemplate != null
1790 && nowSuffixTemplate.equals(savedSuffixTemplate);
1794 * Initialises the Backups tabbed panel.
1798 private JPanel initBackupsTab()
1800 JPanel backupsTab = new JPanel();
1801 backupsTab.setBorder(new TitledBorder(
1802 MessageManager.getString("label.backup_files")));
1803 backupsTab.setLayout(new GridBagLayout());
1805 GridBagConstraints gbc = new GridBagConstraints();
1808 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1809 gbc.fill = GridBagConstraints.NONE;
1811 initBackupsTabPresetsPanel();
1812 initBackupsTabSuffixPanel();
1813 initBackupsTabKeepFilesPanel();
1814 initBackupsTabFilenameExamplesPanel();
1816 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1818 .setText(MessageManager.getString("label.enable_backupfiles"));
1819 enableBackupFiles.addActionListener(new ActionListener()
1822 public void actionPerformed(ActionEvent e)
1824 // enable other options only when the first is checked
1825 backupsOptionsSetEnabled();
1830 // enable checkbox 1 col
1834 gbc.gridy = 0; // row 0
1835 backupsTab.add(enableBackupFiles, gbc);
1837 // summary of scheme box (over two rows)
1841 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1842 gbc.fill = GridBagConstraints.BOTH;
1843 backupsTab.add(exampleFilesPanel, gbc);
1845 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1846 gbc.fill = GridBagConstraints.NONE;
1848 // fill empty space on right
1851 backupsTab.add(new JPanel(), gbc);
1856 gbc.gridy++; // row 1
1857 backupsTab.add(presetsPanel, gbc);
1859 // gbc.anchor = GridBagConstraints.NORTHWEST;
1860 // now using whole row
1865 gbc.gridy++; // row 2
1866 backupsTab.add(keepfilesPanel, gbc);
1868 // filename strategy box
1869 gbc.gridy++; // row 3
1870 backupsTab.add(suffixPanel, gbc);
1873 gbc.gridy++; // row 4
1875 backupsTab.add(new JPanel(), gbc);
1877 backupsOptionsSetEnabled();
1881 protected static final int BACKUPFILESSCHEMECUSTOMISE = 0;
1883 private static final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1884 new IntKeyStringValueEntry(1,
1885 MessageManager.getString("label.default")),
1886 new IntKeyStringValueEntry(2,
1887 MessageManager.getString("label.single_file")),
1888 new IntKeyStringValueEntry(3,
1889 MessageManager.getString("label.keep_all_versions")),
1890 new IntKeyStringValueEntry(4,
1891 MessageManager.getString("label.rolled_backups")),
1893 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1894 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1895 MessageManager.getString("label.customise")) };
1897 private static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1902 private static final long serialVersionUID = 125L;
1905 put(1, new BackupFilesPresetEntry(
1906 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1908 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1909 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1910 3, false, true, 10, true));
1911 put(4, new BackupFilesPresetEntry(
1912 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1917 private JPanel initBackupsTabPresetsPanel()
1920 String title = MessageManager.getString("label.schemes");
1921 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1922 // TitledBorder tb = new TitledBorder(title);
1923 // tb.setTitleFont(LABEL_FONT);
1924 // presetsPanel.setBorder(tb);
1926 presetsPanel.setLayout(new GridBagLayout());
1928 GridBagConstraints gbc = new GridBagConstraints();
1931 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1932 gbc.fill = GridBagConstraints.NONE;
1939 presetsPanel.add(new JLabel(title + ":"), gbc);
1941 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1943 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1946 // put "Previously saved scheme" item in italics (it's not really
1947 // selectable, as such -- it deselects itself when selected) and
1948 // "Customise" in bold
1949 backupfilesPresetsCombo
1950 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1951 backupfilesPresetsCombo.addActionListener(new ActionListener()
1954 public void actionPerformed(ActionEvent e)
1956 backupsTabUpdatePresets();
1960 // dropdown list of preset schemes
1962 presetsPanel.add(backupfilesPresetsCombo, gbc);
1964 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1965 revertButton.addActionListener(new ActionListener()
1968 public void actionPerformed(ActionEvent e)
1970 loadLastSavedBackupsOptions();
1974 revertButton.setFont(LABEL_FONT);
1976 // "Cancel changes" button (aligned with combo box above)
1979 presetsPanel.add(revertButton, gbc);
1981 return presetsPanel;
1984 private JPanel initBackupsTabFilenameExamplesPanel()
1986 String title = MessageManager
1987 .getString("label.summary_of_backups_scheme");
1988 TitledBorder tb = new TitledBorder(title);
1989 exampleFilesPanel.setBorder(tb);
1990 exampleFilesPanel.setLayout(new GridBagLayout());
1993 backupfilesExampleLabel.setEditable(false);
1994 backupfilesExampleLabel
1995 .setBackground(exampleFilesPanel.getBackground());
1997 updateBackupFilesExampleLabel();
1999 GridBagConstraints gbc = new GridBagConstraints();
2002 gbc.fill = GridBagConstraints.NONE;
2003 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2005 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2006 return exampleFilesPanel;
2009 protected void backupsTabUpdatePresets()
2011 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2013 int key = entry.getKey();
2014 String value = entry.getValue();
2016 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
2017 if (key != BACKUPFILESSCHEMECUSTOMISE)
2019 if (backupfilesPresetEntriesValues.containsKey(key))
2021 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
2025 System.out.println("Preset '" + value + "' not implemented");
2029 backupfilesCustomOptionsSetEnabled();
2030 updateBackupFilesExampleLabel();
2033 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
2035 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
2036 return e != null ? e.getKey() : 0;
2039 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
2042 for (int i = 0; i < c.getItemCount(); i++)
2044 IntKeyStringValueEntry e = c.getItemAt(i);
2045 if (e.getKey() == key)
2047 c.setSelectedIndex(i);
2051 backupsTabUpdatePresets();
2054 private JPanel initBackupsTabSuffixPanel()
2056 suffixPanel.setBorder(new TitledBorder(
2057 MessageManager.getString("label.backup_filename_strategy")));
2058 suffixPanel.setLayout(new GridBagLayout());
2061 .setText(MessageManager.getString("label.append_to_filename"));
2062 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2063 suffixTemplateLabel.setFont(LABEL_FONT);
2065 final String tooltip = JvSwingUtils.wrapTooltip(true,
2066 MessageManager.getString("label.append_to_filename_tooltip"));
2067 suffixTemplate.setToolTipText(tooltip);
2068 suffixTemplate.addActionListener(new ActionListener()
2071 public void actionPerformed(ActionEvent e)
2073 updateBackupFilesExampleLabel();
2074 backupfilesCustomOptionsSetEnabled();
2078 KeyListener kl = new KeyListener()
2081 public void keyReleased(KeyEvent e)
2083 updateBackupFilesExampleLabel();
2084 backupfilesCustomOptionsSetEnabled();
2088 public void keyPressed(KeyEvent e)
2092 // disable use of ':' or '/' or '\'
2094 public void keyTyped(KeyEvent e)
2096 char c = e.getKeyChar();
2097 if (c == ':' || c == '/' || c == '\\')
2099 // don't process ':' or '/' or '\'
2105 suffixTemplate.addKeyListener(kl);
2109 .setText(MessageManager.getString("label.index_digits"));
2110 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2111 suffixDigitsLabel.setFont(LABEL_FONT);
2114 ChangeListener c = new ChangeListener()
2117 public void stateChanged(ChangeEvent e)
2119 updateBackupFilesExampleLabel();
2123 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2125 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2126 MessageManager.getString("label.increment_index"));
2127 suffixReverse.addActionListener(new ActionListener()
2130 public void actionPerformed(ActionEvent e)
2132 boolean okay = true;
2133 if (warnAboutSuffixReverseChange())
2136 okay = confirmSuffixReverseChange();
2140 updateBackupFilesExampleLabel();
2144 boolean savedSuffixReverse = Cache
2145 .getDefault(BackupFiles.REVERSE_ORDER, false);
2146 suffixReverse.setSelected(savedSuffixReverse);
2151 GridBagConstraints sgbc = new GridBagConstraints();
2153 // first row (template text box)
2154 sgbc.anchor = GridBagConstraints.WEST;
2158 sgbc.gridheight = 1;
2161 sgbc.fill = GridBagConstraints.NONE;
2162 suffixPanel.add(suffixTemplateLabel, sgbc);
2165 sgbc.fill = GridBagConstraints.HORIZONTAL;
2166 suffixPanel.add(suffixTemplate, sgbc);
2168 // second row (number of digits spinner)
2172 sgbc.fill = GridBagConstraints.NONE;
2173 suffixPanel.add(suffixDigitsLabel, sgbc);
2176 sgbc.fill = GridBagConstraints.HORIZONTAL;
2177 suffixPanel.add(suffixDigitsSpinner, sgbc);
2179 // third row (forward order radio selection)
2182 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2183 sgbc.fill = GridBagConstraints.HORIZONTAL;
2184 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2186 // fourth row (reverse order radio selection)
2188 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2192 protected boolean confirmSuffixReverseChange()
2194 boolean ret = false;
2195 String warningMessage = MessageManager
2196 .getString("label.warning_confirm_change_reverse");
2197 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
2199 MessageManager.getString("label.change_increment_decrement"),
2200 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2202 ret = (confirm == JvOptionPane.YES_OPTION);
2206 private JPanel initBackupsTabKeepFilesPanel()
2208 keepfilesPanel.setBorder(
2209 new TitledBorder(MessageManager.getString("label.keep_files")));
2210 keepfilesPanel.setLayout(new GridBagLayout());
2212 backupfilesKeepAll.setLabels(
2213 MessageManager.getString("label.keep_all_backup_files"),
2214 MessageManager.getString(
2215 "label.keep_only_this_number_of_backup_files"));
2216 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2219 public void actionPerformed(ActionEvent e)
2221 updateBackupFilesExampleLabel();
2224 backupfilesKeepAll.addActionListener(new ActionListener()
2227 public void actionPerformed(ActionEvent e)
2229 keepRollMaxOptionsEnabled();
2230 updateBackupFilesExampleLabel();
2234 ChangeListener c = new ChangeListener()
2237 public void stateChanged(ChangeEvent e)
2239 updateBackupFilesExampleLabel();
2243 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2245 backupfilesConfirmDelete.setLabels(
2246 MessageManager.getString("label.always_ask"),
2247 MessageManager.getString("label.auto_delete"));
2248 // update the enabled section
2249 keepRollMaxOptionsEnabled();
2251 GridBagConstraints kgbc = new GridBagConstraints();
2253 // first row (template text box)
2254 kgbc.anchor = GridBagConstraints.WEST;
2257 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2258 kgbc.gridheight = 1;
2261 kgbc.fill = GridBagConstraints.HORIZONTAL;
2262 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2268 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2269 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2272 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2273 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2275 // third row (indented)
2277 kgbc.insets = new Insets(0, 20, 0, 0);
2280 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2281 kgbc.fill = GridBagConstraints.HORIZONTAL;
2284 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2286 // fourth row (indented)
2288 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2291 JPanel jp = new JPanel();
2292 jp.setLayout(new FlowLayout());
2294 .setText(MessageManager
2295 .getString("label.autodelete_old_backup_files"));
2296 oldBackupFilesLabel.setFont(LABEL_FONT);
2297 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2298 jp.add(oldBackupFilesLabel);
2299 jp.add(backupfilesConfirmDelete.getTrueButton());
2300 jp.add(backupfilesConfirmDelete.getFalseButton());
2301 keepfilesPanel.add(jp, kgbc);
2303 return keepfilesPanel;
2306 protected void updateBackupFilesExampleLabel()
2308 int exampleindex = 12;
2309 String base = MessageManager.getString("label.filename") + ".fa";
2310 if (base == null || base.length() == 0)
2312 base = "file_name.fa";
2315 boolean reverse = suffixReverse.isSelected();
2316 boolean keepAll = backupfilesKeepAll.isSelected();
2318 String suffix = suffixTemplate.getText();
2321 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2322 if (suffix == null || suffix.length() == 0)
2324 backupfilesExampleLabel
2325 .setText(MessageManager.getString("label.no_backup_files"));
2326 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2330 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2331 rollMax = rollMax < 1 ? 1 : rollMax;
2333 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2338 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2339 digits = digits < 1 ? 1 : digits;
2341 int lowersurround = 2;
2342 int uppersurround = 0;
2343 StringBuilder exampleSB = new StringBuilder();
2344 boolean firstLine = true;
2349 int max = keepAll ? exampleindex : rollMax;
2350 for (int index = min; index <= max; index++)
2352 if (index == min + lowersurround && index < max - uppersurround - 1)
2354 exampleSB.append("\n...");
2356 else if (index > min + lowersurround && index < max - uppersurround)
2368 exampleSB.append("\n");
2370 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2371 base, suffix, digits));
2374 // no extra text needed
2376 else if (index == min)
2378 String newest = MessageManager.getString("label.braced_newest");
2379 if (newest != null && newest.length() > 0)
2381 exampleSB.append(" " + newest);
2384 else if (index == max)
2386 String oldest = MessageManager.getString("label.braced_oldest");
2387 if (oldest != null && oldest.length() > 0)
2389 exampleSB.append(" " + oldest);
2398 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2399 : exampleindex - rollMax + 1;
2400 int max = exampleindex;
2402 for (int index = min; index <= max; index++)
2405 if (index == min + lowersurround && index < max - uppersurround - 1)
2407 exampleSB.append("\n...");
2409 else if (index > min + lowersurround && index < max - uppersurround)
2421 exampleSB.append("\n");
2423 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2424 base, suffix, digits));
2427 // no extra text needed
2429 else if (index == min)
2431 String oldest = MessageManager.getString("label.braced_oldest");
2432 if (oldest != null && oldest.length() > 0)
2434 exampleSB.append(" " + oldest);
2437 else if (index == max)
2439 String newest = MessageManager.getString("label.braced_newest");
2440 if (newest != null && newest.length() > 0)
2442 exampleSB.append(" " + newest);
2450 backupfilesExampleLabel.setText(exampleSB.toString());
2453 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2454 boolean useExistingVal, ChangeListener c)
2461 i = Integer.parseInt((String) s.getValue());
2462 } catch (Exception e)
2465 "Exception casting the initial value of s.getValue()");
2469 setIntegerSpinner(s, min, max, i, c);
2472 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2475 // integer spinner for number of digits
2480 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2483 s.addChangeListener(c);
2487 protected static int getSpinnerInt(JSpinner s, int def)
2493 i = (Integer) s.getValue();
2494 } catch (Exception e)
2496 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2501 protected void keepRollMaxOptionsEnabled()
2503 boolean enabled = backupfilesKeepAll.isEnabled()
2504 && !backupfilesKeepAll.isSelected();
2505 oldBackupFilesLabel.setEnabled(enabled);
2506 backupfilesRollMaxSpinner.setEnabled(enabled);
2507 backupfilesConfirmDelete.setEnabled(enabled);
2510 protected void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2512 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2513 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2514 && suffixTemplate.getText()
2515 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2516 keepfilesPanel.setEnabled(enabled);
2517 backupfilesKeepAll.setEnabled(enabled);
2518 oldBackupFilesLabel.setEnabled(enabled);
2519 keepRollMaxOptionsEnabled();
2522 private void backupfilesSuffixTemplateDigitsSetEnabled()
2524 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2525 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2526 suffixDigitsLabel.setEnabled(enabled);
2527 suffixDigitsSpinner.setEnabled(enabled);
2528 suffixReverse.setEnabled(enabled);
2531 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2533 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2534 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2535 suffixPanel.setEnabled(enabled);
2536 suffixTemplateLabel.setEnabled(enabled);
2537 suffixTemplate.setEnabled(enabled);
2538 backupfilesSuffixTemplateDigitsSetEnabled();
2541 protected void backupfilesCustomOptionsSetEnabled()
2543 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2544 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2546 backupfilesSuffixTemplateSetEnabled(enabled);
2547 backupfilesKeepAllSetEnabled(enabled);
2550 private void backupfilesSummarySetEnabled()
2552 boolean enabled = enableBackupFiles.isSelected();
2553 backupfilesExampleLabel.setEnabled(enabled);
2554 exampleFilesPanel.setEnabled(enabled);
2557 private void backupfilesPresetsSetEnabled()
2559 boolean enabled = enableBackupFiles.isSelected();
2560 presetsPanel.setEnabled(enabled);
2561 backupfilesPresetsCombo.setEnabled(enabled);
2564 protected void backupsOptionsSetEnabled()
2566 backupfilesPresetsSetEnabled();
2567 backupfilesSummarySetEnabled();
2568 backupfilesCustomOptionsSetEnabled();
2571 protected void backupsSetOptions(String suffix, int digits,
2572 boolean reverse, boolean keepAll, int rollMax,
2573 boolean confirmDelete)
2575 suffixTemplate.setText(suffix);
2576 suffixDigitsSpinner.setValue(digits);
2577 suffixReverse.setSelected(reverse);
2578 backupfilesKeepAll.setSelected(keepAll);
2579 backupfilesRollMaxSpinner.setValue(rollMax);
2580 backupfilesConfirmDelete.setSelected(confirmDelete);
2583 protected void backupsSetOptions(BackupFilesPresetEntry p)
2585 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2589 protected void autoIdWidth_actionPerformed()
2591 // TODO Auto-generated method stub
2595 protected void userIdWidth_actionPerformed()
2597 // TODO Auto-generated method stub
2601 protected void maxColour_actionPerformed(JPanel panel)
2605 protected void minColour_actionPerformed(JPanel panel)
2609 protected void gapColour_actionPerformed(JPanel panel)
2613 protected void hiddenColour_actionPerformed(JPanel panel)
2617 protected void showunconserved_actionPerformed(ActionEvent e)
2619 // TODO Auto-generated method stub
2623 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2627 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2637 public void ok_actionPerformed(ActionEvent e)
2647 public void cancel_actionPerformed(ActionEvent e)
2657 public void annotations_actionPerformed(ActionEvent e)
2664 public void startupFileTextfield_mouseClicked()
2668 public void newLink_actionPerformed(ActionEvent e)
2673 public void editLink_actionPerformed(ActionEvent e)
2678 public void deleteLink_actionPerformed(ActionEvent e)
2683 public void defaultBrowser_mouseClicked(MouseEvent e)
2688 public void linkURLList_keyTyped(KeyEvent e)
2693 public void useProxy_actionPerformed()
2695 boolean enabled = useProxy.isSelected();
2696 portLabel.setEnabled(enabled);
2697 serverLabel.setEnabled(enabled);
2698 proxyServerTB.setEnabled(enabled);
2699 proxyPortTB.setEnabled(enabled);
2703 * Customer renderer for JTable: supports column of radio buttons
2705 public class RadioButtonRenderer extends JRadioButton
2706 implements TableCellRenderer
2708 public RadioButtonRenderer()
2710 setHorizontalAlignment(CENTER);
2711 setToolTipText(MessageManager.getString("label.urltooltip"));
2715 public Component getTableCellRendererComponent(JTable table,
2716 Object value, boolean isSelected, boolean hasFocus, int row,
2719 setSelected((boolean) value);
2721 // set colours to match rest of table
2724 setBackground(table.getSelectionBackground());
2725 setForeground(table.getSelectionForeground());
2729 setBackground(table.getBackground());
2730 setForeground(table.getForeground());
2737 * Customer cell editor for JTable: supports column of radio buttons in
2738 * conjunction with renderer
2740 public class RadioButtonEditor extends AbstractCellEditor
2741 implements TableCellEditor
2743 private JRadioButton button = new JRadioButton();
2745 public RadioButtonEditor()
2747 button.setHorizontalAlignment(SwingConstants.CENTER);
2748 this.button.addActionListener(new ActionListener()
2751 public void actionPerformed(ActionEvent e)
2753 fireEditingStopped();
2759 public Component getTableCellEditorComponent(JTable table, Object value,
2760 boolean isSelected, int row, int column)
2762 button.setSelected((boolean) value);
2767 public Object getCellEditorValue()
2769 return button.isSelected();
2775 class IntKeyStringValueEntry
2781 public IntKeyStringValueEntry(int k, String v)
2788 public String toString()
2790 return this.getValue();
2798 public String getValue()
2804 class BackupFilesPresetEntry
2816 boolean confirmDelete;
2818 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2819 boolean keepAll, int rollMax, boolean confirmDelete)
2821 this.suffix = suffix;
2822 this.digits = digits;
2823 this.reverse = reverse;
2824 this.keepAll = keepAll;
2825 this.rollMax = rollMax;
2826 this.confirmDelete = confirmDelete;
2830 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2835 private static final long serialVersionUID = 88L;
2838 public Component getListCellRendererComponent(JList list, Object value,
2839 int index, boolean isSelected, boolean cellHasFocus)
2841 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2844 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2845 if (e.getKey() == GPreferences.BACKUPFILESSCHEMECUSTOMISE)
2848 this.setFont(this.getFont().deriveFont(Font.BOLD));
2850 } catch (Exception e) {