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 structureDimensions = new JTextField();
185 protected JTextField chimeraPath = new JTextField();
187 protected ButtonGroup mappingMethod = new ButtonGroup();
189 protected JRadioButton siftsMapping = new JRadioButton();
191 protected JRadioButton nwMapping = new JRadioButton();
194 * Colours tab components
196 protected JPanel minColour = new JPanel();
198 protected JPanel maxColour = new JPanel();
200 protected JComboBox<String> protColour = new JComboBox<>();
202 protected JComboBox<String> nucColour = new JComboBox<>();
205 * Overview tab components
207 protected JPanel gapColour = new JPanel();
209 protected JPanel hiddenColour = new JPanel();
211 protected JCheckBox useLegacyGap;
213 protected JCheckBox showHiddenAtStart;
215 protected JLabel gapLabel;
218 * Connections tab components
220 public JTable linkUrlTable = new JTable();
222 public JButton editLink = new JButton();
224 public JButton deleteLink = new JButton();
226 public JTextField filterTB = new JTextField();
228 protected JButton doReset = new JButton();
230 protected JButton userOnly = new JButton();
232 protected JLabel portLabel = new JLabel();
234 protected JLabel serverLabel = new JLabel();
236 protected JTextField proxyServerTB = new JTextField();
238 protected JTextField proxyPortTB = new JTextField();
240 protected JTextField defaultBrowser = new JTextField();
242 protected JCheckBox useProxy = new JCheckBox();
244 protected JCheckBox usagestats = new JCheckBox();
246 protected JCheckBox questionnaire = new JCheckBox();
248 protected JCheckBox versioncheck = new JCheckBox();
251 * Output tab components
253 protected JComboBox<Object> epsRendering = new JComboBox<>();
255 protected JComboBox<Object> htmlRendering = new JComboBox<>();
257 protected JComboBox<Object> svgRendering = new JComboBox<>();
259 protected JLabel userIdWidthlabel = new JLabel();
261 protected JCheckBox autoIdWidth = new JCheckBox();
263 protected JTextField userIdWidth = new JTextField();
265 protected JCheckBox blcjv = new JCheckBox();
267 protected JCheckBox pileupjv = new JCheckBox();
269 protected JCheckBox clustaljv = new JCheckBox();
271 protected JCheckBox msfjv = new JCheckBox();
273 protected JCheckBox fastajv = new JCheckBox();
275 protected JCheckBox pfamjv = new JCheckBox();
277 protected JCheckBox pirjv = new JCheckBox();
279 protected JCheckBox modellerOutput = new JCheckBox();
281 protected JCheckBox embbedBioJSON = new JCheckBox();
284 * Editing tab components
286 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
288 protected JCheckBox padGaps = new JCheckBox();
290 protected JCheckBox sortByTree = new JCheckBox();
295 protected JPanel wsTab = new JPanel();
298 * Backups tab components
299 * a lot of these are member variables instead of local variables only so that they
300 * can be enabled/disabled easily in one go
303 protected JCheckBox enableBackupFiles = new JCheckBox();
305 protected JPanel presetsPanel = new JPanel();
307 protected JButton revertButton = new JButton();
309 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
311 protected JPanel suffixPanel = new JPanel();
313 protected JPanel keepfilesPanel = new JPanel();
315 protected JPanel exampleFilesPanel = new JPanel();
317 protected JTextField suffixTemplate = new JTextField(null, 8);
319 protected JLabel suffixTemplateLabel = new JLabel();
321 protected JLabel suffixDigitsLabel = new JLabel();
323 protected JSpinner suffixDigitsSpinner = new JSpinner();
325 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
327 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
329 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
331 protected JLabel oldBackupFilesLabel = new JLabel();
333 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
335 protected JTextArea backupfilesExampleLabel = new JTextArea();
338 * Creates a new GPreferences object.
340 public GPreferences()
345 } catch (Exception ex)
347 ex.printStackTrace();
352 * Construct the panel and its tabbed sub-panels.
356 private void jbInit() throws Exception
358 final JTabbedPane tabbedPane = new JTabbedPane();
359 this.setLayout(new BorderLayout());
360 JPanel okCancelPanel = initOkCancelPanel();
361 this.add(tabbedPane, BorderLayout.CENTER);
362 this.add(okCancelPanel, BorderLayout.SOUTH);
364 tabbedPane.add(initVisualTab(),
365 MessageManager.getString("label.visual"));
367 tabbedPane.add(initColoursTab(),
368 MessageManager.getString("label.colours"));
370 tabbedPane.add(initOverviewTab(),
371 MessageManager.getString("label.overview"));
373 tabbedPane.add(initStructureTab(),
374 MessageManager.getString("label.structure"));
376 tabbedPane.add(initConnectionsTab(),
377 MessageManager.getString("label.connections"));
379 if (!Platform.isJS())
381 tabbedPane.add(initBackupsTab(),
382 MessageManager.getString("label.backups"));
385 tabbedPane.add(initLinksTab(),
386 MessageManager.getString("label.urllinks"));
388 tabbedPane.add(initOutputTab(),
389 MessageManager.getString("label.output"));
391 tabbedPane.add(initEditingTab(),
392 MessageManager.getString("label.editing"));
395 * See WsPreferences for the real work of configuring this tab.
397 if (!Platform.isJS())
399 wsTab.setLayout(new BorderLayout());
400 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
404 * Handler to validate a tab before leaving it - currently only for
407 tabbedPane.addChangeListener(new ChangeListener()
409 private Component lastTab;
412 public void stateChanged(ChangeEvent e)
414 if (lastTab == structureTab
415 && tabbedPane.getSelectedComponent() != structureTab)
417 if (!validateStructure())
419 tabbedPane.setSelectedComponent(structureTab);
423 lastTab = tabbedPane.getSelectedComponent();
430 * Initialises the Editing tabbed panel.
434 private JPanel initEditingTab()
436 JPanel editingTab = new JPanel();
437 editingTab.setLayout(null);
438 autoCalculateConsCheck.setFont(LABEL_FONT);
439 autoCalculateConsCheck.setText(
440 MessageManager.getString("label.autocalculate_consensus"));
441 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
442 padGaps.setFont(LABEL_FONT);
444 MessageManager.getString("label.pad_gaps_when_editing"));
445 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
446 sortByTree.setFont(LABEL_FONT);
448 .setText(MessageManager.getString("label.sort_with_new_tree"));
449 sortByTree.setToolTipText(MessageManager.getString(
450 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
451 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
452 editingTab.add(autoCalculateConsCheck);
453 editingTab.add(padGaps);
454 editingTab.add(sortByTree);
459 * Initialises the Output tab
463 private JPanel initOutputTab()
465 JPanel outputTab = new JPanel();
466 outputTab.setLayout(null);
468 JLabel epsLabel = new JLabel(
469 MessageManager.formatMessage("label.rendering_style", "EPS"));
470 epsLabel.setFont(LABEL_FONT);
471 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
472 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
473 epsRendering.setFont(LABEL_FONT);
474 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
475 JLabel htmlLabel = new JLabel(
476 MessageManager.formatMessage("label.rendering_style", "HTML"));
477 htmlLabel.setFont(LABEL_FONT);
478 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
479 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
480 htmlRendering.setFont(LABEL_FONT);
481 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
482 JLabel svgLabel = new JLabel(
483 MessageManager.formatMessage("label.rendering_style", "SVG"));
484 svgLabel.setFont(LABEL_FONT);
485 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
486 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
487 svgRendering.setFont(LABEL_FONT);
488 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
490 JLabel jLabel1 = new JLabel();
491 jLabel1.setFont(LABEL_FONT);
492 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
493 jLabel1.setText(MessageManager.getString("label.append_start_end"));
494 jLabel1.setFont(LABEL_FONT);
496 fastajv.setFont(LABEL_FONT);
497 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
498 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
499 blcjv.setText(MessageManager.getString("label.blc") + " ");
500 fastajv.setText(MessageManager.getString("label.fasta") + " ");
501 msfjv.setText(MessageManager.getString("label.msf") + " ");
502 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
503 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
504 msfjv.setFont(LABEL_FONT);
505 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
506 pirjv.setText(MessageManager.getString("label.pir") + " ");
507 JPanel jPanel11 = new JPanel();
508 jPanel11.setFont(LABEL_FONT);
509 TitledBorder titledBorder2 = new TitledBorder(
510 MessageManager.getString("label.file_output"));
511 jPanel11.setBorder(titledBorder2);
512 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
513 GridLayout gridLayout3 = new GridLayout();
514 jPanel11.setLayout(gridLayout3);
515 gridLayout3.setRows(8);
516 blcjv.setFont(LABEL_FONT);
517 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
518 clustaljv.setFont(LABEL_FONT);
519 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
520 pfamjv.setFont(LABEL_FONT);
521 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
522 pileupjv.setFont(LABEL_FONT);
523 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
524 pirjv.setFont(LABEL_FONT);
525 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
526 autoIdWidth.setFont(LABEL_FONT);
528 MessageManager.getString("label.automatically_set_id_width"));
529 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
530 .getString("label.adjusts_width_generated_eps_png")));
531 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
532 autoIdWidth.addActionListener(new ActionListener()
536 public void actionPerformed(ActionEvent e)
538 autoIdWidth_actionPerformed();
541 userIdWidthlabel.setFont(LABEL_FONT);
542 userIdWidthlabel.setText(
543 MessageManager.getString("label.figure_id_column_width"));
544 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
545 .getString("label.manually_specify_width_left_column")));
546 userIdWidthlabel.setToolTipText(
547 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
548 "label.manually_specify_width_left_column")));
549 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
550 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
551 userIdWidth.setText("");
552 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
553 userIdWidth.addActionListener(new ActionListener()
557 public void actionPerformed(ActionEvent e)
559 userIdWidth_actionPerformed();
562 modellerOutput.setFont(LABEL_FONT);
564 .setText(MessageManager.getString("label.use_modeller_output"));
565 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
566 embbedBioJSON.setFont(LABEL_FONT);
567 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
568 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
570 jPanel11.add(jLabel1);
572 jPanel11.add(clustaljv);
573 jPanel11.add(fastajv);
575 jPanel11.add(pfamjv);
576 jPanel11.add(pileupjv);
578 outputTab.add(autoIdWidth);
579 outputTab.add(userIdWidth);
580 outputTab.add(userIdWidthlabel);
581 outputTab.add(modellerOutput);
582 if (!Platform.isJS())
585 * JalviewJS doesn't support Lineart option or SVG output
587 outputTab.add(embbedBioJSON);
588 outputTab.add(epsLabel);
589 outputTab.add(epsRendering);
590 outputTab.add(htmlLabel);
591 outputTab.add(htmlRendering);
592 outputTab.add(svgLabel);
593 outputTab.add(svgRendering);
595 outputTab.add(jPanel11);
600 * Initialises the Connections tabbed panel.
604 private JPanel initConnectionsTab()
606 JPanel connectTab = new JPanel();
607 connectTab.setLayout(new GridBagLayout());
609 // Label for browser text box
610 JLabel browserLabel = new JLabel();
611 browserLabel.setFont(LABEL_FONT);
612 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
613 browserLabel.setText(
614 MessageManager.getString("label.default_browser_unix"));
615 defaultBrowser.setFont(LABEL_FONT);
616 defaultBrowser.setText("");
617 final String tooltip = JvSwingUtils.wrapTooltip(true,
618 MessageManager.getString("label.double_click_to_browse"));
619 defaultBrowser.setToolTipText(tooltip);
620 defaultBrowser.addMouseListener(new MouseAdapter()
623 public void mouseClicked(MouseEvent e)
625 if (e.getClickCount() > 1)
627 defaultBrowser_mouseClicked(e);
632 JPanel proxyPanel = initConnTabProxyPanel();
633 initConnTabCheckboxes();
635 // Add default Browser text box
636 connectTab.add(browserLabel,
637 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
638 GridBagConstraints.WEST, GridBagConstraints.NONE,
639 new Insets(10, 0, 5, 5), 5, 1));
640 defaultBrowser.setFont(LABEL_FONT);
641 defaultBrowser.setText("");
643 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
644 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
645 new Insets(10, 0, 5, 10), 30, 1));
647 // Add proxy server panel
648 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
649 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
650 new Insets(10, 0, 5, 12), 4, 10));
652 // Add usage stats, version check and questionnaire checkboxes
653 connectTab.add(usagestats,
654 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
655 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
656 new Insets(0, 2, 5, 5), 70, 1));
657 connectTab.add(questionnaire,
658 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
659 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
660 new Insets(0, 2, 5, 10), 70, 1));
661 connectTab.add(versioncheck,
662 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
663 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
664 new Insets(0, 2, 5, 5), 70, 1));
666 // Add padding so the panel doesn't look ridiculous
667 JPanel spacePanel = new JPanel();
668 connectTab.add(spacePanel,
669 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
670 GridBagConstraints.WEST, GridBagConstraints.BOTH,
671 new Insets(0, 0, 0, 5), 70, 1));
677 * Initialises the Links tabbed panel.
681 private JPanel initLinksTab()
683 JPanel linkTab = new JPanel();
684 linkTab.setLayout(new GridBagLayout());
686 // Set up table for Url links
687 linkUrlTable.getTableHeader().setReorderingAllowed(false);
688 linkUrlTable.setFillsViewportHeight(true);
689 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
690 linkUrlTable.setAutoCreateRowSorter(true);
691 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
693 // adjust row height so radio buttons actually fit
694 // don't do this in the renderer, it causes the awt thread to activate
696 JRadioButton temp = new JRadioButton();
697 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
699 // Table in scrollpane so that the table is given a scrollbar
700 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
701 linkScrollPane.setBorder(null);
703 // Panel for links functionality
704 JPanel linkPanel = new JPanel(new GridBagLayout());
705 linkPanel.setBorder(new TitledBorder(
706 MessageManager.getString("label.url_linkfrom_sequence_id")));
708 // Put the Url links panel together
710 // Buttons go at top right, resizing only resizes the blank space vertically
711 JPanel buttonPanel = initLinkTabUrlButtons();
712 GridBagConstraints linkConstraints1 = new GridBagConstraints();
713 linkConstraints1.insets = new Insets(0, 0, 5, 0);
714 linkConstraints1.gridx = 0;
715 linkConstraints1.gridy = 0;
716 linkConstraints1.weightx = 1.0;
717 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
718 linkTab.add(buttonPanel, linkConstraints1);
720 // Links table goes at top left, resizing resizes the table
721 GridBagConstraints linkConstraints2 = new GridBagConstraints();
722 linkConstraints2.insets = new Insets(0, 0, 5, 5);
723 linkConstraints2.gridx = 0;
724 linkConstraints2.gridy = 1;
725 linkConstraints2.weightx = 1.0;
726 linkConstraints2.weighty = 1.0;
727 linkConstraints2.fill = GridBagConstraints.BOTH;
728 linkTab.add(linkScrollPane, linkConstraints2);
730 // Filter box and buttons goes at bottom left, resizing resizes the text box
731 JPanel filterPanel = initLinkTabFilterPanel();
732 GridBagConstraints linkConstraints3 = new GridBagConstraints();
733 linkConstraints3.insets = new Insets(0, 0, 0, 5);
734 linkConstraints3.gridx = 0;
735 linkConstraints3.gridy = 2;
736 linkConstraints3.weightx = 1.0;
737 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
738 linkTab.add(filterPanel, linkConstraints3);
743 private JPanel initLinkTabFilterPanel()
745 // Filter textbox and reset button
746 JLabel filterLabel = new JLabel(
747 MessageManager.getString("label.filter"));
748 filterLabel.setFont(LABEL_FONT);
749 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
750 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
752 filterTB.setFont(LABEL_FONT);
753 filterTB.setText("");
755 doReset.setText(MessageManager.getString("action.showall"));
756 userOnly.setText(MessageManager.getString("action.customfilter"));
758 // Panel for filter functionality
759 JPanel filterPanel = new JPanel(new GridBagLayout());
760 filterPanel.setBorder(new TitledBorder("Filter"));
761 GridBagConstraints gbc = new GridBagConstraints();
764 gbc.fill = GridBagConstraints.NONE;
765 gbc.anchor = GridBagConstraints.WEST;
767 filterPanel.add(filterLabel, gbc);
769 GridBagConstraints gbc1 = new GridBagConstraints();
772 gbc1.fill = GridBagConstraints.HORIZONTAL;
773 gbc1.anchor = GridBagConstraints.WEST;
775 filterPanel.add(filterTB, gbc1);
777 GridBagConstraints gbc2 = new GridBagConstraints();
779 gbc2.fill = GridBagConstraints.NONE;
780 gbc2.anchor = GridBagConstraints.WEST;
781 filterPanel.add(doReset, gbc2);
783 GridBagConstraints gbc3 = new GridBagConstraints();
785 gbc3.fill = GridBagConstraints.NONE;
786 gbc3.anchor = GridBagConstraints.WEST;
787 filterPanel.add(userOnly, gbc3);
792 private JPanel initLinkTabUrlButtons()
794 // Buttons for new / edit / delete Url links
795 JButton newLink = new JButton();
796 newLink.setText(MessageManager.getString("action.new"));
798 editLink.setText(MessageManager.getString("action.edit"));
800 deleteLink.setText(MessageManager.getString("action.delete"));
802 // no current selection, so initially disable delete/edit buttons
803 editLink.setEnabled(false);
804 deleteLink.setEnabled(false);
806 newLink.addActionListener(new java.awt.event.ActionListener()
809 public void actionPerformed(ActionEvent e)
811 newLink_actionPerformed(e);
815 editLink.setText(MessageManager.getString("action.edit"));
816 editLink.addActionListener(new java.awt.event.ActionListener()
819 public void actionPerformed(ActionEvent e)
821 editLink_actionPerformed(e);
825 deleteLink.setText(MessageManager.getString("action.delete"));
826 deleteLink.addActionListener(new java.awt.event.ActionListener()
829 public void actionPerformed(ActionEvent e)
831 deleteLink_actionPerformed(e);
835 JPanel buttonPanel = new JPanel(new GridBagLayout());
836 buttonPanel.setBorder(new TitledBorder("Edit links"));
837 GridBagConstraints gbc = new GridBagConstraints();
840 gbc.fill = GridBagConstraints.NONE;
841 buttonPanel.add(newLink, gbc);
843 GridBagConstraints gbc1 = new GridBagConstraints();
846 gbc1.fill = GridBagConstraints.NONE;
847 buttonPanel.add(editLink, gbc1);
849 GridBagConstraints gbc2 = new GridBagConstraints();
852 gbc2.fill = GridBagConstraints.NONE;
853 buttonPanel.add(deleteLink, gbc2);
855 GridBagConstraints gbc3 = new GridBagConstraints();
858 gbc3.fill = GridBagConstraints.HORIZONTAL;
860 JPanel spacePanel = new JPanel();
861 spacePanel.setBorder(null);
862 buttonPanel.add(spacePanel, gbc3);
868 * Initialises the proxy server panel in the Connections tab
870 * @return the proxy server panel
872 private JPanel initConnTabProxyPanel()
874 // Label for server text box
875 serverLabel.setText(MessageManager.getString("label.address"));
876 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
877 serverLabel.setFont(LABEL_FONT);
879 // Proxy server and port text boxes
880 proxyServerTB.setFont(LABEL_FONT);
881 proxyPortTB.setFont(LABEL_FONT);
883 // Label for Port text box
884 portLabel.setFont(LABEL_FONT);
885 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
886 portLabel.setText(MessageManager.getString("label.port"));
888 // Use proxy server checkbox
889 useProxy.setFont(LABEL_FONT);
890 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
891 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
892 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
893 useProxy.addActionListener(new ActionListener()
896 public void actionPerformed(ActionEvent e)
898 useProxy_actionPerformed();
902 // Make proxy server panel
903 JPanel proxyPanel = new JPanel();
904 TitledBorder titledBorder1 = new TitledBorder(
905 MessageManager.getString("label.proxy_server"));
906 proxyPanel.setBorder(titledBorder1);
907 proxyPanel.setLayout(new GridBagLayout());
908 proxyPanel.add(serverLabel,
909 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
910 GridBagConstraints.WEST, GridBagConstraints.NONE,
911 new Insets(0, 2, 2, 0), 5, 0));
912 proxyPanel.add(portLabel,
913 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
914 GridBagConstraints.WEST, GridBagConstraints.NONE,
915 new Insets(0, 0, 2, 0), 11, 0));
916 proxyPanel.add(useProxy,
917 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
918 GridBagConstraints.WEST, GridBagConstraints.NONE,
919 new Insets(0, 2, 5, 185), 2, -4));
920 proxyPanel.add(proxyPortTB,
921 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
922 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
923 new Insets(0, 2, 2, 2), 54, 1));
924 proxyPanel.add(proxyServerTB,
925 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
926 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
927 new Insets(0, 2, 2, 0), 263, 1));
933 * Initialises the checkboxes in the Connections tab
935 private void initConnTabCheckboxes()
937 // Usage stats checkbox label
939 MessageManager.getString("label.send_usage_statistics"));
940 usagestats.setFont(LABEL_FONT);
941 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
942 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
944 // Questionnaire checkbox label
945 questionnaire.setText(
946 MessageManager.getString("label.check_for_questionnaires"));
947 questionnaire.setFont(LABEL_FONT);
948 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
949 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
951 // Check for latest version checkbox label
952 versioncheck.setText(
953 MessageManager.getString("label.check_for_latest_version"));
954 versioncheck.setFont(LABEL_FONT);
955 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
956 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
960 * Initialises the parent panel which contains the tabbed sections.
964 private JPanel initOkCancelPanel()
966 JButton ok = new JButton();
967 ok.setText(MessageManager.getString("action.ok"));
968 ok.addActionListener(new ActionListener()
971 public void actionPerformed(ActionEvent e)
973 ok_actionPerformed(e);
976 JButton cancel = new JButton();
977 cancel.setText(MessageManager.getString("action.cancel"));
978 cancel.addActionListener(new ActionListener()
981 public void actionPerformed(ActionEvent e)
983 cancel_actionPerformed(e);
986 JPanel okCancelPanel = new JPanel();
987 okCancelPanel.add(ok);
988 okCancelPanel.add(cancel);
989 return okCancelPanel;
993 * Initialises the Colours tabbed panel.
997 private JPanel initColoursTab()
999 JPanel coloursTab = new JPanel();
1000 coloursTab.setBorder(new TitledBorder(
1001 MessageManager.getString("action.open_new_alignment")));
1002 coloursTab.setLayout(new FlowLayout());
1003 JLabel mincolourLabel = new JLabel();
1004 mincolourLabel.setFont(LABEL_FONT);
1005 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1006 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1007 minColour.setFont(LABEL_FONT);
1008 minColour.setBorder(BorderFactory.createEtchedBorder());
1009 minColour.setPreferredSize(new Dimension(40, 20));
1010 minColour.addMouseListener(new MouseAdapter()
1013 public void mousePressed(MouseEvent e)
1015 minColour_actionPerformed(minColour);
1018 JLabel maxcolourLabel = new JLabel();
1019 maxcolourLabel.setFont(LABEL_FONT);
1020 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1021 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1022 maxColour.setFont(LABEL_FONT);
1023 maxColour.setBorder(BorderFactory.createEtchedBorder());
1024 maxColour.setPreferredSize(new Dimension(40, 20));
1025 maxColour.addMouseListener(new MouseAdapter()
1028 public void mousePressed(MouseEvent e)
1030 maxColour_actionPerformed(maxColour);
1034 protColour.setFont(LABEL_FONT);
1035 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1036 JLabel protColourLabel = new JLabel();
1037 protColourLabel.setFont(LABEL_FONT);
1038 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1039 protColourLabel.setText(
1040 MessageManager.getString("label.prot_alignment_colour") + " ");
1041 JvSwingUtils.addtoLayout(coloursTab,
1043 .getString("label.default_colour_scheme_for_alignment"),
1044 protColourLabel, protColour);
1046 nucColour.setFont(LABEL_FONT);
1047 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1048 JLabel nucColourLabel = new JLabel();
1049 nucColourLabel.setFont(LABEL_FONT);
1050 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1051 nucColourLabel.setText(
1052 MessageManager.getString("label.nuc_alignment_colour") + " ");
1053 JvSwingUtils.addtoLayout(coloursTab,
1055 .getString("label.default_colour_scheme_for_alignment"),
1056 nucColourLabel, nucColour);
1058 JPanel annotationShding = new JPanel();
1059 annotationShding.setBorder(new TitledBorder(
1060 MessageManager.getString("label.annotation_shading_default")));
1061 annotationShding.setLayout(new GridLayout(1, 2));
1062 JvSwingUtils.addtoLayout(annotationShding,
1063 MessageManager.getString(
1064 "label.default_minimum_colour_annotation_shading"),
1065 mincolourLabel, minColour);
1066 JvSwingUtils.addtoLayout(annotationShding,
1067 MessageManager.getString(
1068 "label.default_maximum_colour_annotation_shading"),
1069 maxcolourLabel, maxColour);
1070 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1075 * Initialises the Overview tabbed panel.
1079 private JPanel initOverviewTab()
1081 JPanel overviewPanel = new JPanel();
1082 overviewPanel.setBorder(new TitledBorder(
1083 MessageManager.getString("label.overview_settings")));
1085 gapColour.setFont(LABEL_FONT);
1086 // fixing the border colours stops apparent colour bleed from the panel
1087 gapColour.setBorder(
1088 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1089 gapColour.setPreferredSize(new Dimension(40, 20));
1090 gapColour.addMouseListener(new MouseAdapter()
1093 public void mousePressed(MouseEvent e)
1095 gapColour_actionPerformed(gapColour);
1099 hiddenColour.setFont(LABEL_FONT);
1100 // fixing the border colours stops apparent colour bleed from the panel
1101 hiddenColour.setBorder(
1102 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1103 hiddenColour.setPreferredSize(new Dimension(40, 20));
1104 hiddenColour.addMouseListener(new MouseAdapter()
1107 public void mousePressed(MouseEvent e)
1109 hiddenColour_actionPerformed(hiddenColour);
1113 useLegacyGap = new JCheckBox(
1114 MessageManager.getString("label.ov_legacy_gap"));
1115 useLegacyGap.setFont(LABEL_FONT);
1116 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1117 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1118 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1119 gapLabel.setFont(LABEL_FONT);
1120 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1121 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1122 showHiddenAtStart = new JCheckBox(
1123 MessageManager.getString("label.ov_show_hide_default"));
1124 showHiddenAtStart.setFont(LABEL_FONT);
1125 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1126 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1127 JLabel hiddenLabel = new JLabel(
1128 MessageManager.getString("label.hidden_colour"));
1129 hiddenLabel.setFont(LABEL_FONT);
1130 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1131 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1133 useLegacyGap.addActionListener(new ActionListener()
1136 public void actionPerformed(ActionEvent e)
1138 useLegacyGaps_actionPerformed(e);
1142 overviewPanel.setLayout(new GridBagLayout());
1143 GridBagConstraints c1 = new GridBagConstraints();
1145 c1.fill = GridBagConstraints.HORIZONTAL;
1150 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1151 overviewPanel.add(useLegacyGap, c1);
1153 GridBagConstraints c2 = new GridBagConstraints();
1154 c2.fill = GridBagConstraints.HORIZONTAL;
1157 c2.insets = new Insets(0, 15, 0, 10);
1158 overviewPanel.add(gapLabel, c2);
1160 GridBagConstraints c3 = new GridBagConstraints();
1161 c3.fill = GridBagConstraints.HORIZONTAL;
1164 c3.insets = new Insets(0, 0, 0, 15);
1165 overviewPanel.add(gapColour, c3);
1167 GridBagConstraints c4 = new GridBagConstraints();
1168 c4.fill = GridBagConstraints.HORIZONTAL;
1172 overviewPanel.add(showHiddenAtStart, c4);
1174 GridBagConstraints c5 = new GridBagConstraints();
1175 c5.fill = GridBagConstraints.HORIZONTAL;
1178 c5.insets = new Insets(0, 15, 0, 10);
1179 overviewPanel.add(hiddenLabel, c5);
1181 GridBagConstraints c6 = new GridBagConstraints();
1182 c6.fill = GridBagConstraints.HORIZONTAL;
1185 c6.insets = new Insets(0, 0, 0, 15);
1186 overviewPanel.add(hiddenColour, c6);
1188 JButton resetButton = new JButton(
1189 MessageManager.getString("label.reset_to_defaults"));
1191 resetButton.addActionListener(new ActionListener()
1194 public void actionPerformed(ActionEvent e)
1196 resetOvDefaults_actionPerformed(e);
1200 GridBagConstraints c7 = new GridBagConstraints();
1201 c7.fill = GridBagConstraints.NONE;
1204 c7.insets = new Insets(10, 0, 0, 0);
1205 c7.anchor = GridBagConstraints.WEST;
1206 overviewPanel.add(resetButton, c7);
1208 // Add padding so the panel doesn't look ridiculous
1209 JPanel spacePanel = new JPanel();
1210 overviewPanel.add(spacePanel,
1211 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1212 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1213 new Insets(0, 0, 0, 5), 0, 0));
1215 return overviewPanel;
1219 * Initialises the Structure tabbed panel.
1223 private JPanel initStructureTab()
1225 structureTab = new JPanel();
1227 structureTab.setBorder(new TitledBorder(
1228 MessageManager.getString("label.structure_options")));
1229 structureTab.setLayout(null);
1230 final int width = 400;
1231 final int height = 22;
1232 final int lineSpacing = 25;
1235 structFromPdb.setFont(LABEL_FONT);
1237 .setText(MessageManager.getString("label.struct_from_pdb"));
1238 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1239 structFromPdb.addActionListener(new ActionListener()
1242 public void actionPerformed(ActionEvent e)
1244 boolean selected = structFromPdb.isSelected();
1245 // enable other options only when the first is checked
1246 useRnaView.setEnabled(selected);
1247 addSecondaryStructure.setEnabled(selected);
1248 addTempFactor.setEnabled(selected);
1251 structureTab.add(structFromPdb);
1253 // indent checkboxes that are conditional on the first one
1254 ypos += lineSpacing;
1255 useRnaView.setFont(LABEL_FONT);
1256 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1257 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1258 structureTab.add(useRnaView);
1260 ypos += lineSpacing;
1261 addSecondaryStructure.setFont(LABEL_FONT);
1262 addSecondaryStructure
1263 .setText(MessageManager.getString("label.autoadd_secstr"));
1264 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1265 structureTab.add(addSecondaryStructure);
1267 ypos += lineSpacing;
1268 addTempFactor.setFont(LABEL_FONT);
1269 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1270 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1271 structureTab.add(addTempFactor);
1273 ypos += lineSpacing;
1274 JLabel viewerLabel = new JLabel();
1275 viewerLabel.setFont(LABEL_FONT);
1276 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1277 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1278 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1279 structureTab.add(viewerLabel);
1281 structViewer.setFont(LABEL_FONT);
1282 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1283 structViewer.addItem(ViewerType.JMOL.name());
1284 structViewer.addItem(ViewerType.CHIMERA.name());
1285 structViewer.addActionListener(new ActionListener()
1289 public void actionPerformed(ActionEvent e)
1291 structureViewer_actionPerformed(
1292 (String) structViewer.getSelectedItem());
1295 structureTab.add(structViewer);
1298 ypos += lineSpacing;
1299 JLabel dimLabel = new JLabel();
1300 dimLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1301 dimLabel.setHorizontalAlignment(SwingConstants.LEFT);
1303 MessageManager.getString("label.structure_dimensions"));
1304 dimLabel.setBounds(new Rectangle(10, ypos, 140, height));
1305 structureTab.add(dimLabel);
1307 structureDimensions.setFont(LABEL_FONT);
1308 structureDimensions.setBounds(new Rectangle(160, ypos, 120, height));
1309 structureTab.add(structureDimensions);
1311 ypos += lineSpacing;
1312 JLabel pathLabel = new JLabel();
1313 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1314 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1315 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1316 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1317 structureTab.add(pathLabel);
1319 chimeraPath.setFont(LABEL_FONT);
1320 chimeraPath.setText("");
1321 final String tooltip = JvSwingUtils.wrapTooltip(true,
1322 MessageManager.getString("label.chimera_path_tip"));
1323 chimeraPath.setToolTipText(tooltip);
1324 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1325 chimeraPath.addMouseListener(new MouseAdapter()
1328 public void mouseClicked(MouseEvent e)
1330 if (e.getClickCount() == 2)
1332 String chosen = openFileChooser();
1335 chimeraPath.setText(chosen);
1340 structureTab.add(chimeraPath);
1342 ypos += lineSpacing;
1343 nwMapping.setFont(LABEL_FONT);
1344 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1345 siftsMapping.setFont(LABEL_FONT);
1346 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1347 mappingMethod.add(nwMapping);
1348 mappingMethod.add(siftsMapping);
1349 JPanel mappingPanel = new JPanel();
1350 mappingPanel.setFont(LABEL_FONT);
1351 TitledBorder mmTitledBorder = new TitledBorder(
1352 MessageManager.getString("label.mapping_method"));
1353 mmTitledBorder.setTitleFont(LABEL_FONT);
1354 mappingPanel.setBorder(mmTitledBorder);
1355 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1356 // GridLayout mappingLayout = new GridLayout();
1357 mappingPanel.setLayout(new GridLayout());
1358 mappingPanel.add(nwMapping);
1359 mappingPanel.add(siftsMapping);
1360 structureTab.add(mappingPanel);
1362 ypos += lineSpacing;
1363 ypos += lineSpacing;
1364 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1365 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1366 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1367 structureTab.add(docFieldPref);
1370 * hide Chimera options in JalviewJS
1372 if (Platform.isJS())
1374 pathLabel.setVisible(false);
1375 chimeraPath.setVisible(false);
1376 viewerLabel.setVisible(false);
1377 structViewer.setVisible(false);
1380 return structureTab;
1384 * Action on choosing a structure viewer from combobox options.
1386 * @param selectedItem
1388 protected void structureViewer_actionPerformed(String selectedItem)
1393 * Show a dialog for the user to choose a file. Returns the chosen path, or
1398 protected String openFileChooser()
1400 String choice = null;
1401 JFileChooser chooser = new JFileChooser();
1403 // chooser.setFileView(new JalviewFileView());
1404 chooser.setDialogTitle(
1405 MessageManager.getString("label.open_local_file"));
1406 chooser.setToolTipText(MessageManager.getString("action.open"));
1408 int value = chooser.showOpenDialog(this);
1410 if (value == JFileChooser.APPROVE_OPTION)
1412 choice = chooser.getSelectedFile().getPath();
1418 * Validate the structure tab preferences; if invalid, set focus on this tab.
1422 protected boolean validateStructure(FocusEvent e)
1424 if (!validateStructure())
1426 e.getComponent().requestFocusInWindow();
1432 protected boolean validateStructure()
1438 * Initialises the Visual tabbed panel.
1442 private JPanel initVisualTab()
1444 JPanel visualTab = new JPanel();
1445 visualTab.setBorder(new TitledBorder(
1446 MessageManager.getString("action.open_new_alignment")));
1447 visualTab.setLayout(null);
1448 fullScreen.setFont(LABEL_FONT);
1449 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1450 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1451 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1452 quality.setEnabled(false);
1453 quality.setFont(LABEL_FONT);
1454 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1455 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1456 quality.setSelected(true);
1457 quality.setText(MessageManager.getString("label.quality"));
1458 conservation.setEnabled(false);
1459 conservation.setFont(LABEL_FONT);
1460 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1461 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1462 conservation.setSelected(true);
1463 conservation.setText(MessageManager.getString("label.conservation"));
1464 identity.setEnabled(false);
1465 identity.setFont(LABEL_FONT);
1466 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1467 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1468 identity.setSelected(true);
1469 identity.setText(MessageManager.getString("label.consensus"));
1470 showOccupancy.setFont(LABEL_FONT);
1471 showOccupancy.setEnabled(false);
1472 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1473 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1474 showOccupancy.setSelected(true);
1475 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1477 JLabel showGroupbits = new JLabel();
1478 showGroupbits.setFont(LABEL_FONT);
1479 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1480 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1482 .setText(MessageManager.getString("action.show_group") + ":");
1483 JLabel showConsensbits = new JLabel();
1484 showConsensbits.setFont(LABEL_FONT);
1485 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1486 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1488 .setText(MessageManager.getString("label.consensus") + ":");
1489 showConsensHistogram.setEnabled(false);
1490 showConsensHistogram.setFont(LABEL_FONT);
1491 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1492 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1493 showConsensHistogram.setSelected(true);
1494 showConsensHistogram
1495 .setText(MessageManager.getString("label.histogram"));
1496 showConsensLogo.setEnabled(false);
1497 showConsensLogo.setFont(LABEL_FONT);
1498 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1499 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1500 showConsensLogo.setSelected(true);
1501 showConsensLogo.setText(MessageManager.getString("label.logo"));
1502 showGroupConsensus.setEnabled(false);
1503 showGroupConsensus.setFont(LABEL_FONT);
1504 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1505 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1506 showGroupConsensus.setSelected(true);
1507 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1508 showGroupConservation.setEnabled(false);
1509 showGroupConservation.setFont(LABEL_FONT);
1510 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1511 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1512 showGroupConservation.setSelected(true);
1513 showGroupConservation
1514 .setText(MessageManager.getString("label.conservation"));
1515 showNpTooltip.setEnabled(true);
1516 showNpTooltip.setFont(LABEL_FONT);
1517 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1518 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1519 showNpTooltip.setSelected(true);
1520 showNpTooltip.setText(
1521 MessageManager.getString("label.non_positional_features"));
1522 showDbRefTooltip.setEnabled(true);
1523 showDbRefTooltip.setFont(LABEL_FONT);
1524 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1525 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1526 showDbRefTooltip.setSelected(true);
1528 .setText(MessageManager.getString("label.database_references"));
1529 annotations.setFont(LABEL_FONT);
1530 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1531 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1532 annotations.setSelected(true);
1533 annotations.setText(MessageManager.getString("label.show_annotations"));
1534 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1535 annotations.addActionListener(new ActionListener()
1538 public void actionPerformed(ActionEvent e)
1540 annotations_actionPerformed(e);
1543 identity.addActionListener(new ActionListener()
1546 public void actionPerformed(ActionEvent e)
1548 annotations_actionPerformed(e);
1551 showGroupConsensus.addActionListener(new ActionListener()
1554 public void actionPerformed(ActionEvent e)
1556 annotations_actionPerformed(e);
1559 showUnconserved.setFont(LABEL_FONT);
1560 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1561 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1562 showUnconserved.setSelected(true);
1564 .setText(MessageManager.getString("action.show_unconserved"));
1565 showUnconserved.addActionListener(new ActionListener()
1568 public void actionPerformed(ActionEvent e)
1570 showunconserved_actionPerformed(e);
1574 // TODO these are not yet added to / action from Preferences
1575 // JCheckBox shareSelections = new JCheckBox();
1576 // shareSelections.setFont(verdana11);
1577 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1578 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1579 // shareSelections.setSelected(true);
1580 // shareSelections.setText(MessageManager
1581 // .getString("label.share_selection_across_views"));
1582 // JCheckBox followHighlight = new JCheckBox();
1583 // followHighlight.setFont(verdana11);
1584 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1585 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1586 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1587 // followHighlight.setSelected(true);
1588 // followHighlight.setText(MessageManager
1589 // .getString("label.scroll_highlighted_regions"));
1591 seqLimit.setFont(LABEL_FONT);
1592 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1593 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1594 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1595 smoothFont.setFont(LABEL_FONT);
1596 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1597 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1598 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1599 scaleProteinToCdna.setFont(LABEL_FONT);
1600 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1601 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1602 scaleProteinToCdna.setText(
1603 MessageManager.getString("label.scale_protein_to_cdna"));
1604 scaleProteinToCdna.setToolTipText(
1605 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1606 JLabel gapLabel = new JLabel();
1607 gapLabel.setFont(LABEL_FONT);
1608 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1609 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1610 JLabel fontLabel = new JLabel();
1611 fontLabel.setFont(LABEL_FONT);
1612 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1613 fontLabel.setText(MessageManager.getString("label.font"));
1614 fontSizeCB.setFont(LABEL_FONT);
1615 fontSizeCB.setBounds(new Rectangle(320, 115, 65, 23)); // BH 2019.09.24 y
1616 // added 3 pixels for
1618 fontStyleCB.setFont(LABEL_FONT);
1619 fontStyleCB.setBounds(new Rectangle(382, 115, 80, 23)); // BH 2019.09.24 y
1622 fontNameCB.setFont(LABEL_FONT);
1623 fontNameCB.setBounds(new Rectangle(172, 115, 147, 23)); // BH 2019.09.24 y
1626 gapSymbolCB.setFont(LABEL_FONT);
1627 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1628 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1629 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1630 gapSymbolCB.setRenderer(dlcr);
1632 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1633 startupCheckbox.setFont(LABEL_FONT);
1634 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1635 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1636 startupCheckbox.setSelected(true);
1637 startupFileTextfield.setFont(LABEL_FONT);
1638 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1639 final String tooltip = JvSwingUtils.wrapTooltip(true,
1640 MessageManager.getString("label.double_click_to_browse"));
1641 startupFileTextfield.setToolTipText(tooltip);
1642 startupFileTextfield.addMouseListener(new MouseAdapter()
1645 public void mouseClicked(MouseEvent e)
1647 if (e.getClickCount() > 1)
1649 startupFileTextfield_mouseClicked();
1654 sortby.setFont(LABEL_FONT);
1655 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1656 JLabel sortLabel = new JLabel();
1657 sortLabel.setFont(LABEL_FONT);
1658 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1659 sortLabel.setText(MessageManager.getString("label.sort_by"));
1660 sortAnnBy.setFont(LABEL_FONT);
1661 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1662 JLabel sortAnnLabel = new JLabel();
1663 sortAnnLabel.setFont(LABEL_FONT);
1664 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1665 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1666 sortAutocalc.setFont(LABEL_FONT);
1667 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1669 JPanel annsettingsPanel = new JPanel();
1670 annsettingsPanel.setBounds(new Rectangle(173, 13, 330, 100)); // BH
1682 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1683 annsettingsPanel.setBorder(new EtchedBorder());
1684 visualTab.add(annsettingsPanel);
1685 Border jb = new EmptyBorder(1, 1, 4, 5);
1686 annotations.setBorder(jb);
1687 showOccupancy.setBorder(jb);
1688 quality.setBorder(jb);
1689 conservation.setBorder(jb);
1690 identity.setBorder(jb);
1691 showConsensbits.setBorder(jb);
1692 showGroupbits.setBorder(jb);
1693 showGroupConsensus.setBorder(jb);
1694 showGroupConservation.setBorder(jb);
1695 showConsensHistogram.setBorder(jb);
1696 showConsensLogo.setBorder(jb);
1698 JPanel autoAnnotSettings = new JPanel();
1699 annsettingsPanel.add(autoAnnotSettings);
1700 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1701 autoAnnotSettings.add(annotations);
1702 autoAnnotSettings.add(quality);
1703 // second row of autoannotation box
1704 autoAnnotSettings = new JPanel();
1705 annsettingsPanel.add(autoAnnotSettings);
1707 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1708 autoAnnotSettings.add(conservation);
1709 autoAnnotSettings.add(identity);
1710 autoAnnotSettings.add(showOccupancy);
1711 autoAnnotSettings.add(showGroupbits);
1712 autoAnnotSettings.add(showGroupConservation);
1713 autoAnnotSettings.add(showGroupConsensus);
1714 autoAnnotSettings.add(showConsensbits);
1715 autoAnnotSettings.add(showConsensHistogram);
1716 autoAnnotSettings.add(showConsensLogo);
1718 JPanel tooltipSettings = new JPanel();
1719 tooltipSettings.setBorder(new TitledBorder(
1720 MessageManager.getString("label.sequence_id_tooltip")));
1721 tooltipSettings.setBounds(173, 140, 220, 62);
1722 tooltipSettings.setLayout(new GridLayout(2, 1));
1723 tooltipSettings.add(showDbRefTooltip);
1724 tooltipSettings.add(showNpTooltip);
1725 visualTab.add(tooltipSettings);
1727 wrap.setFont(LABEL_FONT);
1728 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1729 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1730 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1731 rightAlign.setFont(LABEL_FONT);
1732 rightAlign.setForeground(Color.black);
1733 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1734 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1735 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1736 idItalics.setFont(LABEL_FONT_ITALIC);
1737 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1738 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1740 MessageManager.getString("label.sequence_name_italics"));
1741 openoverv.setFont(LABEL_FONT);
1742 openoverv.setActionCommand(
1743 MessageManager.getString("label.open_overview"));
1744 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1745 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1746 openoverv.setText(MessageManager.getString("label.open_overview"));
1747 JPanel jPanel2 = new JPanel();
1748 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1749 jPanel2.setLayout(new GridLayout(14, 1));
1750 jPanel2.add(fullScreen);
1751 jPanel2.add(openoverv);
1752 jPanel2.add(seqLimit);
1753 jPanel2.add(rightAlign);
1754 jPanel2.add(fontLabel);
1755 jPanel2.add(showUnconserved);
1756 jPanel2.add(idItalics);
1757 jPanel2.add(smoothFont);
1758 jPanel2.add(scaleProteinToCdna);
1759 jPanel2.add(gapLabel);
1761 jPanel2.add(sortLabel);
1762 jPanel2.add(sortAnnLabel);
1763 jPanel2.add(startupCheckbox);
1764 visualTab.add(jPanel2);
1765 visualTab.add(startupFileTextfield);
1766 visualTab.add(sortby);
1767 visualTab.add(sortAnnBy);
1768 visualTab.add(sortAutocalc);
1769 visualTab.add(gapSymbolCB);
1770 visualTab.add(fontNameCB);
1771 visualTab.add(fontSizeCB);
1772 visualTab.add(fontStyleCB);
1774 if (Platform.isJS())
1776 startupCheckbox.setVisible(false);
1777 startupFileTextfield.setVisible(false);
1784 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1787 protected void loadLastSavedBackupsOptions()
1790 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1791 setComboIntStringKey(backupfilesPresetsCombo,
1792 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1793 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1794 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1796 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1797 suffixReverse.setSelected(
1798 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1800 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1801 backupfilesRollMaxSpinner
1802 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1803 backupfilesConfirmDelete.setSelected(
1804 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1806 backupsOptionsSetEnabled();
1807 updateBackupFilesExampleLabel();
1810 protected boolean warnAboutSuffixReverseChange()
1812 boolean savedSuffixReverse = Cache.getDefault(BackupFiles.REVERSE_ORDER,
1814 int savedSuffixDigits = Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3);
1815 String savedSuffixTemplate = Cache.getDefault(BackupFiles.SUFFIX,
1816 ".bak" + BackupFiles.NUM_PLACEHOLDER);
1818 boolean nowSuffixReverse = suffixReverse.isSelected();
1819 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1820 String nowSuffixTemplate = suffixTemplate.getText();
1821 return nowSuffixReverse != savedSuffixReverse
1822 && nowSuffixDigits == savedSuffixDigits
1823 && nowSuffixTemplate != null
1824 && nowSuffixTemplate.equals(savedSuffixTemplate);
1828 * Initialises the Backups tabbed panel.
1832 private JPanel initBackupsTab()
1834 JPanel backupsTab = new JPanel();
1835 backupsTab.setBorder(new TitledBorder(
1836 MessageManager.getString("label.backup_files")));
1837 backupsTab.setLayout(new GridBagLayout());
1839 GridBagConstraints gbc = new GridBagConstraints();
1842 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1843 gbc.fill = GridBagConstraints.NONE;
1845 initBackupsTabPresetsPanel();
1846 initBackupsTabSuffixPanel();
1847 initBackupsTabKeepFilesPanel();
1848 initBackupsTabFilenameExamplesPanel();
1850 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1852 .setText(MessageManager.getString("label.enable_backupfiles"));
1853 enableBackupFiles.addActionListener(new ActionListener()
1856 public void actionPerformed(ActionEvent e)
1858 // enable other options only when the first is checked
1859 backupsOptionsSetEnabled();
1864 // enable checkbox 1 col
1868 gbc.gridy = 0; // row 0
1869 backupsTab.add(enableBackupFiles, gbc);
1871 // summary of scheme box (over two rows)
1875 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1876 gbc.fill = GridBagConstraints.BOTH;
1877 backupsTab.add(exampleFilesPanel, gbc);
1879 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1880 gbc.fill = GridBagConstraints.NONE;
1882 // fill empty space on right
1885 backupsTab.add(new JPanel(), gbc);
1890 gbc.gridy++; // row 1
1891 backupsTab.add(presetsPanel, gbc);
1893 // gbc.anchor = GridBagConstraints.NORTHWEST;
1894 // now using whole row
1899 gbc.gridy++; // row 2
1900 backupsTab.add(keepfilesPanel, gbc);
1902 // filename strategy box
1903 gbc.gridy++; // row 3
1904 backupsTab.add(suffixPanel, gbc);
1907 gbc.gridy++; // row 4
1909 backupsTab.add(new JPanel(), gbc);
1911 backupsOptionsSetEnabled();
1915 protected static final int BACKUPFILESSCHEMECUSTOMISE = 0;
1917 private static final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1918 new IntKeyStringValueEntry(1,
1919 MessageManager.getString("label.default")),
1920 new IntKeyStringValueEntry(2,
1921 MessageManager.getString("label.single_file")),
1922 new IntKeyStringValueEntry(3,
1923 MessageManager.getString("label.keep_all_versions")),
1924 new IntKeyStringValueEntry(4,
1925 MessageManager.getString("label.rolled_backups")),
1927 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1928 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1929 MessageManager.getString("label.customise")) };
1931 private static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1936 private static final long serialVersionUID = 125L;
1939 put(1, new BackupFilesPresetEntry(
1940 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1942 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1943 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1944 3, false, true, 10, true));
1945 put(4, new BackupFilesPresetEntry(
1946 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1951 private JPanel initBackupsTabPresetsPanel()
1954 String title = MessageManager.getString("label.schemes");
1955 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1956 // TitledBorder tb = new TitledBorder(title);
1957 // tb.setTitleFont(LABEL_FONT);
1958 // presetsPanel.setBorder(tb);
1960 presetsPanel.setLayout(new GridBagLayout());
1962 GridBagConstraints gbc = new GridBagConstraints();
1965 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1966 gbc.fill = GridBagConstraints.NONE;
1973 presetsPanel.add(new JLabel(title + ":"), gbc);
1975 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1977 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1980 // put "Previously saved scheme" item in italics (it's not really
1981 // selectable, as such -- it deselects itself when selected) and
1982 // "Customise" in bold
1983 backupfilesPresetsCombo
1984 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1985 backupfilesPresetsCombo.addActionListener(new ActionListener()
1988 public void actionPerformed(ActionEvent e)
1990 backupsTabUpdatePresets();
1994 // dropdown list of preset schemes
1996 presetsPanel.add(backupfilesPresetsCombo, gbc);
1998 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1999 revertButton.addActionListener(new ActionListener()
2002 public void actionPerformed(ActionEvent e)
2004 loadLastSavedBackupsOptions();
2008 revertButton.setFont(LABEL_FONT);
2010 // "Cancel changes" button (aligned with combo box above)
2013 presetsPanel.add(revertButton, gbc);
2015 return presetsPanel;
2018 private JPanel initBackupsTabFilenameExamplesPanel()
2020 String title = MessageManager
2021 .getString("label.summary_of_backups_scheme");
2022 TitledBorder tb = new TitledBorder(title);
2023 exampleFilesPanel.setBorder(tb);
2024 exampleFilesPanel.setLayout(new GridBagLayout());
2027 backupfilesExampleLabel.setEditable(false);
2028 backupfilesExampleLabel
2029 .setBackground(exampleFilesPanel.getBackground());
2031 updateBackupFilesExampleLabel();
2033 GridBagConstraints gbc = new GridBagConstraints();
2036 gbc.fill = GridBagConstraints.NONE;
2037 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2039 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2040 return exampleFilesPanel;
2043 protected void backupsTabUpdatePresets()
2045 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2047 int key = entry.getKey();
2048 String value = entry.getValue();
2050 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
2051 if (key != BACKUPFILESSCHEMECUSTOMISE)
2053 if (backupfilesPresetEntriesValues.containsKey(key))
2055 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
2059 System.out.println("Preset '" + value + "' not implemented");
2063 backupfilesCustomOptionsSetEnabled();
2064 updateBackupFilesExampleLabel();
2067 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
2069 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
2070 return e != null ? e.getKey() : 0;
2073 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
2076 for (int i = 0; i < c.getItemCount(); i++)
2078 IntKeyStringValueEntry e = c.getItemAt(i);
2079 if (e.getKey() == key)
2081 c.setSelectedIndex(i);
2085 backupsTabUpdatePresets();
2088 private JPanel initBackupsTabSuffixPanel()
2090 suffixPanel.setBorder(new TitledBorder(
2091 MessageManager.getString("label.backup_filename_strategy")));
2092 suffixPanel.setLayout(new GridBagLayout());
2095 .setText(MessageManager.getString("label.append_to_filename"));
2096 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2097 suffixTemplateLabel.setFont(LABEL_FONT);
2099 final String tooltip = JvSwingUtils.wrapTooltip(true,
2100 MessageManager.getString("label.append_to_filename_tooltip"));
2101 suffixTemplate.setToolTipText(tooltip);
2102 suffixTemplate.addActionListener(new ActionListener()
2105 public void actionPerformed(ActionEvent e)
2107 updateBackupFilesExampleLabel();
2108 backupfilesCustomOptionsSetEnabled();
2112 KeyListener kl = new KeyListener()
2115 public void keyReleased(KeyEvent e)
2117 updateBackupFilesExampleLabel();
2118 backupfilesCustomOptionsSetEnabled();
2122 public void keyPressed(KeyEvent e)
2126 // disable use of ':' or '/' or '\'
2128 public void keyTyped(KeyEvent e)
2130 char c = e.getKeyChar();
2131 if (c == ':' || c == '/' || c == '\\')
2133 // don't process ':' or '/' or '\'
2139 suffixTemplate.addKeyListener(kl);
2143 .setText(MessageManager.getString("label.index_digits"));
2144 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2145 suffixDigitsLabel.setFont(LABEL_FONT);
2148 ChangeListener c = new ChangeListener()
2151 public void stateChanged(ChangeEvent e)
2153 updateBackupFilesExampleLabel();
2157 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2159 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2160 MessageManager.getString("label.increment_index"));
2161 suffixReverse.addActionListener(new ActionListener()
2164 public void actionPerformed(ActionEvent e)
2166 boolean okay = true;
2167 if (warnAboutSuffixReverseChange())
2170 okay = confirmSuffixReverseChange();
2174 updateBackupFilesExampleLabel();
2178 boolean savedSuffixReverse = Cache
2179 .getDefault(BackupFiles.REVERSE_ORDER, false);
2180 suffixReverse.setSelected(savedSuffixReverse);
2185 GridBagConstraints sgbc = new GridBagConstraints();
2187 // first row (template text box)
2188 sgbc.anchor = GridBagConstraints.WEST;
2192 sgbc.gridheight = 1;
2195 sgbc.fill = GridBagConstraints.NONE;
2196 suffixPanel.add(suffixTemplateLabel, sgbc);
2199 sgbc.fill = GridBagConstraints.HORIZONTAL;
2200 suffixPanel.add(suffixTemplate, sgbc);
2202 // second row (number of digits spinner)
2206 sgbc.fill = GridBagConstraints.NONE;
2207 suffixPanel.add(suffixDigitsLabel, sgbc);
2210 sgbc.fill = GridBagConstraints.HORIZONTAL;
2211 suffixPanel.add(suffixDigitsSpinner, sgbc);
2213 // third row (forward order radio selection)
2216 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2217 sgbc.fill = GridBagConstraints.HORIZONTAL;
2218 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2220 // fourth row (reverse order radio selection)
2222 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2226 protected boolean confirmSuffixReverseChange()
2228 boolean ret = false;
2229 String warningMessage = MessageManager
2230 .getString("label.warning_confirm_change_reverse");
2231 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
2233 MessageManager.getString("label.change_increment_decrement"),
2234 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2236 ret = (confirm == JvOptionPane.YES_OPTION);
2240 private JPanel initBackupsTabKeepFilesPanel()
2242 keepfilesPanel.setBorder(
2243 new TitledBorder(MessageManager.getString("label.keep_files")));
2244 keepfilesPanel.setLayout(new GridBagLayout());
2246 backupfilesKeepAll.setLabels(
2247 MessageManager.getString("label.keep_all_backup_files"),
2248 MessageManager.getString(
2249 "label.keep_only_this_number_of_backup_files"));
2250 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2253 public void actionPerformed(ActionEvent e)
2255 updateBackupFilesExampleLabel();
2258 backupfilesKeepAll.addActionListener(new ActionListener()
2261 public void actionPerformed(ActionEvent e)
2263 keepRollMaxOptionsEnabled();
2264 updateBackupFilesExampleLabel();
2268 ChangeListener c = new ChangeListener()
2271 public void stateChanged(ChangeEvent e)
2273 updateBackupFilesExampleLabel();
2277 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2279 backupfilesConfirmDelete.setLabels(
2280 MessageManager.getString("label.always_ask"),
2281 MessageManager.getString("label.auto_delete"));
2282 // update the enabled section
2283 keepRollMaxOptionsEnabled();
2285 GridBagConstraints kgbc = new GridBagConstraints();
2287 // first row (template text box)
2288 kgbc.anchor = GridBagConstraints.WEST;
2291 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2292 kgbc.gridheight = 1;
2295 kgbc.fill = GridBagConstraints.HORIZONTAL;
2296 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2302 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2303 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2306 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2307 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2309 // third row (indented)
2311 kgbc.insets = new Insets(0, 20, 0, 0);
2314 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2315 kgbc.fill = GridBagConstraints.HORIZONTAL;
2318 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2320 // fourth row (indented)
2322 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2325 JPanel jp = new JPanel();
2326 jp.setLayout(new FlowLayout());
2328 .setText(MessageManager
2329 .getString("label.autodelete_old_backup_files"));
2330 oldBackupFilesLabel.setFont(LABEL_FONT);
2331 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2332 jp.add(oldBackupFilesLabel);
2333 jp.add(backupfilesConfirmDelete.getTrueButton());
2334 jp.add(backupfilesConfirmDelete.getFalseButton());
2335 keepfilesPanel.add(jp, kgbc);
2337 return keepfilesPanel;
2340 protected void updateBackupFilesExampleLabel()
2342 int exampleindex = 12;
2343 String base = MessageManager.getString("label.filename") + ".fa";
2344 if (base == null || base.length() == 0)
2346 base = "file_name.fa";
2349 boolean reverse = suffixReverse.isSelected();
2350 boolean keepAll = backupfilesKeepAll.isSelected();
2352 String suffix = suffixTemplate.getText();
2355 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2356 if (suffix == null || suffix.length() == 0)
2358 backupfilesExampleLabel
2359 .setText(MessageManager.getString("label.no_backup_files"));
2360 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2364 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2365 rollMax = rollMax < 1 ? 1 : rollMax;
2367 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2372 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2373 digits = digits < 1 ? 1 : digits;
2375 int lowersurround = 2;
2376 int uppersurround = 0;
2377 StringBuilder exampleSB = new StringBuilder();
2378 boolean firstLine = true;
2383 int max = keepAll ? exampleindex : rollMax;
2384 for (int index = min; index <= max; index++)
2386 if (index == min + lowersurround && index < max - uppersurround - 1)
2388 exampleSB.append("\n...");
2390 else if (index > min + lowersurround && index < max - uppersurround)
2402 exampleSB.append("\n");
2404 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2405 base, suffix, digits));
2408 // no extra text needed
2410 else if (index == min)
2412 String newest = MessageManager.getString("label.braced_newest");
2413 if (newest != null && newest.length() > 0)
2415 exampleSB.append(" " + newest);
2418 else if (index == max)
2420 String oldest = MessageManager.getString("label.braced_oldest");
2421 if (oldest != null && oldest.length() > 0)
2423 exampleSB.append(" " + oldest);
2432 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2433 : exampleindex - rollMax + 1;
2434 int max = exampleindex;
2436 for (int index = min; index <= max; index++)
2439 if (index == min + lowersurround && index < max - uppersurround - 1)
2441 exampleSB.append("\n...");
2443 else if (index > min + lowersurround && index < max - uppersurround)
2455 exampleSB.append("\n");
2457 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2458 base, suffix, digits));
2461 // no extra text needed
2463 else if (index == min)
2465 String oldest = MessageManager.getString("label.braced_oldest");
2466 if (oldest != null && oldest.length() > 0)
2468 exampleSB.append(" " + oldest);
2471 else if (index == max)
2473 String newest = MessageManager.getString("label.braced_newest");
2474 if (newest != null && newest.length() > 0)
2476 exampleSB.append(" " + newest);
2484 backupfilesExampleLabel.setText(exampleSB.toString());
2487 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2488 boolean useExistingVal, ChangeListener c)
2495 i = Integer.parseInt((String) s.getValue());
2496 } catch (Exception e)
2499 "Exception casting the initial value of s.getValue()");
2503 setIntegerSpinner(s, min, max, i, c);
2506 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2509 // integer spinner for number of digits
2514 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2517 s.addChangeListener(c);
2521 protected static int getSpinnerInt(JSpinner s, int def)
2527 i = (Integer) s.getValue();
2528 } catch (Exception e)
2530 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2535 protected void keepRollMaxOptionsEnabled()
2537 boolean enabled = backupfilesKeepAll.isEnabled()
2538 && !backupfilesKeepAll.isSelected();
2539 oldBackupFilesLabel.setEnabled(enabled);
2540 backupfilesRollMaxSpinner.setEnabled(enabled);
2541 backupfilesConfirmDelete.setEnabled(enabled);
2544 protected void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2546 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2547 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2548 && suffixTemplate.getText()
2549 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2550 keepfilesPanel.setEnabled(enabled);
2551 backupfilesKeepAll.setEnabled(enabled);
2552 oldBackupFilesLabel.setEnabled(enabled);
2553 keepRollMaxOptionsEnabled();
2556 private void backupfilesSuffixTemplateDigitsSetEnabled()
2558 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2559 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2560 suffixDigitsLabel.setEnabled(enabled);
2561 suffixDigitsSpinner.setEnabled(enabled);
2562 suffixReverse.setEnabled(enabled);
2565 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2567 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2568 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2569 suffixPanel.setEnabled(enabled);
2570 suffixTemplateLabel.setEnabled(enabled);
2571 suffixTemplate.setEnabled(enabled);
2572 backupfilesSuffixTemplateDigitsSetEnabled();
2575 protected void backupfilesCustomOptionsSetEnabled()
2577 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2578 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2580 backupfilesSuffixTemplateSetEnabled(enabled);
2581 backupfilesKeepAllSetEnabled(enabled);
2584 private void backupfilesSummarySetEnabled()
2586 boolean enabled = enableBackupFiles.isSelected();
2587 backupfilesExampleLabel.setEnabled(enabled);
2588 exampleFilesPanel.setEnabled(enabled);
2591 private void backupfilesPresetsSetEnabled()
2593 boolean enabled = enableBackupFiles.isSelected();
2594 presetsPanel.setEnabled(enabled);
2595 backupfilesPresetsCombo.setEnabled(enabled);
2598 protected void backupsOptionsSetEnabled()
2600 backupfilesPresetsSetEnabled();
2601 backupfilesSummarySetEnabled();
2602 backupfilesCustomOptionsSetEnabled();
2605 protected void backupsSetOptions(String suffix, int digits,
2606 boolean reverse, boolean keepAll, int rollMax,
2607 boolean confirmDelete)
2609 suffixTemplate.setText(suffix);
2610 suffixDigitsSpinner.setValue(digits);
2611 suffixReverse.setSelected(reverse);
2612 backupfilesKeepAll.setSelected(keepAll);
2613 backupfilesRollMaxSpinner.setValue(rollMax);
2614 backupfilesConfirmDelete.setSelected(confirmDelete);
2617 protected void backupsSetOptions(BackupFilesPresetEntry p)
2619 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2623 protected void autoIdWidth_actionPerformed()
2625 // TODO Auto-generated method stub
2629 protected void userIdWidth_actionPerformed()
2631 // TODO Auto-generated method stub
2635 protected void maxColour_actionPerformed(JPanel panel)
2639 protected void minColour_actionPerformed(JPanel panel)
2643 protected void gapColour_actionPerformed(JPanel panel)
2647 protected void hiddenColour_actionPerformed(JPanel panel)
2651 protected void showunconserved_actionPerformed(ActionEvent e)
2653 // TODO Auto-generated method stub
2657 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2661 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2671 public void ok_actionPerformed(ActionEvent e)
2681 public void cancel_actionPerformed(ActionEvent e)
2691 public void annotations_actionPerformed(ActionEvent e)
2698 public void startupFileTextfield_mouseClicked()
2702 public void newLink_actionPerformed(ActionEvent e)
2707 public void editLink_actionPerformed(ActionEvent e)
2712 public void deleteLink_actionPerformed(ActionEvent e)
2717 public void defaultBrowser_mouseClicked(MouseEvent e)
2722 public void linkURLList_keyTyped(KeyEvent e)
2727 public void useProxy_actionPerformed()
2729 boolean enabled = useProxy.isSelected();
2730 portLabel.setEnabled(enabled);
2731 serverLabel.setEnabled(enabled);
2732 proxyServerTB.setEnabled(enabled);
2733 proxyPortTB.setEnabled(enabled);
2737 * Customer renderer for JTable: supports column of radio buttons
2739 public class RadioButtonRenderer extends JRadioButton
2740 implements TableCellRenderer
2742 public RadioButtonRenderer()
2744 setHorizontalAlignment(CENTER);
2745 setToolTipText(MessageManager.getString("label.urltooltip"));
2749 public Component getTableCellRendererComponent(JTable table,
2750 Object value, boolean isSelected, boolean hasFocus, int row,
2753 setSelected((boolean) value);
2755 // set colours to match rest of table
2758 setBackground(table.getSelectionBackground());
2759 setForeground(table.getSelectionForeground());
2763 setBackground(table.getBackground());
2764 setForeground(table.getForeground());
2771 * Customer cell editor for JTable: supports column of radio buttons in
2772 * conjunction with renderer
2774 public class RadioButtonEditor extends AbstractCellEditor
2775 implements TableCellEditor
2777 private JRadioButton button = new JRadioButton();
2779 public RadioButtonEditor()
2781 button.setHorizontalAlignment(SwingConstants.CENTER);
2782 this.button.addActionListener(new ActionListener()
2784 @SuppressWarnings("synthetic-access")
2786 public void actionPerformed(ActionEvent e)
2788 fireEditingStopped();
2794 public Component getTableCellEditorComponent(JTable table, Object value,
2795 boolean isSelected, int row, int column)
2797 button.setSelected((boolean) value);
2802 public Object getCellEditorValue()
2804 return button.isSelected();
2810 class IntKeyStringValueEntry
2816 public IntKeyStringValueEntry(int k, String v)
2823 public String toString()
2825 return this.getValue();
2833 public String getValue()
2839 class BackupFilesPresetEntry
2851 boolean confirmDelete;
2853 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2854 boolean keepAll, int rollMax, boolean confirmDelete)
2856 this.suffix = suffix;
2857 this.digits = digits;
2858 this.reverse = reverse;
2859 this.keepAll = keepAll;
2860 this.rollMax = rollMax;
2861 this.confirmDelete = confirmDelete;
2865 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2870 private static final long serialVersionUID = 88L;
2873 public Component getListCellRendererComponent(JList<?> list, Object value,
2874 int index, boolean isSelected, boolean cellHasFocus)
2876 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2879 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2880 if (e.getKey() == GPreferences.BACKUPFILESSCHEMECUSTOMISE)
2883 this.setFont(this.getFont().deriveFont(Font.BOLD));
2885 } catch (Exception e) {