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.io.BackupFilesPresetEntry;
35 import jalview.io.IntKeyStringValueEntry;
36 import jalview.util.MessageManager;
38 import java.awt.BorderLayout;
39 import java.awt.Color;
40 import java.awt.Component;
41 import java.awt.Dimension;
42 import java.awt.FlowLayout;
44 import java.awt.GridBagConstraints;
45 import java.awt.GridBagLayout;
46 import java.awt.GridLayout;
47 import java.awt.Insets;
48 import java.awt.Rectangle;
49 import java.awt.event.ActionEvent;
50 import java.awt.event.ActionListener;
51 import java.awt.event.FocusEvent;
52 import java.awt.event.KeyEvent;
53 import java.awt.event.KeyListener;
54 import java.awt.event.MouseAdapter;
55 import java.awt.event.MouseEvent;
56 import java.util.Arrays;
57 import java.util.List;
59 import javax.swing.AbstractCellEditor;
60 import javax.swing.BorderFactory;
61 import javax.swing.ButtonGroup;
62 import javax.swing.DefaultListCellRenderer;
63 import javax.swing.JButton;
64 import javax.swing.JCheckBox;
65 import javax.swing.JComboBox;
66 import javax.swing.JFileChooser;
67 import javax.swing.JLabel;
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 JLabel userIdWidthlabel = new JLabel();
254 protected JCheckBox autoIdWidth = new JCheckBox();
256 protected JTextField userIdWidth = new JTextField();
258 protected JCheckBox blcjv = new JCheckBox();
260 protected JCheckBox pileupjv = new JCheckBox();
262 protected JCheckBox clustaljv = new JCheckBox();
264 protected JCheckBox msfjv = new JCheckBox();
266 protected JCheckBox fastajv = new JCheckBox();
268 protected JCheckBox pfamjv = new JCheckBox();
270 protected JCheckBox pirjv = new JCheckBox();
272 protected JCheckBox modellerOutput = new JCheckBox();
274 protected JCheckBox embbedBioJSON = new JCheckBox();
277 * Editing tab components
279 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
281 protected JCheckBox padGaps = new JCheckBox();
283 protected JCheckBox sortByTree = new JCheckBox();
288 protected JPanel wsTab = new JPanel();
291 * Backups tab components
292 * a lot of these are member variables instead of local variables only so that they
293 * can be enabled/disabled easily in one go
296 protected JCheckBox enableBackupFiles = new JCheckBox();
298 protected JPanel presetsPanel = new JPanel();
300 protected JLabel presetsComboLabel = new JLabel();
302 protected JCheckBox customiseCheckbox = new JCheckBox();
304 protected JButton revertButton = new JButton();
306 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
308 private int backupfilesPresetsComboLastSelected = 0;
310 protected JPanel suffixPanel = new JPanel();
312 protected JPanel keepfilesPanel = new JPanel();
314 protected JPanel exampleFilesPanel = new JPanel();
316 protected JTextField suffixTemplate = new JTextField(null, 8);
318 protected JLabel suffixTemplateLabel = new JLabel();
320 protected JLabel suffixDigitsLabel = new JLabel();
322 protected JSpinner suffixDigitsSpinner = new JSpinner();
324 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
326 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
328 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
330 protected JLabel oldBackupFilesLabel = new JLabel();
332 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
334 protected JTextArea backupfilesExampleLabel = new JTextArea();
337 * Creates a new GPreferences object.
339 public GPreferences()
344 } catch (Exception ex)
346 ex.printStackTrace();
351 * Construct the panel and its tabbed sub-panels.
355 private void jbInit() throws Exception
357 final JTabbedPane tabbedPane = new JTabbedPane();
358 this.setLayout(new BorderLayout());
359 JPanel okCancelPanel = initOkCancelPanel();
360 this.add(tabbedPane, BorderLayout.CENTER);
361 this.add(okCancelPanel, BorderLayout.SOUTH);
363 tabbedPane.add(initVisualTab(),
364 MessageManager.getString("label.visual"));
366 tabbedPane.add(initColoursTab(),
367 MessageManager.getString("label.colours"));
369 tabbedPane.add(initOverviewTab(),
370 MessageManager.getString("label.overview"));
372 tabbedPane.add(initStructureTab(),
373 MessageManager.getString("label.structure"));
375 tabbedPane.add(initConnectionsTab(),
376 MessageManager.getString("label.connections"));
378 tabbedPane.add(initBackupsTab(),
379 MessageManager.getString("label.backups"));
381 tabbedPane.add(initLinksTab(),
382 MessageManager.getString("label.urllinks"));
384 tabbedPane.add(initOutputTab(),
385 MessageManager.getString("label.output"));
387 tabbedPane.add(initEditingTab(),
388 MessageManager.getString("label.editing"));
391 * See WsPreferences for the real work of configuring this tab.
393 wsTab.setLayout(new BorderLayout());
394 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
397 * Handler to validate a tab before leaving it - currently only for
400 tabbedPane.addChangeListener(new ChangeListener()
402 private Component lastTab;
405 public void stateChanged(ChangeEvent e)
407 if (lastTab == structureTab
408 && tabbedPane.getSelectedComponent() != structureTab)
410 if (!validateStructure())
412 tabbedPane.setSelectedComponent(structureTab);
416 lastTab = tabbedPane.getSelectedComponent();
423 * Initialises the Editing tabbed panel.
427 private JPanel initEditingTab()
429 JPanel editingTab = new JPanel();
430 editingTab.setLayout(null);
431 autoCalculateConsCheck.setFont(LABEL_FONT);
432 autoCalculateConsCheck.setText(
433 MessageManager.getString("label.autocalculate_consensus"));
434 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
435 padGaps.setFont(LABEL_FONT);
437 MessageManager.getString("label.pad_gaps_when_editing"));
438 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
439 sortByTree.setFont(LABEL_FONT);
441 .setText(MessageManager.getString("label.sort_with_new_tree"));
442 sortByTree.setToolTipText(MessageManager.getString(
443 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
444 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
445 editingTab.add(autoCalculateConsCheck);
446 editingTab.add(padGaps);
447 editingTab.add(sortByTree);
452 * Initialises the Output tabbed panel.
456 private JPanel initOutputTab()
458 JPanel outputTab = new JPanel();
459 outputTab.setLayout(null);
460 JLabel epsLabel = new JLabel();
461 epsLabel.setFont(LABEL_FONT);
462 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
463 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
464 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
465 epsRendering.setFont(LABEL_FONT);
466 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
467 JLabel jLabel1 = new JLabel();
468 jLabel1.setFont(LABEL_FONT);
469 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
470 jLabel1.setText(MessageManager.getString("label.append_start_end"));
471 jLabel1.setFont(LABEL_FONT);
472 fastajv.setFont(LABEL_FONT);
473 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
474 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
475 blcjv.setText(MessageManager.getString("label.blc") + " ");
476 fastajv.setText(MessageManager.getString("label.fasta") + " ");
477 msfjv.setText(MessageManager.getString("label.msf") + " ");
478 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
479 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
480 msfjv.setFont(LABEL_FONT);
481 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
482 pirjv.setText(MessageManager.getString("label.pir") + " ");
483 JPanel jPanel11 = new JPanel();
484 jPanel11.setFont(LABEL_FONT);
485 TitledBorder titledBorder2 = new TitledBorder(
486 MessageManager.getString("label.file_output"));
487 jPanel11.setBorder(titledBorder2);
488 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
489 GridLayout gridLayout3 = new GridLayout();
490 jPanel11.setLayout(gridLayout3);
491 gridLayout3.setRows(8);
492 blcjv.setFont(LABEL_FONT);
493 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
494 clustaljv.setFont(LABEL_FONT);
495 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
496 pfamjv.setFont(LABEL_FONT);
497 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
498 pileupjv.setFont(LABEL_FONT);
499 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
500 pirjv.setFont(LABEL_FONT);
501 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
502 autoIdWidth.setFont(LABEL_FONT);
504 MessageManager.getString("label.automatically_set_id_width"));
505 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
506 .getString("label.adjusts_width_generated_eps_png")));
507 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
508 autoIdWidth.addActionListener(new ActionListener()
512 public void actionPerformed(ActionEvent e)
514 autoIdWidth_actionPerformed();
517 userIdWidthlabel.setFont(LABEL_FONT);
518 userIdWidthlabel.setText(
519 MessageManager.getString("label.figure_id_column_width"));
520 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
521 .getString("label.manually_specify_width_left_column")));
522 userIdWidthlabel.setToolTipText(
523 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
524 "label.manually_specify_width_left_column")));
525 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
526 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
527 userIdWidth.setText("");
528 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
529 userIdWidth.addActionListener(new ActionListener()
533 public void actionPerformed(ActionEvent e)
535 userIdWidth_actionPerformed();
538 modellerOutput.setFont(LABEL_FONT);
540 .setText(MessageManager.getString("label.use_modeller_output"));
541 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
542 embbedBioJSON.setFont(LABEL_FONT);
543 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
544 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
546 jPanel11.add(jLabel1);
548 jPanel11.add(clustaljv);
549 jPanel11.add(fastajv);
551 jPanel11.add(pfamjv);
552 jPanel11.add(pileupjv);
554 outputTab.add(autoIdWidth);
555 outputTab.add(userIdWidth);
556 outputTab.add(userIdWidthlabel);
557 outputTab.add(modellerOutput);
558 outputTab.add(embbedBioJSON);
559 outputTab.add(epsLabel);
560 outputTab.add(epsRendering);
561 outputTab.add(jPanel11);
566 * Initialises the Connections tabbed panel.
570 private JPanel initConnectionsTab()
572 JPanel connectTab = new JPanel();
573 connectTab.setLayout(new GridBagLayout());
575 // Label for browser text box
576 JLabel browserLabel = new JLabel();
577 browserLabel.setFont(LABEL_FONT);
578 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
579 browserLabel.setText(
580 MessageManager.getString("label.default_browser_unix"));
581 defaultBrowser.setFont(LABEL_FONT);
582 defaultBrowser.setText("");
583 final String tooltip = JvSwingUtils.wrapTooltip(true,
584 MessageManager.getString("label.double_click_to_browse"));
585 defaultBrowser.setToolTipText(tooltip);
586 defaultBrowser.addMouseListener(new MouseAdapter()
589 public void mouseClicked(MouseEvent e)
591 if (e.getClickCount() > 1)
593 defaultBrowser_mouseClicked(e);
598 JPanel proxyPanel = initConnTabProxyPanel();
599 initConnTabCheckboxes();
601 // Add default Browser text box
602 connectTab.add(browserLabel,
603 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
604 GridBagConstraints.WEST, GridBagConstraints.NONE,
605 new Insets(10, 0, 5, 5), 5, 1));
606 defaultBrowser.setFont(LABEL_FONT);
607 defaultBrowser.setText("");
609 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
610 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
611 new Insets(10, 0, 5, 10), 30, 1));
613 // Add proxy server panel
614 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
615 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
616 new Insets(10, 0, 5, 12), 4, 10));
618 // Add usage stats, version check and questionnaire checkboxes
619 connectTab.add(usagestats,
620 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
621 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
622 new Insets(0, 2, 5, 5), 70, 1));
623 connectTab.add(questionnaire,
624 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
625 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
626 new Insets(0, 2, 5, 10), 70, 1));
627 connectTab.add(versioncheck,
628 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
629 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
630 new Insets(0, 2, 5, 5), 70, 1));
632 versioncheck.setVisible(false);
634 // Add padding so the panel doesn't look ridiculous
635 JPanel spacePanel = new JPanel();
636 connectTab.add(spacePanel,
637 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
638 GridBagConstraints.WEST, GridBagConstraints.BOTH,
639 new Insets(0, 0, 0, 5), 70, 1));
645 * Initialises the Links tabbed panel.
649 private JPanel initLinksTab()
651 JPanel linkTab = new JPanel();
652 linkTab.setLayout(new GridBagLayout());
654 // Set up table for Url links
655 linkUrlTable.getTableHeader().setReorderingAllowed(false);
656 linkUrlTable.setFillsViewportHeight(true);
657 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
658 linkUrlTable.setAutoCreateRowSorter(true);
659 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
661 // adjust row height so radio buttons actually fit
662 // don't do this in the renderer, it causes the awt thread to activate
664 JRadioButton temp = new JRadioButton();
665 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
667 // Table in scrollpane so that the table is given a scrollbar
668 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
669 linkScrollPane.setBorder(null);
671 // Panel for links functionality
672 JPanel linkPanel = new JPanel(new GridBagLayout());
673 linkPanel.setBorder(new TitledBorder(
674 MessageManager.getString("label.url_linkfrom_sequence_id")));
676 // Put the Url links panel together
678 // Buttons go at top right, resizing only resizes the blank space vertically
679 JPanel buttonPanel = initLinkTabUrlButtons();
680 GridBagConstraints linkConstraints1 = new GridBagConstraints();
681 linkConstraints1.insets = new Insets(0, 0, 5, 0);
682 linkConstraints1.gridx = 0;
683 linkConstraints1.gridy = 0;
684 linkConstraints1.weightx = 1.0;
685 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
686 linkTab.add(buttonPanel, linkConstraints1);
688 // Links table goes at top left, resizing resizes the table
689 GridBagConstraints linkConstraints2 = new GridBagConstraints();
690 linkConstraints2.insets = new Insets(0, 0, 5, 5);
691 linkConstraints2.gridx = 0;
692 linkConstraints2.gridy = 1;
693 linkConstraints2.weightx = 1.0;
694 linkConstraints2.weighty = 1.0;
695 linkConstraints2.fill = GridBagConstraints.BOTH;
696 linkTab.add(linkScrollPane, linkConstraints2);
698 // Filter box and buttons goes at bottom left, resizing resizes the text box
699 JPanel filterPanel = initLinkTabFilterPanel();
700 GridBagConstraints linkConstraints3 = new GridBagConstraints();
701 linkConstraints3.insets = new Insets(0, 0, 0, 5);
702 linkConstraints3.gridx = 0;
703 linkConstraints3.gridy = 2;
704 linkConstraints3.weightx = 1.0;
705 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
706 linkTab.add(filterPanel, linkConstraints3);
711 private JPanel initLinkTabFilterPanel()
713 // Filter textbox and reset button
714 JLabel filterLabel = new JLabel(
715 MessageManager.getString("label.filter"));
716 filterLabel.setFont(LABEL_FONT);
717 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
718 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
720 filterTB.setFont(LABEL_FONT);
721 filterTB.setText("");
723 doReset.setText(MessageManager.getString("action.showall"));
724 userOnly.setText(MessageManager.getString("action.customfilter"));
726 // Panel for filter functionality
727 JPanel filterPanel = new JPanel(new GridBagLayout());
728 filterPanel.setBorder(new TitledBorder("Filter"));
729 GridBagConstraints gbc = new GridBagConstraints();
732 gbc.fill = GridBagConstraints.NONE;
733 gbc.anchor = GridBagConstraints.WEST;
735 filterPanel.add(filterLabel, gbc);
737 GridBagConstraints gbc1 = new GridBagConstraints();
740 gbc1.fill = GridBagConstraints.HORIZONTAL;
741 gbc1.anchor = GridBagConstraints.WEST;
743 filterPanel.add(filterTB, gbc1);
745 GridBagConstraints gbc2 = new GridBagConstraints();
747 gbc2.fill = GridBagConstraints.NONE;
748 gbc2.anchor = GridBagConstraints.WEST;
749 filterPanel.add(doReset, gbc2);
751 GridBagConstraints gbc3 = new GridBagConstraints();
753 gbc3.fill = GridBagConstraints.NONE;
754 gbc3.anchor = GridBagConstraints.WEST;
755 filterPanel.add(userOnly, gbc3);
760 private JPanel initLinkTabUrlButtons()
762 // Buttons for new / edit / delete Url links
763 JButton newLink = new JButton();
764 newLink.setText(MessageManager.getString("action.new"));
766 editLink.setText(MessageManager.getString("action.edit"));
768 deleteLink.setText(MessageManager.getString("action.delete"));
770 // no current selection, so initially disable delete/edit buttons
771 editLink.setEnabled(false);
772 deleteLink.setEnabled(false);
774 newLink.addActionListener(new java.awt.event.ActionListener()
777 public void actionPerformed(ActionEvent e)
779 newLink_actionPerformed(e);
783 editLink.setText(MessageManager.getString("action.edit"));
784 editLink.addActionListener(new java.awt.event.ActionListener()
787 public void actionPerformed(ActionEvent e)
789 editLink_actionPerformed(e);
793 deleteLink.setText(MessageManager.getString("action.delete"));
794 deleteLink.addActionListener(new java.awt.event.ActionListener()
797 public void actionPerformed(ActionEvent e)
799 deleteLink_actionPerformed(e);
803 JPanel buttonPanel = new JPanel(new GridBagLayout());
804 buttonPanel.setBorder(new TitledBorder("Edit links"));
805 GridBagConstraints gbc = new GridBagConstraints();
808 gbc.fill = GridBagConstraints.NONE;
809 buttonPanel.add(newLink, gbc);
811 GridBagConstraints gbc1 = new GridBagConstraints();
814 gbc1.fill = GridBagConstraints.NONE;
815 buttonPanel.add(editLink, gbc1);
817 GridBagConstraints gbc2 = new GridBagConstraints();
820 gbc2.fill = GridBagConstraints.NONE;
821 buttonPanel.add(deleteLink, gbc2);
823 GridBagConstraints gbc3 = new GridBagConstraints();
826 gbc3.fill = GridBagConstraints.HORIZONTAL;
828 JPanel spacePanel = new JPanel();
829 spacePanel.setBorder(null);
830 buttonPanel.add(spacePanel, gbc3);
836 * Initialises the proxy server panel in the Connections tab
838 * @return the proxy server panel
840 private JPanel initConnTabProxyPanel()
842 // Label for server text box
843 serverLabel.setText(MessageManager.getString("label.address"));
844 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
845 serverLabel.setFont(LABEL_FONT);
847 // Proxy server and port text boxes
848 proxyServerTB.setFont(LABEL_FONT);
849 proxyPortTB.setFont(LABEL_FONT);
851 // Label for Port text box
852 portLabel.setFont(LABEL_FONT);
853 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
854 portLabel.setText(MessageManager.getString("label.port"));
856 // Use proxy server checkbox
857 useProxy.setFont(LABEL_FONT);
858 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
859 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
860 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
861 useProxy.addActionListener(new ActionListener()
864 public void actionPerformed(ActionEvent e)
866 useProxy_actionPerformed();
870 // Make proxy server panel
871 JPanel proxyPanel = new JPanel();
872 TitledBorder titledBorder1 = new TitledBorder(
873 MessageManager.getString("label.proxy_server"));
874 proxyPanel.setBorder(titledBorder1);
875 proxyPanel.setLayout(new GridBagLayout());
876 proxyPanel.add(serverLabel,
877 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
878 GridBagConstraints.WEST, GridBagConstraints.NONE,
879 new Insets(0, 2, 2, 0), 5, 0));
880 proxyPanel.add(portLabel,
881 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
882 GridBagConstraints.WEST, GridBagConstraints.NONE,
883 new Insets(0, 0, 2, 0), 11, 0));
884 proxyPanel.add(useProxy,
885 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
886 GridBagConstraints.WEST, GridBagConstraints.NONE,
887 new Insets(0, 2, 5, 185), 2, -4));
888 proxyPanel.add(proxyPortTB,
889 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
890 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
891 new Insets(0, 2, 2, 2), 54, 1));
892 proxyPanel.add(proxyServerTB,
893 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
894 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
895 new Insets(0, 2, 2, 0), 263, 1));
901 * Initialises the checkboxes in the Connections tab
903 private void initConnTabCheckboxes()
905 // Usage stats checkbox label
907 MessageManager.getString("label.send_usage_statistics"));
908 usagestats.setFont(LABEL_FONT);
909 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
910 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
912 // Questionnaire checkbox label
913 questionnaire.setText(
914 MessageManager.getString("label.check_for_questionnaires"));
915 questionnaire.setFont(LABEL_FONT);
916 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
917 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
919 // Check for latest version checkbox label
920 versioncheck.setText(
921 MessageManager.getString("label.check_for_latest_version"));
922 versioncheck.setFont(LABEL_FONT);
923 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
924 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
928 * Initialises the parent panel which contains the tabbed sections.
932 private JPanel initOkCancelPanel()
934 JButton ok = new JButton();
935 ok.setText(MessageManager.getString("action.ok"));
936 ok.addActionListener(new ActionListener()
939 public void actionPerformed(ActionEvent e)
941 ok_actionPerformed(e);
944 JButton cancel = new JButton();
945 cancel.setText(MessageManager.getString("action.cancel"));
946 cancel.addActionListener(new ActionListener()
949 public void actionPerformed(ActionEvent e)
951 cancel_actionPerformed(e);
954 JPanel okCancelPanel = new JPanel();
955 okCancelPanel.add(ok);
956 okCancelPanel.add(cancel);
957 return okCancelPanel;
961 * Initialises the Colours tabbed panel.
965 private JPanel initColoursTab()
967 JPanel coloursTab = new JPanel();
968 coloursTab.setBorder(new TitledBorder(
969 MessageManager.getString("action.open_new_alignment")));
970 coloursTab.setLayout(new FlowLayout());
971 JLabel mincolourLabel = new JLabel();
972 mincolourLabel.setFont(LABEL_FONT);
973 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
974 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
975 minColour.setFont(LABEL_FONT);
976 minColour.setBorder(BorderFactory.createEtchedBorder());
977 minColour.setPreferredSize(new Dimension(40, 20));
978 minColour.addMouseListener(new MouseAdapter()
981 public void mousePressed(MouseEvent e)
983 minColour_actionPerformed(minColour);
986 JLabel maxcolourLabel = new JLabel();
987 maxcolourLabel.setFont(LABEL_FONT);
988 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
989 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
990 maxColour.setFont(LABEL_FONT);
991 maxColour.setBorder(BorderFactory.createEtchedBorder());
992 maxColour.setPreferredSize(new Dimension(40, 20));
993 maxColour.addMouseListener(new MouseAdapter()
996 public void mousePressed(MouseEvent e)
998 maxColour_actionPerformed(maxColour);
1002 protColour.setFont(LABEL_FONT);
1003 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1004 JLabel protColourLabel = new JLabel();
1005 protColourLabel.setFont(LABEL_FONT);
1006 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1007 protColourLabel.setText(
1008 MessageManager.getString("label.prot_alignment_colour") + " ");
1009 JvSwingUtils.addtoLayout(coloursTab,
1011 .getString("label.default_colour_scheme_for_alignment"),
1012 protColourLabel, protColour);
1014 nucColour.setFont(LABEL_FONT);
1015 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1016 JLabel nucColourLabel = new JLabel();
1017 nucColourLabel.setFont(LABEL_FONT);
1018 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1019 nucColourLabel.setText(
1020 MessageManager.getString("label.nuc_alignment_colour") + " ");
1021 JvSwingUtils.addtoLayout(coloursTab,
1023 .getString("label.default_colour_scheme_for_alignment"),
1024 nucColourLabel, nucColour);
1026 JPanel annotationShding = new JPanel();
1027 annotationShding.setBorder(new TitledBorder(
1028 MessageManager.getString("label.annotation_shading_default")));
1029 annotationShding.setLayout(new GridLayout(1, 2));
1030 JvSwingUtils.addtoLayout(annotationShding,
1031 MessageManager.getString(
1032 "label.default_minimum_colour_annotation_shading"),
1033 mincolourLabel, minColour);
1034 JvSwingUtils.addtoLayout(annotationShding,
1035 MessageManager.getString(
1036 "label.default_maximum_colour_annotation_shading"),
1037 maxcolourLabel, maxColour);
1038 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1043 * Initialises the Overview tabbed panel.
1047 private JPanel initOverviewTab()
1049 JPanel overviewPanel = new JPanel();
1050 overviewPanel.setBorder(new TitledBorder(
1051 MessageManager.getString("label.overview_settings")));
1053 gapColour.setFont(LABEL_FONT);
1054 // fixing the border colours stops apparent colour bleed from the panel
1055 gapColour.setBorder(
1056 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1057 gapColour.setPreferredSize(new Dimension(40, 20));
1058 gapColour.addMouseListener(new MouseAdapter()
1061 public void mousePressed(MouseEvent e)
1063 gapColour_actionPerformed(gapColour);
1067 hiddenColour.setFont(LABEL_FONT);
1068 // fixing the border colours stops apparent colour bleed from the panel
1069 hiddenColour.setBorder(
1070 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1071 hiddenColour.setPreferredSize(new Dimension(40, 20));
1072 hiddenColour.addMouseListener(new MouseAdapter()
1075 public void mousePressed(MouseEvent e)
1077 hiddenColour_actionPerformed(hiddenColour);
1081 useLegacyGap = new JCheckBox(
1082 MessageManager.getString("label.ov_legacy_gap"));
1083 useLegacyGap.setFont(LABEL_FONT);
1084 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1085 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1086 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1087 gapLabel.setFont(LABEL_FONT);
1088 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1089 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1090 showHiddenAtStart = new JCheckBox(
1091 MessageManager.getString("label.ov_show_hide_default"));
1092 showHiddenAtStart.setFont(LABEL_FONT);
1093 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1094 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1095 JLabel hiddenLabel = new JLabel(
1096 MessageManager.getString("label.hidden_colour"));
1097 hiddenLabel.setFont(LABEL_FONT);
1098 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1099 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1101 useLegacyGap.addActionListener(new ActionListener()
1104 public void actionPerformed(ActionEvent e)
1106 useLegacyGaps_actionPerformed(e);
1110 overviewPanel.setLayout(new GridBagLayout());
1111 GridBagConstraints c1 = new GridBagConstraints();
1113 c1.fill = GridBagConstraints.HORIZONTAL;
1118 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1119 overviewPanel.add(useLegacyGap, c1);
1121 GridBagConstraints c2 = new GridBagConstraints();
1122 c2.fill = GridBagConstraints.HORIZONTAL;
1125 c2.insets = new Insets(0, 15, 0, 10);
1126 overviewPanel.add(gapLabel, c2);
1128 GridBagConstraints c3 = new GridBagConstraints();
1129 c3.fill = GridBagConstraints.HORIZONTAL;
1132 c3.insets = new Insets(0, 0, 0, 15);
1133 overviewPanel.add(gapColour, c3);
1135 GridBagConstraints c4 = new GridBagConstraints();
1136 c4.fill = GridBagConstraints.HORIZONTAL;
1140 overviewPanel.add(showHiddenAtStart, c4);
1142 GridBagConstraints c5 = new GridBagConstraints();
1143 c5.fill = GridBagConstraints.HORIZONTAL;
1146 c5.insets = new Insets(0, 15, 0, 10);
1147 overviewPanel.add(hiddenLabel, c5);
1149 GridBagConstraints c6 = new GridBagConstraints();
1150 c6.fill = GridBagConstraints.HORIZONTAL;
1153 c6.insets = new Insets(0, 0, 0, 15);
1154 overviewPanel.add(hiddenColour, c6);
1156 JButton resetButton = new JButton(
1157 MessageManager.getString("label.reset_to_defaults"));
1159 resetButton.addActionListener(new ActionListener()
1162 public void actionPerformed(ActionEvent e)
1164 resetOvDefaults_actionPerformed(e);
1168 GridBagConstraints c7 = new GridBagConstraints();
1169 c7.fill = GridBagConstraints.NONE;
1172 c7.insets = new Insets(10, 0, 0, 0);
1173 c7.anchor = GridBagConstraints.WEST;
1174 overviewPanel.add(resetButton, c7);
1176 // Add padding so the panel doesn't look ridiculous
1177 JPanel spacePanel = new JPanel();
1178 overviewPanel.add(spacePanel,
1179 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1180 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1181 new Insets(0, 0, 0, 5), 0, 0));
1183 return overviewPanel;
1187 * Initialises the Structure tabbed panel.
1191 private JPanel initStructureTab()
1193 structureTab = new JPanel();
1195 structureTab.setBorder(new TitledBorder(
1196 MessageManager.getString("label.structure_options")));
1197 structureTab.setLayout(null);
1198 final int width = 420;
1199 final int height = 22;
1200 final int lineSpacing = 25;
1203 structFromPdb.setFont(LABEL_FONT);
1205 .setText(MessageManager.getString("label.struct_from_pdb"));
1206 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1207 structFromPdb.addActionListener(new ActionListener()
1210 public void actionPerformed(ActionEvent e)
1212 boolean selected = structFromPdb.isSelected();
1213 // enable other options only when the first is checked
1214 useRnaView.setEnabled(selected);
1215 addSecondaryStructure.setEnabled(selected);
1216 addTempFactor.setEnabled(selected);
1219 structureTab.add(structFromPdb);
1221 // indent checkboxes that are conditional on the first one
1222 ypos += lineSpacing;
1223 useRnaView.setFont(LABEL_FONT);
1224 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1225 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1226 structureTab.add(useRnaView);
1228 ypos += lineSpacing;
1229 addSecondaryStructure.setFont(LABEL_FONT);
1230 addSecondaryStructure
1231 .setText(MessageManager.getString("label.autoadd_secstr"));
1232 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1233 structureTab.add(addSecondaryStructure);
1235 ypos += lineSpacing;
1236 addTempFactor.setFont(LABEL_FONT);
1237 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1238 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1239 structureTab.add(addTempFactor);
1241 ypos += lineSpacing;
1242 JLabel viewerLabel = new JLabel();
1243 viewerLabel.setFont(LABEL_FONT);
1244 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1245 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1246 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1247 structureTab.add(viewerLabel);
1249 structViewer.setFont(LABEL_FONT);
1250 structViewer.setBounds(new Rectangle(180, ypos, 120, height));
1251 structViewer.addItem(ViewerType.JMOL.name());
1252 structViewer.addItem(ViewerType.CHIMERA.name());
1253 structViewer.addItem(ViewerType.CHIMERAX.name());
1254 structViewer.addActionListener(new ActionListener()
1257 public void actionPerformed(ActionEvent e)
1259 structureViewer_actionPerformed(
1260 (String) structViewer.getSelectedItem());
1263 structureTab.add(structViewer);
1265 ypos += lineSpacing;
1266 JLabel pathLabel = new JLabel();
1267 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1268 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1269 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1270 pathLabel.setBounds(new Rectangle(10, ypos, 160, height));
1271 structureTab.add(pathLabel);
1273 chimeraPath.setFont(LABEL_FONT);
1274 chimeraPath.setText("");
1275 final String tooltip = JvSwingUtils.wrapTooltip(true,
1276 MessageManager.getString("label.chimera_path_tip"));
1277 chimeraPath.setToolTipText(tooltip);
1278 chimeraPath.setBounds(new Rectangle(180, ypos, 300, height));
1279 chimeraPath.addMouseListener(new MouseAdapter()
1282 public void mouseClicked(MouseEvent e)
1284 if (e.getClickCount() == 2)
1286 String chosen = openFileChooser();
1289 chimeraPath.setText(chosen);
1294 structureTab.add(chimeraPath);
1296 ypos += lineSpacing;
1297 nwMapping.setFont(LABEL_FONT);
1298 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1299 siftsMapping.setFont(LABEL_FONT);
1300 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1301 mappingMethod.add(nwMapping);
1302 mappingMethod.add(siftsMapping);
1303 JPanel mappingPanel = new JPanel();
1304 mappingPanel.setFont(LABEL_FONT);
1305 TitledBorder mmTitledBorder = new TitledBorder(
1306 MessageManager.getString("label.mapping_method"));
1307 mmTitledBorder.setTitleFont(LABEL_FONT);
1308 mappingPanel.setBorder(mmTitledBorder);
1309 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1310 // GridLayout mappingLayout = new GridLayout();
1311 mappingPanel.setLayout(new GridLayout());
1312 mappingPanel.add(nwMapping);
1313 mappingPanel.add(siftsMapping);
1314 structureTab.add(mappingPanel);
1316 ypos += lineSpacing;
1317 ypos += lineSpacing;
1318 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1319 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1320 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1321 structureTab.add(docFieldPref);
1323 return structureTab;
1327 * Action on choosing a structure viewer from combobox options.
1329 * @param selectedItem
1331 protected void structureViewer_actionPerformed(String selectedItem)
1336 * Show a dialog for the user to choose a file. Returns the chosen path, or
1341 protected String openFileChooser()
1343 String choice = null;
1344 JFileChooser chooser = new JFileChooser();
1346 // chooser.setFileView(new JalviewFileView());
1347 chooser.setDialogTitle(
1348 MessageManager.getString("label.open_local_file"));
1349 chooser.setToolTipText(MessageManager.getString("action.open"));
1351 int value = chooser.showOpenDialog(this);
1353 if (value == JFileChooser.APPROVE_OPTION)
1355 choice = chooser.getSelectedFile().getPath();
1361 * Validate the structure tab preferences; if invalid, set focus on this tab.
1365 protected boolean validateStructure(FocusEvent e)
1367 if (!validateStructure())
1369 e.getComponent().requestFocusInWindow();
1375 protected boolean validateStructure()
1381 * Initialises the Visual tabbed panel.
1385 private JPanel initVisualTab()
1387 JPanel visualTab = new JPanel();
1388 visualTab.setBorder(new TitledBorder(
1389 MessageManager.getString("action.open_new_alignment")));
1390 visualTab.setLayout(null);
1391 fullScreen.setFont(LABEL_FONT);
1392 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1393 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1394 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1395 quality.setEnabled(false);
1396 quality.setFont(LABEL_FONT);
1397 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1398 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1399 quality.setSelected(true);
1400 quality.setText(MessageManager.getString("label.quality"));
1401 conservation.setEnabled(false);
1402 conservation.setFont(LABEL_FONT);
1403 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1404 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1405 conservation.setSelected(true);
1406 conservation.setText(MessageManager.getString("label.conservation"));
1407 identity.setEnabled(false);
1408 identity.setFont(LABEL_FONT);
1409 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1410 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1411 identity.setSelected(true);
1412 identity.setText(MessageManager.getString("label.consensus"));
1413 showOccupancy.setFont(LABEL_FONT);
1414 showOccupancy.setEnabled(false);
1415 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1416 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1417 showOccupancy.setSelected(true);
1418 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1420 JLabel showGroupbits = new JLabel();
1421 showGroupbits.setFont(LABEL_FONT);
1422 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1423 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1425 .setText(MessageManager.getString("action.show_group") + ":");
1426 JLabel showConsensbits = new JLabel();
1427 showConsensbits.setFont(LABEL_FONT);
1428 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1429 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1431 .setText(MessageManager.getString("label.consensus") + ":");
1432 showConsensHistogram.setEnabled(false);
1433 showConsensHistogram.setFont(LABEL_FONT);
1434 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1435 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1436 showConsensHistogram.setSelected(true);
1437 showConsensHistogram
1438 .setText(MessageManager.getString("label.histogram"));
1439 showConsensLogo.setEnabled(false);
1440 showConsensLogo.setFont(LABEL_FONT);
1441 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1442 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1443 showConsensLogo.setSelected(true);
1444 showConsensLogo.setText(MessageManager.getString("label.logo"));
1445 showGroupConsensus.setEnabled(false);
1446 showGroupConsensus.setFont(LABEL_FONT);
1447 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1448 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1449 showGroupConsensus.setSelected(true);
1450 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1451 showGroupConservation.setEnabled(false);
1452 showGroupConservation.setFont(LABEL_FONT);
1453 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1454 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1455 showGroupConservation.setSelected(true);
1456 showGroupConservation
1457 .setText(MessageManager.getString("label.conservation"));
1458 showNpTooltip.setEnabled(true);
1459 showNpTooltip.setFont(LABEL_FONT);
1460 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1461 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1462 showNpTooltip.setSelected(true);
1463 showNpTooltip.setText(
1464 MessageManager.getString("label.non_positional_features"));
1465 showDbRefTooltip.setEnabled(true);
1466 showDbRefTooltip.setFont(LABEL_FONT);
1467 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1468 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1469 showDbRefTooltip.setSelected(true);
1471 .setText(MessageManager.getString("label.database_references"));
1472 annotations.setFont(LABEL_FONT);
1473 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1474 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1475 annotations.setSelected(true);
1476 annotations.setText(MessageManager.getString("label.show_annotations"));
1477 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1478 annotations.addActionListener(new ActionListener()
1481 public void actionPerformed(ActionEvent e)
1483 annotations_actionPerformed(e);
1486 identity.addActionListener(new ActionListener()
1489 public void actionPerformed(ActionEvent e)
1491 annotations_actionPerformed(e);
1494 showGroupConsensus.addActionListener(new ActionListener()
1497 public void actionPerformed(ActionEvent e)
1499 annotations_actionPerformed(e);
1502 showUnconserved.setFont(LABEL_FONT);
1503 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1504 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1505 showUnconserved.setSelected(true);
1507 .setText(MessageManager.getString("action.show_unconserved"));
1508 showUnconserved.addActionListener(new ActionListener()
1511 public void actionPerformed(ActionEvent e)
1513 showunconserved_actionPerformed(e);
1517 // TODO these are not yet added to / action from Preferences
1518 // JCheckBox shareSelections = new JCheckBox();
1519 // shareSelections.setFont(verdana11);
1520 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1521 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1522 // shareSelections.setSelected(true);
1523 // shareSelections.setText(MessageManager
1524 // .getString("label.share_selection_across_views"));
1525 // JCheckBox followHighlight = new JCheckBox();
1526 // followHighlight.setFont(verdana11);
1527 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1528 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1529 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1530 // followHighlight.setSelected(true);
1531 // followHighlight.setText(MessageManager
1532 // .getString("label.scroll_highlighted_regions"));
1534 seqLimit.setFont(LABEL_FONT);
1535 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1536 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1537 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1538 smoothFont.setFont(LABEL_FONT);
1539 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1540 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1541 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1542 scaleProteinToCdna.setFont(LABEL_FONT);
1543 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1544 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1545 scaleProteinToCdna.setText(
1546 MessageManager.getString("label.scale_protein_to_cdna"));
1547 scaleProteinToCdna.setToolTipText(
1548 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1549 JLabel gapLabel = new JLabel();
1550 gapLabel.setFont(LABEL_FONT);
1551 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1552 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1553 JLabel fontLabel = new JLabel();
1554 fontLabel.setFont(LABEL_FONT);
1555 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1556 fontLabel.setText(MessageManager.getString("label.font"));
1557 fontSizeCB.setFont(LABEL_FONT);
1558 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1559 fontStyleCB.setFont(LABEL_FONT);
1560 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1561 fontNameCB.setFont(LABEL_FONT);
1562 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1563 gapSymbolCB.setFont(LABEL_FONT);
1564 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1565 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1566 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1567 gapSymbolCB.setRenderer(dlcr);
1569 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1570 startupCheckbox.setFont(LABEL_FONT);
1571 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1572 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1573 startupCheckbox.setSelected(true);
1574 startupFileTextfield.setFont(LABEL_FONT);
1575 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1576 final String tooltip = JvSwingUtils.wrapTooltip(true,
1577 MessageManager.getString("label.double_click_to_browse"));
1578 startupFileTextfield.setToolTipText(tooltip);
1579 startupFileTextfield.addMouseListener(new MouseAdapter()
1582 public void mouseClicked(MouseEvent e)
1584 if (e.getClickCount() > 1)
1586 startupFileTextfield_mouseClicked();
1591 sortby.setFont(LABEL_FONT);
1592 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1593 JLabel sortLabel = new JLabel();
1594 sortLabel.setFont(LABEL_FONT);
1595 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1596 sortLabel.setText(MessageManager.getString("label.sort_by"));
1597 sortAnnBy.setFont(LABEL_FONT);
1598 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1599 JLabel sortAnnLabel = new JLabel();
1600 sortAnnLabel.setFont(LABEL_FONT);
1601 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1602 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1603 sortAutocalc.setFont(LABEL_FONT);
1604 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1606 JPanel annsettingsPanel = new JPanel();
1607 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1608 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1609 annsettingsPanel.setBorder(new EtchedBorder());
1610 visualTab.add(annsettingsPanel);
1611 Border jb = new EmptyBorder(1, 1, 4, 5);
1612 annotations.setBorder(jb);
1613 showOccupancy.setBorder(jb);
1614 quality.setBorder(jb);
1615 conservation.setBorder(jb);
1616 identity.setBorder(jb);
1617 showConsensbits.setBorder(jb);
1618 showGroupbits.setBorder(jb);
1619 showGroupConsensus.setBorder(jb);
1620 showGroupConservation.setBorder(jb);
1621 showConsensHistogram.setBorder(jb);
1622 showConsensLogo.setBorder(jb);
1624 JPanel autoAnnotSettings = new JPanel();
1625 annsettingsPanel.add(autoAnnotSettings);
1626 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1627 autoAnnotSettings.add(annotations);
1628 autoAnnotSettings.add(quality);
1629 // second row of autoannotation box
1630 autoAnnotSettings = new JPanel();
1631 annsettingsPanel.add(autoAnnotSettings);
1633 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1634 autoAnnotSettings.add(conservation);
1635 autoAnnotSettings.add(identity);
1636 autoAnnotSettings.add(showOccupancy);
1637 autoAnnotSettings.add(showGroupbits);
1638 autoAnnotSettings.add(showGroupConservation);
1639 autoAnnotSettings.add(showGroupConsensus);
1640 autoAnnotSettings.add(showConsensbits);
1641 autoAnnotSettings.add(showConsensHistogram);
1642 autoAnnotSettings.add(showConsensLogo);
1644 JPanel tooltipSettings = new JPanel();
1645 tooltipSettings.setBorder(new TitledBorder(
1646 MessageManager.getString("label.sequence_id_tooltip")));
1647 tooltipSettings.setBounds(173, 140, 220, 62);
1648 tooltipSettings.setLayout(new GridLayout(2, 1));
1649 tooltipSettings.add(showDbRefTooltip);
1650 tooltipSettings.add(showNpTooltip);
1651 visualTab.add(tooltipSettings);
1653 wrap.setFont(LABEL_FONT);
1654 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1655 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1656 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1657 rightAlign.setFont(LABEL_FONT);
1658 rightAlign.setForeground(Color.black);
1659 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1660 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1661 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1662 idItalics.setFont(LABEL_FONT_ITALIC);
1663 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1664 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1666 MessageManager.getString("label.sequence_name_italics"));
1667 openoverv.setFont(LABEL_FONT);
1668 openoverv.setActionCommand(
1669 MessageManager.getString("label.open_overview"));
1670 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1671 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1672 openoverv.setText(MessageManager.getString("label.open_overview"));
1673 JPanel jPanel2 = new JPanel();
1674 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1675 jPanel2.setLayout(new GridLayout(14, 1));
1676 jPanel2.add(fullScreen);
1677 jPanel2.add(openoverv);
1678 jPanel2.add(seqLimit);
1679 jPanel2.add(rightAlign);
1680 jPanel2.add(fontLabel);
1681 jPanel2.add(showUnconserved);
1682 jPanel2.add(idItalics);
1683 jPanel2.add(smoothFont);
1684 jPanel2.add(scaleProteinToCdna);
1685 jPanel2.add(gapLabel);
1687 jPanel2.add(sortLabel);
1688 jPanel2.add(sortAnnLabel);
1689 jPanel2.add(startupCheckbox);
1690 visualTab.add(jPanel2);
1691 visualTab.add(startupFileTextfield);
1692 visualTab.add(sortby);
1693 visualTab.add(sortAnnBy);
1694 visualTab.add(sortAutocalc);
1695 visualTab.add(gapSymbolCB);
1696 visualTab.add(fontNameCB);
1697 visualTab.add(fontSizeCB);
1698 visualTab.add(fontStyleCB);
1703 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1706 protected void loadLastSavedBackupsOptions()
1708 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1709 .getSavedBackupEntry();
1711 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1713 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1714 .createBackupFilesPresetEntry(Cache
1715 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1716 if (backupfilesCustomEntry == null)
1718 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1719 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1721 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1722 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1723 backupfilesCustomEntry);
1725 setComboIntStringKey(backupfilesPresetsCombo,
1726 Cache.getDefault(BackupFiles.NS + "_PRESET",
1727 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1729 backupsSetOptions(savedPreset);
1731 backupsOptionsSetEnabled();
1732 updateBackupFilesExampleLabel();
1735 private boolean warnAboutSuffixReverseChange()
1737 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1738 .getSavedBackupEntry();
1739 boolean savedSuffixReverse = bfpe.reverse;
1740 int savedSuffixDigits = bfpe.digits;
1741 String savedSuffixTemplate = bfpe.suffix;
1743 boolean nowSuffixReverse = suffixReverse.isSelected();
1744 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1745 String nowSuffixTemplate = suffixTemplate.getText();
1746 return nowSuffixReverse != savedSuffixReverse
1747 && nowSuffixDigits == savedSuffixDigits
1748 && nowSuffixTemplate != null
1749 && nowSuffixTemplate.equals(savedSuffixTemplate);
1753 * Initialises the Backups tabbed panel.
1757 private JPanel initBackupsTab()
1759 JPanel backupsTab = new JPanel();
1760 backupsTab.setBorder(new TitledBorder(
1761 MessageManager.getString("label.backup_files")));
1762 backupsTab.setLayout(new GridBagLayout());
1764 GridBagConstraints gbc = new GridBagConstraints();
1767 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1768 gbc.fill = GridBagConstraints.NONE;
1770 initBackupsTabPresetsPanel();
1771 initBackupsTabSuffixPanel();
1772 initBackupsTabKeepFilesPanel();
1773 initBackupsTabFilenameExamplesPanel();
1775 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1777 .setText(MessageManager.getString("label.enable_backupfiles"));
1778 enableBackupFiles.addActionListener(new ActionListener()
1781 public void actionPerformed(ActionEvent e)
1783 // enable other options only when the first is checked
1784 backupsOptionsSetEnabled();
1789 // enable checkbox 1 col
1793 gbc.gridy = 0; // row 0
1794 backupsTab.add(enableBackupFiles, gbc);
1796 // summary of scheme box (over two rows)
1800 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1801 gbc.fill = GridBagConstraints.BOTH;
1802 backupsTab.add(exampleFilesPanel, gbc);
1804 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1805 gbc.fill = GridBagConstraints.NONE;
1807 // fill empty space on right
1810 backupsTab.add(new JPanel(), gbc);
1815 gbc.gridy++; // row 1
1816 backupsTab.add(presetsPanel, gbc);
1818 // now using whole row
1823 gbc.gridy++; // row 2
1824 backupsTab.add(keepfilesPanel, gbc);
1826 // filename strategy box
1827 gbc.gridy++; // row 3
1828 backupsTab.add(suffixPanel, gbc);
1831 gbc.gridy++; // row 4
1833 backupsTab.add(new JPanel(), gbc);
1835 backupsOptionsSetEnabled();
1839 private JPanel initBackupsTabPresetsPanel()
1842 String title = MessageManager.getString("label.schemes");
1844 presetsPanel.setLayout(new GridBagLayout());
1846 GridBagConstraints gbc = new GridBagConstraints();
1849 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1850 gbc.fill = GridBagConstraints.NONE;
1858 presetsComboLabel = new JLabel(title + ":");
1859 presetsPanel.add(presetsComboLabel, gbc);
1861 List<Object> entries = Arrays
1862 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
1863 List<String> tooltips = Arrays.asList(
1864 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
1865 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
1868 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1870 backupfilesPresetsCombo
1871 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1875 backupfilesPresetsCombo.addActionListener(new ActionListener()
1878 public void actionPerformed(ActionEvent e)
1880 int key = getComboIntStringKey(backupfilesPresetsCombo);
1881 if (!customiseCheckbox.isSelected())
1883 backupfilesPresetsComboLastSelected = key;
1885 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1887 if (customiseCheckbox.isSelected())
1889 // got here by clicking on customiseCheckbox so don't change the values
1890 backupfilesCustomOptionsSetEnabled();
1894 backupsTabUpdatePresets();
1895 backupfilesCustomOptionsSetEnabled();
1900 customiseCheckbox.setSelected(false);
1901 backupsTabUpdatePresets();
1902 backupfilesCustomOptionsSetEnabled();
1907 // dropdown list of preset schemes
1909 presetsPanel.add(backupfilesPresetsCombo, gbc);
1911 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1912 revertButton.setToolTipText(
1913 MessageManager.getString("label.cancel_changes_description"));
1914 revertButton.addActionListener(new ActionListener()
1917 public void actionPerformed(ActionEvent e)
1920 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
1921 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
1922 backupfilesCustomOptionsSetEnabled();
1926 revertButton.setFont(LABEL_FONT);
1928 customiseCheckbox.setFont(LABEL_FONT);
1929 customiseCheckbox.setText(MessageManager.getString("label.customise"));
1930 customiseCheckbox.addActionListener(new ActionListener()
1933 public void actionPerformed(ActionEvent e)
1935 int currently = getComboIntStringKey(backupfilesPresetsCombo);
1936 if (customiseCheckbox.isSelected())
1938 backupfilesPresetsComboLastSelected = currently;
1939 setComboIntStringKey(backupfilesPresetsCombo,
1940 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
1944 setComboIntStringKey(backupfilesPresetsCombo,
1945 backupfilesPresetsComboLastSelected);
1948 backupfilesCustomOptionsSetEnabled();
1951 customiseCheckbox.setToolTipText(
1952 MessageManager.getString("label.customise_description"));
1954 // customise checkbox
1957 presetsPanel.add(customiseCheckbox, gbc);
1959 // "Cancel changes" button (aligned with combo box above)
1961 presetsPanel.add(revertButton, gbc);
1963 return presetsPanel;
1966 private JPanel initBackupsTabFilenameExamplesPanel()
1968 String title = MessageManager
1969 .getString("label.scheme_examples");
1970 TitledBorder tb = new TitledBorder(title);
1971 exampleFilesPanel.setBorder(tb);
1972 exampleFilesPanel.setLayout(new GridBagLayout());
1975 backupfilesExampleLabel.setEditable(false);
1976 backupfilesExampleLabel
1977 .setBackground(exampleFilesPanel.getBackground());
1979 updateBackupFilesExampleLabel();
1981 GridBagConstraints gbc = new GridBagConstraints();
1984 gbc.fill = GridBagConstraints.NONE;
1985 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1987 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1988 return exampleFilesPanel;
1991 private void backupsTabUpdatePresets()
1993 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1996 String value = entry.v;
1998 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2002 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2008 "Preset '" + value + "' [key:" + key + "] not implemented");
2011 // Custom options will now be enabled when the customiseCheckbox is checked
2012 // (performed above)
2013 // backupfilesCustomOptionsSetEnabled();
2014 updateBackupFilesExampleLabel();
2017 protected int getComboIntStringKey(
2018 JComboBox<Object> backupfilesPresetsCombo2)
2020 IntKeyStringValueEntry e;
2023 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2025 } catch (Exception ex)
2028 "Problem casting Combo entry to IntKeyStringValueEntry.");
2031 return e != null ? e.k : 0;
2034 protected void setComboIntStringKey(
2035 JComboBox<Object> backupfilesPresetsCombo2,
2038 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2040 IntKeyStringValueEntry e;
2043 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2044 } catch (Exception ex)
2047 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2052 backupfilesPresetsCombo2.setSelectedIndex(i);
2056 // backupsTabUpdatePresets();
2059 private JPanel initBackupsTabSuffixPanel()
2061 suffixPanel.setBorder(new TitledBorder(
2062 MessageManager.getString("label.backup_filename_strategy")));
2063 suffixPanel.setLayout(new GridBagLayout());
2066 .setText(MessageManager.getString("label.append_to_filename"));
2067 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2068 suffixTemplateLabel.setFont(LABEL_FONT);
2070 final String tooltip = JvSwingUtils.wrapTooltip(true,
2071 MessageManager.getString("label.append_to_filename_tooltip"));
2072 suffixTemplate.setToolTipText(tooltip);
2073 suffixTemplate.addActionListener(new ActionListener()
2076 public void actionPerformed(ActionEvent e)
2078 updateBackupFilesExampleLabel();
2079 backupfilesCustomOptionsSetEnabled();
2080 backupfilesRevertButtonSetEnabled(true);
2084 suffixTemplate.addKeyListener(new KeyListener()
2087 public void keyReleased(KeyEvent e)
2089 updateBackupFilesExampleLabel();
2090 backupfilesCustomOptionsSetEnabled();
2091 backupfilesRevertButtonSetEnabled(true);
2095 public void keyPressed(KeyEvent e)
2099 // disable use of ':' or '/' or '\'
2101 public void keyTyped(KeyEvent e)
2103 char c = e.getKeyChar();
2104 if (c == ':' || c == '/' || c == '\\')
2106 // don't process ':' or '/' or '\'
2115 .setText(MessageManager.getString("label.index_digits"));
2116 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2117 suffixDigitsLabel.setFont(LABEL_FONT);
2118 ChangeListener c = new ChangeListener()
2121 public void stateChanged(ChangeEvent e)
2123 backupfilesRevertButtonSetEnabled(true);
2124 updateBackupFilesExampleLabel();
2128 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2129 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2131 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2132 MessageManager.getString("label.increment_index"));
2133 suffixReverse.addActionListener(new ActionListener()
2136 public void actionPerformed(ActionEvent e)
2138 boolean okay = true;
2139 if (warnAboutSuffixReverseChange())
2142 okay = confirmSuffixReverseChange();
2146 backupfilesRevertButtonSetEnabled(true);
2147 updateBackupFilesExampleLabel();
2151 boolean savedSuffixReverse = BackupFilesPresetEntry
2152 .getSavedBackupEntry().reverse;
2153 suffixReverse.setSelected(savedSuffixReverse);
2158 GridBagConstraints sgbc = new GridBagConstraints();
2160 // first row (template text box)
2161 sgbc.anchor = GridBagConstraints.WEST;
2165 sgbc.gridheight = 1;
2168 sgbc.fill = GridBagConstraints.NONE;
2169 suffixPanel.add(suffixTemplateLabel, sgbc);
2172 sgbc.fill = GridBagConstraints.HORIZONTAL;
2173 suffixPanel.add(suffixTemplate, sgbc);
2175 // second row (number of digits spinner)
2179 sgbc.fill = GridBagConstraints.NONE;
2180 suffixPanel.add(suffixDigitsLabel, sgbc);
2183 sgbc.fill = GridBagConstraints.HORIZONTAL;
2184 suffixPanel.add(suffixDigitsSpinner, sgbc);
2186 // third row (forward order radio selection)
2189 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2190 sgbc.fill = GridBagConstraints.HORIZONTAL;
2191 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2193 // fourth row (reverse order radio selection)
2195 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2199 private boolean confirmSuffixReverseChange()
2201 boolean ret = false;
2202 String warningMessage = MessageManager
2203 .getString("label.warning_confirm_change_reverse");
2204 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2206 MessageManager.getString("label.change_increment_decrement"),
2207 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2209 ret = (confirm == JvOptionPane.YES_OPTION);
2213 private JPanel initBackupsTabKeepFilesPanel()
2215 keepfilesPanel.setBorder(
2216 new TitledBorder(MessageManager.getString("label.keep_files")));
2217 keepfilesPanel.setLayout(new GridBagLayout());
2219 backupfilesKeepAll.setLabels(
2220 MessageManager.getString("label.keep_all_backup_files"),
2221 MessageManager.getString(
2222 "label.keep_only_this_number_of_backup_files"));
2223 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2226 public void actionPerformed(ActionEvent e)
2228 backupfilesRevertButtonSetEnabled(true);
2229 updateBackupFilesExampleLabel();
2232 backupfilesKeepAll.addActionListener(new ActionListener()
2235 public void actionPerformed(ActionEvent e)
2237 backupfilesRevertButtonSetEnabled(true);
2238 keepRollMaxOptionsEnabled();
2239 updateBackupFilesExampleLabel();
2243 ChangeListener c = new ChangeListener()
2246 public void stateChanged(ChangeEvent e)
2248 backupfilesRevertButtonSetEnabled(true);
2249 updateBackupFilesExampleLabel();
2253 setIntegerSpinner(backupfilesRollMaxSpinner,
2254 BackupFilesPresetEntry.ROLLMAXMIN,
2255 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2257 backupfilesConfirmDelete.setLabels(
2258 MessageManager.getString("label.always_ask"),
2259 MessageManager.getString("label.auto_delete"));
2260 backupfilesConfirmDelete.addActionListener(new ActionListener()
2263 public void actionPerformed(ActionEvent e)
2265 backupfilesRevertButtonSetEnabled(true);
2268 // update the enabled section
2269 keepRollMaxOptionsEnabled();
2271 GridBagConstraints kgbc = new GridBagConstraints();
2273 // first row (template text box)
2274 kgbc.anchor = GridBagConstraints.WEST;
2277 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2278 kgbc.gridheight = 1;
2281 kgbc.fill = GridBagConstraints.HORIZONTAL;
2282 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2288 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2289 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2292 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2293 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2295 // third row (indented)
2297 kgbc.insets = new Insets(0, 20, 0, 0);
2300 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2301 kgbc.fill = GridBagConstraints.HORIZONTAL;
2304 JPanel jp = new JPanel();
2305 jp.setLayout(new FlowLayout());
2307 .setText(MessageManager
2308 .getString("label.autodelete_old_backup_files"));
2309 oldBackupFilesLabel.setFont(LABEL_FONT);
2310 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2311 jp.add(oldBackupFilesLabel);
2312 jp.add(backupfilesConfirmDelete.getTrueButton());
2313 jp.add(backupfilesConfirmDelete.getFalseButton());
2314 keepfilesPanel.add(jp, kgbc);
2316 return keepfilesPanel;
2319 protected void updateBackupFilesExampleLabel()
2321 int exampleindex = 12;
2322 String base = MessageManager.getString("label.filename") + ".fa";
2323 if (base == null || base.length() == 0)
2325 base = "file_name.fa";
2328 boolean reverse = suffixReverse.isSelected();
2329 boolean keepAll = backupfilesKeepAll.isSelected();
2331 String suffix = suffixTemplate.getText();
2334 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2335 if (suffix == null || suffix.length() == 0)
2337 backupfilesExampleLabel
2338 .setText(MessageManager.getString("label.no_backup_files"));
2339 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2343 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2344 rollMax = rollMax < 1 ? 1 : rollMax;
2346 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2351 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2352 digits = digits < 1 ? 1 : digits;
2354 int lowersurround = 2;
2355 int uppersurround = 0;
2356 StringBuilder exampleSB = new StringBuilder();
2357 boolean firstLine = true;
2363 int max = keepAll ? exampleindex : rollMax;
2364 for (int index = min; index <= max; index++)
2366 if (index == min + lowersurround && index < max - uppersurround - 1)
2368 exampleSB.append("\n...");
2371 else if (index > min + lowersurround && index < max - uppersurround)
2383 exampleSB.append("\n");
2386 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2387 base, suffix, digits));
2390 // no extra text needed
2392 else if (index == min)
2394 String newest = MessageManager.getString("label.braced_newest");
2395 if (newest != null && newest.length() > 0)
2397 exampleSB.append(" " + newest);
2400 else if (index == max)
2402 String oldest = MessageManager.getString("label.braced_oldest");
2403 if (oldest != null && oldest.length() > 0)
2405 exampleSB.append(" " + oldest);
2414 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2415 : exampleindex - rollMax + 1;
2416 int max = exampleindex;
2418 for (int index = min; index <= max; index++)
2421 if (index == min + lowersurround && index < max - uppersurround - 1)
2423 exampleSB.append("\n...");
2426 else if (index > min + lowersurround && index < max - uppersurround)
2438 exampleSB.append("\n");
2441 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2442 base, suffix, digits));
2445 // no extra text needed
2447 else if (index == min)
2449 String oldest = MessageManager.getString("label.braced_oldest");
2450 if (oldest != null && oldest.length() > 0)
2452 exampleSB.append(" " + oldest);
2455 else if (index == max)
2457 String newest = MessageManager.getString("label.braced_newest");
2458 if (newest != null && newest.length() > 0)
2460 exampleSB.append(" " + newest);
2468 // add some extra empty lines to pad out the example files box. ugh, please tell
2469 // me how to do this better
2470 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2471 if (remainingLines > 0)
2473 for (int i = 0; i < remainingLines; i++)
2475 exampleSB.append("\n ");
2480 backupfilesExampleLabel.setText(exampleSB.toString());
2483 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2484 boolean useExistingVal, ChangeListener c)
2491 i = ((Integer) s.getValue()).intValue();
2492 } catch (Exception e)
2495 "Exception casting the initial value of s.getValue()");
2499 setIntegerSpinner(s, min, max, i, c);
2502 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2505 // integer spinner for number of digits
2510 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2513 s.addChangeListener(c);
2517 protected static int getSpinnerInt(JSpinner s, int def)
2523 i = (Integer) s.getValue();
2524 } catch (Exception e)
2526 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2531 private void keepRollMaxOptionsEnabled()
2533 boolean enabled = backupfilesKeepAll.isEnabled()
2534 && !backupfilesKeepAll.isSelected();
2535 oldBackupFilesLabel.setEnabled(enabled);
2536 backupfilesRollMaxSpinner.setEnabled(enabled);
2537 backupfilesConfirmDelete.setEnabled(enabled);
2540 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2542 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2543 && customiseCheckbox.isSelected()
2544 && suffixTemplate.getText()
2545 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2546 keepfilesPanel.setEnabled(enabled);
2547 backupfilesKeepAll.setEnabled(enabled);
2548 oldBackupFilesLabel.setEnabled(enabled);
2549 keepRollMaxOptionsEnabled();
2552 private void backupfilesSuffixTemplateDigitsSetEnabled()
2554 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2555 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2556 suffixDigitsLabel.setEnabled(enabled);
2557 suffixDigitsSpinner.setEnabled(enabled);
2558 suffixReverse.setEnabled(enabled);
2561 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2563 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2564 && customiseCheckbox.isSelected();
2565 suffixPanel.setEnabled(enabled);
2566 suffixTemplateLabel.setEnabled(enabled);
2567 suffixTemplate.setEnabled(enabled);
2568 backupfilesSuffixTemplateDigitsSetEnabled();
2571 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2573 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2574 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2575 revertButton.setEnabled(enabled);
2578 private boolean backupfilesCustomChanged()
2580 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2581 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2582 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2583 return !custom.equals(current);
2586 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2588 String suffix = suffixTemplate.getText();
2589 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2590 boolean reverse = suffixReverse.isSelected();
2591 boolean keepAll = backupfilesKeepAll.isSelected();
2592 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2593 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2595 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2596 reverse, keepAll, rollMax, confirmDelete);
2601 protected void backupfilesCustomOptionsSetEnabled()
2603 boolean enabled = customiseCheckbox.isSelected();
2605 backupfilesRevertButtonSetEnabled(enabled);
2606 backupfilesSuffixTemplateSetEnabled(enabled);
2607 backupfilesKeepAllSetEnabled(enabled);
2610 private void backupfilesSummarySetEnabled()
2612 boolean enabled = enableBackupFiles.isSelected();
2613 backupfilesExampleLabel.setEnabled(enabled);
2614 exampleFilesPanel.setEnabled(enabled);
2617 private void backupfilesPresetsSetEnabled()
2619 boolean enabled = enableBackupFiles.isSelected();
2620 presetsPanel.setEnabled(enabled);
2621 presetsComboLabel.setEnabled(enabled);
2622 backupfilesPresetsCombo.setEnabled(enabled);
2623 customiseCheckbox.setEnabled(enabled);
2624 revertButton.setEnabled(enabled);
2627 protected void backupsOptionsSetEnabled()
2629 backupfilesPresetsSetEnabled();
2630 backupfilesSummarySetEnabled();
2631 backupfilesCustomOptionsSetEnabled();
2634 protected void backupsSetOptions(String suffix, int digits,
2635 boolean reverse, boolean keepAll, int rollMax,
2636 boolean confirmDelete)
2638 suffixTemplate.setText(suffix);
2639 suffixDigitsSpinner.setValue(digits);
2640 suffixReverse.setSelected(reverse);
2641 backupfilesKeepAll.setSelected(keepAll);
2642 backupfilesRollMaxSpinner.setValue(rollMax);
2643 backupfilesConfirmDelete.setSelected(confirmDelete);
2646 protected void backupsSetOptions(BackupFilesPresetEntry p)
2648 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2652 protected void autoIdWidth_actionPerformed()
2654 // TODO Auto-generated method stub
2658 protected void userIdWidth_actionPerformed()
2660 // TODO Auto-generated method stub
2664 protected void maxColour_actionPerformed(JPanel panel)
2668 protected void minColour_actionPerformed(JPanel panel)
2672 protected void gapColour_actionPerformed(JPanel panel)
2676 protected void hiddenColour_actionPerformed(JPanel panel)
2680 protected void showunconserved_actionPerformed(ActionEvent e)
2682 // TODO Auto-generated method stub
2686 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2690 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2700 public void ok_actionPerformed(ActionEvent e)
2710 public void cancel_actionPerformed(ActionEvent e)
2720 public void annotations_actionPerformed(ActionEvent e)
2727 public void startupFileTextfield_mouseClicked()
2731 public void newLink_actionPerformed(ActionEvent e)
2736 public void editLink_actionPerformed(ActionEvent e)
2741 public void deleteLink_actionPerformed(ActionEvent e)
2746 public void defaultBrowser_mouseClicked(MouseEvent e)
2751 public void linkURLList_keyTyped(KeyEvent e)
2756 public void useProxy_actionPerformed()
2758 boolean enabled = useProxy.isSelected();
2759 portLabel.setEnabled(enabled);
2760 serverLabel.setEnabled(enabled);
2761 proxyServerTB.setEnabled(enabled);
2762 proxyPortTB.setEnabled(enabled);
2766 * Customer renderer for JTable: supports column of radio buttons
2768 public class RadioButtonRenderer extends JRadioButton
2769 implements TableCellRenderer
2771 public RadioButtonRenderer()
2773 setHorizontalAlignment(CENTER);
2774 setToolTipText(MessageManager.getString("label.urltooltip"));
2778 public Component getTableCellRendererComponent(JTable table,
2779 Object value, boolean isSelected, boolean hasFocus, int row,
2782 setSelected((boolean) value);
2784 // set colours to match rest of table
2787 setBackground(table.getSelectionBackground());
2788 setForeground(table.getSelectionForeground());
2792 setBackground(table.getBackground());
2793 setForeground(table.getForeground());
2800 * Customer cell editor for JTable: supports column of radio buttons in
2801 * conjunction with renderer
2803 public class RadioButtonEditor extends AbstractCellEditor
2804 implements TableCellEditor
2806 private JRadioButton button = new JRadioButton();
2808 public RadioButtonEditor()
2810 button.setHorizontalAlignment(SwingConstants.CENTER);
2811 this.button.addActionListener(new ActionListener()
2814 public void actionPerformed(ActionEvent e)
2816 fireEditingStopped();
2822 public Component getTableCellEditorComponent(JTable table, Object value,
2823 boolean isSelected, int row, int column)
2825 button.setSelected((boolean) value);
2830 public Object getCellEditorValue()
2832 return button.isSelected();