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 tabbedPane.add(initBackupsTab(),
377 MessageManager.getString("label.backups"));
379 tabbedPane.add(initLinksTab(),
380 MessageManager.getString("label.urllinks"));
382 tabbedPane.add(initOutputTab(),
383 MessageManager.getString("label.output"));
385 tabbedPane.add(initEditingTab(),
386 MessageManager.getString("label.editing"));
389 * See WsPreferences for the real work of configuring this tab.
391 if (!Platform.isJS())
393 wsTab.setLayout(new BorderLayout());
394 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
398 * Handler to validate a tab before leaving it - currently only for
401 tabbedPane.addChangeListener(new ChangeListener()
403 private Component lastTab;
406 public void stateChanged(ChangeEvent e)
408 if (lastTab == structureTab
409 && tabbedPane.getSelectedComponent() != structureTab)
411 if (!validateStructure())
413 tabbedPane.setSelectedComponent(structureTab);
417 lastTab = tabbedPane.getSelectedComponent();
424 * Initialises the Editing tabbed panel.
428 private JPanel initEditingTab()
430 JPanel editingTab = new JPanel();
431 editingTab.setLayout(null);
432 autoCalculateConsCheck.setFont(LABEL_FONT);
433 autoCalculateConsCheck.setText(
434 MessageManager.getString("label.autocalculate_consensus"));
435 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
436 padGaps.setFont(LABEL_FONT);
438 MessageManager.getString("label.pad_gaps_when_editing"));
439 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
440 sortByTree.setFont(LABEL_FONT);
442 .setText(MessageManager.getString("label.sort_with_new_tree"));
443 sortByTree.setToolTipText(MessageManager.getString(
444 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
445 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
446 editingTab.add(autoCalculateConsCheck);
447 editingTab.add(padGaps);
448 editingTab.add(sortByTree);
453 * Initialises the Output tab
457 private JPanel initOutputTab()
459 JPanel outputTab = new JPanel();
460 outputTab.setLayout(null);
462 JLabel epsLabel = new JLabel(
463 MessageManager.formatMessage("label.rendering_style", "EPS"));
464 epsLabel.setFont(LABEL_FONT);
465 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
466 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
467 epsRendering.setFont(LABEL_FONT);
468 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
469 JLabel htmlLabel = new JLabel(
470 MessageManager.formatMessage("label.rendering_style", "HTML"));
471 htmlLabel.setFont(LABEL_FONT);
472 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
473 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
474 htmlRendering.setFont(LABEL_FONT);
475 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
476 JLabel svgLabel = new JLabel(
477 MessageManager.formatMessage("label.rendering_style", "SVG"));
478 svgLabel.setFont(LABEL_FONT);
479 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
480 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
481 svgRendering.setFont(LABEL_FONT);
482 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
484 JLabel jLabel1 = new JLabel();
485 jLabel1.setFont(LABEL_FONT);
486 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
487 jLabel1.setText(MessageManager.getString("label.append_start_end"));
488 jLabel1.setFont(LABEL_FONT);
490 fastajv.setFont(LABEL_FONT);
491 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
492 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
493 blcjv.setText(MessageManager.getString("label.blc") + " ");
494 fastajv.setText(MessageManager.getString("label.fasta") + " ");
495 msfjv.setText(MessageManager.getString("label.msf") + " ");
496 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
497 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
498 msfjv.setFont(LABEL_FONT);
499 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
500 pirjv.setText(MessageManager.getString("label.pir") + " ");
501 JPanel jPanel11 = new JPanel();
502 jPanel11.setFont(LABEL_FONT);
503 TitledBorder titledBorder2 = new TitledBorder(
504 MessageManager.getString("label.file_output"));
505 jPanel11.setBorder(titledBorder2);
506 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
507 GridLayout gridLayout3 = new GridLayout();
508 jPanel11.setLayout(gridLayout3);
509 gridLayout3.setRows(8);
510 blcjv.setFont(LABEL_FONT);
511 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
512 clustaljv.setFont(LABEL_FONT);
513 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
514 pfamjv.setFont(LABEL_FONT);
515 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
516 pileupjv.setFont(LABEL_FONT);
517 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
518 pirjv.setFont(LABEL_FONT);
519 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
520 autoIdWidth.setFont(LABEL_FONT);
522 MessageManager.getString("label.automatically_set_id_width"));
523 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
524 .getString("label.adjusts_width_generated_eps_png")));
525 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
526 autoIdWidth.addActionListener(new ActionListener()
530 public void actionPerformed(ActionEvent e)
532 autoIdWidth_actionPerformed();
535 userIdWidthlabel.setFont(LABEL_FONT);
536 userIdWidthlabel.setText(
537 MessageManager.getString("label.figure_id_column_width"));
538 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
539 .getString("label.manually_specify_width_left_column")));
540 userIdWidthlabel.setToolTipText(
541 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
542 "label.manually_specify_width_left_column")));
543 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
544 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
545 userIdWidth.setText("");
546 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
547 userIdWidth.addActionListener(new ActionListener()
551 public void actionPerformed(ActionEvent e)
553 userIdWidth_actionPerformed();
556 modellerOutput.setFont(LABEL_FONT);
558 .setText(MessageManager.getString("label.use_modeller_output"));
559 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
560 embbedBioJSON.setFont(LABEL_FONT);
561 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
562 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
564 jPanel11.add(jLabel1);
566 jPanel11.add(clustaljv);
567 jPanel11.add(fastajv);
569 jPanel11.add(pfamjv);
570 jPanel11.add(pileupjv);
572 outputTab.add(autoIdWidth);
573 outputTab.add(userIdWidth);
574 outputTab.add(userIdWidthlabel);
575 outputTab.add(modellerOutput);
576 if (!Platform.isJS())
579 * JalviewJS doesn't support Lineart option or SVG output
581 outputTab.add(embbedBioJSON);
582 outputTab.add(epsLabel);
583 outputTab.add(epsRendering);
584 outputTab.add(htmlLabel);
585 outputTab.add(htmlRendering);
586 outputTab.add(svgLabel);
587 outputTab.add(svgRendering);
589 outputTab.add(jPanel11);
594 * Initialises the Connections tabbed panel.
598 private JPanel initConnectionsTab()
600 JPanel connectTab = new JPanel();
601 connectTab.setLayout(new GridBagLayout());
603 // Label for browser text box
604 JLabel browserLabel = new JLabel();
605 browserLabel.setFont(LABEL_FONT);
606 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
607 browserLabel.setText(
608 MessageManager.getString("label.default_browser_unix"));
609 defaultBrowser.setFont(LABEL_FONT);
610 defaultBrowser.setText("");
611 final String tooltip = JvSwingUtils.wrapTooltip(true,
612 MessageManager.getString("label.double_click_to_browse"));
613 defaultBrowser.setToolTipText(tooltip);
614 defaultBrowser.addMouseListener(new MouseAdapter()
617 public void mouseClicked(MouseEvent e)
619 if (e.getClickCount() > 1)
621 defaultBrowser_mouseClicked(e);
626 JPanel proxyPanel = initConnTabProxyPanel();
627 initConnTabCheckboxes();
629 // Add default Browser text box
630 connectTab.add(browserLabel,
631 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
632 GridBagConstraints.WEST, GridBagConstraints.NONE,
633 new Insets(10, 0, 5, 5), 5, 1));
634 defaultBrowser.setFont(LABEL_FONT);
635 defaultBrowser.setText("");
637 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
638 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
639 new Insets(10, 0, 5, 10), 30, 1));
641 // Add proxy server panel
642 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
643 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
644 new Insets(10, 0, 5, 12), 4, 10));
646 // Add usage stats, version check and questionnaire checkboxes
647 connectTab.add(usagestats,
648 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
649 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
650 new Insets(0, 2, 5, 5), 70, 1));
651 connectTab.add(questionnaire,
652 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
653 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
654 new Insets(0, 2, 5, 10), 70, 1));
655 connectTab.add(versioncheck,
656 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
657 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
658 new Insets(0, 2, 5, 5), 70, 1));
660 // Add padding so the panel doesn't look ridiculous
661 JPanel spacePanel = new JPanel();
662 connectTab.add(spacePanel,
663 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
664 GridBagConstraints.WEST, GridBagConstraints.BOTH,
665 new Insets(0, 0, 0, 5), 70, 1));
671 * Initialises the Links tabbed panel.
675 private JPanel initLinksTab()
677 JPanel linkTab = new JPanel();
678 linkTab.setLayout(new GridBagLayout());
680 // Set up table for Url links
681 linkUrlTable.getTableHeader().setReorderingAllowed(false);
682 linkUrlTable.setFillsViewportHeight(true);
683 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
684 linkUrlTable.setAutoCreateRowSorter(true);
685 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
687 // adjust row height so radio buttons actually fit
688 // don't do this in the renderer, it causes the awt thread to activate
690 JRadioButton temp = new JRadioButton();
691 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
693 // Table in scrollpane so that the table is given a scrollbar
694 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
695 linkScrollPane.setBorder(null);
697 // Panel for links functionality
698 JPanel linkPanel = new JPanel(new GridBagLayout());
699 linkPanel.setBorder(new TitledBorder(
700 MessageManager.getString("label.url_linkfrom_sequence_id")));
702 // Put the Url links panel together
704 // Buttons go at top right, resizing only resizes the blank space vertically
705 JPanel buttonPanel = initLinkTabUrlButtons();
706 GridBagConstraints linkConstraints1 = new GridBagConstraints();
707 linkConstraints1.insets = new Insets(0, 0, 5, 0);
708 linkConstraints1.gridx = 0;
709 linkConstraints1.gridy = 0;
710 linkConstraints1.weightx = 1.0;
711 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
712 linkTab.add(buttonPanel, linkConstraints1);
714 // Links table goes at top left, resizing resizes the table
715 GridBagConstraints linkConstraints2 = new GridBagConstraints();
716 linkConstraints2.insets = new Insets(0, 0, 5, 5);
717 linkConstraints2.gridx = 0;
718 linkConstraints2.gridy = 1;
719 linkConstraints2.weightx = 1.0;
720 linkConstraints2.weighty = 1.0;
721 linkConstraints2.fill = GridBagConstraints.BOTH;
722 linkTab.add(linkScrollPane, linkConstraints2);
724 // Filter box and buttons goes at bottom left, resizing resizes the text box
725 JPanel filterPanel = initLinkTabFilterPanel();
726 GridBagConstraints linkConstraints3 = new GridBagConstraints();
727 linkConstraints3.insets = new Insets(0, 0, 0, 5);
728 linkConstraints3.gridx = 0;
729 linkConstraints3.gridy = 2;
730 linkConstraints3.weightx = 1.0;
731 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
732 linkTab.add(filterPanel, linkConstraints3);
737 private JPanel initLinkTabFilterPanel()
739 // Filter textbox and reset button
740 JLabel filterLabel = new JLabel(
741 MessageManager.getString("label.filter"));
742 filterLabel.setFont(LABEL_FONT);
743 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
744 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
746 filterTB.setFont(LABEL_FONT);
747 filterTB.setText("");
749 doReset.setText(MessageManager.getString("action.showall"));
750 userOnly.setText(MessageManager.getString("action.customfilter"));
752 // Panel for filter functionality
753 JPanel filterPanel = new JPanel(new GridBagLayout());
754 filterPanel.setBorder(new TitledBorder("Filter"));
755 GridBagConstraints gbc = new GridBagConstraints();
758 gbc.fill = GridBagConstraints.NONE;
759 gbc.anchor = GridBagConstraints.WEST;
761 filterPanel.add(filterLabel, gbc);
763 GridBagConstraints gbc1 = new GridBagConstraints();
766 gbc1.fill = GridBagConstraints.HORIZONTAL;
767 gbc1.anchor = GridBagConstraints.WEST;
769 filterPanel.add(filterTB, gbc1);
771 GridBagConstraints gbc2 = new GridBagConstraints();
773 gbc2.fill = GridBagConstraints.NONE;
774 gbc2.anchor = GridBagConstraints.WEST;
775 filterPanel.add(doReset, gbc2);
777 GridBagConstraints gbc3 = new GridBagConstraints();
779 gbc3.fill = GridBagConstraints.NONE;
780 gbc3.anchor = GridBagConstraints.WEST;
781 filterPanel.add(userOnly, gbc3);
786 private JPanel initLinkTabUrlButtons()
788 // Buttons for new / edit / delete Url links
789 JButton newLink = new JButton();
790 newLink.setText(MessageManager.getString("action.new"));
792 editLink.setText(MessageManager.getString("action.edit"));
794 deleteLink.setText(MessageManager.getString("action.delete"));
796 // no current selection, so initially disable delete/edit buttons
797 editLink.setEnabled(false);
798 deleteLink.setEnabled(false);
800 newLink.addActionListener(new java.awt.event.ActionListener()
803 public void actionPerformed(ActionEvent e)
805 newLink_actionPerformed(e);
809 editLink.setText(MessageManager.getString("action.edit"));
810 editLink.addActionListener(new java.awt.event.ActionListener()
813 public void actionPerformed(ActionEvent e)
815 editLink_actionPerformed(e);
819 deleteLink.setText(MessageManager.getString("action.delete"));
820 deleteLink.addActionListener(new java.awt.event.ActionListener()
823 public void actionPerformed(ActionEvent e)
825 deleteLink_actionPerformed(e);
829 JPanel buttonPanel = new JPanel(new GridBagLayout());
830 buttonPanel.setBorder(new TitledBorder("Edit links"));
831 GridBagConstraints gbc = new GridBagConstraints();
834 gbc.fill = GridBagConstraints.NONE;
835 buttonPanel.add(newLink, gbc);
837 GridBagConstraints gbc1 = new GridBagConstraints();
840 gbc1.fill = GridBagConstraints.NONE;
841 buttonPanel.add(editLink, gbc1);
843 GridBagConstraints gbc2 = new GridBagConstraints();
846 gbc2.fill = GridBagConstraints.NONE;
847 buttonPanel.add(deleteLink, gbc2);
849 GridBagConstraints gbc3 = new GridBagConstraints();
852 gbc3.fill = GridBagConstraints.HORIZONTAL;
854 JPanel spacePanel = new JPanel();
855 spacePanel.setBorder(null);
856 buttonPanel.add(spacePanel, gbc3);
862 * Initialises the proxy server panel in the Connections tab
864 * @return the proxy server panel
866 private JPanel initConnTabProxyPanel()
868 // Label for server text box
869 serverLabel.setText(MessageManager.getString("label.address"));
870 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
871 serverLabel.setFont(LABEL_FONT);
873 // Proxy server and port text boxes
874 proxyServerTB.setFont(LABEL_FONT);
875 proxyPortTB.setFont(LABEL_FONT);
877 // Label for Port text box
878 portLabel.setFont(LABEL_FONT);
879 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
880 portLabel.setText(MessageManager.getString("label.port"));
882 // Use proxy server checkbox
883 useProxy.setFont(LABEL_FONT);
884 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
885 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
886 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
887 useProxy.addActionListener(new ActionListener()
890 public void actionPerformed(ActionEvent e)
892 useProxy_actionPerformed();
896 // Make proxy server panel
897 JPanel proxyPanel = new JPanel();
898 TitledBorder titledBorder1 = new TitledBorder(
899 MessageManager.getString("label.proxy_server"));
900 proxyPanel.setBorder(titledBorder1);
901 proxyPanel.setLayout(new GridBagLayout());
902 proxyPanel.add(serverLabel,
903 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
904 GridBagConstraints.WEST, GridBagConstraints.NONE,
905 new Insets(0, 2, 2, 0), 5, 0));
906 proxyPanel.add(portLabel,
907 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
908 GridBagConstraints.WEST, GridBagConstraints.NONE,
909 new Insets(0, 0, 2, 0), 11, 0));
910 proxyPanel.add(useProxy,
911 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
912 GridBagConstraints.WEST, GridBagConstraints.NONE,
913 new Insets(0, 2, 5, 185), 2, -4));
914 proxyPanel.add(proxyPortTB,
915 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
916 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
917 new Insets(0, 2, 2, 2), 54, 1));
918 proxyPanel.add(proxyServerTB,
919 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
920 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
921 new Insets(0, 2, 2, 0), 263, 1));
927 * Initialises the checkboxes in the Connections tab
929 private void initConnTabCheckboxes()
931 // Usage stats checkbox label
933 MessageManager.getString("label.send_usage_statistics"));
934 usagestats.setFont(LABEL_FONT);
935 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
936 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
938 // Questionnaire checkbox label
939 questionnaire.setText(
940 MessageManager.getString("label.check_for_questionnaires"));
941 questionnaire.setFont(LABEL_FONT);
942 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
943 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
945 // Check for latest version checkbox label
946 versioncheck.setText(
947 MessageManager.getString("label.check_for_latest_version"));
948 versioncheck.setFont(LABEL_FONT);
949 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
950 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
954 * Initialises the parent panel which contains the tabbed sections.
958 private JPanel initOkCancelPanel()
960 JButton ok = new JButton();
961 ok.setText(MessageManager.getString("action.ok"));
962 ok.addActionListener(new ActionListener()
965 public void actionPerformed(ActionEvent e)
967 ok_actionPerformed(e);
970 JButton cancel = new JButton();
971 cancel.setText(MessageManager.getString("action.cancel"));
972 cancel.addActionListener(new ActionListener()
975 public void actionPerformed(ActionEvent e)
977 cancel_actionPerformed(e);
980 JPanel okCancelPanel = new JPanel();
981 okCancelPanel.add(ok);
982 okCancelPanel.add(cancel);
983 return okCancelPanel;
987 * Initialises the Colours tabbed panel.
991 private JPanel initColoursTab()
993 JPanel coloursTab = new JPanel();
994 coloursTab.setBorder(new TitledBorder(
995 MessageManager.getString("action.open_new_alignment")));
996 coloursTab.setLayout(new FlowLayout());
997 JLabel mincolourLabel = new JLabel();
998 mincolourLabel.setFont(LABEL_FONT);
999 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1000 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1001 minColour.setFont(LABEL_FONT);
1002 minColour.setBorder(BorderFactory.createEtchedBorder());
1003 minColour.setPreferredSize(new Dimension(40, 20));
1004 minColour.addMouseListener(new MouseAdapter()
1007 public void mousePressed(MouseEvent e)
1009 minColour_actionPerformed(minColour);
1012 JLabel maxcolourLabel = new JLabel();
1013 maxcolourLabel.setFont(LABEL_FONT);
1014 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1015 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1016 maxColour.setFont(LABEL_FONT);
1017 maxColour.setBorder(BorderFactory.createEtchedBorder());
1018 maxColour.setPreferredSize(new Dimension(40, 20));
1019 maxColour.addMouseListener(new MouseAdapter()
1022 public void mousePressed(MouseEvent e)
1024 maxColour_actionPerformed(maxColour);
1028 protColour.setFont(LABEL_FONT);
1029 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1030 JLabel protColourLabel = new JLabel();
1031 protColourLabel.setFont(LABEL_FONT);
1032 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1033 protColourLabel.setText(
1034 MessageManager.getString("label.prot_alignment_colour") + " ");
1035 JvSwingUtils.addtoLayout(coloursTab,
1037 .getString("label.default_colour_scheme_for_alignment"),
1038 protColourLabel, protColour);
1040 nucColour.setFont(LABEL_FONT);
1041 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1042 JLabel nucColourLabel = new JLabel();
1043 nucColourLabel.setFont(LABEL_FONT);
1044 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1045 nucColourLabel.setText(
1046 MessageManager.getString("label.nuc_alignment_colour") + " ");
1047 JvSwingUtils.addtoLayout(coloursTab,
1049 .getString("label.default_colour_scheme_for_alignment"),
1050 nucColourLabel, nucColour);
1052 JPanel annotationShding = new JPanel();
1053 annotationShding.setBorder(new TitledBorder(
1054 MessageManager.getString("label.annotation_shading_default")));
1055 annotationShding.setLayout(new GridLayout(1, 2));
1056 JvSwingUtils.addtoLayout(annotationShding,
1057 MessageManager.getString(
1058 "label.default_minimum_colour_annotation_shading"),
1059 mincolourLabel, minColour);
1060 JvSwingUtils.addtoLayout(annotationShding,
1061 MessageManager.getString(
1062 "label.default_maximum_colour_annotation_shading"),
1063 maxcolourLabel, maxColour);
1064 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1069 * Initialises the Overview tabbed panel.
1073 private JPanel initOverviewTab()
1075 JPanel overviewPanel = new JPanel();
1076 overviewPanel.setBorder(new TitledBorder(
1077 MessageManager.getString("label.overview_settings")));
1079 gapColour.setFont(LABEL_FONT);
1080 // fixing the border colours stops apparent colour bleed from the panel
1081 gapColour.setBorder(
1082 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1083 gapColour.setPreferredSize(new Dimension(40, 20));
1084 gapColour.addMouseListener(new MouseAdapter()
1087 public void mousePressed(MouseEvent e)
1089 gapColour_actionPerformed(gapColour);
1093 hiddenColour.setFont(LABEL_FONT);
1094 // fixing the border colours stops apparent colour bleed from the panel
1095 hiddenColour.setBorder(
1096 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1097 hiddenColour.setPreferredSize(new Dimension(40, 20));
1098 hiddenColour.addMouseListener(new MouseAdapter()
1101 public void mousePressed(MouseEvent e)
1103 hiddenColour_actionPerformed(hiddenColour);
1107 useLegacyGap = new JCheckBox(
1108 MessageManager.getString("label.ov_legacy_gap"));
1109 useLegacyGap.setFont(LABEL_FONT);
1110 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1111 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1112 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1113 gapLabel.setFont(LABEL_FONT);
1114 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1115 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1116 showHiddenAtStart = new JCheckBox(
1117 MessageManager.getString("label.ov_show_hide_default"));
1118 showHiddenAtStart.setFont(LABEL_FONT);
1119 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1120 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1121 JLabel hiddenLabel = new JLabel(
1122 MessageManager.getString("label.hidden_colour"));
1123 hiddenLabel.setFont(LABEL_FONT);
1124 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1125 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1127 useLegacyGap.addActionListener(new ActionListener()
1130 public void actionPerformed(ActionEvent e)
1132 useLegacyGaps_actionPerformed(e);
1136 overviewPanel.setLayout(new GridBagLayout());
1137 GridBagConstraints c1 = new GridBagConstraints();
1139 c1.fill = GridBagConstraints.HORIZONTAL;
1144 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1145 overviewPanel.add(useLegacyGap, c1);
1147 GridBagConstraints c2 = new GridBagConstraints();
1148 c2.fill = GridBagConstraints.HORIZONTAL;
1151 c2.insets = new Insets(0, 15, 0, 10);
1152 overviewPanel.add(gapLabel, c2);
1154 GridBagConstraints c3 = new GridBagConstraints();
1155 c3.fill = GridBagConstraints.HORIZONTAL;
1158 c3.insets = new Insets(0, 0, 0, 15);
1159 overviewPanel.add(gapColour, c3);
1161 GridBagConstraints c4 = new GridBagConstraints();
1162 c4.fill = GridBagConstraints.HORIZONTAL;
1166 overviewPanel.add(showHiddenAtStart, c4);
1168 GridBagConstraints c5 = new GridBagConstraints();
1169 c5.fill = GridBagConstraints.HORIZONTAL;
1172 c5.insets = new Insets(0, 15, 0, 10);
1173 overviewPanel.add(hiddenLabel, c5);
1175 GridBagConstraints c6 = new GridBagConstraints();
1176 c6.fill = GridBagConstraints.HORIZONTAL;
1179 c6.insets = new Insets(0, 0, 0, 15);
1180 overviewPanel.add(hiddenColour, c6);
1182 JButton resetButton = new JButton(
1183 MessageManager.getString("label.reset_to_defaults"));
1185 resetButton.addActionListener(new ActionListener()
1188 public void actionPerformed(ActionEvent e)
1190 resetOvDefaults_actionPerformed(e);
1194 GridBagConstraints c7 = new GridBagConstraints();
1195 c7.fill = GridBagConstraints.NONE;
1198 c7.insets = new Insets(10, 0, 0, 0);
1199 c7.anchor = GridBagConstraints.WEST;
1200 overviewPanel.add(resetButton, c7);
1202 // Add padding so the panel doesn't look ridiculous
1203 JPanel spacePanel = new JPanel();
1204 overviewPanel.add(spacePanel,
1205 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1206 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1207 new Insets(0, 0, 0, 5), 0, 0));
1209 return overviewPanel;
1213 * Initialises the Structure tabbed panel.
1217 private JPanel initStructureTab()
1219 structureTab = new JPanel();
1221 structureTab.setBorder(new TitledBorder(
1222 MessageManager.getString("label.structure_options")));
1223 structureTab.setLayout(null);
1224 final int width = 400;
1225 final int height = 22;
1226 final int lineSpacing = 25;
1229 structFromPdb.setFont(LABEL_FONT);
1231 .setText(MessageManager.getString("label.struct_from_pdb"));
1232 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1233 structFromPdb.addActionListener(new ActionListener()
1236 public void actionPerformed(ActionEvent e)
1238 boolean selected = structFromPdb.isSelected();
1239 // enable other options only when the first is checked
1240 useRnaView.setEnabled(selected);
1241 addSecondaryStructure.setEnabled(selected);
1242 addTempFactor.setEnabled(selected);
1245 structureTab.add(structFromPdb);
1247 // indent checkboxes that are conditional on the first one
1248 ypos += lineSpacing;
1249 useRnaView.setFont(LABEL_FONT);
1250 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1251 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1252 structureTab.add(useRnaView);
1254 ypos += lineSpacing;
1255 addSecondaryStructure.setFont(LABEL_FONT);
1256 addSecondaryStructure
1257 .setText(MessageManager.getString("label.autoadd_secstr"));
1258 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1259 structureTab.add(addSecondaryStructure);
1261 ypos += lineSpacing;
1262 addTempFactor.setFont(LABEL_FONT);
1263 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1264 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1265 structureTab.add(addTempFactor);
1267 ypos += lineSpacing;
1268 JLabel viewerLabel = new JLabel();
1269 viewerLabel.setFont(LABEL_FONT);
1270 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1271 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1272 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1273 structureTab.add(viewerLabel);
1275 structViewer.setFont(LABEL_FONT);
1276 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1277 structViewer.addItem(ViewerType.JMOL.name());
1278 structViewer.addItem(ViewerType.CHIMERA.name());
1279 structViewer.addActionListener(new ActionListener()
1282 public void actionPerformed(ActionEvent e)
1284 structureViewer_actionPerformed(
1285 (String) structViewer.getSelectedItem());
1288 structureTab.add(structViewer);
1290 ypos += lineSpacing;
1291 JLabel pathLabel = new JLabel();
1292 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1293 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1294 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1295 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1296 structureTab.add(pathLabel);
1298 chimeraPath.setFont(LABEL_FONT);
1299 chimeraPath.setText("");
1300 final String tooltip = JvSwingUtils.wrapTooltip(true,
1301 MessageManager.getString("label.chimera_path_tip"));
1302 chimeraPath.setToolTipText(tooltip);
1303 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1304 chimeraPath.addMouseListener(new MouseAdapter()
1307 public void mouseClicked(MouseEvent e)
1309 if (e.getClickCount() == 2)
1311 String chosen = openFileChooser();
1314 chimeraPath.setText(chosen);
1319 structureTab.add(chimeraPath);
1321 ypos += lineSpacing;
1322 nwMapping.setFont(LABEL_FONT);
1323 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1324 siftsMapping.setFont(LABEL_FONT);
1325 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1326 mappingMethod.add(nwMapping);
1327 mappingMethod.add(siftsMapping);
1328 JPanel mappingPanel = new JPanel();
1329 mappingPanel.setFont(LABEL_FONT);
1330 TitledBorder mmTitledBorder = new TitledBorder(
1331 MessageManager.getString("label.mapping_method"));
1332 mmTitledBorder.setTitleFont(LABEL_FONT);
1333 mappingPanel.setBorder(mmTitledBorder);
1334 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1335 // GridLayout mappingLayout = new GridLayout();
1336 mappingPanel.setLayout(new GridLayout());
1337 mappingPanel.add(nwMapping);
1338 mappingPanel.add(siftsMapping);
1339 structureTab.add(mappingPanel);
1341 ypos += lineSpacing;
1342 ypos += lineSpacing;
1343 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1344 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1345 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1346 structureTab.add(docFieldPref);
1349 * hide Chimera options in JalviewJS
1351 if (Platform.isJS())
1353 pathLabel.setVisible(false);
1354 chimeraPath.setVisible(false);
1355 viewerLabel.setVisible(false);
1356 structViewer.setVisible(false);
1359 return structureTab;
1363 * Action on choosing a structure viewer from combobox options.
1365 * @param selectedItem
1367 protected void structureViewer_actionPerformed(String selectedItem)
1372 * Show a dialog for the user to choose a file. Returns the chosen path, or
1377 protected String openFileChooser()
1379 String choice = null;
1380 JFileChooser chooser = new JFileChooser();
1382 // chooser.setFileView(new JalviewFileView());
1383 chooser.setDialogTitle(
1384 MessageManager.getString("label.open_local_file"));
1385 chooser.setToolTipText(MessageManager.getString("action.open"));
1387 int value = chooser.showOpenDialog(this);
1389 if (value == JFileChooser.APPROVE_OPTION)
1391 choice = chooser.getSelectedFile().getPath();
1397 * Validate the structure tab preferences; if invalid, set focus on this tab.
1401 protected boolean validateStructure(FocusEvent e)
1403 if (!validateStructure())
1405 e.getComponent().requestFocusInWindow();
1411 protected boolean validateStructure()
1417 * Initialises the Visual tabbed panel.
1421 private JPanel initVisualTab()
1423 JPanel visualTab = new JPanel();
1424 visualTab.setBorder(new TitledBorder(
1425 MessageManager.getString("action.open_new_alignment")));
1426 visualTab.setLayout(null);
1427 fullScreen.setFont(LABEL_FONT);
1428 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1429 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1430 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1431 quality.setEnabled(false);
1432 quality.setFont(LABEL_FONT);
1433 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1434 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1435 quality.setSelected(true);
1436 quality.setText(MessageManager.getString("label.quality"));
1437 conservation.setEnabled(false);
1438 conservation.setFont(LABEL_FONT);
1439 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1440 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1441 conservation.setSelected(true);
1442 conservation.setText(MessageManager.getString("label.conservation"));
1443 identity.setEnabled(false);
1444 identity.setFont(LABEL_FONT);
1445 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1446 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1447 identity.setSelected(true);
1448 identity.setText(MessageManager.getString("label.consensus"));
1449 showOccupancy.setFont(LABEL_FONT);
1450 showOccupancy.setEnabled(false);
1451 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1452 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1453 showOccupancy.setSelected(true);
1454 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1456 JLabel showGroupbits = new JLabel();
1457 showGroupbits.setFont(LABEL_FONT);
1458 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1459 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1461 .setText(MessageManager.getString("action.show_group") + ":");
1462 JLabel showConsensbits = new JLabel();
1463 showConsensbits.setFont(LABEL_FONT);
1464 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1465 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1467 .setText(MessageManager.getString("label.consensus") + ":");
1468 showConsensHistogram.setEnabled(false);
1469 showConsensHistogram.setFont(LABEL_FONT);
1470 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1471 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1472 showConsensHistogram.setSelected(true);
1473 showConsensHistogram
1474 .setText(MessageManager.getString("label.histogram"));
1475 showConsensLogo.setEnabled(false);
1476 showConsensLogo.setFont(LABEL_FONT);
1477 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1478 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1479 showConsensLogo.setSelected(true);
1480 showConsensLogo.setText(MessageManager.getString("label.logo"));
1481 showGroupConsensus.setEnabled(false);
1482 showGroupConsensus.setFont(LABEL_FONT);
1483 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1484 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1485 showGroupConsensus.setSelected(true);
1486 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1487 showGroupConservation.setEnabled(false);
1488 showGroupConservation.setFont(LABEL_FONT);
1489 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1490 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1491 showGroupConservation.setSelected(true);
1492 showGroupConservation
1493 .setText(MessageManager.getString("label.conservation"));
1494 showNpTooltip.setEnabled(true);
1495 showNpTooltip.setFont(LABEL_FONT);
1496 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1497 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1498 showNpTooltip.setSelected(true);
1499 showNpTooltip.setText(
1500 MessageManager.getString("label.non_positional_features"));
1501 showDbRefTooltip.setEnabled(true);
1502 showDbRefTooltip.setFont(LABEL_FONT);
1503 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1504 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1505 showDbRefTooltip.setSelected(true);
1507 .setText(MessageManager.getString("label.database_references"));
1508 annotations.setFont(LABEL_FONT);
1509 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1510 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1511 annotations.setSelected(true);
1512 annotations.setText(MessageManager.getString("label.show_annotations"));
1513 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1514 annotations.addActionListener(new ActionListener()
1517 public void actionPerformed(ActionEvent e)
1519 annotations_actionPerformed(e);
1522 identity.addActionListener(new ActionListener()
1525 public void actionPerformed(ActionEvent e)
1527 annotations_actionPerformed(e);
1530 showGroupConsensus.addActionListener(new ActionListener()
1533 public void actionPerformed(ActionEvent e)
1535 annotations_actionPerformed(e);
1538 showUnconserved.setFont(LABEL_FONT);
1539 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1540 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1541 showUnconserved.setSelected(true);
1543 .setText(MessageManager.getString("action.show_unconserved"));
1544 showUnconserved.addActionListener(new ActionListener()
1547 public void actionPerformed(ActionEvent e)
1549 showunconserved_actionPerformed(e);
1553 // TODO these are not yet added to / action from Preferences
1554 // JCheckBox shareSelections = new JCheckBox();
1555 // shareSelections.setFont(verdana11);
1556 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1557 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1558 // shareSelections.setSelected(true);
1559 // shareSelections.setText(MessageManager
1560 // .getString("label.share_selection_across_views"));
1561 // JCheckBox followHighlight = new JCheckBox();
1562 // followHighlight.setFont(verdana11);
1563 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1564 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1565 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1566 // followHighlight.setSelected(true);
1567 // followHighlight.setText(MessageManager
1568 // .getString("label.scroll_highlighted_regions"));
1570 seqLimit.setFont(LABEL_FONT);
1571 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1572 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1573 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1574 smoothFont.setFont(LABEL_FONT);
1575 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1576 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1577 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1578 scaleProteinToCdna.setFont(LABEL_FONT);
1579 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1580 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1581 scaleProteinToCdna.setText(
1582 MessageManager.getString("label.scale_protein_to_cdna"));
1583 scaleProteinToCdna.setToolTipText(
1584 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1585 JLabel gapLabel = new JLabel();
1586 gapLabel.setFont(LABEL_FONT);
1587 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1588 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1589 JLabel fontLabel = new JLabel();
1590 fontLabel.setFont(LABEL_FONT);
1591 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1592 fontLabel.setText(MessageManager.getString("label.font"));
1593 fontSizeCB.setFont(LABEL_FONT);
1594 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1595 fontStyleCB.setFont(LABEL_FONT);
1596 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1597 fontNameCB.setFont(LABEL_FONT);
1598 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1599 gapSymbolCB.setFont(LABEL_FONT);
1600 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1601 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1602 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1603 gapSymbolCB.setRenderer(dlcr);
1605 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1606 startupCheckbox.setFont(LABEL_FONT);
1607 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1608 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1609 startupCheckbox.setSelected(true);
1610 startupFileTextfield.setFont(LABEL_FONT);
1611 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1612 final String tooltip = JvSwingUtils.wrapTooltip(true,
1613 MessageManager.getString("label.double_click_to_browse"));
1614 startupFileTextfield.setToolTipText(tooltip);
1615 startupFileTextfield.addMouseListener(new MouseAdapter()
1618 public void mouseClicked(MouseEvent e)
1620 if (e.getClickCount() > 1)
1622 startupFileTextfield_mouseClicked();
1627 sortby.setFont(LABEL_FONT);
1628 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1629 JLabel sortLabel = new JLabel();
1630 sortLabel.setFont(LABEL_FONT);
1631 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1632 sortLabel.setText(MessageManager.getString("label.sort_by"));
1633 sortAnnBy.setFont(LABEL_FONT);
1634 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1635 JLabel sortAnnLabel = new JLabel();
1636 sortAnnLabel.setFont(LABEL_FONT);
1637 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1638 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1639 sortAutocalc.setFont(LABEL_FONT);
1640 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1642 JPanel annsettingsPanel = new JPanel();
1643 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1644 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1645 annsettingsPanel.setBorder(new EtchedBorder());
1646 visualTab.add(annsettingsPanel);
1647 Border jb = new EmptyBorder(1, 1, 4, 5);
1648 annotations.setBorder(jb);
1649 showOccupancy.setBorder(jb);
1650 quality.setBorder(jb);
1651 conservation.setBorder(jb);
1652 identity.setBorder(jb);
1653 showConsensbits.setBorder(jb);
1654 showGroupbits.setBorder(jb);
1655 showGroupConsensus.setBorder(jb);
1656 showGroupConservation.setBorder(jb);
1657 showConsensHistogram.setBorder(jb);
1658 showConsensLogo.setBorder(jb);
1660 JPanel autoAnnotSettings = new JPanel();
1661 annsettingsPanel.add(autoAnnotSettings);
1662 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1663 autoAnnotSettings.add(annotations);
1664 autoAnnotSettings.add(quality);
1665 // second row of autoannotation box
1666 autoAnnotSettings = new JPanel();
1667 annsettingsPanel.add(autoAnnotSettings);
1669 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1670 autoAnnotSettings.add(conservation);
1671 autoAnnotSettings.add(identity);
1672 autoAnnotSettings.add(showOccupancy);
1673 autoAnnotSettings.add(showGroupbits);
1674 autoAnnotSettings.add(showGroupConservation);
1675 autoAnnotSettings.add(showGroupConsensus);
1676 autoAnnotSettings.add(showConsensbits);
1677 autoAnnotSettings.add(showConsensHistogram);
1678 autoAnnotSettings.add(showConsensLogo);
1680 JPanel tooltipSettings = new JPanel();
1681 tooltipSettings.setBorder(new TitledBorder(
1682 MessageManager.getString("label.sequence_id_tooltip")));
1683 tooltipSettings.setBounds(173, 140, 220, 62);
1684 tooltipSettings.setLayout(new GridLayout(2, 1));
1685 tooltipSettings.add(showDbRefTooltip);
1686 tooltipSettings.add(showNpTooltip);
1687 visualTab.add(tooltipSettings);
1689 wrap.setFont(LABEL_FONT);
1690 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1691 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1692 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1693 rightAlign.setFont(LABEL_FONT);
1694 rightAlign.setForeground(Color.black);
1695 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1696 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1697 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1698 idItalics.setFont(LABEL_FONT_ITALIC);
1699 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1700 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1702 MessageManager.getString("label.sequence_name_italics"));
1703 openoverv.setFont(LABEL_FONT);
1704 openoverv.setActionCommand(
1705 MessageManager.getString("label.open_overview"));
1706 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1707 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1708 openoverv.setText(MessageManager.getString("label.open_overview"));
1709 JPanel jPanel2 = new JPanel();
1710 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1711 jPanel2.setLayout(new GridLayout(14, 1));
1712 jPanel2.add(fullScreen);
1713 jPanel2.add(openoverv);
1714 jPanel2.add(seqLimit);
1715 jPanel2.add(rightAlign);
1716 jPanel2.add(fontLabel);
1717 jPanel2.add(showUnconserved);
1718 jPanel2.add(idItalics);
1719 jPanel2.add(smoothFont);
1720 jPanel2.add(scaleProteinToCdna);
1721 jPanel2.add(gapLabel);
1723 jPanel2.add(sortLabel);
1724 jPanel2.add(sortAnnLabel);
1725 jPanel2.add(startupCheckbox);
1726 visualTab.add(jPanel2);
1727 visualTab.add(startupFileTextfield);
1728 visualTab.add(sortby);
1729 visualTab.add(sortAnnBy);
1730 visualTab.add(sortAutocalc);
1731 visualTab.add(gapSymbolCB);
1732 visualTab.add(fontNameCB);
1733 visualTab.add(fontSizeCB);
1734 visualTab.add(fontStyleCB);
1736 if (Platform.isJS())
1738 startupCheckbox.setVisible(false);
1739 startupFileTextfield.setVisible(false);
1746 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1749 protected void loadLastSavedBackupsOptions()
1752 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1753 setComboIntStringKey(backupfilesPresetsCombo,
1754 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1755 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1756 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1758 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1759 suffixReverse.setSelected(
1760 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1762 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1763 backupfilesRollMaxSpinner
1764 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1765 backupfilesConfirmDelete.setSelected(
1766 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1768 backupsOptionsSetEnabled();
1769 updateBackupFilesExampleLabel();
1772 private boolean warnAboutSuffixReverseChange()
1774 boolean savedSuffixReverse = Cache.getDefault(BackupFiles.REVERSE_ORDER,
1776 int savedSuffixDigits = Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3);
1777 String savedSuffixTemplate = Cache.getDefault(BackupFiles.SUFFIX,
1778 ".bak" + BackupFiles.NUM_PLACEHOLDER);
1780 boolean nowSuffixReverse = suffixReverse.isSelected();
1781 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1782 String nowSuffixTemplate = suffixTemplate.getText();
1783 return nowSuffixReverse != savedSuffixReverse
1784 && nowSuffixDigits == savedSuffixDigits
1785 && nowSuffixTemplate != null
1786 && nowSuffixTemplate.equals(savedSuffixTemplate);
1790 * Initialises the Backups tabbed panel.
1794 private JPanel initBackupsTab()
1796 JPanel backupsTab = new JPanel();
1797 backupsTab.setBorder(new TitledBorder(
1798 MessageManager.getString("label.backup_files")));
1799 backupsTab.setLayout(new GridBagLayout());
1801 GridBagConstraints gbc = new GridBagConstraints();
1804 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1805 gbc.fill = GridBagConstraints.NONE;
1807 initBackupsTabPresetsPanel();
1808 initBackupsTabSuffixPanel();
1809 initBackupsTabKeepFilesPanel();
1810 initBackupsTabFilenameExamplesPanel();
1812 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1814 .setText(MessageManager.getString("label.enable_backupfiles"));
1815 enableBackupFiles.addActionListener(new ActionListener()
1818 public void actionPerformed(ActionEvent e)
1820 // enable other options only when the first is checked
1821 backupsOptionsSetEnabled();
1826 // enable checkbox 1 col
1830 gbc.gridy = 0; // row 0
1831 backupsTab.add(enableBackupFiles, gbc);
1833 // summary of scheme box (over two rows)
1837 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1838 gbc.fill = GridBagConstraints.BOTH;
1839 backupsTab.add(exampleFilesPanel, gbc);
1841 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1842 gbc.fill = GridBagConstraints.NONE;
1844 // fill empty space on right
1847 backupsTab.add(new JPanel(), gbc);
1852 gbc.gridy++; // row 1
1853 backupsTab.add(presetsPanel, gbc);
1855 // gbc.anchor = GridBagConstraints.NORTHWEST;
1856 // now using whole row
1861 gbc.gridy++; // row 2
1862 backupsTab.add(keepfilesPanel, gbc);
1864 // filename strategy box
1865 gbc.gridy++; // row 3
1866 backupsTab.add(suffixPanel, gbc);
1869 gbc.gridy++; // row 4
1871 backupsTab.add(new JPanel(), gbc);
1873 backupsOptionsSetEnabled();
1877 protected static final int BACKUPFILESSCHEMECUSTOMISE = 0;
1879 private static final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1880 new IntKeyStringValueEntry(1,
1881 MessageManager.getString("label.default")),
1882 new IntKeyStringValueEntry(2,
1883 MessageManager.getString("label.single_file")),
1884 new IntKeyStringValueEntry(3,
1885 MessageManager.getString("label.keep_all_versions")),
1886 new IntKeyStringValueEntry(4,
1887 MessageManager.getString("label.rolled_backups")),
1889 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1890 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1891 MessageManager.getString("label.customise")) };
1893 private static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1898 private static final long serialVersionUID = 125L;
1901 put(1, new BackupFilesPresetEntry(
1902 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1904 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1905 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1906 3, false, true, 10, true));
1907 put(4, new BackupFilesPresetEntry(
1908 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1913 private JPanel initBackupsTabPresetsPanel()
1916 String title = MessageManager.getString("label.schemes");
1917 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1918 // TitledBorder tb = new TitledBorder(title);
1919 // tb.setTitleFont(LABEL_FONT);
1920 // presetsPanel.setBorder(tb);
1922 presetsPanel.setLayout(new GridBagLayout());
1924 GridBagConstraints gbc = new GridBagConstraints();
1927 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1928 gbc.fill = GridBagConstraints.NONE;
1935 presetsPanel.add(new JLabel(title + ":"), gbc);
1937 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1939 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1942 // put "Previously saved scheme" item in italics (it's not really
1943 // selectable, as such -- it deselects itself when selected) and
1944 // "Customise" in bold
1945 backupfilesPresetsCombo
1946 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1947 backupfilesPresetsCombo.addActionListener(new ActionListener()
1950 public void actionPerformed(ActionEvent e)
1952 backupsTabUpdatePresets();
1956 // dropdown list of preset schemes
1958 presetsPanel.add(backupfilesPresetsCombo, gbc);
1960 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1961 revertButton.addActionListener(new ActionListener()
1964 public void actionPerformed(ActionEvent e)
1966 loadLastSavedBackupsOptions();
1970 revertButton.setFont(LABEL_FONT);
1972 // "Cancel changes" button (aligned with combo box above)
1975 presetsPanel.add(revertButton, gbc);
1977 return presetsPanel;
1980 private JPanel initBackupsTabFilenameExamplesPanel()
1982 String title = MessageManager
1983 .getString("label.summary_of_backups_scheme");
1984 TitledBorder tb = new TitledBorder(title);
1985 exampleFilesPanel.setBorder(tb);
1986 exampleFilesPanel.setLayout(new GridBagLayout());
1989 backupfilesExampleLabel.setEditable(false);
1990 backupfilesExampleLabel
1991 .setBackground(exampleFilesPanel.getBackground());
1993 updateBackupFilesExampleLabel();
1995 GridBagConstraints gbc = new GridBagConstraints();
1998 gbc.fill = GridBagConstraints.NONE;
1999 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2001 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2002 return exampleFilesPanel;
2005 private void backupsTabUpdatePresets()
2007 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2009 int key = entry.getKey();
2010 String value = entry.getValue();
2012 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
2013 if (key != BACKUPFILESSCHEMECUSTOMISE)
2015 if (backupfilesPresetEntriesValues.containsKey(key))
2017 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
2021 System.out.println("Preset '" + value + "' not implemented");
2025 backupfilesCustomOptionsSetEnabled();
2026 updateBackupFilesExampleLabel();
2029 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
2031 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
2032 return e != null ? e.getKey() : 0;
2035 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
2038 for (int i = 0; i < c.getItemCount(); i++)
2040 IntKeyStringValueEntry e = c.getItemAt(i);
2041 if (e.getKey() == key)
2043 c.setSelectedIndex(i);
2047 backupsTabUpdatePresets();
2050 private JPanel initBackupsTabSuffixPanel()
2052 suffixPanel.setBorder(new TitledBorder(
2053 MessageManager.getString("label.backup_filename_strategy")));
2054 suffixPanel.setLayout(new GridBagLayout());
2057 .setText(MessageManager.getString("label.append_to_filename"));
2058 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2059 suffixTemplateLabel.setFont(LABEL_FONT);
2061 final String tooltip = JvSwingUtils.wrapTooltip(true,
2062 MessageManager.getString("label.append_to_filename_tooltip"));
2063 suffixTemplate.setToolTipText(tooltip);
2064 suffixTemplate.addActionListener(new ActionListener()
2067 public void actionPerformed(ActionEvent e)
2069 updateBackupFilesExampleLabel();
2070 backupfilesCustomOptionsSetEnabled();
2074 KeyListener kl = new KeyListener()
2077 public void keyReleased(KeyEvent e)
2079 updateBackupFilesExampleLabel();
2080 backupfilesCustomOptionsSetEnabled();
2084 public void keyPressed(KeyEvent e)
2088 // disable use of ':' or '/' or '\'
2090 public void keyTyped(KeyEvent e)
2092 char c = e.getKeyChar();
2093 if (c == ':' || c == '/' || c == '\\')
2095 // don't process ':' or '/' or '\'
2101 suffixTemplate.addKeyListener(kl);
2105 .setText(MessageManager.getString("label.index_digits"));
2106 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2107 suffixDigitsLabel.setFont(LABEL_FONT);
2110 ChangeListener c = new ChangeListener()
2113 public void stateChanged(ChangeEvent e)
2115 updateBackupFilesExampleLabel();
2119 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2121 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2122 MessageManager.getString("label.increment_index"));
2123 suffixReverse.addActionListener(new ActionListener()
2126 public void actionPerformed(ActionEvent e)
2128 boolean okay = true;
2129 if (warnAboutSuffixReverseChange())
2132 okay = confirmSuffixReverseChange();
2136 updateBackupFilesExampleLabel();
2140 boolean savedSuffixReverse = Cache
2141 .getDefault(BackupFiles.REVERSE_ORDER, false);
2142 suffixReverse.setSelected(savedSuffixReverse);
2147 GridBagConstraints sgbc = new GridBagConstraints();
2149 // first row (template text box)
2150 sgbc.anchor = GridBagConstraints.WEST;
2154 sgbc.gridheight = 1;
2157 sgbc.fill = GridBagConstraints.NONE;
2158 suffixPanel.add(suffixTemplateLabel, sgbc);
2161 sgbc.fill = GridBagConstraints.HORIZONTAL;
2162 suffixPanel.add(suffixTemplate, sgbc);
2164 // second row (number of digits spinner)
2168 sgbc.fill = GridBagConstraints.NONE;
2169 suffixPanel.add(suffixDigitsLabel, sgbc);
2172 sgbc.fill = GridBagConstraints.HORIZONTAL;
2173 suffixPanel.add(suffixDigitsSpinner, sgbc);
2175 // third row (forward order radio selection)
2178 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2179 sgbc.fill = GridBagConstraints.HORIZONTAL;
2180 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2182 // fourth row (reverse order radio selection)
2184 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2188 private boolean confirmSuffixReverseChange()
2190 boolean ret = false;
2191 String warningMessage = MessageManager
2192 .getString("label.warning_confirm_change_reverse");
2193 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2195 MessageManager.getString("label.change_increment_decrement"),
2196 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2198 ret = (confirm == JvOptionPane.YES_OPTION);
2202 private JPanel initBackupsTabKeepFilesPanel()
2204 keepfilesPanel.setBorder(
2205 new TitledBorder(MessageManager.getString("label.keep_files")));
2206 keepfilesPanel.setLayout(new GridBagLayout());
2208 backupfilesKeepAll.setLabels(
2209 MessageManager.getString("label.keep_all_backup_files"),
2210 MessageManager.getString(
2211 "label.keep_only_this_number_of_backup_files"));
2212 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2215 public void actionPerformed(ActionEvent e)
2217 updateBackupFilesExampleLabel();
2220 backupfilesKeepAll.addActionListener(new ActionListener()
2223 public void actionPerformed(ActionEvent e)
2225 keepRollMaxOptionsEnabled();
2226 updateBackupFilesExampleLabel();
2230 ChangeListener c = new ChangeListener()
2233 public void stateChanged(ChangeEvent e)
2235 updateBackupFilesExampleLabel();
2239 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2241 backupfilesConfirmDelete.setLabels(
2242 MessageManager.getString("label.always_ask"),
2243 MessageManager.getString("label.auto_delete"));
2244 // update the enabled section
2245 keepRollMaxOptionsEnabled();
2247 GridBagConstraints kgbc = new GridBagConstraints();
2249 // first row (template text box)
2250 kgbc.anchor = GridBagConstraints.WEST;
2253 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2254 kgbc.gridheight = 1;
2257 kgbc.fill = GridBagConstraints.HORIZONTAL;
2258 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2264 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2265 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2268 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2269 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2271 // third row (indented)
2273 kgbc.insets = new Insets(0, 20, 0, 0);
2276 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2277 kgbc.fill = GridBagConstraints.HORIZONTAL;
2280 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2282 // fourth row (indented)
2284 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2287 JPanel jp = new JPanel();
2288 jp.setLayout(new FlowLayout());
2290 .setText(MessageManager
2291 .getString("label.autodelete_old_backup_files"));
2292 oldBackupFilesLabel.setFont(LABEL_FONT);
2293 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2294 jp.add(oldBackupFilesLabel);
2295 jp.add(backupfilesConfirmDelete.getTrueButton());
2296 jp.add(backupfilesConfirmDelete.getFalseButton());
2297 keepfilesPanel.add(jp, kgbc);
2299 return keepfilesPanel;
2302 protected void updateBackupFilesExampleLabel()
2304 int exampleindex = 12;
2305 String base = MessageManager.getString("label.filename") + ".fa";
2306 if (base == null || base.length() == 0)
2308 base = "file_name.fa";
2311 boolean reverse = suffixReverse.isSelected();
2312 boolean keepAll = backupfilesKeepAll.isSelected();
2314 String suffix = suffixTemplate.getText();
2317 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2318 if (suffix == null || suffix.length() == 0)
2320 backupfilesExampleLabel
2321 .setText(MessageManager.getString("label.no_backup_files"));
2322 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2326 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2327 rollMax = rollMax < 1 ? 1 : rollMax;
2329 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2334 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2335 digits = digits < 1 ? 1 : digits;
2337 int lowersurround = 2;
2338 int uppersurround = 0;
2339 StringBuilder exampleSB = new StringBuilder();
2340 boolean firstLine = true;
2345 int max = keepAll ? exampleindex : rollMax;
2346 for (int index = min; index <= max; index++)
2348 if (index == min + lowersurround && index < max - uppersurround - 1)
2350 exampleSB.append("\n...");
2352 else if (index > min + lowersurround && index < max - uppersurround)
2364 exampleSB.append("\n");
2366 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2367 base, suffix, digits));
2370 // no extra text needed
2372 else if (index == min)
2374 String newest = MessageManager.getString("label.braced_newest");
2375 if (newest != null && newest.length() > 0)
2377 exampleSB.append(" " + newest);
2380 else if (index == max)
2382 String oldest = MessageManager.getString("label.braced_oldest");
2383 if (oldest != null && oldest.length() > 0)
2385 exampleSB.append(" " + oldest);
2394 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2395 : exampleindex - rollMax + 1;
2396 int max = exampleindex;
2398 for (int index = min; index <= max; index++)
2401 if (index == min + lowersurround && index < max - uppersurround - 1)
2403 exampleSB.append("\n...");
2405 else if (index > min + lowersurround && index < max - uppersurround)
2417 exampleSB.append("\n");
2419 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2420 base, suffix, digits));
2423 // no extra text needed
2425 else if (index == min)
2427 String oldest = MessageManager.getString("label.braced_oldest");
2428 if (oldest != null && oldest.length() > 0)
2430 exampleSB.append(" " + oldest);
2433 else if (index == max)
2435 String newest = MessageManager.getString("label.braced_newest");
2436 if (newest != null && newest.length() > 0)
2438 exampleSB.append(" " + newest);
2446 backupfilesExampleLabel.setText(exampleSB.toString());
2449 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2450 boolean useExistingVal, ChangeListener c)
2457 i = Integer.parseInt((String) s.getValue());
2458 } catch (Exception e)
2461 "Exception casting the initial value of s.getValue()");
2465 setIntegerSpinner(s, min, max, i, c);
2468 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2471 // integer spinner for number of digits
2476 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2479 s.addChangeListener(c);
2483 protected static int getSpinnerInt(JSpinner s, int def)
2489 i = (Integer) s.getValue();
2490 } catch (Exception e)
2492 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2497 private void keepRollMaxOptionsEnabled()
2499 boolean enabled = backupfilesKeepAll.isEnabled()
2500 && !backupfilesKeepAll.isSelected();
2501 oldBackupFilesLabel.setEnabled(enabled);
2502 backupfilesRollMaxSpinner.setEnabled(enabled);
2503 backupfilesConfirmDelete.setEnabled(enabled);
2506 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2508 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2509 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2510 && suffixTemplate.getText()
2511 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2512 keepfilesPanel.setEnabled(enabled);
2513 backupfilesKeepAll.setEnabled(enabled);
2514 oldBackupFilesLabel.setEnabled(enabled);
2515 keepRollMaxOptionsEnabled();
2518 private void backupfilesSuffixTemplateDigitsSetEnabled()
2520 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2521 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2522 suffixDigitsLabel.setEnabled(enabled);
2523 suffixDigitsSpinner.setEnabled(enabled);
2524 suffixReverse.setEnabled(enabled);
2527 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2529 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2530 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2531 suffixPanel.setEnabled(enabled);
2532 suffixTemplateLabel.setEnabled(enabled);
2533 suffixTemplate.setEnabled(enabled);
2534 backupfilesSuffixTemplateDigitsSetEnabled();
2537 protected void backupfilesCustomOptionsSetEnabled()
2539 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2540 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2542 backupfilesSuffixTemplateSetEnabled(enabled);
2543 backupfilesKeepAllSetEnabled(enabled);
2546 private void backupfilesSummarySetEnabled()
2548 boolean enabled = enableBackupFiles.isSelected();
2549 backupfilesExampleLabel.setEnabled(enabled);
2550 exampleFilesPanel.setEnabled(enabled);
2553 private void backupfilesPresetsSetEnabled()
2555 boolean enabled = enableBackupFiles.isSelected();
2556 presetsPanel.setEnabled(enabled);
2557 backupfilesPresetsCombo.setEnabled(enabled);
2560 protected void backupsOptionsSetEnabled()
2562 backupfilesPresetsSetEnabled();
2563 backupfilesSummarySetEnabled();
2564 backupfilesCustomOptionsSetEnabled();
2567 protected void backupsSetOptions(String suffix, int digits,
2568 boolean reverse, boolean keepAll, int rollMax,
2569 boolean confirmDelete)
2571 suffixTemplate.setText(suffix);
2572 suffixDigitsSpinner.setValue(digits);
2573 suffixReverse.setSelected(reverse);
2574 backupfilesKeepAll.setSelected(keepAll);
2575 backupfilesRollMaxSpinner.setValue(rollMax);
2576 backupfilesConfirmDelete.setSelected(confirmDelete);
2579 protected void backupsSetOptions(BackupFilesPresetEntry p)
2581 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2585 protected void autoIdWidth_actionPerformed()
2587 // TODO Auto-generated method stub
2591 protected void userIdWidth_actionPerformed()
2593 // TODO Auto-generated method stub
2597 protected void maxColour_actionPerformed(JPanel panel)
2601 protected void minColour_actionPerformed(JPanel panel)
2605 protected void gapColour_actionPerformed(JPanel panel)
2609 protected void hiddenColour_actionPerformed(JPanel panel)
2613 protected void showunconserved_actionPerformed(ActionEvent e)
2615 // TODO Auto-generated method stub
2619 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2623 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2633 public void ok_actionPerformed(ActionEvent e)
2643 public void cancel_actionPerformed(ActionEvent e)
2653 public void annotations_actionPerformed(ActionEvent e)
2660 public void startupFileTextfield_mouseClicked()
2664 public void newLink_actionPerformed(ActionEvent e)
2669 public void editLink_actionPerformed(ActionEvent e)
2674 public void deleteLink_actionPerformed(ActionEvent e)
2679 public void defaultBrowser_mouseClicked(MouseEvent e)
2684 public void linkURLList_keyTyped(KeyEvent e)
2689 public void useProxy_actionPerformed()
2691 boolean enabled = useProxy.isSelected();
2692 portLabel.setEnabled(enabled);
2693 serverLabel.setEnabled(enabled);
2694 proxyServerTB.setEnabled(enabled);
2695 proxyPortTB.setEnabled(enabled);
2699 * Customer renderer for JTable: supports column of radio buttons
2701 public class RadioButtonRenderer extends JRadioButton
2702 implements TableCellRenderer
2704 public RadioButtonRenderer()
2706 setHorizontalAlignment(CENTER);
2707 setToolTipText(MessageManager.getString("label.urltooltip"));
2711 public Component getTableCellRendererComponent(JTable table,
2712 Object value, boolean isSelected, boolean hasFocus, int row,
2715 setSelected((boolean) value);
2717 // set colours to match rest of table
2720 setBackground(table.getSelectionBackground());
2721 setForeground(table.getSelectionForeground());
2725 setBackground(table.getBackground());
2726 setForeground(table.getForeground());
2733 * Customer cell editor for JTable: supports column of radio buttons in
2734 * conjunction with renderer
2736 public class RadioButtonEditor extends AbstractCellEditor
2737 implements TableCellEditor
2739 private JRadioButton button = new JRadioButton();
2741 public RadioButtonEditor()
2743 button.setHorizontalAlignment(SwingConstants.CENTER);
2744 this.button.addActionListener(new ActionListener()
2747 public void actionPerformed(ActionEvent e)
2749 fireEditingStopped();
2755 public Component getTableCellEditorComponent(JTable table, Object value,
2756 boolean isSelected, int row, int column)
2758 button.setSelected((boolean) value);
2763 public Object getCellEditorValue()
2765 return button.isSelected();
2771 class IntKeyStringValueEntry
2777 public IntKeyStringValueEntry(int k, String v)
2784 public String toString()
2786 return this.getValue();
2794 public String getValue()
2800 class BackupFilesPresetEntry
2812 boolean confirmDelete;
2814 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2815 boolean keepAll, int rollMax, boolean confirmDelete)
2817 this.suffix = suffix;
2818 this.digits = digits;
2819 this.reverse = reverse;
2820 this.keepAll = keepAll;
2821 this.rollMax = rollMax;
2822 this.confirmDelete = confirmDelete;
2826 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2831 private static final long serialVersionUID = 88L;
2834 public Component getListCellRendererComponent(JList list, Object value,
2835 int index, boolean isSelected, boolean cellHasFocus)
2837 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2840 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2841 if (e.getKey() == GPreferences.BACKUPFILESSCHEMECUSTOMISE)
2844 this.setFont(this.getFont().deriveFont(Font.BOLD));
2846 } catch (Exception e) {