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 public class GPreferences extends JPanel
97 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
99 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
100 .getLabelFont(false, true);
102 private static final Font LABEL_FONT_BOLD = JvSwingUtils
103 .getLabelFont(true, false);
106 * Visual tab components
108 protected JCheckBox fullScreen = new JCheckBox();
110 protected JCheckBox openoverv = new JCheckBox();
112 protected JCheckBox seqLimit = new JCheckBox();
114 protected JCheckBox rightAlign = new JCheckBox();
116 protected JComboBox<String> fontSizeCB = new JComboBox<>();
118 protected JComboBox<String> fontStyleCB = new JComboBox<>();
120 protected JComboBox<String> fontNameCB = new JComboBox<>();
122 protected JCheckBox showOccupancy = new JCheckBox();
124 protected JCheckBox showUnconserved = new JCheckBox();
126 protected JCheckBox idItalics = new JCheckBox();
128 protected JCheckBox smoothFont = new JCheckBox();
130 protected JCheckBox scaleProteinToCdna = new JCheckBox();
132 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
134 protected JCheckBox wrap = new JCheckBox();
136 protected JComboBox<String> sortby = new JComboBox<>();
138 protected JComboBox<String> sortAnnBy = new JComboBox<>();
140 protected JComboBox<String> sortAutocalc = new JComboBox<>();
142 protected JCheckBox startupCheckbox = new JCheckBox();
144 protected JTextField startupFileTextfield = new JTextField();
146 // below are in the 'second column'
147 protected JCheckBox annotations = new JCheckBox();
149 protected JCheckBox quality = new JCheckBox();
151 protected JCheckBox conservation = new JCheckBox();
153 protected JCheckBox identity = new JCheckBox();
155 protected JCheckBox showGroupConsensus = new JCheckBox();
157 protected JCheckBox showGroupConservation = new JCheckBox();
159 protected JCheckBox showConsensHistogram = new JCheckBox();
161 protected JCheckBox showConsensLogo = new JCheckBox();
163 protected JCheckBox showDbRefTooltip = new JCheckBox();
165 protected JCheckBox showNpTooltip = new JCheckBox();
168 * Structure tab and components
170 protected JPanel structureTab;
172 protected JCheckBox structFromPdb = new JCheckBox();
174 protected JCheckBox useRnaView = new JCheckBox();
176 protected JCheckBox addSecondaryStructure = new JCheckBox();
178 protected JCheckBox addTempFactor = new JCheckBox();
180 protected JComboBox<String> structViewer = new JComboBox<>();
182 protected JTextField chimeraPath = new JTextField();
184 protected ButtonGroup mappingMethod = new ButtonGroup();
186 protected JRadioButton siftsMapping = new JRadioButton();
188 protected JRadioButton nwMapping = new JRadioButton();
191 * Colours tab components
193 protected JPanel minColour = new JPanel();
195 protected JPanel maxColour = new JPanel();
197 protected JComboBox<String> protColour = new JComboBox<>();
199 protected JComboBox<String> nucColour = new JComboBox<>();
202 * Overview tab components
204 protected JPanel gapColour = new JPanel();
206 protected JPanel hiddenColour = new JPanel();
208 protected JCheckBox useLegacyGap;
210 protected JCheckBox showHiddenAtStart;
212 protected JLabel gapLabel;
215 * Connections tab components
217 protected JTable linkUrlTable = new JTable();
219 protected JButton editLink = new JButton();
221 protected JButton deleteLink = new JButton();
223 protected JTextField filterTB = new JTextField();
225 protected JButton doReset = new JButton();
227 protected JButton userOnly = new JButton();
229 protected JLabel portLabel = new JLabel();
231 protected JLabel serverLabel = new JLabel();
233 protected JTextField proxyServerTB = new JTextField();
235 protected JTextField proxyPortTB = new JTextField();
237 protected JTextField defaultBrowser = new JTextField();
239 protected JCheckBox useProxy = new JCheckBox();
241 protected JCheckBox usagestats = new JCheckBox();
243 protected JCheckBox questionnaire = new JCheckBox();
245 protected JCheckBox versioncheck = new JCheckBox();
248 * Output tab components
250 protected JComboBox<Object> epsRendering = new JComboBox<>();
252 protected JComboBox<Object> htmlRendering = new JComboBox<>();
254 protected JComboBox<Object> svgRendering = new JComboBox<>();
256 protected JLabel userIdWidthlabel = new JLabel();
258 protected JCheckBox autoIdWidth = new JCheckBox();
260 protected JTextField userIdWidth = new JTextField();
262 protected JCheckBox blcjv = new JCheckBox();
264 protected JCheckBox pileupjv = new JCheckBox();
266 protected JCheckBox clustaljv = new JCheckBox();
268 protected JCheckBox msfjv = new JCheckBox();
270 protected JCheckBox fastajv = new JCheckBox();
272 protected JCheckBox pfamjv = new JCheckBox();
274 protected JCheckBox pirjv = new JCheckBox();
276 protected JCheckBox modellerOutput = new JCheckBox();
278 protected JCheckBox embbedBioJSON = new JCheckBox();
281 * Editing tab components
283 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
285 protected JCheckBox padGaps = new JCheckBox();
287 protected JCheckBox sortByTree = new JCheckBox();
292 protected JPanel wsTab = new JPanel();
295 * Backups tab components
296 * a lot of these are member variables instead of local variables only so that they
297 * can be enabled/disabled easily in one go
300 protected JCheckBox enableBackupFiles = new JCheckBox();
302 protected JPanel presetsPanel = new JPanel();
304 protected JButton revertButton = new JButton();
306 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
308 protected JPanel suffixPanel = new JPanel();
310 protected JPanel keepfilesPanel = new JPanel();
312 protected JPanel exampleFilesPanel = new JPanel();
314 protected JTextField suffixTemplate = new JTextField(null, 8);
316 protected JLabel suffixTemplateLabel = new JLabel();
318 protected JLabel suffixDigitsLabel = new JLabel();
320 protected JSpinner suffixDigitsSpinner = new JSpinner();
322 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
324 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
326 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
328 protected JLabel oldBackupFilesLabel = new JLabel();
330 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
332 protected JTextArea backupfilesExampleLabel = new JTextArea();
335 * Creates a new GPreferences object.
337 public GPreferences()
342 } catch (Exception ex)
344 ex.printStackTrace();
349 * Construct the panel and its tabbed sub-panels.
353 private void jbInit() throws Exception
355 final JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane();
356 this.setLayout(new BorderLayout());
357 JPanel okCancelPanel = initOkCancelPanel();
358 this.add(tabbedPane, BorderLayout.CENTER);
359 this.add(okCancelPanel, BorderLayout.SOUTH);
361 tabbedPane.add(initVisualTab(),
362 MessageManager.getString("label.visual"));
364 tabbedPane.add(initColoursTab(),
365 MessageManager.getString("label.colours"));
367 tabbedPane.add(initOverviewTab(),
368 MessageManager.getString("label.overview"));
370 tabbedPane.add(initStructureTab(),
371 MessageManager.getString("label.structure"));
373 tabbedPane.add(initConnectionsTab(),
374 MessageManager.getString("label.connections"));
376 if (!Platform.isJS())
378 tabbedPane.add(initBackupsTab(),
379 MessageManager.getString("label.backups"));
382 tabbedPane.add(initLinksTab(),
383 MessageManager.getString("label.urllinks"));
385 tabbedPane.add(initOutputTab(),
386 MessageManager.getString("label.output"));
388 tabbedPane.add(initEditingTab(),
389 MessageManager.getString("label.editing"));
392 * See WsPreferences for the real work of configuring this tab.
394 if (!Platform.isJS())
396 wsTab.setLayout(new BorderLayout());
397 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
401 * Handler to validate a tab before leaving it - currently only for
404 tabbedPane.addChangeListener(new ChangeListener()
406 private Component lastTab;
409 public void stateChanged(ChangeEvent e)
411 if (lastTab == structureTab
412 && tabbedPane.getSelectedComponent() != structureTab)
414 if (!validateStructure())
416 tabbedPane.setSelectedComponent(structureTab);
420 lastTab = tabbedPane.getSelectedComponent();
427 * Initialises the Editing tabbed panel.
431 private JPanel initEditingTab()
433 JPanel editingTab = new JPanel();
434 editingTab.setLayout(null);
435 autoCalculateConsCheck.setFont(LABEL_FONT);
436 autoCalculateConsCheck.setText(
437 MessageManager.getString("label.autocalculate_consensus"));
438 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
439 padGaps.setFont(LABEL_FONT);
441 MessageManager.getString("label.pad_gaps_when_editing"));
442 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
443 sortByTree.setFont(LABEL_FONT);
445 .setText(MessageManager.getString("label.sort_with_new_tree"));
446 sortByTree.setToolTipText(MessageManager.getString(
447 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
448 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
449 editingTab.add(autoCalculateConsCheck);
450 editingTab.add(padGaps);
451 editingTab.add(sortByTree);
456 * Initialises the Output tab
460 private JPanel initOutputTab()
462 JPanel outputTab = new JPanel();
463 outputTab.setLayout(null);
465 JLabel epsLabel = new JLabel(
466 MessageManager.formatMessage("label.rendering_style", "EPS"));
467 epsLabel.setFont(LABEL_FONT);
468 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
469 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
470 epsRendering.setFont(LABEL_FONT);
471 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
472 JLabel htmlLabel = new JLabel(
473 MessageManager.formatMessage("label.rendering_style", "HTML"));
474 htmlLabel.setFont(LABEL_FONT);
475 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
476 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
477 htmlRendering.setFont(LABEL_FONT);
478 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
479 JLabel svgLabel = new JLabel(
480 MessageManager.formatMessage("label.rendering_style", "SVG"));
481 svgLabel.setFont(LABEL_FONT);
482 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
483 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
484 svgRendering.setFont(LABEL_FONT);
485 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
487 JLabel jLabel1 = new JLabel();
488 jLabel1.setFont(LABEL_FONT);
489 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
490 jLabel1.setText(MessageManager.getString("label.append_start_end"));
491 jLabel1.setFont(LABEL_FONT);
493 fastajv.setFont(LABEL_FONT);
494 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
495 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
496 blcjv.setText(MessageManager.getString("label.blc") + " ");
497 fastajv.setText(MessageManager.getString("label.fasta") + " ");
498 msfjv.setText(MessageManager.getString("label.msf") + " ");
499 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
500 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
501 msfjv.setFont(LABEL_FONT);
502 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
503 pirjv.setText(MessageManager.getString("label.pir") + " ");
504 JPanel jPanel11 = new JPanel();
505 jPanel11.setFont(LABEL_FONT);
506 TitledBorder titledBorder2 = new TitledBorder(
507 MessageManager.getString("label.file_output"));
508 jPanel11.setBorder(titledBorder2);
509 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
510 GridLayout gridLayout3 = new GridLayout();
511 jPanel11.setLayout(gridLayout3);
512 gridLayout3.setRows(8);
513 blcjv.setFont(LABEL_FONT);
514 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
515 clustaljv.setFont(LABEL_FONT);
516 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
517 pfamjv.setFont(LABEL_FONT);
518 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
519 pileupjv.setFont(LABEL_FONT);
520 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
521 pirjv.setFont(LABEL_FONT);
522 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
523 autoIdWidth.setFont(LABEL_FONT);
525 MessageManager.getString("label.automatically_set_id_width"));
526 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
527 .getString("label.adjusts_width_generated_eps_png")));
528 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
529 autoIdWidth.addActionListener(new ActionListener()
533 public void actionPerformed(ActionEvent e)
535 autoIdWidth_actionPerformed();
538 userIdWidthlabel.setFont(LABEL_FONT);
539 userIdWidthlabel.setText(
540 MessageManager.getString("label.figure_id_column_width"));
541 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
542 .getString("label.manually_specify_width_left_column")));
543 userIdWidthlabel.setToolTipText(
544 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
545 "label.manually_specify_width_left_column")));
546 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
547 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
548 userIdWidth.setText("");
549 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
550 userIdWidth.addActionListener(new ActionListener()
554 public void actionPerformed(ActionEvent e)
556 userIdWidth_actionPerformed();
559 modellerOutput.setFont(LABEL_FONT);
561 .setText(MessageManager.getString("label.use_modeller_output"));
562 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
563 embbedBioJSON.setFont(LABEL_FONT);
564 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
565 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
567 jPanel11.add(jLabel1);
569 jPanel11.add(clustaljv);
570 jPanel11.add(fastajv);
572 jPanel11.add(pfamjv);
573 jPanel11.add(pileupjv);
575 outputTab.add(autoIdWidth);
576 outputTab.add(userIdWidth);
577 outputTab.add(userIdWidthlabel);
578 outputTab.add(modellerOutput);
579 if (!Platform.isJS())
582 * JalviewJS doesn't support Lineart option or SVG output
584 outputTab.add(embbedBioJSON);
585 outputTab.add(epsLabel);
586 outputTab.add(epsRendering);
587 outputTab.add(htmlLabel);
588 outputTab.add(htmlRendering);
589 outputTab.add(svgLabel);
590 outputTab.add(svgRendering);
592 outputTab.add(jPanel11);
597 * Initialises the Connections tabbed panel.
601 private JPanel initConnectionsTab()
603 JPanel connectTab = new JPanel();
604 connectTab.setLayout(new GridBagLayout());
606 // Label for browser text box
607 JLabel browserLabel = new JLabel();
608 browserLabel.setFont(LABEL_FONT);
609 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
610 browserLabel.setText(
611 MessageManager.getString("label.default_browser_unix"));
612 defaultBrowser.setFont(LABEL_FONT);
613 defaultBrowser.setText("");
614 final String tooltip = JvSwingUtils.wrapTooltip(true,
615 MessageManager.getString("label.double_click_to_browse"));
616 defaultBrowser.setToolTipText(tooltip);
617 defaultBrowser.addMouseListener(new MouseAdapter()
620 public void mouseClicked(MouseEvent e)
622 if (e.getClickCount() > 1)
624 defaultBrowser_mouseClicked(e);
629 JPanel proxyPanel = initConnTabProxyPanel();
630 initConnTabCheckboxes();
632 // Add default Browser text box
633 connectTab.add(browserLabel,
634 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
635 GridBagConstraints.WEST, GridBagConstraints.NONE,
636 new Insets(10, 0, 5, 5), 5, 1));
637 defaultBrowser.setFont(LABEL_FONT);
638 defaultBrowser.setText("");
640 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
641 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
642 new Insets(10, 0, 5, 10), 30, 1));
644 // Add proxy server panel
645 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
646 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
647 new Insets(10, 0, 5, 12), 4, 10));
649 // Add usage stats, version check and questionnaire checkboxes
650 connectTab.add(usagestats,
651 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
652 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
653 new Insets(0, 2, 5, 5), 70, 1));
654 connectTab.add(questionnaire,
655 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
656 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
657 new Insets(0, 2, 5, 10), 70, 1));
658 connectTab.add(versioncheck,
659 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
660 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
661 new Insets(0, 2, 5, 5), 70, 1));
663 // Add padding so the panel doesn't look ridiculous
664 JPanel spacePanel = new JPanel();
665 connectTab.add(spacePanel,
666 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
667 GridBagConstraints.WEST, GridBagConstraints.BOTH,
668 new Insets(0, 0, 0, 5), 70, 1));
674 * Initialises the Links tabbed panel.
678 private JPanel initLinksTab()
680 JPanel linkTab = new JPanel();
681 linkTab.setLayout(new GridBagLayout());
683 // Set up table for Url links
684 linkUrlTable.getTableHeader().setReorderingAllowed(false);
685 linkUrlTable.setFillsViewportHeight(true);
686 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
687 linkUrlTable.setAutoCreateRowSorter(true);
688 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
690 // adjust row height so radio buttons actually fit
691 // don't do this in the renderer, it causes the awt thread to activate
693 JRadioButton temp = new JRadioButton();
694 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
696 // Table in scrollpane so that the table is given a scrollbar
697 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
698 linkScrollPane.setBorder(null);
700 // Panel for links functionality
701 JPanel linkPanel = new JPanel(new GridBagLayout());
702 linkPanel.setBorder(new TitledBorder(
703 MessageManager.getString("label.url_linkfrom_sequence_id")));
705 // Put the Url links panel together
707 // Buttons go at top right, resizing only resizes the blank space vertically
708 JPanel buttonPanel = initLinkTabUrlButtons();
709 GridBagConstraints linkConstraints1 = new GridBagConstraints();
710 linkConstraints1.insets = new Insets(0, 0, 5, 0);
711 linkConstraints1.gridx = 0;
712 linkConstraints1.gridy = 0;
713 linkConstraints1.weightx = 1.0;
714 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
715 linkTab.add(buttonPanel, linkConstraints1);
717 // Links table goes at top left, resizing resizes the table
718 GridBagConstraints linkConstraints2 = new GridBagConstraints();
719 linkConstraints2.insets = new Insets(0, 0, 5, 5);
720 linkConstraints2.gridx = 0;
721 linkConstraints2.gridy = 1;
722 linkConstraints2.weightx = 1.0;
723 linkConstraints2.weighty = 1.0;
724 linkConstraints2.fill = GridBagConstraints.BOTH;
725 linkTab.add(linkScrollPane, linkConstraints2);
727 // Filter box and buttons goes at bottom left, resizing resizes the text box
728 JPanel filterPanel = initLinkTabFilterPanel();
729 GridBagConstraints linkConstraints3 = new GridBagConstraints();
730 linkConstraints3.insets = new Insets(0, 0, 0, 5);
731 linkConstraints3.gridx = 0;
732 linkConstraints3.gridy = 2;
733 linkConstraints3.weightx = 1.0;
734 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
735 linkTab.add(filterPanel, linkConstraints3);
740 private JPanel initLinkTabFilterPanel()
742 // Filter textbox and reset button
743 JLabel filterLabel = new JLabel(
744 MessageManager.getString("label.filter"));
745 filterLabel.setFont(LABEL_FONT);
746 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
747 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
749 filterTB.setFont(LABEL_FONT);
750 filterTB.setText("");
752 doReset.setText(MessageManager.getString("action.showall"));
753 userOnly.setText(MessageManager.getString("action.customfilter"));
755 // Panel for filter functionality
756 JPanel filterPanel = new JPanel(new GridBagLayout());
757 filterPanel.setBorder(new TitledBorder("Filter"));
758 GridBagConstraints gbc = new GridBagConstraints();
761 gbc.fill = GridBagConstraints.NONE;
762 gbc.anchor = GridBagConstraints.WEST;
764 filterPanel.add(filterLabel, gbc);
766 GridBagConstraints gbc1 = new GridBagConstraints();
769 gbc1.fill = GridBagConstraints.HORIZONTAL;
770 gbc1.anchor = GridBagConstraints.WEST;
772 filterPanel.add(filterTB, gbc1);
774 GridBagConstraints gbc2 = new GridBagConstraints();
776 gbc2.fill = GridBagConstraints.NONE;
777 gbc2.anchor = GridBagConstraints.WEST;
778 filterPanel.add(doReset, gbc2);
780 GridBagConstraints gbc3 = new GridBagConstraints();
782 gbc3.fill = GridBagConstraints.NONE;
783 gbc3.anchor = GridBagConstraints.WEST;
784 filterPanel.add(userOnly, gbc3);
789 private JPanel initLinkTabUrlButtons()
791 // Buttons for new / edit / delete Url links
792 JButton newLink = new JButton();
793 newLink.setText(MessageManager.getString("action.new"));
795 editLink.setText(MessageManager.getString("action.edit"));
797 deleteLink.setText(MessageManager.getString("action.delete"));
799 // no current selection, so initially disable delete/edit buttons
800 editLink.setEnabled(false);
801 deleteLink.setEnabled(false);
803 newLink.addActionListener(new java.awt.event.ActionListener()
806 public void actionPerformed(ActionEvent e)
808 newLink_actionPerformed(e);
812 editLink.setText(MessageManager.getString("action.edit"));
813 editLink.addActionListener(new java.awt.event.ActionListener()
816 public void actionPerformed(ActionEvent e)
818 editLink_actionPerformed(e);
822 deleteLink.setText(MessageManager.getString("action.delete"));
823 deleteLink.addActionListener(new java.awt.event.ActionListener()
826 public void actionPerformed(ActionEvent e)
828 deleteLink_actionPerformed(e);
832 JPanel buttonPanel = new JPanel(new GridBagLayout());
833 buttonPanel.setBorder(new TitledBorder("Edit links"));
834 GridBagConstraints gbc = new GridBagConstraints();
837 gbc.fill = GridBagConstraints.NONE;
838 buttonPanel.add(newLink, gbc);
840 GridBagConstraints gbc1 = new GridBagConstraints();
843 gbc1.fill = GridBagConstraints.NONE;
844 buttonPanel.add(editLink, gbc1);
846 GridBagConstraints gbc2 = new GridBagConstraints();
849 gbc2.fill = GridBagConstraints.NONE;
850 buttonPanel.add(deleteLink, gbc2);
852 GridBagConstraints gbc3 = new GridBagConstraints();
855 gbc3.fill = GridBagConstraints.HORIZONTAL;
857 JPanel spacePanel = new JPanel();
858 spacePanel.setBorder(null);
859 buttonPanel.add(spacePanel, gbc3);
865 * Initialises the proxy server panel in the Connections tab
867 * @return the proxy server panel
869 private JPanel initConnTabProxyPanel()
871 // Label for server text box
872 serverLabel.setText(MessageManager.getString("label.address"));
873 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
874 serverLabel.setFont(LABEL_FONT);
876 // Proxy server and port text boxes
877 proxyServerTB.setFont(LABEL_FONT);
878 proxyPortTB.setFont(LABEL_FONT);
880 // Label for Port text box
881 portLabel.setFont(LABEL_FONT);
882 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
883 portLabel.setText(MessageManager.getString("label.port"));
885 // Use proxy server checkbox
886 useProxy.setFont(LABEL_FONT);
887 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
888 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
889 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
890 useProxy.addActionListener(new ActionListener()
893 public void actionPerformed(ActionEvent e)
895 useProxy_actionPerformed();
899 // Make proxy server panel
900 JPanel proxyPanel = new JPanel();
901 TitledBorder titledBorder1 = new TitledBorder(
902 MessageManager.getString("label.proxy_server"));
903 proxyPanel.setBorder(titledBorder1);
904 proxyPanel.setLayout(new GridBagLayout());
905 proxyPanel.add(serverLabel,
906 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
907 GridBagConstraints.WEST, GridBagConstraints.NONE,
908 new Insets(0, 2, 2, 0), 5, 0));
909 proxyPanel.add(portLabel,
910 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
911 GridBagConstraints.WEST, GridBagConstraints.NONE,
912 new Insets(0, 0, 2, 0), 11, 0));
913 proxyPanel.add(useProxy,
914 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
915 GridBagConstraints.WEST, GridBagConstraints.NONE,
916 new Insets(0, 2, 5, 185), 2, -4));
917 proxyPanel.add(proxyPortTB,
918 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
919 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
920 new Insets(0, 2, 2, 2), 54, 1));
921 proxyPanel.add(proxyServerTB,
922 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
923 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
924 new Insets(0, 2, 2, 0), 263, 1));
930 * Initialises the checkboxes in the Connections tab
932 private void initConnTabCheckboxes()
934 // Usage stats checkbox label
936 MessageManager.getString("label.send_usage_statistics"));
937 usagestats.setFont(LABEL_FONT);
938 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
939 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
941 // Questionnaire checkbox label
942 questionnaire.setText(
943 MessageManager.getString("label.check_for_questionnaires"));
944 questionnaire.setFont(LABEL_FONT);
945 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
946 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
948 // Check for latest version checkbox label
949 versioncheck.setText(
950 MessageManager.getString("label.check_for_latest_version"));
951 versioncheck.setFont(LABEL_FONT);
952 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
953 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
957 * Initialises the parent panel which contains the tabbed sections.
961 private JPanel initOkCancelPanel()
963 JButton ok = new JButton();
964 ok.setText(MessageManager.getString("action.ok"));
965 ok.addActionListener(new ActionListener()
968 public void actionPerformed(ActionEvent e)
970 ok_actionPerformed(e);
973 JButton cancel = new JButton();
974 cancel.setText(MessageManager.getString("action.cancel"));
975 cancel.addActionListener(new ActionListener()
978 public void actionPerformed(ActionEvent e)
980 cancel_actionPerformed(e);
983 JPanel okCancelPanel = new JPanel();
984 okCancelPanel.add(ok);
985 okCancelPanel.add(cancel);
986 return okCancelPanel;
990 * Initialises the Colours tabbed panel.
994 private JPanel initColoursTab()
996 JPanel coloursTab = new JPanel();
997 coloursTab.setBorder(new TitledBorder(
998 MessageManager.getString("action.open_new_alignment")));
999 coloursTab.setLayout(new FlowLayout());
1000 JLabel mincolourLabel = new JLabel();
1001 mincolourLabel.setFont(LABEL_FONT);
1002 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1003 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1004 minColour.setFont(LABEL_FONT);
1005 minColour.setBorder(BorderFactory.createEtchedBorder());
1006 minColour.setPreferredSize(new Dimension(40, 20));
1007 minColour.addMouseListener(new MouseAdapter()
1010 public void mousePressed(MouseEvent e)
1012 minColour_actionPerformed(minColour);
1015 JLabel maxcolourLabel = new JLabel();
1016 maxcolourLabel.setFont(LABEL_FONT);
1017 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1018 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1019 maxColour.setFont(LABEL_FONT);
1020 maxColour.setBorder(BorderFactory.createEtchedBorder());
1021 maxColour.setPreferredSize(new Dimension(40, 20));
1022 maxColour.addMouseListener(new MouseAdapter()
1025 public void mousePressed(MouseEvent e)
1027 maxColour_actionPerformed(maxColour);
1031 protColour.setFont(LABEL_FONT);
1032 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1033 JLabel protColourLabel = new JLabel();
1034 protColourLabel.setFont(LABEL_FONT);
1035 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1036 protColourLabel.setText(
1037 MessageManager.getString("label.prot_alignment_colour") + " ");
1038 JvSwingUtils.addtoLayout(coloursTab,
1040 .getString("label.default_colour_scheme_for_alignment"),
1041 protColourLabel, protColour);
1043 nucColour.setFont(LABEL_FONT);
1044 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1045 JLabel nucColourLabel = new JLabel();
1046 nucColourLabel.setFont(LABEL_FONT);
1047 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1048 nucColourLabel.setText(
1049 MessageManager.getString("label.nuc_alignment_colour") + " ");
1050 JvSwingUtils.addtoLayout(coloursTab,
1052 .getString("label.default_colour_scheme_for_alignment"),
1053 nucColourLabel, nucColour);
1055 JPanel annotationShding = new JPanel();
1056 annotationShding.setBorder(new TitledBorder(
1057 MessageManager.getString("label.annotation_shading_default")));
1058 annotationShding.setLayout(new GridLayout(1, 2));
1059 JvSwingUtils.addtoLayout(annotationShding,
1060 MessageManager.getString(
1061 "label.default_minimum_colour_annotation_shading"),
1062 mincolourLabel, minColour);
1063 JvSwingUtils.addtoLayout(annotationShding,
1064 MessageManager.getString(
1065 "label.default_maximum_colour_annotation_shading"),
1066 maxcolourLabel, maxColour);
1067 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1072 * Initialises the Overview tabbed panel.
1076 private JPanel initOverviewTab()
1078 JPanel overviewPanel = new JPanel();
1079 overviewPanel.setBorder(new TitledBorder(
1080 MessageManager.getString("label.overview_settings")));
1082 gapColour.setFont(LABEL_FONT);
1083 // fixing the border colours stops apparent colour bleed from the panel
1084 gapColour.setBorder(
1085 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1086 gapColour.setPreferredSize(new Dimension(40, 20));
1087 gapColour.addMouseListener(new MouseAdapter()
1090 public void mousePressed(MouseEvent e)
1092 gapColour_actionPerformed(gapColour);
1096 hiddenColour.setFont(LABEL_FONT);
1097 // fixing the border colours stops apparent colour bleed from the panel
1098 hiddenColour.setBorder(
1099 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1100 hiddenColour.setPreferredSize(new Dimension(40, 20));
1101 hiddenColour.addMouseListener(new MouseAdapter()
1104 public void mousePressed(MouseEvent e)
1106 hiddenColour_actionPerformed(hiddenColour);
1110 useLegacyGap = new JCheckBox(
1111 MessageManager.getString("label.ov_legacy_gap"));
1112 useLegacyGap.setFont(LABEL_FONT);
1113 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1114 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1115 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1116 gapLabel.setFont(LABEL_FONT);
1117 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1118 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1119 showHiddenAtStart = new JCheckBox(
1120 MessageManager.getString("label.ov_show_hide_default"));
1121 showHiddenAtStart.setFont(LABEL_FONT);
1122 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1123 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1124 JLabel hiddenLabel = new JLabel(
1125 MessageManager.getString("label.hidden_colour"));
1126 hiddenLabel.setFont(LABEL_FONT);
1127 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1128 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1130 useLegacyGap.addActionListener(new ActionListener()
1133 public void actionPerformed(ActionEvent e)
1135 useLegacyGaps_actionPerformed(e);
1139 overviewPanel.setLayout(new GridBagLayout());
1140 GridBagConstraints c1 = new GridBagConstraints();
1142 c1.fill = GridBagConstraints.HORIZONTAL;
1147 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1148 overviewPanel.add(useLegacyGap, c1);
1150 GridBagConstraints c2 = new GridBagConstraints();
1151 c2.fill = GridBagConstraints.HORIZONTAL;
1154 c2.insets = new Insets(0, 15, 0, 10);
1155 overviewPanel.add(gapLabel, c2);
1157 GridBagConstraints c3 = new GridBagConstraints();
1158 c3.fill = GridBagConstraints.HORIZONTAL;
1161 c3.insets = new Insets(0, 0, 0, 15);
1162 overviewPanel.add(gapColour, c3);
1164 GridBagConstraints c4 = new GridBagConstraints();
1165 c4.fill = GridBagConstraints.HORIZONTAL;
1169 overviewPanel.add(showHiddenAtStart, c4);
1171 GridBagConstraints c5 = new GridBagConstraints();
1172 c5.fill = GridBagConstraints.HORIZONTAL;
1175 c5.insets = new Insets(0, 15, 0, 10);
1176 overviewPanel.add(hiddenLabel, c5);
1178 GridBagConstraints c6 = new GridBagConstraints();
1179 c6.fill = GridBagConstraints.HORIZONTAL;
1182 c6.insets = new Insets(0, 0, 0, 15);
1183 overviewPanel.add(hiddenColour, c6);
1185 JButton resetButton = new JButton(
1186 MessageManager.getString("label.reset_to_defaults"));
1188 resetButton.addActionListener(new ActionListener()
1191 public void actionPerformed(ActionEvent e)
1193 resetOvDefaults_actionPerformed(e);
1197 GridBagConstraints c7 = new GridBagConstraints();
1198 c7.fill = GridBagConstraints.NONE;
1201 c7.insets = new Insets(10, 0, 0, 0);
1202 c7.anchor = GridBagConstraints.WEST;
1203 overviewPanel.add(resetButton, c7);
1205 // Add padding so the panel doesn't look ridiculous
1206 JPanel spacePanel = new JPanel();
1207 overviewPanel.add(spacePanel,
1208 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1209 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1210 new Insets(0, 0, 0, 5), 0, 0));
1212 return overviewPanel;
1216 * Initialises the Structure tabbed panel.
1220 private JPanel initStructureTab()
1222 structureTab = new JPanel();
1224 structureTab.setBorder(new TitledBorder(
1225 MessageManager.getString("label.structure_options")));
1226 structureTab.setLayout(null);
1227 final int width = 400;
1228 final int height = 22;
1229 final int lineSpacing = 25;
1232 structFromPdb.setFont(LABEL_FONT);
1234 .setText(MessageManager.getString("label.struct_from_pdb"));
1235 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1236 structFromPdb.addActionListener(new ActionListener()
1239 public void actionPerformed(ActionEvent e)
1241 boolean selected = structFromPdb.isSelected();
1242 // enable other options only when the first is checked
1243 useRnaView.setEnabled(selected);
1244 addSecondaryStructure.setEnabled(selected);
1245 addTempFactor.setEnabled(selected);
1248 structureTab.add(structFromPdb);
1250 // indent checkboxes that are conditional on the first one
1251 ypos += lineSpacing;
1252 useRnaView.setFont(LABEL_FONT);
1253 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1254 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1255 structureTab.add(useRnaView);
1257 ypos += lineSpacing;
1258 addSecondaryStructure.setFont(LABEL_FONT);
1259 addSecondaryStructure
1260 .setText(MessageManager.getString("label.autoadd_secstr"));
1261 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1262 structureTab.add(addSecondaryStructure);
1264 ypos += lineSpacing;
1265 addTempFactor.setFont(LABEL_FONT);
1266 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1267 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1268 structureTab.add(addTempFactor);
1270 ypos += lineSpacing;
1271 JLabel viewerLabel = new JLabel();
1272 viewerLabel.setFont(LABEL_FONT);
1273 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1274 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1275 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1276 structureTab.add(viewerLabel);
1278 structViewer.setFont(LABEL_FONT);
1279 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1280 structViewer.addItem(ViewerType.JMOL.name());
1281 structViewer.addItem(ViewerType.CHIMERA.name());
1282 structViewer.addActionListener(new ActionListener()
1285 public void actionPerformed(ActionEvent e)
1287 structureViewer_actionPerformed(
1288 (String) structViewer.getSelectedItem());
1291 structureTab.add(structViewer);
1293 ypos += lineSpacing;
1294 JLabel pathLabel = new JLabel();
1295 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1296 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1297 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1298 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1299 structureTab.add(pathLabel);
1301 chimeraPath.setFont(LABEL_FONT);
1302 chimeraPath.setText("");
1303 final String tooltip = JvSwingUtils.wrapTooltip(true,
1304 MessageManager.getString("label.chimera_path_tip"));
1305 chimeraPath.setToolTipText(tooltip);
1306 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1307 chimeraPath.addMouseListener(new MouseAdapter()
1310 public void mouseClicked(MouseEvent e)
1312 if (e.getClickCount() == 2)
1314 String chosen = openFileChooser();
1317 chimeraPath.setText(chosen);
1322 structureTab.add(chimeraPath);
1324 ypos += lineSpacing;
1325 nwMapping.setFont(LABEL_FONT);
1326 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1327 siftsMapping.setFont(LABEL_FONT);
1328 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1329 mappingMethod.add(nwMapping);
1330 mappingMethod.add(siftsMapping);
1331 JPanel mappingPanel = new JPanel();
1332 mappingPanel.setFont(LABEL_FONT);
1333 TitledBorder mmTitledBorder = new TitledBorder(
1334 MessageManager.getString("label.mapping_method"));
1335 mmTitledBorder.setTitleFont(LABEL_FONT);
1336 mappingPanel.setBorder(mmTitledBorder);
1337 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1338 // GridLayout mappingLayout = new GridLayout();
1339 mappingPanel.setLayout(new GridLayout());
1340 mappingPanel.add(nwMapping);
1341 mappingPanel.add(siftsMapping);
1342 structureTab.add(mappingPanel);
1344 ypos += lineSpacing;
1345 ypos += lineSpacing;
1346 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1347 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1348 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1349 structureTab.add(docFieldPref);
1352 * hide Chimera options in JalviewJS
1354 if (Platform.isJS())
1356 pathLabel.setVisible(false);
1357 chimeraPath.setVisible(false);
1358 viewerLabel.setVisible(false);
1359 structViewer.setVisible(false);
1362 return structureTab;
1366 * Action on choosing a structure viewer from combobox options.
1368 * @param selectedItem
1370 protected void structureViewer_actionPerformed(String selectedItem)
1375 * Show a dialog for the user to choose a file. Returns the chosen path, or
1380 protected String openFileChooser()
1382 String choice = null;
1383 JFileChooser chooser = new JFileChooser();
1385 // chooser.setFileView(new JalviewFileView());
1386 chooser.setDialogTitle(
1387 MessageManager.getString("label.open_local_file"));
1388 chooser.setToolTipText(MessageManager.getString("action.open"));
1390 int value = chooser.showOpenDialog(this);
1392 if (value == JFileChooser.APPROVE_OPTION)
1394 choice = chooser.getSelectedFile().getPath();
1400 * Validate the structure tab preferences; if invalid, set focus on this tab.
1404 protected boolean validateStructure(FocusEvent e)
1406 if (!validateStructure())
1408 e.getComponent().requestFocusInWindow();
1414 protected boolean validateStructure()
1420 * Initialises the Visual tabbed panel.
1424 private JPanel initVisualTab()
1426 JPanel visualTab = new JPanel();
1427 visualTab.setBorder(new TitledBorder(
1428 MessageManager.getString("action.open_new_alignment")));
1429 visualTab.setLayout(null);
1430 fullScreen.setFont(LABEL_FONT);
1431 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1432 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1433 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1434 quality.setEnabled(false);
1435 quality.setFont(LABEL_FONT);
1436 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1437 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1438 quality.setSelected(true);
1439 quality.setText(MessageManager.getString("label.quality"));
1440 conservation.setEnabled(false);
1441 conservation.setFont(LABEL_FONT);
1442 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1443 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1444 conservation.setSelected(true);
1445 conservation.setText(MessageManager.getString("label.conservation"));
1446 identity.setEnabled(false);
1447 identity.setFont(LABEL_FONT);
1448 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1449 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1450 identity.setSelected(true);
1451 identity.setText(MessageManager.getString("label.consensus"));
1452 showOccupancy.setFont(LABEL_FONT);
1453 showOccupancy.setEnabled(false);
1454 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1455 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1456 showOccupancy.setSelected(true);
1457 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1459 JLabel showGroupbits = new JLabel();
1460 showGroupbits.setFont(LABEL_FONT);
1461 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1462 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1464 .setText(MessageManager.getString("action.show_group") + ":");
1465 JLabel showConsensbits = new JLabel();
1466 showConsensbits.setFont(LABEL_FONT);
1467 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1468 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1470 .setText(MessageManager.getString("label.consensus") + ":");
1471 showConsensHistogram.setEnabled(false);
1472 showConsensHistogram.setFont(LABEL_FONT);
1473 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1474 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1475 showConsensHistogram.setSelected(true);
1476 showConsensHistogram
1477 .setText(MessageManager.getString("label.histogram"));
1478 showConsensLogo.setEnabled(false);
1479 showConsensLogo.setFont(LABEL_FONT);
1480 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1481 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1482 showConsensLogo.setSelected(true);
1483 showConsensLogo.setText(MessageManager.getString("label.logo"));
1484 showGroupConsensus.setEnabled(false);
1485 showGroupConsensus.setFont(LABEL_FONT);
1486 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1487 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1488 showGroupConsensus.setSelected(true);
1489 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1490 showGroupConservation.setEnabled(false);
1491 showGroupConservation.setFont(LABEL_FONT);
1492 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1493 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1494 showGroupConservation.setSelected(true);
1495 showGroupConservation
1496 .setText(MessageManager.getString("label.conservation"));
1497 showNpTooltip.setEnabled(true);
1498 showNpTooltip.setFont(LABEL_FONT);
1499 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1500 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1501 showNpTooltip.setSelected(true);
1502 showNpTooltip.setText(
1503 MessageManager.getString("label.non_positional_features"));
1504 showDbRefTooltip.setEnabled(true);
1505 showDbRefTooltip.setFont(LABEL_FONT);
1506 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1507 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1508 showDbRefTooltip.setSelected(true);
1510 .setText(MessageManager.getString("label.database_references"));
1511 annotations.setFont(LABEL_FONT);
1512 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1513 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1514 annotations.setSelected(true);
1515 annotations.setText(MessageManager.getString("label.show_annotations"));
1516 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1517 annotations.addActionListener(new ActionListener()
1520 public void actionPerformed(ActionEvent e)
1522 annotations_actionPerformed(e);
1525 identity.addActionListener(new ActionListener()
1528 public void actionPerformed(ActionEvent e)
1530 annotations_actionPerformed(e);
1533 showGroupConsensus.addActionListener(new ActionListener()
1536 public void actionPerformed(ActionEvent e)
1538 annotations_actionPerformed(e);
1541 showUnconserved.setFont(LABEL_FONT);
1542 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1543 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1544 showUnconserved.setSelected(true);
1546 .setText(MessageManager.getString("action.show_unconserved"));
1547 showUnconserved.addActionListener(new ActionListener()
1550 public void actionPerformed(ActionEvent e)
1552 showunconserved_actionPerformed(e);
1556 // TODO these are not yet added to / action from Preferences
1557 // JCheckBox shareSelections = new JCheckBox();
1558 // shareSelections.setFont(verdana11);
1559 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1560 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1561 // shareSelections.setSelected(true);
1562 // shareSelections.setText(MessageManager
1563 // .getString("label.share_selection_across_views"));
1564 // JCheckBox followHighlight = new JCheckBox();
1565 // followHighlight.setFont(verdana11);
1566 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1567 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1568 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1569 // followHighlight.setSelected(true);
1570 // followHighlight.setText(MessageManager
1571 // .getString("label.scroll_highlighted_regions"));
1573 seqLimit.setFont(LABEL_FONT);
1574 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1575 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1576 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1577 smoothFont.setFont(LABEL_FONT);
1578 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1579 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1580 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1581 scaleProteinToCdna.setFont(LABEL_FONT);
1582 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1583 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1584 scaleProteinToCdna.setText(
1585 MessageManager.getString("label.scale_protein_to_cdna"));
1586 scaleProteinToCdna.setToolTipText(
1587 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1588 JLabel gapLabel = new JLabel();
1589 gapLabel.setFont(LABEL_FONT);
1590 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1591 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1592 JLabel fontLabel = new JLabel();
1593 fontLabel.setFont(LABEL_FONT);
1594 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1595 fontLabel.setText(MessageManager.getString("label.font"));
1596 fontSizeCB.setFont(LABEL_FONT);
1597 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1598 fontStyleCB.setFont(LABEL_FONT);
1599 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1600 fontNameCB.setFont(LABEL_FONT);
1601 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1602 gapSymbolCB.setFont(LABEL_FONT);
1603 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1604 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1605 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1606 gapSymbolCB.setRenderer(dlcr);
1608 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1609 startupCheckbox.setFont(LABEL_FONT);
1610 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1611 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1612 startupCheckbox.setSelected(true);
1613 startupFileTextfield.setFont(LABEL_FONT);
1614 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1615 final String tooltip = JvSwingUtils.wrapTooltip(true,
1616 MessageManager.getString("label.double_click_to_browse"));
1617 startupFileTextfield.setToolTipText(tooltip);
1618 startupFileTextfield.addMouseListener(new MouseAdapter()
1621 public void mouseClicked(MouseEvent e)
1623 if (e.getClickCount() > 1)
1625 startupFileTextfield_mouseClicked();
1630 sortby.setFont(LABEL_FONT);
1631 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1632 JLabel sortLabel = new JLabel();
1633 sortLabel.setFont(LABEL_FONT);
1634 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1635 sortLabel.setText(MessageManager.getString("label.sort_by"));
1636 sortAnnBy.setFont(LABEL_FONT);
1637 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1638 JLabel sortAnnLabel = new JLabel();
1639 sortAnnLabel.setFont(LABEL_FONT);
1640 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1641 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1642 sortAutocalc.setFont(LABEL_FONT);
1643 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1645 JPanel annsettingsPanel = new JPanel();
1646 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1647 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1648 annsettingsPanel.setBorder(new EtchedBorder());
1649 visualTab.add(annsettingsPanel);
1650 Border jb = new EmptyBorder(1, 1, 4, 5);
1651 annotations.setBorder(jb);
1652 showOccupancy.setBorder(jb);
1653 quality.setBorder(jb);
1654 conservation.setBorder(jb);
1655 identity.setBorder(jb);
1656 showConsensbits.setBorder(jb);
1657 showGroupbits.setBorder(jb);
1658 showGroupConsensus.setBorder(jb);
1659 showGroupConservation.setBorder(jb);
1660 showConsensHistogram.setBorder(jb);
1661 showConsensLogo.setBorder(jb);
1663 JPanel autoAnnotSettings = new JPanel();
1664 annsettingsPanel.add(autoAnnotSettings);
1665 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1666 autoAnnotSettings.add(annotations);
1667 autoAnnotSettings.add(quality);
1668 // second row of autoannotation box
1669 autoAnnotSettings = new JPanel();
1670 annsettingsPanel.add(autoAnnotSettings);
1672 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1673 autoAnnotSettings.add(conservation);
1674 autoAnnotSettings.add(identity);
1675 autoAnnotSettings.add(showOccupancy);
1676 autoAnnotSettings.add(showGroupbits);
1677 autoAnnotSettings.add(showGroupConservation);
1678 autoAnnotSettings.add(showGroupConsensus);
1679 autoAnnotSettings.add(showConsensbits);
1680 autoAnnotSettings.add(showConsensHistogram);
1681 autoAnnotSettings.add(showConsensLogo);
1683 JPanel tooltipSettings = new JPanel();
1684 tooltipSettings.setBorder(new TitledBorder(
1685 MessageManager.getString("label.sequence_id_tooltip")));
1686 tooltipSettings.setBounds(173, 140, 220, 62);
1687 tooltipSettings.setLayout(new GridLayout(2, 1));
1688 tooltipSettings.add(showDbRefTooltip);
1689 tooltipSettings.add(showNpTooltip);
1690 visualTab.add(tooltipSettings);
1692 wrap.setFont(LABEL_FONT);
1693 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1694 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1695 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1696 rightAlign.setFont(LABEL_FONT);
1697 rightAlign.setForeground(Color.black);
1698 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1699 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1700 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1701 idItalics.setFont(LABEL_FONT_ITALIC);
1702 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1703 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1705 MessageManager.getString("label.sequence_name_italics"));
1706 openoverv.setFont(LABEL_FONT);
1707 openoverv.setActionCommand(
1708 MessageManager.getString("label.open_overview"));
1709 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1710 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1711 openoverv.setText(MessageManager.getString("label.open_overview"));
1712 JPanel jPanel2 = new JPanel();
1713 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1714 jPanel2.setLayout(new GridLayout(14, 1));
1715 jPanel2.add(fullScreen);
1716 jPanel2.add(openoverv);
1717 jPanel2.add(seqLimit);
1718 jPanel2.add(rightAlign);
1719 jPanel2.add(fontLabel);
1720 jPanel2.add(showUnconserved);
1721 jPanel2.add(idItalics);
1722 jPanel2.add(smoothFont);
1723 jPanel2.add(scaleProteinToCdna);
1724 jPanel2.add(gapLabel);
1726 jPanel2.add(sortLabel);
1727 jPanel2.add(sortAnnLabel);
1728 jPanel2.add(startupCheckbox);
1729 visualTab.add(jPanel2);
1730 visualTab.add(startupFileTextfield);
1731 visualTab.add(sortby);
1732 visualTab.add(sortAnnBy);
1733 visualTab.add(sortAutocalc);
1734 visualTab.add(gapSymbolCB);
1735 visualTab.add(fontNameCB);
1736 visualTab.add(fontSizeCB);
1737 visualTab.add(fontStyleCB);
1739 if (Platform.isJS())
1741 startupCheckbox.setVisible(false);
1742 startupFileTextfield.setVisible(false);
1749 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1752 protected void loadLastSavedBackupsOptions()
1755 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1756 setComboIntStringKey(backupfilesPresetsCombo,
1757 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1758 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1759 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1761 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1762 suffixReverse.setSelected(
1763 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1765 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1766 backupfilesRollMaxSpinner
1767 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1768 backupfilesConfirmDelete.setSelected(
1769 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1771 backupsOptionsSetEnabled();
1772 updateBackupFilesExampleLabel();
1775 private boolean warnAboutSuffixReverseChange()
1777 boolean savedSuffixReverse = Cache.getDefault(BackupFiles.REVERSE_ORDER,
1779 int savedSuffixDigits = Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3);
1780 String savedSuffixTemplate = Cache.getDefault(BackupFiles.SUFFIX,
1781 ".bak" + BackupFiles.NUM_PLACEHOLDER);
1783 boolean nowSuffixReverse = suffixReverse.isSelected();
1784 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1785 String nowSuffixTemplate = suffixTemplate.getText();
1786 return nowSuffixReverse != savedSuffixReverse
1787 && nowSuffixDigits == savedSuffixDigits
1788 && nowSuffixTemplate != null
1789 && nowSuffixTemplate.equals(savedSuffixTemplate);
1793 * Initialises the Backups tabbed panel.
1797 private JPanel initBackupsTab()
1799 JPanel backupsTab = new JPanel();
1800 backupsTab.setBorder(new TitledBorder(
1801 MessageManager.getString("label.backup_files")));
1802 backupsTab.setLayout(new GridBagLayout());
1804 GridBagConstraints gbc = new GridBagConstraints();
1807 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1808 gbc.fill = GridBagConstraints.NONE;
1810 initBackupsTabPresetsPanel();
1811 initBackupsTabSuffixPanel();
1812 initBackupsTabKeepFilesPanel();
1813 initBackupsTabFilenameExamplesPanel();
1815 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1817 .setText(MessageManager.getString("label.enable_backupfiles"));
1818 enableBackupFiles.addActionListener(new ActionListener()
1821 public void actionPerformed(ActionEvent e)
1823 // enable other options only when the first is checked
1824 backupsOptionsSetEnabled();
1829 // enable checkbox 1 col
1833 gbc.gridy = 0; // row 0
1834 backupsTab.add(enableBackupFiles, gbc);
1836 // summary of scheme box (over two rows)
1840 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1841 gbc.fill = GridBagConstraints.BOTH;
1842 backupsTab.add(exampleFilesPanel, gbc);
1844 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1845 gbc.fill = GridBagConstraints.NONE;
1847 // fill empty space on right
1850 backupsTab.add(new JPanel(), gbc);
1855 gbc.gridy++; // row 1
1856 backupsTab.add(presetsPanel, gbc);
1858 // gbc.anchor = GridBagConstraints.NORTHWEST;
1859 // now using whole row
1864 gbc.gridy++; // row 2
1865 backupsTab.add(keepfilesPanel, gbc);
1867 // filename strategy box
1868 gbc.gridy++; // row 3
1869 backupsTab.add(suffixPanel, gbc);
1872 gbc.gridy++; // row 4
1874 backupsTab.add(new JPanel(), gbc);
1876 backupsOptionsSetEnabled();
1880 protected static final int BACKUPFILESSCHEMECUSTOMISE = 0;
1882 private static final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1883 new IntKeyStringValueEntry(1,
1884 MessageManager.getString("label.default")),
1885 new IntKeyStringValueEntry(2,
1886 MessageManager.getString("label.single_file")),
1887 new IntKeyStringValueEntry(3,
1888 MessageManager.getString("label.keep_all_versions")),
1889 new IntKeyStringValueEntry(4,
1890 MessageManager.getString("label.rolled_backups")),
1892 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1893 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1894 MessageManager.getString("label.customise")) };
1896 private static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1901 private static final long serialVersionUID = 125L;
1904 put(1, new BackupFilesPresetEntry(
1905 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1907 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1908 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1909 3, false, true, 10, true));
1910 put(4, new BackupFilesPresetEntry(
1911 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1916 private JPanel initBackupsTabPresetsPanel()
1919 String title = MessageManager.getString("label.schemes");
1920 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1921 // TitledBorder tb = new TitledBorder(title);
1922 // tb.setTitleFont(LABEL_FONT);
1923 // presetsPanel.setBorder(tb);
1925 presetsPanel.setLayout(new GridBagLayout());
1927 GridBagConstraints gbc = new GridBagConstraints();
1930 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1931 gbc.fill = GridBagConstraints.NONE;
1938 presetsPanel.add(new JLabel(title + ":"), gbc);
1940 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1942 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1945 // put "Previously saved scheme" item in italics (it's not really
1946 // selectable, as such -- it deselects itself when selected) and
1947 // "Customise" in bold
1948 backupfilesPresetsCombo
1949 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1950 backupfilesPresetsCombo.addActionListener(new ActionListener()
1953 public void actionPerformed(ActionEvent e)
1955 backupsTabUpdatePresets();
1959 // dropdown list of preset schemes
1961 presetsPanel.add(backupfilesPresetsCombo, gbc);
1963 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1964 revertButton.addActionListener(new ActionListener()
1967 public void actionPerformed(ActionEvent e)
1969 loadLastSavedBackupsOptions();
1973 revertButton.setFont(LABEL_FONT);
1975 // "Cancel changes" button (aligned with combo box above)
1978 presetsPanel.add(revertButton, gbc);
1980 return presetsPanel;
1983 private JPanel initBackupsTabFilenameExamplesPanel()
1985 String title = MessageManager
1986 .getString("label.summary_of_backups_scheme");
1987 TitledBorder tb = new TitledBorder(title);
1988 exampleFilesPanel.setBorder(tb);
1989 exampleFilesPanel.setLayout(new GridBagLayout());
1992 backupfilesExampleLabel.setEditable(false);
1993 backupfilesExampleLabel
1994 .setBackground(exampleFilesPanel.getBackground());
1996 updateBackupFilesExampleLabel();
1998 GridBagConstraints gbc = new GridBagConstraints();
2001 gbc.fill = GridBagConstraints.NONE;
2002 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2004 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2005 return exampleFilesPanel;
2008 private void backupsTabUpdatePresets()
2010 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2012 int key = entry.getKey();
2013 String value = entry.getValue();
2015 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
2016 if (key != BACKUPFILESSCHEMECUSTOMISE)
2018 if (backupfilesPresetEntriesValues.containsKey(key))
2020 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
2024 System.out.println("Preset '" + value + "' not implemented");
2028 backupfilesCustomOptionsSetEnabled();
2029 updateBackupFilesExampleLabel();
2032 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
2034 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
2035 return e != null ? e.getKey() : 0;
2038 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
2041 for (int i = 0; i < c.getItemCount(); i++)
2043 IntKeyStringValueEntry e = c.getItemAt(i);
2044 if (e.getKey() == key)
2046 c.setSelectedIndex(i);
2050 backupsTabUpdatePresets();
2053 private JPanel initBackupsTabSuffixPanel()
2055 suffixPanel.setBorder(new TitledBorder(
2056 MessageManager.getString("label.backup_filename_strategy")));
2057 suffixPanel.setLayout(new GridBagLayout());
2060 .setText(MessageManager.getString("label.append_to_filename"));
2061 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2062 suffixTemplateLabel.setFont(LABEL_FONT);
2064 final String tooltip = JvSwingUtils.wrapTooltip(true,
2065 MessageManager.getString("label.append_to_filename_tooltip"));
2066 suffixTemplate.setToolTipText(tooltip);
2067 suffixTemplate.addActionListener(new ActionListener()
2070 public void actionPerformed(ActionEvent e)
2072 updateBackupFilesExampleLabel();
2073 backupfilesCustomOptionsSetEnabled();
2077 KeyListener kl = new KeyListener()
2080 public void keyReleased(KeyEvent e)
2082 updateBackupFilesExampleLabel();
2083 backupfilesCustomOptionsSetEnabled();
2087 public void keyPressed(KeyEvent e)
2091 // disable use of ':' or '/' or '\'
2093 public void keyTyped(KeyEvent e)
2095 char c = e.getKeyChar();
2096 if (c == ':' || c == '/' || c == '\\')
2098 // don't process ':' or '/' or '\'
2104 suffixTemplate.addKeyListener(kl);
2108 .setText(MessageManager.getString("label.index_digits"));
2109 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2110 suffixDigitsLabel.setFont(LABEL_FONT);
2113 ChangeListener c = new ChangeListener()
2116 public void stateChanged(ChangeEvent e)
2118 updateBackupFilesExampleLabel();
2122 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2124 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2125 MessageManager.getString("label.increment_index"));
2126 suffixReverse.addActionListener(new ActionListener()
2129 public void actionPerformed(ActionEvent e)
2131 boolean okay = true;
2132 if (warnAboutSuffixReverseChange())
2135 okay = confirmSuffixReverseChange();
2139 updateBackupFilesExampleLabel();
2143 boolean savedSuffixReverse = Cache
2144 .getDefault(BackupFiles.REVERSE_ORDER, false);
2145 suffixReverse.setSelected(savedSuffixReverse);
2150 GridBagConstraints sgbc = new GridBagConstraints();
2152 // first row (template text box)
2153 sgbc.anchor = GridBagConstraints.WEST;
2157 sgbc.gridheight = 1;
2160 sgbc.fill = GridBagConstraints.NONE;
2161 suffixPanel.add(suffixTemplateLabel, sgbc);
2164 sgbc.fill = GridBagConstraints.HORIZONTAL;
2165 suffixPanel.add(suffixTemplate, sgbc);
2167 // second row (number of digits spinner)
2171 sgbc.fill = GridBagConstraints.NONE;
2172 suffixPanel.add(suffixDigitsLabel, sgbc);
2175 sgbc.fill = GridBagConstraints.HORIZONTAL;
2176 suffixPanel.add(suffixDigitsSpinner, sgbc);
2178 // third row (forward order radio selection)
2181 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2182 sgbc.fill = GridBagConstraints.HORIZONTAL;
2183 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2185 // fourth row (reverse order radio selection)
2187 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2191 private boolean confirmSuffixReverseChange()
2193 boolean ret = false;
2194 String warningMessage = MessageManager
2195 .getString("label.warning_confirm_change_reverse");
2196 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2198 MessageManager.getString("label.change_increment_decrement"),
2199 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2201 ret = (confirm == JvOptionPane.YES_OPTION);
2205 private JPanel initBackupsTabKeepFilesPanel()
2207 keepfilesPanel.setBorder(
2208 new TitledBorder(MessageManager.getString("label.keep_files")));
2209 keepfilesPanel.setLayout(new GridBagLayout());
2211 backupfilesKeepAll.setLabels(
2212 MessageManager.getString("label.keep_all_backup_files"),
2213 MessageManager.getString(
2214 "label.keep_only_this_number_of_backup_files"));
2215 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2218 public void actionPerformed(ActionEvent e)
2220 updateBackupFilesExampleLabel();
2223 backupfilesKeepAll.addActionListener(new ActionListener()
2226 public void actionPerformed(ActionEvent e)
2228 keepRollMaxOptionsEnabled();
2229 updateBackupFilesExampleLabel();
2233 ChangeListener c = new ChangeListener()
2236 public void stateChanged(ChangeEvent e)
2238 updateBackupFilesExampleLabel();
2242 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2244 backupfilesConfirmDelete.setLabels(
2245 MessageManager.getString("label.always_ask"),
2246 MessageManager.getString("label.auto_delete"));
2247 // update the enabled section
2248 keepRollMaxOptionsEnabled();
2250 GridBagConstraints kgbc = new GridBagConstraints();
2252 // first row (template text box)
2253 kgbc.anchor = GridBagConstraints.WEST;
2256 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2257 kgbc.gridheight = 1;
2260 kgbc.fill = GridBagConstraints.HORIZONTAL;
2261 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2267 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2268 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2271 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2272 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2274 // third row (indented)
2276 kgbc.insets = new Insets(0, 20, 0, 0);
2279 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2280 kgbc.fill = GridBagConstraints.HORIZONTAL;
2283 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2285 // fourth row (indented)
2287 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2290 JPanel jp = new JPanel();
2291 jp.setLayout(new FlowLayout());
2293 .setText(MessageManager
2294 .getString("label.autodelete_old_backup_files"));
2295 oldBackupFilesLabel.setFont(LABEL_FONT);
2296 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2297 jp.add(oldBackupFilesLabel);
2298 jp.add(backupfilesConfirmDelete.getTrueButton());
2299 jp.add(backupfilesConfirmDelete.getFalseButton());
2300 keepfilesPanel.add(jp, kgbc);
2302 return keepfilesPanel;
2305 protected void updateBackupFilesExampleLabel()
2307 int exampleindex = 12;
2308 String base = MessageManager.getString("label.filename") + ".fa";
2309 if (base == null || base.length() == 0)
2311 base = "file_name.fa";
2314 boolean reverse = suffixReverse.isSelected();
2315 boolean keepAll = backupfilesKeepAll.isSelected();
2317 String suffix = suffixTemplate.getText();
2320 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2321 if (suffix == null || suffix.length() == 0)
2323 backupfilesExampleLabel
2324 .setText(MessageManager.getString("label.no_backup_files"));
2325 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2329 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2330 rollMax = rollMax < 1 ? 1 : rollMax;
2332 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2337 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2338 digits = digits < 1 ? 1 : digits;
2340 int lowersurround = 2;
2341 int uppersurround = 0;
2342 StringBuilder exampleSB = new StringBuilder();
2343 boolean firstLine = true;
2348 int max = keepAll ? exampleindex : rollMax;
2349 for (int index = min; index <= max; index++)
2351 if (index == min + lowersurround && index < max - uppersurround - 1)
2353 exampleSB.append("\n...");
2355 else if (index > min + lowersurround && index < max - uppersurround)
2367 exampleSB.append("\n");
2369 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2370 base, suffix, digits));
2373 // no extra text needed
2375 else if (index == min)
2377 String newest = MessageManager.getString("label.braced_newest");
2378 if (newest != null && newest.length() > 0)
2380 exampleSB.append(" " + newest);
2383 else if (index == max)
2385 String oldest = MessageManager.getString("label.braced_oldest");
2386 if (oldest != null && oldest.length() > 0)
2388 exampleSB.append(" " + oldest);
2397 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2398 : exampleindex - rollMax + 1;
2399 int max = exampleindex;
2401 for (int index = min; index <= max; index++)
2404 if (index == min + lowersurround && index < max - uppersurround - 1)
2406 exampleSB.append("\n...");
2408 else if (index > min + lowersurround && index < max - uppersurround)
2420 exampleSB.append("\n");
2422 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2423 base, suffix, digits));
2426 // no extra text needed
2428 else if (index == min)
2430 String oldest = MessageManager.getString("label.braced_oldest");
2431 if (oldest != null && oldest.length() > 0)
2433 exampleSB.append(" " + oldest);
2436 else if (index == max)
2438 String newest = MessageManager.getString("label.braced_newest");
2439 if (newest != null && newest.length() > 0)
2441 exampleSB.append(" " + newest);
2449 backupfilesExampleLabel.setText(exampleSB.toString());
2452 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2453 boolean useExistingVal, ChangeListener c)
2460 i = Integer.parseInt((String) s.getValue());
2461 } catch (Exception e)
2464 "Exception casting the initial value of s.getValue()");
2468 setIntegerSpinner(s, min, max, i, c);
2471 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2474 // integer spinner for number of digits
2479 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2482 s.addChangeListener(c);
2486 protected static int getSpinnerInt(JSpinner s, int def)
2492 i = (Integer) s.getValue();
2493 } catch (Exception e)
2495 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2500 private void keepRollMaxOptionsEnabled()
2502 boolean enabled = backupfilesKeepAll.isEnabled()
2503 && !backupfilesKeepAll.isSelected();
2504 oldBackupFilesLabel.setEnabled(enabled);
2505 backupfilesRollMaxSpinner.setEnabled(enabled);
2506 backupfilesConfirmDelete.setEnabled(enabled);
2509 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2511 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2512 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2513 && suffixTemplate.getText()
2514 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2515 keepfilesPanel.setEnabled(enabled);
2516 backupfilesKeepAll.setEnabled(enabled);
2517 oldBackupFilesLabel.setEnabled(enabled);
2518 keepRollMaxOptionsEnabled();
2521 private void backupfilesSuffixTemplateDigitsSetEnabled()
2523 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2524 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2525 suffixDigitsLabel.setEnabled(enabled);
2526 suffixDigitsSpinner.setEnabled(enabled);
2527 suffixReverse.setEnabled(enabled);
2530 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2532 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2533 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2534 suffixPanel.setEnabled(enabled);
2535 suffixTemplateLabel.setEnabled(enabled);
2536 suffixTemplate.setEnabled(enabled);
2537 backupfilesSuffixTemplateDigitsSetEnabled();
2540 protected void backupfilesCustomOptionsSetEnabled()
2542 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2543 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2545 backupfilesSuffixTemplateSetEnabled(enabled);
2546 backupfilesKeepAllSetEnabled(enabled);
2549 private void backupfilesSummarySetEnabled()
2551 boolean enabled = enableBackupFiles.isSelected();
2552 backupfilesExampleLabel.setEnabled(enabled);
2553 exampleFilesPanel.setEnabled(enabled);
2556 private void backupfilesPresetsSetEnabled()
2558 boolean enabled = enableBackupFiles.isSelected();
2559 presetsPanel.setEnabled(enabled);
2560 backupfilesPresetsCombo.setEnabled(enabled);
2563 protected void backupsOptionsSetEnabled()
2565 backupfilesPresetsSetEnabled();
2566 backupfilesSummarySetEnabled();
2567 backupfilesCustomOptionsSetEnabled();
2570 protected void backupsSetOptions(String suffix, int digits,
2571 boolean reverse, boolean keepAll, int rollMax,
2572 boolean confirmDelete)
2574 suffixTemplate.setText(suffix);
2575 suffixDigitsSpinner.setValue(digits);
2576 suffixReverse.setSelected(reverse);
2577 backupfilesKeepAll.setSelected(keepAll);
2578 backupfilesRollMaxSpinner.setValue(rollMax);
2579 backupfilesConfirmDelete.setSelected(confirmDelete);
2582 protected void backupsSetOptions(BackupFilesPresetEntry p)
2584 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2588 protected void autoIdWidth_actionPerformed()
2590 // TODO Auto-generated method stub
2594 protected void userIdWidth_actionPerformed()
2596 // TODO Auto-generated method stub
2600 protected void maxColour_actionPerformed(JPanel panel)
2604 protected void minColour_actionPerformed(JPanel panel)
2608 protected void gapColour_actionPerformed(JPanel panel)
2612 protected void hiddenColour_actionPerformed(JPanel panel)
2616 protected void showunconserved_actionPerformed(ActionEvent e)
2618 // TODO Auto-generated method stub
2622 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2626 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2636 public void ok_actionPerformed(ActionEvent e)
2646 public void cancel_actionPerformed(ActionEvent e)
2656 public void annotations_actionPerformed(ActionEvent e)
2663 public void startupFileTextfield_mouseClicked()
2667 public void newLink_actionPerformed(ActionEvent e)
2672 public void editLink_actionPerformed(ActionEvent e)
2677 public void deleteLink_actionPerformed(ActionEvent e)
2682 public void defaultBrowser_mouseClicked(MouseEvent e)
2687 public void linkURLList_keyTyped(KeyEvent e)
2692 public void useProxy_actionPerformed()
2694 boolean enabled = useProxy.isSelected();
2695 portLabel.setEnabled(enabled);
2696 serverLabel.setEnabled(enabled);
2697 proxyServerTB.setEnabled(enabled);
2698 proxyPortTB.setEnabled(enabled);
2702 * Customer renderer for JTable: supports column of radio buttons
2704 public class RadioButtonRenderer extends JRadioButton
2705 implements TableCellRenderer
2707 public RadioButtonRenderer()
2709 setHorizontalAlignment(CENTER);
2710 setToolTipText(MessageManager.getString("label.urltooltip"));
2714 public Component getTableCellRendererComponent(JTable table,
2715 Object value, boolean isSelected, boolean hasFocus, int row,
2718 setSelected((boolean) value);
2720 // set colours to match rest of table
2723 setBackground(table.getSelectionBackground());
2724 setForeground(table.getSelectionForeground());
2728 setBackground(table.getBackground());
2729 setForeground(table.getForeground());
2736 * Customer cell editor for JTable: supports column of radio buttons in
2737 * conjunction with renderer
2739 public class RadioButtonEditor extends AbstractCellEditor
2740 implements TableCellEditor
2742 private JRadioButton button = new JRadioButton();
2744 public RadioButtonEditor()
2746 button.setHorizontalAlignment(SwingConstants.CENTER);
2747 this.button.addActionListener(new ActionListener()
2750 public void actionPerformed(ActionEvent e)
2752 fireEditingStopped();
2758 public Component getTableCellEditorComponent(JTable table, Object value,
2759 boolean isSelected, int row, int column)
2761 button.setSelected((boolean) value);
2766 public Object getCellEditorValue()
2768 return button.isSelected();
2774 class IntKeyStringValueEntry
2780 public IntKeyStringValueEntry(int k, String v)
2787 public String toString()
2789 return this.getValue();
2797 public String getValue()
2803 class BackupFilesPresetEntry
2815 boolean confirmDelete;
2817 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2818 boolean keepAll, int rollMax, boolean confirmDelete)
2820 this.suffix = suffix;
2821 this.digits = digits;
2822 this.reverse = reverse;
2823 this.keepAll = keepAll;
2824 this.rollMax = rollMax;
2825 this.confirmDelete = confirmDelete;
2829 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2834 private static final long serialVersionUID = 88L;
2837 public Component getListCellRendererComponent(JList list, Object value,
2838 int index, boolean isSelected, boolean cellHasFocus)
2840 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2843 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2844 if (e.getKey() == GPreferences.BACKUPFILESSCHEMECUSTOMISE)
2847 this.setFont(this.getFont().deriveFont(Font.BOLD));
2849 } catch (Exception e) {