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;
36 import java.awt.BorderLayout;
37 import java.awt.Color;
38 import java.awt.Component;
39 import java.awt.Dimension;
40 import java.awt.FlowLayout;
42 import java.awt.GridBagConstraints;
43 import java.awt.GridBagLayout;
44 import java.awt.GridLayout;
45 import java.awt.Insets;
46 import java.awt.Rectangle;
47 import java.awt.event.ActionEvent;
48 import java.awt.event.ActionListener;
49 import java.awt.event.FocusEvent;
50 import java.awt.event.KeyEvent;
51 import java.awt.event.KeyListener;
52 import java.awt.event.MouseAdapter;
53 import java.awt.event.MouseEvent;
54 import java.util.HashMap;
57 import javax.swing.AbstractCellEditor;
58 import javax.swing.BorderFactory;
59 import javax.swing.ButtonGroup;
60 import javax.swing.DefaultListCellRenderer;
61 import javax.swing.JButton;
62 import javax.swing.JCheckBox;
63 import javax.swing.JComboBox;
64 import javax.swing.JFileChooser;
65 import javax.swing.JLabel;
66 import javax.swing.JList;
67 import javax.swing.JPanel;
68 import javax.swing.JRadioButton;
69 import javax.swing.JScrollPane;
70 import javax.swing.JSpinner;
71 import javax.swing.JTabbedPane;
72 import javax.swing.JTable;
73 import javax.swing.JTextArea;
74 import javax.swing.JTextField;
75 import javax.swing.ListSelectionModel;
76 import javax.swing.SpinnerModel;
77 import javax.swing.SpinnerNumberModel;
78 import javax.swing.SwingConstants;
79 import javax.swing.border.Border;
80 import javax.swing.border.EmptyBorder;
81 import javax.swing.border.EtchedBorder;
82 import javax.swing.border.TitledBorder;
83 import javax.swing.event.ChangeEvent;
84 import javax.swing.event.ChangeListener;
85 import javax.swing.table.TableCellEditor;
86 import javax.swing.table.TableCellRenderer;
89 * Base class for the Preferences panel.
94 public class GPreferences extends JPanel
96 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
98 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
99 .getLabelFont(false, true);
101 private static final Font LABEL_FONT_BOLD = JvSwingUtils
102 .getLabelFont(true, false);
105 * Visual tab components
107 protected JCheckBox fullScreen = new JCheckBox();
109 protected JCheckBox openoverv = new JCheckBox();
111 protected JCheckBox seqLimit = new JCheckBox();
113 protected JCheckBox rightAlign = new JCheckBox();
115 protected JComboBox<String> fontSizeCB = new JComboBox<>();
117 protected JComboBox<String> fontStyleCB = new JComboBox<>();
119 protected JComboBox<String> fontNameCB = new JComboBox<>();
121 protected JCheckBox showOccupancy = new JCheckBox();
123 protected JCheckBox showUnconserved = new JCheckBox();
125 protected JCheckBox idItalics = new JCheckBox();
127 protected JCheckBox smoothFont = new JCheckBox();
129 protected JCheckBox scaleProteinToCdna = new JCheckBox();
131 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
133 protected JCheckBox wrap = new JCheckBox();
135 protected JComboBox<String> sortby = new JComboBox<>();
137 protected JComboBox<String> sortAnnBy = new JComboBox<>();
139 protected JComboBox<String> sortAutocalc = new JComboBox<>();
141 protected JCheckBox startupCheckbox = new JCheckBox();
143 protected JTextField startupFileTextfield = new JTextField();
145 // below are in the 'second column'
146 protected JCheckBox annotations = new JCheckBox();
148 protected JCheckBox quality = new JCheckBox();
150 protected JCheckBox conservation = new JCheckBox();
152 protected JCheckBox identity = new JCheckBox();
154 protected JCheckBox showGroupConsensus = new JCheckBox();
156 protected JCheckBox showGroupConservation = new JCheckBox();
158 protected JCheckBox showConsensHistogram = new JCheckBox();
160 protected JCheckBox showConsensLogo = new JCheckBox();
162 protected JCheckBox showDbRefTooltip = new JCheckBox();
164 protected JCheckBox showNpTooltip = new JCheckBox();
167 * Structure tab and components
169 protected JPanel structureTab;
171 protected JCheckBox structFromPdb = new JCheckBox();
173 protected JCheckBox useRnaView = new JCheckBox();
175 protected JCheckBox addSecondaryStructure = new JCheckBox();
177 protected JCheckBox addTempFactor = new JCheckBox();
179 protected JComboBox<String> structViewer = new JComboBox<>();
181 protected JTextField chimeraPath = new JTextField();
183 protected ButtonGroup mappingMethod = new ButtonGroup();
185 protected JRadioButton siftsMapping = new JRadioButton();
187 protected JRadioButton nwMapping = new JRadioButton();
190 * Colours tab components
192 protected JPanel minColour = new JPanel();
194 protected JPanel maxColour = new JPanel();
196 protected JComboBox<String> protColour = new JComboBox<>();
198 protected JComboBox<String> nucColour = new JComboBox<>();
201 * Overview tab components
203 protected JPanel gapColour = new JPanel();
205 protected JPanel hiddenColour = new JPanel();
207 protected JCheckBox useLegacyGap;
209 protected JCheckBox showHiddenAtStart;
211 protected JLabel gapLabel;
214 * Connections tab components
216 protected JTable linkUrlTable = new JTable();
218 protected JButton editLink = new JButton();
220 protected JButton deleteLink = new JButton();
222 protected JTextField filterTB = new JTextField();
224 protected JButton doReset = new JButton();
226 protected JButton userOnly = new JButton();
228 protected JLabel portLabel = new JLabel();
230 protected JLabel serverLabel = new JLabel();
232 protected JTextField proxyServerTB = new JTextField();
234 protected JTextField proxyPortTB = new JTextField();
236 protected JTextField defaultBrowser = new JTextField();
238 protected JCheckBox useProxy = new JCheckBox();
240 protected JCheckBox usagestats = new JCheckBox();
242 protected JCheckBox questionnaire = new JCheckBox();
244 protected JCheckBox versioncheck = new JCheckBox();
247 * Output tab components
249 protected JComboBox<Object> epsRendering = new JComboBox<>();
251 protected JLabel userIdWidthlabel = new JLabel();
253 protected JCheckBox autoIdWidth = new JCheckBox();
255 protected JTextField userIdWidth = new JTextField();
257 protected JCheckBox blcjv = new JCheckBox();
259 protected JCheckBox pileupjv = new JCheckBox();
261 protected JCheckBox clustaljv = new JCheckBox();
263 protected JCheckBox msfjv = new JCheckBox();
265 protected JCheckBox fastajv = new JCheckBox();
267 protected JCheckBox pfamjv = new JCheckBox();
269 protected JCheckBox pirjv = new JCheckBox();
271 protected JCheckBox modellerOutput = new JCheckBox();
273 protected JCheckBox embbedBioJSON = new JCheckBox();
276 * Editing tab components
278 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
280 protected JCheckBox padGaps = new JCheckBox();
282 protected JCheckBox sortByTree = new JCheckBox();
287 protected JPanel wsTab = new JPanel();
290 * Backups tab components
291 * a lot of these are member variables instead of local variables only so that they
292 * can be enabled/disabled easily in one go
295 protected JCheckBox enableBackupFiles = new JCheckBox();
297 protected JPanel presetsPanel = new JPanel();
299 protected JLabel presetsComboLabel = new JLabel();
301 protected JButton revertButton = new JButton();
303 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
305 protected JPanel suffixPanel = new JPanel();
307 protected JPanel keepfilesPanel = new JPanel();
309 protected JPanel exampleFilesPanel = new JPanel();
311 protected JTextField suffixTemplate = new JTextField(null, 8);
313 protected JLabel suffixTemplateLabel = new JLabel();
315 protected JLabel suffixDigitsLabel = new JLabel();
317 protected JSpinner suffixDigitsSpinner = new JSpinner();
319 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
321 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
323 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
325 protected JLabel oldBackupFilesLabel = new JLabel();
327 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
329 protected JTextArea backupfilesExampleLabel = new JTextArea();
332 * Creates a new GPreferences object.
334 public GPreferences()
339 } catch (Exception ex)
341 ex.printStackTrace();
346 * Construct the panel and its tabbed sub-panels.
350 private void jbInit() throws Exception
352 final JTabbedPane tabbedPane = new JTabbedPane();
353 this.setLayout(new BorderLayout());
354 JPanel okCancelPanel = initOkCancelPanel();
355 this.add(tabbedPane, BorderLayout.CENTER);
356 this.add(okCancelPanel, BorderLayout.SOUTH);
358 tabbedPane.add(initVisualTab(),
359 MessageManager.getString("label.visual"));
361 tabbedPane.add(initColoursTab(),
362 MessageManager.getString("label.colours"));
364 tabbedPane.add(initOverviewTab(),
365 MessageManager.getString("label.overview"));
367 tabbedPane.add(initStructureTab(),
368 MessageManager.getString("label.structure"));
370 tabbedPane.add(initConnectionsTab(),
371 MessageManager.getString("label.connections"));
373 tabbedPane.add(initBackupsTab(),
374 MessageManager.getString("label.backups"));
376 tabbedPane.add(initLinksTab(),
377 MessageManager.getString("label.urllinks"));
379 tabbedPane.add(initOutputTab(),
380 MessageManager.getString("label.output"));
382 tabbedPane.add(initEditingTab(),
383 MessageManager.getString("label.editing"));
386 * See WsPreferences for the real work of configuring this tab.
388 wsTab.setLayout(new BorderLayout());
389 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
392 * Handler to validate a tab before leaving it - currently only for
395 tabbedPane.addChangeListener(new ChangeListener()
397 private Component lastTab;
400 public void stateChanged(ChangeEvent e)
402 if (lastTab == structureTab
403 && tabbedPane.getSelectedComponent() != structureTab)
405 if (!validateStructure())
407 tabbedPane.setSelectedComponent(structureTab);
411 lastTab = tabbedPane.getSelectedComponent();
418 * Initialises the Editing tabbed panel.
422 private JPanel initEditingTab()
424 JPanel editingTab = new JPanel();
425 editingTab.setLayout(null);
426 autoCalculateConsCheck.setFont(LABEL_FONT);
427 autoCalculateConsCheck.setText(
428 MessageManager.getString("label.autocalculate_consensus"));
429 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
430 padGaps.setFont(LABEL_FONT);
432 MessageManager.getString("label.pad_gaps_when_editing"));
433 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
434 sortByTree.setFont(LABEL_FONT);
436 .setText(MessageManager.getString("label.sort_with_new_tree"));
437 sortByTree.setToolTipText(MessageManager.getString(
438 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
439 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
440 editingTab.add(autoCalculateConsCheck);
441 editingTab.add(padGaps);
442 editingTab.add(sortByTree);
447 * Initialises the Output tabbed panel.
451 private JPanel initOutputTab()
453 JPanel outputTab = new JPanel();
454 outputTab.setLayout(null);
455 JLabel epsLabel = new JLabel();
456 epsLabel.setFont(LABEL_FONT);
457 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
458 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
459 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
460 epsRendering.setFont(LABEL_FONT);
461 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
462 JLabel jLabel1 = new JLabel();
463 jLabel1.setFont(LABEL_FONT);
464 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
465 jLabel1.setText(MessageManager.getString("label.append_start_end"));
466 jLabel1.setFont(LABEL_FONT);
467 fastajv.setFont(LABEL_FONT);
468 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
469 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
470 blcjv.setText(MessageManager.getString("label.blc") + " ");
471 fastajv.setText(MessageManager.getString("label.fasta") + " ");
472 msfjv.setText(MessageManager.getString("label.msf") + " ");
473 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
474 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
475 msfjv.setFont(LABEL_FONT);
476 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
477 pirjv.setText(MessageManager.getString("label.pir") + " ");
478 JPanel jPanel11 = new JPanel();
479 jPanel11.setFont(LABEL_FONT);
480 TitledBorder titledBorder2 = new TitledBorder(
481 MessageManager.getString("label.file_output"));
482 jPanel11.setBorder(titledBorder2);
483 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
484 GridLayout gridLayout3 = new GridLayout();
485 jPanel11.setLayout(gridLayout3);
486 gridLayout3.setRows(8);
487 blcjv.setFont(LABEL_FONT);
488 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
489 clustaljv.setFont(LABEL_FONT);
490 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
491 pfamjv.setFont(LABEL_FONT);
492 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
493 pileupjv.setFont(LABEL_FONT);
494 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
495 pirjv.setFont(LABEL_FONT);
496 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
497 autoIdWidth.setFont(LABEL_FONT);
499 MessageManager.getString("label.automatically_set_id_width"));
500 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
501 .getString("label.adjusts_width_generated_eps_png")));
502 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
503 autoIdWidth.addActionListener(new ActionListener()
507 public void actionPerformed(ActionEvent e)
509 autoIdWidth_actionPerformed();
512 userIdWidthlabel.setFont(LABEL_FONT);
513 userIdWidthlabel.setText(
514 MessageManager.getString("label.figure_id_column_width"));
515 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
516 .getString("label.manually_specify_width_left_column")));
517 userIdWidthlabel.setToolTipText(
518 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
519 "label.manually_specify_width_left_column")));
520 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
521 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
522 userIdWidth.setText("");
523 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
524 userIdWidth.addActionListener(new ActionListener()
528 public void actionPerformed(ActionEvent e)
530 userIdWidth_actionPerformed();
533 modellerOutput.setFont(LABEL_FONT);
535 .setText(MessageManager.getString("label.use_modeller_output"));
536 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
537 embbedBioJSON.setFont(LABEL_FONT);
538 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
539 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
541 jPanel11.add(jLabel1);
543 jPanel11.add(clustaljv);
544 jPanel11.add(fastajv);
546 jPanel11.add(pfamjv);
547 jPanel11.add(pileupjv);
549 outputTab.add(autoIdWidth);
550 outputTab.add(userIdWidth);
551 outputTab.add(userIdWidthlabel);
552 outputTab.add(modellerOutput);
553 outputTab.add(embbedBioJSON);
554 outputTab.add(epsLabel);
555 outputTab.add(epsRendering);
556 outputTab.add(jPanel11);
561 * Initialises the Connections tabbed panel.
565 private JPanel initConnectionsTab()
567 JPanel connectTab = new JPanel();
568 connectTab.setLayout(new GridBagLayout());
570 // Label for browser text box
571 JLabel browserLabel = new JLabel();
572 browserLabel.setFont(LABEL_FONT);
573 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
574 browserLabel.setText(
575 MessageManager.getString("label.default_browser_unix"));
576 defaultBrowser.setFont(LABEL_FONT);
577 defaultBrowser.setText("");
578 final String tooltip = JvSwingUtils.wrapTooltip(true,
579 MessageManager.getString("label.double_click_to_browse"));
580 defaultBrowser.setToolTipText(tooltip);
581 defaultBrowser.addMouseListener(new MouseAdapter()
584 public void mouseClicked(MouseEvent e)
586 if (e.getClickCount() > 1)
588 defaultBrowser_mouseClicked(e);
593 JPanel proxyPanel = initConnTabProxyPanel();
594 initConnTabCheckboxes();
596 // Add default Browser text box
597 connectTab.add(browserLabel,
598 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
599 GridBagConstraints.WEST, GridBagConstraints.NONE,
600 new Insets(10, 0, 5, 5), 5, 1));
601 defaultBrowser.setFont(LABEL_FONT);
602 defaultBrowser.setText("");
604 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
605 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
606 new Insets(10, 0, 5, 10), 30, 1));
608 // Add proxy server panel
609 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
610 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
611 new Insets(10, 0, 5, 12), 4, 10));
613 // Add usage stats, version check and questionnaire checkboxes
614 connectTab.add(usagestats,
615 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
616 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
617 new Insets(0, 2, 5, 5), 70, 1));
618 connectTab.add(questionnaire,
619 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
620 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
621 new Insets(0, 2, 5, 10), 70, 1));
622 connectTab.add(versioncheck,
623 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
624 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
625 new Insets(0, 2, 5, 5), 70, 1));
627 // Add padding so the panel doesn't look ridiculous
628 JPanel spacePanel = new JPanel();
629 connectTab.add(spacePanel,
630 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
631 GridBagConstraints.WEST, GridBagConstraints.BOTH,
632 new Insets(0, 0, 0, 5), 70, 1));
638 * Initialises the Links tabbed panel.
642 private JPanel initLinksTab()
644 JPanel linkTab = new JPanel();
645 linkTab.setLayout(new GridBagLayout());
647 // Set up table for Url links
648 linkUrlTable.getTableHeader().setReorderingAllowed(false);
649 linkUrlTable.setFillsViewportHeight(true);
650 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
651 linkUrlTable.setAutoCreateRowSorter(true);
652 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
654 // adjust row height so radio buttons actually fit
655 // don't do this in the renderer, it causes the awt thread to activate
657 JRadioButton temp = new JRadioButton();
658 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
660 // Table in scrollpane so that the table is given a scrollbar
661 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
662 linkScrollPane.setBorder(null);
664 // Panel for links functionality
665 JPanel linkPanel = new JPanel(new GridBagLayout());
666 linkPanel.setBorder(new TitledBorder(
667 MessageManager.getString("label.url_linkfrom_sequence_id")));
669 // Put the Url links panel together
671 // Buttons go at top right, resizing only resizes the blank space vertically
672 JPanel buttonPanel = initLinkTabUrlButtons();
673 GridBagConstraints linkConstraints1 = new GridBagConstraints();
674 linkConstraints1.insets = new Insets(0, 0, 5, 0);
675 linkConstraints1.gridx = 0;
676 linkConstraints1.gridy = 0;
677 linkConstraints1.weightx = 1.0;
678 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
679 linkTab.add(buttonPanel, linkConstraints1);
681 // Links table goes at top left, resizing resizes the table
682 GridBagConstraints linkConstraints2 = new GridBagConstraints();
683 linkConstraints2.insets = new Insets(0, 0, 5, 5);
684 linkConstraints2.gridx = 0;
685 linkConstraints2.gridy = 1;
686 linkConstraints2.weightx = 1.0;
687 linkConstraints2.weighty = 1.0;
688 linkConstraints2.fill = GridBagConstraints.BOTH;
689 linkTab.add(linkScrollPane, linkConstraints2);
691 // Filter box and buttons goes at bottom left, resizing resizes the text box
692 JPanel filterPanel = initLinkTabFilterPanel();
693 GridBagConstraints linkConstraints3 = new GridBagConstraints();
694 linkConstraints3.insets = new Insets(0, 0, 0, 5);
695 linkConstraints3.gridx = 0;
696 linkConstraints3.gridy = 2;
697 linkConstraints3.weightx = 1.0;
698 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
699 linkTab.add(filterPanel, linkConstraints3);
704 private JPanel initLinkTabFilterPanel()
706 // Filter textbox and reset button
707 JLabel filterLabel = new JLabel(
708 MessageManager.getString("label.filter"));
709 filterLabel.setFont(LABEL_FONT);
710 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
711 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
713 filterTB.setFont(LABEL_FONT);
714 filterTB.setText("");
716 doReset.setText(MessageManager.getString("action.showall"));
717 userOnly.setText(MessageManager.getString("action.customfilter"));
719 // Panel for filter functionality
720 JPanel filterPanel = new JPanel(new GridBagLayout());
721 filterPanel.setBorder(new TitledBorder("Filter"));
722 GridBagConstraints gbc = new GridBagConstraints();
725 gbc.fill = GridBagConstraints.NONE;
726 gbc.anchor = GridBagConstraints.WEST;
728 filterPanel.add(filterLabel, gbc);
730 GridBagConstraints gbc1 = new GridBagConstraints();
733 gbc1.fill = GridBagConstraints.HORIZONTAL;
734 gbc1.anchor = GridBagConstraints.WEST;
736 filterPanel.add(filterTB, gbc1);
738 GridBagConstraints gbc2 = new GridBagConstraints();
740 gbc2.fill = GridBagConstraints.NONE;
741 gbc2.anchor = GridBagConstraints.WEST;
742 filterPanel.add(doReset, gbc2);
744 GridBagConstraints gbc3 = new GridBagConstraints();
746 gbc3.fill = GridBagConstraints.NONE;
747 gbc3.anchor = GridBagConstraints.WEST;
748 filterPanel.add(userOnly, gbc3);
753 private JPanel initLinkTabUrlButtons()
755 // Buttons for new / edit / delete Url links
756 JButton newLink = new JButton();
757 newLink.setText(MessageManager.getString("action.new"));
759 editLink.setText(MessageManager.getString("action.edit"));
761 deleteLink.setText(MessageManager.getString("action.delete"));
763 // no current selection, so initially disable delete/edit buttons
764 editLink.setEnabled(false);
765 deleteLink.setEnabled(false);
767 newLink.addActionListener(new java.awt.event.ActionListener()
770 public void actionPerformed(ActionEvent e)
772 newLink_actionPerformed(e);
776 editLink.setText(MessageManager.getString("action.edit"));
777 editLink.addActionListener(new java.awt.event.ActionListener()
780 public void actionPerformed(ActionEvent e)
782 editLink_actionPerformed(e);
786 deleteLink.setText(MessageManager.getString("action.delete"));
787 deleteLink.addActionListener(new java.awt.event.ActionListener()
790 public void actionPerformed(ActionEvent e)
792 deleteLink_actionPerformed(e);
796 JPanel buttonPanel = new JPanel(new GridBagLayout());
797 buttonPanel.setBorder(new TitledBorder("Edit links"));
798 GridBagConstraints gbc = new GridBagConstraints();
801 gbc.fill = GridBagConstraints.NONE;
802 buttonPanel.add(newLink, gbc);
804 GridBagConstraints gbc1 = new GridBagConstraints();
807 gbc1.fill = GridBagConstraints.NONE;
808 buttonPanel.add(editLink, gbc1);
810 GridBagConstraints gbc2 = new GridBagConstraints();
813 gbc2.fill = GridBagConstraints.NONE;
814 buttonPanel.add(deleteLink, gbc2);
816 GridBagConstraints gbc3 = new GridBagConstraints();
819 gbc3.fill = GridBagConstraints.HORIZONTAL;
821 JPanel spacePanel = new JPanel();
822 spacePanel.setBorder(null);
823 buttonPanel.add(spacePanel, gbc3);
829 * Initialises the proxy server panel in the Connections tab
831 * @return the proxy server panel
833 private JPanel initConnTabProxyPanel()
835 // Label for server text box
836 serverLabel.setText(MessageManager.getString("label.address"));
837 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
838 serverLabel.setFont(LABEL_FONT);
840 // Proxy server and port text boxes
841 proxyServerTB.setFont(LABEL_FONT);
842 proxyPortTB.setFont(LABEL_FONT);
844 // Label for Port text box
845 portLabel.setFont(LABEL_FONT);
846 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
847 portLabel.setText(MessageManager.getString("label.port"));
849 // Use proxy server checkbox
850 useProxy.setFont(LABEL_FONT);
851 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
852 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
853 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
854 useProxy.addActionListener(new ActionListener()
857 public void actionPerformed(ActionEvent e)
859 useProxy_actionPerformed();
863 // Make proxy server panel
864 JPanel proxyPanel = new JPanel();
865 TitledBorder titledBorder1 = new TitledBorder(
866 MessageManager.getString("label.proxy_server"));
867 proxyPanel.setBorder(titledBorder1);
868 proxyPanel.setLayout(new GridBagLayout());
869 proxyPanel.add(serverLabel,
870 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
871 GridBagConstraints.WEST, GridBagConstraints.NONE,
872 new Insets(0, 2, 2, 0), 5, 0));
873 proxyPanel.add(portLabel,
874 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
875 GridBagConstraints.WEST, GridBagConstraints.NONE,
876 new Insets(0, 0, 2, 0), 11, 0));
877 proxyPanel.add(useProxy,
878 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
879 GridBagConstraints.WEST, GridBagConstraints.NONE,
880 new Insets(0, 2, 5, 185), 2, -4));
881 proxyPanel.add(proxyPortTB,
882 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
883 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
884 new Insets(0, 2, 2, 2), 54, 1));
885 proxyPanel.add(proxyServerTB,
886 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
887 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
888 new Insets(0, 2, 2, 0), 263, 1));
894 * Initialises the checkboxes in the Connections tab
896 private void initConnTabCheckboxes()
898 // Usage stats checkbox label
900 MessageManager.getString("label.send_usage_statistics"));
901 usagestats.setFont(LABEL_FONT);
902 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
903 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
905 // Questionnaire checkbox label
906 questionnaire.setText(
907 MessageManager.getString("label.check_for_questionnaires"));
908 questionnaire.setFont(LABEL_FONT);
909 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
910 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
912 // Check for latest version checkbox label
913 versioncheck.setText(
914 MessageManager.getString("label.check_for_latest_version"));
915 versioncheck.setFont(LABEL_FONT);
916 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
917 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
921 * Initialises the parent panel which contains the tabbed sections.
925 private JPanel initOkCancelPanel()
927 JButton ok = new JButton();
928 ok.setText(MessageManager.getString("action.ok"));
929 ok.addActionListener(new ActionListener()
932 public void actionPerformed(ActionEvent e)
934 ok_actionPerformed(e);
937 JButton cancel = new JButton();
938 cancel.setText(MessageManager.getString("action.cancel"));
939 cancel.addActionListener(new ActionListener()
942 public void actionPerformed(ActionEvent e)
944 cancel_actionPerformed(e);
947 JPanel okCancelPanel = new JPanel();
948 okCancelPanel.add(ok);
949 okCancelPanel.add(cancel);
950 return okCancelPanel;
954 * Initialises the Colours tabbed panel.
958 private JPanel initColoursTab()
960 JPanel coloursTab = new JPanel();
961 coloursTab.setBorder(new TitledBorder(
962 MessageManager.getString("action.open_new_alignment")));
963 coloursTab.setLayout(new FlowLayout());
964 JLabel mincolourLabel = new JLabel();
965 mincolourLabel.setFont(LABEL_FONT);
966 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
967 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
968 minColour.setFont(LABEL_FONT);
969 minColour.setBorder(BorderFactory.createEtchedBorder());
970 minColour.setPreferredSize(new Dimension(40, 20));
971 minColour.addMouseListener(new MouseAdapter()
974 public void mousePressed(MouseEvent e)
976 minColour_actionPerformed(minColour);
979 JLabel maxcolourLabel = new JLabel();
980 maxcolourLabel.setFont(LABEL_FONT);
981 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
982 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
983 maxColour.setFont(LABEL_FONT);
984 maxColour.setBorder(BorderFactory.createEtchedBorder());
985 maxColour.setPreferredSize(new Dimension(40, 20));
986 maxColour.addMouseListener(new MouseAdapter()
989 public void mousePressed(MouseEvent e)
991 maxColour_actionPerformed(maxColour);
995 protColour.setFont(LABEL_FONT);
996 protColour.setBounds(new Rectangle(172, 225, 155, 21));
997 JLabel protColourLabel = new JLabel();
998 protColourLabel.setFont(LABEL_FONT);
999 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1000 protColourLabel.setText(
1001 MessageManager.getString("label.prot_alignment_colour") + " ");
1002 JvSwingUtils.addtoLayout(coloursTab,
1004 .getString("label.default_colour_scheme_for_alignment"),
1005 protColourLabel, protColour);
1007 nucColour.setFont(LABEL_FONT);
1008 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1009 JLabel nucColourLabel = new JLabel();
1010 nucColourLabel.setFont(LABEL_FONT);
1011 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1012 nucColourLabel.setText(
1013 MessageManager.getString("label.nuc_alignment_colour") + " ");
1014 JvSwingUtils.addtoLayout(coloursTab,
1016 .getString("label.default_colour_scheme_for_alignment"),
1017 nucColourLabel, nucColour);
1019 JPanel annotationShding = new JPanel();
1020 annotationShding.setBorder(new TitledBorder(
1021 MessageManager.getString("label.annotation_shading_default")));
1022 annotationShding.setLayout(new GridLayout(1, 2));
1023 JvSwingUtils.addtoLayout(annotationShding,
1024 MessageManager.getString(
1025 "label.default_minimum_colour_annotation_shading"),
1026 mincolourLabel, minColour);
1027 JvSwingUtils.addtoLayout(annotationShding,
1028 MessageManager.getString(
1029 "label.default_maximum_colour_annotation_shading"),
1030 maxcolourLabel, maxColour);
1031 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1036 * Initialises the Overview tabbed panel.
1040 private JPanel initOverviewTab()
1042 JPanel overviewPanel = new JPanel();
1043 overviewPanel.setBorder(new TitledBorder(
1044 MessageManager.getString("label.overview_settings")));
1046 gapColour.setFont(LABEL_FONT);
1047 // fixing the border colours stops apparent colour bleed from the panel
1048 gapColour.setBorder(
1049 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1050 gapColour.setPreferredSize(new Dimension(40, 20));
1051 gapColour.addMouseListener(new MouseAdapter()
1054 public void mousePressed(MouseEvent e)
1056 gapColour_actionPerformed(gapColour);
1060 hiddenColour.setFont(LABEL_FONT);
1061 // fixing the border colours stops apparent colour bleed from the panel
1062 hiddenColour.setBorder(
1063 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1064 hiddenColour.setPreferredSize(new Dimension(40, 20));
1065 hiddenColour.addMouseListener(new MouseAdapter()
1068 public void mousePressed(MouseEvent e)
1070 hiddenColour_actionPerformed(hiddenColour);
1074 useLegacyGap = new JCheckBox(
1075 MessageManager.getString("label.ov_legacy_gap"));
1076 useLegacyGap.setFont(LABEL_FONT);
1077 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1078 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1079 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1080 gapLabel.setFont(LABEL_FONT);
1081 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1082 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1083 showHiddenAtStart = new JCheckBox(
1084 MessageManager.getString("label.ov_show_hide_default"));
1085 showHiddenAtStart.setFont(LABEL_FONT);
1086 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1087 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1088 JLabel hiddenLabel = new JLabel(
1089 MessageManager.getString("label.hidden_colour"));
1090 hiddenLabel.setFont(LABEL_FONT);
1091 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1092 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1094 useLegacyGap.addActionListener(new ActionListener()
1097 public void actionPerformed(ActionEvent e)
1099 useLegacyGaps_actionPerformed(e);
1103 overviewPanel.setLayout(new GridBagLayout());
1104 GridBagConstraints c1 = new GridBagConstraints();
1106 c1.fill = GridBagConstraints.HORIZONTAL;
1111 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1112 overviewPanel.add(useLegacyGap, c1);
1114 GridBagConstraints c2 = new GridBagConstraints();
1115 c2.fill = GridBagConstraints.HORIZONTAL;
1118 c2.insets = new Insets(0, 15, 0, 10);
1119 overviewPanel.add(gapLabel, c2);
1121 GridBagConstraints c3 = new GridBagConstraints();
1122 c3.fill = GridBagConstraints.HORIZONTAL;
1125 c3.insets = new Insets(0, 0, 0, 15);
1126 overviewPanel.add(gapColour, c3);
1128 GridBagConstraints c4 = new GridBagConstraints();
1129 c4.fill = GridBagConstraints.HORIZONTAL;
1133 overviewPanel.add(showHiddenAtStart, c4);
1135 GridBagConstraints c5 = new GridBagConstraints();
1136 c5.fill = GridBagConstraints.HORIZONTAL;
1139 c5.insets = new Insets(0, 15, 0, 10);
1140 overviewPanel.add(hiddenLabel, c5);
1142 GridBagConstraints c6 = new GridBagConstraints();
1143 c6.fill = GridBagConstraints.HORIZONTAL;
1146 c6.insets = new Insets(0, 0, 0, 15);
1147 overviewPanel.add(hiddenColour, c6);
1149 JButton resetButton = new JButton(
1150 MessageManager.getString("label.reset_to_defaults"));
1152 resetButton.addActionListener(new ActionListener()
1155 public void actionPerformed(ActionEvent e)
1157 resetOvDefaults_actionPerformed(e);
1161 GridBagConstraints c7 = new GridBagConstraints();
1162 c7.fill = GridBagConstraints.NONE;
1165 c7.insets = new Insets(10, 0, 0, 0);
1166 c7.anchor = GridBagConstraints.WEST;
1167 overviewPanel.add(resetButton, c7);
1169 // Add padding so the panel doesn't look ridiculous
1170 JPanel spacePanel = new JPanel();
1171 overviewPanel.add(spacePanel,
1172 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1173 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1174 new Insets(0, 0, 0, 5), 0, 0));
1176 return overviewPanel;
1180 * Initialises the Structure tabbed panel.
1184 private JPanel initStructureTab()
1186 structureTab = new JPanel();
1188 structureTab.setBorder(new TitledBorder(
1189 MessageManager.getString("label.structure_options")));
1190 structureTab.setLayout(null);
1191 final int width = 400;
1192 final int height = 22;
1193 final int lineSpacing = 25;
1196 structFromPdb.setFont(LABEL_FONT);
1198 .setText(MessageManager.getString("label.struct_from_pdb"));
1199 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1200 structFromPdb.addActionListener(new ActionListener()
1203 public void actionPerformed(ActionEvent e)
1205 boolean selected = structFromPdb.isSelected();
1206 // enable other options only when the first is checked
1207 useRnaView.setEnabled(selected);
1208 addSecondaryStructure.setEnabled(selected);
1209 addTempFactor.setEnabled(selected);
1212 structureTab.add(structFromPdb);
1214 // indent checkboxes that are conditional on the first one
1215 ypos += lineSpacing;
1216 useRnaView.setFont(LABEL_FONT);
1217 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1218 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1219 structureTab.add(useRnaView);
1221 ypos += lineSpacing;
1222 addSecondaryStructure.setFont(LABEL_FONT);
1223 addSecondaryStructure
1224 .setText(MessageManager.getString("label.autoadd_secstr"));
1225 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1226 structureTab.add(addSecondaryStructure);
1228 ypos += lineSpacing;
1229 addTempFactor.setFont(LABEL_FONT);
1230 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1231 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1232 structureTab.add(addTempFactor);
1234 ypos += lineSpacing;
1235 JLabel viewerLabel = new JLabel();
1236 viewerLabel.setFont(LABEL_FONT);
1237 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1238 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1239 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1240 structureTab.add(viewerLabel);
1242 structViewer.setFont(LABEL_FONT);
1243 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1244 structViewer.addItem(ViewerType.JMOL.name());
1245 structViewer.addItem(ViewerType.CHIMERA.name());
1246 structViewer.addActionListener(new ActionListener()
1249 public void actionPerformed(ActionEvent e)
1251 structureViewer_actionPerformed(
1252 (String) structViewer.getSelectedItem());
1255 structureTab.add(structViewer);
1257 ypos += lineSpacing;
1258 JLabel pathLabel = new JLabel();
1259 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1260 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1261 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1262 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1263 structureTab.add(pathLabel);
1265 chimeraPath.setFont(LABEL_FONT);
1266 chimeraPath.setText("");
1267 final String tooltip = JvSwingUtils.wrapTooltip(true,
1268 MessageManager.getString("label.chimera_path_tip"));
1269 chimeraPath.setToolTipText(tooltip);
1270 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1271 chimeraPath.addMouseListener(new MouseAdapter()
1274 public void mouseClicked(MouseEvent e)
1276 if (e.getClickCount() == 2)
1278 String chosen = openFileChooser();
1281 chimeraPath.setText(chosen);
1286 structureTab.add(chimeraPath);
1288 ypos += lineSpacing;
1289 nwMapping.setFont(LABEL_FONT);
1290 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1291 siftsMapping.setFont(LABEL_FONT);
1292 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1293 mappingMethod.add(nwMapping);
1294 mappingMethod.add(siftsMapping);
1295 JPanel mappingPanel = new JPanel();
1296 mappingPanel.setFont(LABEL_FONT);
1297 TitledBorder mmTitledBorder = new TitledBorder(
1298 MessageManager.getString("label.mapping_method"));
1299 mmTitledBorder.setTitleFont(LABEL_FONT);
1300 mappingPanel.setBorder(mmTitledBorder);
1301 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1302 // GridLayout mappingLayout = new GridLayout();
1303 mappingPanel.setLayout(new GridLayout());
1304 mappingPanel.add(nwMapping);
1305 mappingPanel.add(siftsMapping);
1306 structureTab.add(mappingPanel);
1308 ypos += lineSpacing;
1309 ypos += lineSpacing;
1310 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1311 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1312 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1313 structureTab.add(docFieldPref);
1315 return structureTab;
1319 * Action on choosing a structure viewer from combobox options.
1321 * @param selectedItem
1323 protected void structureViewer_actionPerformed(String selectedItem)
1328 * Show a dialog for the user to choose a file. Returns the chosen path, or
1333 protected String openFileChooser()
1335 String choice = null;
1336 JFileChooser chooser = new JFileChooser();
1338 // chooser.setFileView(new JalviewFileView());
1339 chooser.setDialogTitle(
1340 MessageManager.getString("label.open_local_file"));
1341 chooser.setToolTipText(MessageManager.getString("action.open"));
1343 int value = chooser.showOpenDialog(this);
1345 if (value == JFileChooser.APPROVE_OPTION)
1347 choice = chooser.getSelectedFile().getPath();
1353 * Validate the structure tab preferences; if invalid, set focus on this tab.
1357 protected boolean validateStructure(FocusEvent e)
1359 if (!validateStructure())
1361 e.getComponent().requestFocusInWindow();
1367 protected boolean validateStructure()
1373 * Initialises the Visual tabbed panel.
1377 private JPanel initVisualTab()
1379 JPanel visualTab = new JPanel();
1380 visualTab.setBorder(new TitledBorder(
1381 MessageManager.getString("action.open_new_alignment")));
1382 visualTab.setLayout(null);
1383 fullScreen.setFont(LABEL_FONT);
1384 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1385 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1386 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1387 quality.setEnabled(false);
1388 quality.setFont(LABEL_FONT);
1389 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1390 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1391 quality.setSelected(true);
1392 quality.setText(MessageManager.getString("label.quality"));
1393 conservation.setEnabled(false);
1394 conservation.setFont(LABEL_FONT);
1395 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1396 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1397 conservation.setSelected(true);
1398 conservation.setText(MessageManager.getString("label.conservation"));
1399 identity.setEnabled(false);
1400 identity.setFont(LABEL_FONT);
1401 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1402 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1403 identity.setSelected(true);
1404 identity.setText(MessageManager.getString("label.consensus"));
1405 showOccupancy.setFont(LABEL_FONT);
1406 showOccupancy.setEnabled(false);
1407 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1408 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1409 showOccupancy.setSelected(true);
1410 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1412 JLabel showGroupbits = new JLabel();
1413 showGroupbits.setFont(LABEL_FONT);
1414 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1415 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1417 .setText(MessageManager.getString("action.show_group") + ":");
1418 JLabel showConsensbits = new JLabel();
1419 showConsensbits.setFont(LABEL_FONT);
1420 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1421 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1423 .setText(MessageManager.getString("label.consensus") + ":");
1424 showConsensHistogram.setEnabled(false);
1425 showConsensHistogram.setFont(LABEL_FONT);
1426 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1427 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1428 showConsensHistogram.setSelected(true);
1429 showConsensHistogram
1430 .setText(MessageManager.getString("label.histogram"));
1431 showConsensLogo.setEnabled(false);
1432 showConsensLogo.setFont(LABEL_FONT);
1433 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1434 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1435 showConsensLogo.setSelected(true);
1436 showConsensLogo.setText(MessageManager.getString("label.logo"));
1437 showGroupConsensus.setEnabled(false);
1438 showGroupConsensus.setFont(LABEL_FONT);
1439 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1440 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1441 showGroupConsensus.setSelected(true);
1442 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1443 showGroupConservation.setEnabled(false);
1444 showGroupConservation.setFont(LABEL_FONT);
1445 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1446 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1447 showGroupConservation.setSelected(true);
1448 showGroupConservation
1449 .setText(MessageManager.getString("label.conservation"));
1450 showNpTooltip.setEnabled(true);
1451 showNpTooltip.setFont(LABEL_FONT);
1452 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1453 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1454 showNpTooltip.setSelected(true);
1455 showNpTooltip.setText(
1456 MessageManager.getString("label.non_positional_features"));
1457 showDbRefTooltip.setEnabled(true);
1458 showDbRefTooltip.setFont(LABEL_FONT);
1459 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1460 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1461 showDbRefTooltip.setSelected(true);
1463 .setText(MessageManager.getString("label.database_references"));
1464 annotations.setFont(LABEL_FONT);
1465 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1466 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1467 annotations.setSelected(true);
1468 annotations.setText(MessageManager.getString("label.show_annotations"));
1469 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1470 annotations.addActionListener(new ActionListener()
1473 public void actionPerformed(ActionEvent e)
1475 annotations_actionPerformed(e);
1478 identity.addActionListener(new ActionListener()
1481 public void actionPerformed(ActionEvent e)
1483 annotations_actionPerformed(e);
1486 showGroupConsensus.addActionListener(new ActionListener()
1489 public void actionPerformed(ActionEvent e)
1491 annotations_actionPerformed(e);
1494 showUnconserved.setFont(LABEL_FONT);
1495 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1496 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1497 showUnconserved.setSelected(true);
1499 .setText(MessageManager.getString("action.show_unconserved"));
1500 showUnconserved.addActionListener(new ActionListener()
1503 public void actionPerformed(ActionEvent e)
1505 showunconserved_actionPerformed(e);
1509 // TODO these are not yet added to / action from Preferences
1510 // JCheckBox shareSelections = new JCheckBox();
1511 // shareSelections.setFont(verdana11);
1512 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1513 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1514 // shareSelections.setSelected(true);
1515 // shareSelections.setText(MessageManager
1516 // .getString("label.share_selection_across_views"));
1517 // JCheckBox followHighlight = new JCheckBox();
1518 // followHighlight.setFont(verdana11);
1519 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1520 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1521 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1522 // followHighlight.setSelected(true);
1523 // followHighlight.setText(MessageManager
1524 // .getString("label.scroll_highlighted_regions"));
1526 seqLimit.setFont(LABEL_FONT);
1527 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1528 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1529 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1530 smoothFont.setFont(LABEL_FONT);
1531 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1532 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1533 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1534 scaleProteinToCdna.setFont(LABEL_FONT);
1535 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1536 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1537 scaleProteinToCdna.setText(
1538 MessageManager.getString("label.scale_protein_to_cdna"));
1539 scaleProteinToCdna.setToolTipText(
1540 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1541 JLabel gapLabel = new JLabel();
1542 gapLabel.setFont(LABEL_FONT);
1543 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1544 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1545 JLabel fontLabel = new JLabel();
1546 fontLabel.setFont(LABEL_FONT);
1547 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1548 fontLabel.setText(MessageManager.getString("label.font"));
1549 fontSizeCB.setFont(LABEL_FONT);
1550 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1551 fontStyleCB.setFont(LABEL_FONT);
1552 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1553 fontNameCB.setFont(LABEL_FONT);
1554 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1555 gapSymbolCB.setFont(LABEL_FONT);
1556 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1557 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1558 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1559 gapSymbolCB.setRenderer(dlcr);
1561 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1562 startupCheckbox.setFont(LABEL_FONT);
1563 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1564 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1565 startupCheckbox.setSelected(true);
1566 startupFileTextfield.setFont(LABEL_FONT);
1567 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1568 final String tooltip = JvSwingUtils.wrapTooltip(true,
1569 MessageManager.getString("label.double_click_to_browse"));
1570 startupFileTextfield.setToolTipText(tooltip);
1571 startupFileTextfield.addMouseListener(new MouseAdapter()
1574 public void mouseClicked(MouseEvent e)
1576 if (e.getClickCount() > 1)
1578 startupFileTextfield_mouseClicked();
1583 sortby.setFont(LABEL_FONT);
1584 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1585 JLabel sortLabel = new JLabel();
1586 sortLabel.setFont(LABEL_FONT);
1587 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1588 sortLabel.setText(MessageManager.getString("label.sort_by"));
1589 sortAnnBy.setFont(LABEL_FONT);
1590 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1591 JLabel sortAnnLabel = new JLabel();
1592 sortAnnLabel.setFont(LABEL_FONT);
1593 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1594 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1595 sortAutocalc.setFont(LABEL_FONT);
1596 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1598 JPanel annsettingsPanel = new JPanel();
1599 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1600 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1601 annsettingsPanel.setBorder(new EtchedBorder());
1602 visualTab.add(annsettingsPanel);
1603 Border jb = new EmptyBorder(1, 1, 4, 5);
1604 annotations.setBorder(jb);
1605 showOccupancy.setBorder(jb);
1606 quality.setBorder(jb);
1607 conservation.setBorder(jb);
1608 identity.setBorder(jb);
1609 showConsensbits.setBorder(jb);
1610 showGroupbits.setBorder(jb);
1611 showGroupConsensus.setBorder(jb);
1612 showGroupConservation.setBorder(jb);
1613 showConsensHistogram.setBorder(jb);
1614 showConsensLogo.setBorder(jb);
1616 JPanel autoAnnotSettings = new JPanel();
1617 annsettingsPanel.add(autoAnnotSettings);
1618 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1619 autoAnnotSettings.add(annotations);
1620 autoAnnotSettings.add(quality);
1621 // second row of autoannotation box
1622 autoAnnotSettings = new JPanel();
1623 annsettingsPanel.add(autoAnnotSettings);
1625 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1626 autoAnnotSettings.add(conservation);
1627 autoAnnotSettings.add(identity);
1628 autoAnnotSettings.add(showOccupancy);
1629 autoAnnotSettings.add(showGroupbits);
1630 autoAnnotSettings.add(showGroupConservation);
1631 autoAnnotSettings.add(showGroupConsensus);
1632 autoAnnotSettings.add(showConsensbits);
1633 autoAnnotSettings.add(showConsensHistogram);
1634 autoAnnotSettings.add(showConsensLogo);
1636 JPanel tooltipSettings = new JPanel();
1637 tooltipSettings.setBorder(new TitledBorder(
1638 MessageManager.getString("label.sequence_id_tooltip")));
1639 tooltipSettings.setBounds(173, 140, 220, 62);
1640 tooltipSettings.setLayout(new GridLayout(2, 1));
1641 tooltipSettings.add(showDbRefTooltip);
1642 tooltipSettings.add(showNpTooltip);
1643 visualTab.add(tooltipSettings);
1645 wrap.setFont(LABEL_FONT);
1646 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1647 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1648 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1649 rightAlign.setFont(LABEL_FONT);
1650 rightAlign.setForeground(Color.black);
1651 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1652 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1653 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1654 idItalics.setFont(LABEL_FONT_ITALIC);
1655 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1656 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1658 MessageManager.getString("label.sequence_name_italics"));
1659 openoverv.setFont(LABEL_FONT);
1660 openoverv.setActionCommand(
1661 MessageManager.getString("label.open_overview"));
1662 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1663 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1664 openoverv.setText(MessageManager.getString("label.open_overview"));
1665 JPanel jPanel2 = new JPanel();
1666 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1667 jPanel2.setLayout(new GridLayout(14, 1));
1668 jPanel2.add(fullScreen);
1669 jPanel2.add(openoverv);
1670 jPanel2.add(seqLimit);
1671 jPanel2.add(rightAlign);
1672 jPanel2.add(fontLabel);
1673 jPanel2.add(showUnconserved);
1674 jPanel2.add(idItalics);
1675 jPanel2.add(smoothFont);
1676 jPanel2.add(scaleProteinToCdna);
1677 jPanel2.add(gapLabel);
1679 jPanel2.add(sortLabel);
1680 jPanel2.add(sortAnnLabel);
1681 jPanel2.add(startupCheckbox);
1682 visualTab.add(jPanel2);
1683 visualTab.add(startupFileTextfield);
1684 visualTab.add(sortby);
1685 visualTab.add(sortAnnBy);
1686 visualTab.add(sortAutocalc);
1687 visualTab.add(gapSymbolCB);
1688 visualTab.add(fontNameCB);
1689 visualTab.add(fontSizeCB);
1690 visualTab.add(fontStyleCB);
1695 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1698 protected void loadLastSavedBackupsOptions()
1701 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1702 setComboIntStringKey(backupfilesPresetsCombo,
1703 Cache.getDefault(BackupFiles.NS + "_PRESET", 1));
1704 suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX,
1705 ".bak" + BackupFiles.NUM_PLACEHOLDER));
1707 .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1708 suffixReverse.setSelected(
1709 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1711 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, false));
1712 backupfilesRollMaxSpinner
1713 .setValue(Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1714 backupfilesConfirmDelete.setSelected(
1715 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1717 backupsOptionsSetEnabled();
1718 updateBackupFilesExampleLabel();
1721 private boolean warnAboutSuffixReverseChange()
1723 boolean savedSuffixReverse = Cache.getDefault(BackupFiles.REVERSE_ORDER,
1725 int savedSuffixDigits = Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3);
1726 String savedSuffixTemplate = Cache.getDefault(BackupFiles.SUFFIX,
1727 ".bak" + BackupFiles.NUM_PLACEHOLDER);
1729 boolean nowSuffixReverse = suffixReverse.isSelected();
1730 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1731 String nowSuffixTemplate = suffixTemplate.getText();
1732 return nowSuffixReverse != savedSuffixReverse
1733 && nowSuffixDigits == savedSuffixDigits
1734 && nowSuffixTemplate != null
1735 && nowSuffixTemplate.equals(savedSuffixTemplate);
1739 * Initialises the Backups tabbed panel.
1743 private JPanel initBackupsTab()
1745 JPanel backupsTab = new JPanel();
1746 backupsTab.setBorder(new TitledBorder(
1747 MessageManager.getString("label.backup_files")));
1748 backupsTab.setLayout(new GridBagLayout());
1750 GridBagConstraints gbc = new GridBagConstraints();
1753 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1754 gbc.fill = GridBagConstraints.NONE;
1756 initBackupsTabPresetsPanel();
1757 initBackupsTabSuffixPanel();
1758 initBackupsTabKeepFilesPanel();
1759 initBackupsTabFilenameExamplesPanel();
1761 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1763 .setText(MessageManager.getString("label.enable_backupfiles"));
1764 enableBackupFiles.addActionListener(new ActionListener()
1767 public void actionPerformed(ActionEvent e)
1769 // enable other options only when the first is checked
1770 backupsOptionsSetEnabled();
1775 // enable checkbox 1 col
1779 gbc.gridy = 0; // row 0
1780 backupsTab.add(enableBackupFiles, gbc);
1782 // summary of scheme box (over two rows)
1786 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1787 gbc.fill = GridBagConstraints.BOTH;
1788 backupsTab.add(exampleFilesPanel, gbc);
1790 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1791 gbc.fill = GridBagConstraints.NONE;
1793 // fill empty space on right
1796 backupsTab.add(new JPanel(), gbc);
1801 gbc.gridy++; // row 1
1802 backupsTab.add(presetsPanel, gbc);
1804 // gbc.anchor = GridBagConstraints.NORTHWEST;
1805 // now using whole row
1810 gbc.gridy++; // row 2
1811 backupsTab.add(keepfilesPanel, gbc);
1813 // filename strategy box
1814 gbc.gridy++; // row 3
1815 backupsTab.add(suffixPanel, gbc);
1818 gbc.gridy++; // row 4
1820 backupsTab.add(new JPanel(), gbc);
1822 backupsOptionsSetEnabled();
1826 protected static final int BACKUPFILESSCHEMECUSTOMISE = 0;
1828 private static final IntKeyStringValueEntry[] backupfilesPresetEntries = {
1829 new IntKeyStringValueEntry(1,
1830 MessageManager.getString("label.default")),
1831 new IntKeyStringValueEntry(2,
1832 MessageManager.getString("label.single_file")),
1833 new IntKeyStringValueEntry(3,
1834 MessageManager.getString("label.keep_all_versions")),
1835 new IntKeyStringValueEntry(4,
1836 MessageManager.getString("label.rolled_backups")),
1838 // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
1839 new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
1840 MessageManager.getString("label.customise")) };
1842 private static final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
1847 private static final long serialVersionUID = 125L;
1850 put(1, new BackupFilesPresetEntry(
1851 ".bak" + BackupFiles.NUM_PLACEHOLDER, 3, false, false, 3,
1853 put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false));
1854 put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER,
1855 3, false, true, 10, true));
1856 put(4, new BackupFilesPresetEntry(
1857 "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9,
1862 private JPanel initBackupsTabPresetsPanel()
1865 String title = MessageManager.getString("label.schemes");
1866 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1867 // TitledBorder tb = new TitledBorder(title);
1868 // tb.setTitleFont(LABEL_FONT);
1869 // presetsPanel.setBorder(tb);
1871 presetsPanel.setLayout(new GridBagLayout());
1873 GridBagConstraints gbc = new GridBagConstraints();
1876 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1877 gbc.fill = GridBagConstraints.NONE;
1885 presetsComboLabel = new JLabel(title + ":");
1886 presetsPanel.add(presetsComboLabel, gbc);
1888 for (int i = 0; i < backupfilesPresetEntries.length; i++)
1890 backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]);
1893 // put "Previously saved scheme" item in italics (it's not really
1894 // selectable, as such -- it deselects itself when selected) and
1895 // "Customise" in bold
1896 backupfilesPresetsCombo
1897 .setRenderer(new BackupFilesPresetsComboBoxRenderer());
1898 backupfilesPresetsCombo.addActionListener(new ActionListener()
1901 public void actionPerformed(ActionEvent e)
1903 backupsTabUpdatePresets();
1907 // dropdown list of preset schemes
1909 presetsPanel.add(backupfilesPresetsCombo, gbc);
1911 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1912 revertButton.addActionListener(new ActionListener()
1915 public void actionPerformed(ActionEvent e)
1917 loadLastSavedBackupsOptions();
1921 revertButton.setFont(LABEL_FONT);
1923 // "Cancel changes" button (aligned with combo box above)
1926 presetsPanel.add(revertButton, gbc);
1928 return presetsPanel;
1931 private JPanel initBackupsTabFilenameExamplesPanel()
1933 String title = MessageManager
1934 .getString("label.summary_of_backups_scheme");
1935 TitledBorder tb = new TitledBorder(title);
1936 exampleFilesPanel.setBorder(tb);
1937 exampleFilesPanel.setLayout(new GridBagLayout());
1940 backupfilesExampleLabel.setEditable(false);
1941 backupfilesExampleLabel
1942 .setBackground(exampleFilesPanel.getBackground());
1944 updateBackupFilesExampleLabel();
1946 GridBagConstraints gbc = new GridBagConstraints();
1949 gbc.fill = GridBagConstraints.NONE;
1950 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1952 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1953 return exampleFilesPanel;
1956 private void backupsTabUpdatePresets()
1958 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1960 int key = entry.getKey();
1961 String value = entry.getValue();
1963 // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
1964 if (key != BACKUPFILESSCHEMECUSTOMISE)
1966 if (backupfilesPresetEntriesValues.containsKey(key))
1968 backupsSetOptions(backupfilesPresetEntriesValues.get(key));
1972 System.out.println("Preset '" + value + "' not implemented");
1976 backupfilesCustomOptionsSetEnabled();
1977 updateBackupFilesExampleLabel();
1980 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
1982 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
1983 return e != null ? e.getKey() : 0;
1986 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
1989 for (int i = 0; i < c.getItemCount(); i++)
1991 IntKeyStringValueEntry e = c.getItemAt(i);
1992 if (e.getKey() == key)
1994 c.setSelectedIndex(i);
1998 backupsTabUpdatePresets();
2001 private JPanel initBackupsTabSuffixPanel()
2003 suffixPanel.setBorder(new TitledBorder(
2004 MessageManager.getString("label.backup_filename_strategy")));
2005 suffixPanel.setLayout(new GridBagLayout());
2008 .setText(MessageManager.getString("label.append_to_filename"));
2009 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2010 suffixTemplateLabel.setFont(LABEL_FONT);
2012 final String tooltip = JvSwingUtils.wrapTooltip(true,
2013 MessageManager.getString("label.append_to_filename_tooltip"));
2014 suffixTemplate.setToolTipText(tooltip);
2015 suffixTemplate.addActionListener(new ActionListener()
2018 public void actionPerformed(ActionEvent e)
2020 updateBackupFilesExampleLabel();
2021 backupfilesCustomOptionsSetEnabled();
2025 KeyListener kl = new KeyListener()
2028 public void keyReleased(KeyEvent e)
2030 updateBackupFilesExampleLabel();
2031 backupfilesCustomOptionsSetEnabled();
2035 public void keyPressed(KeyEvent e)
2039 // disable use of ':' or '/' or '\'
2041 public void keyTyped(KeyEvent e)
2043 char c = e.getKeyChar();
2044 if (c == ':' || c == '/' || c == '\\')
2046 // don't process ':' or '/' or '\'
2052 suffixTemplate.addKeyListener(kl);
2056 .setText(MessageManager.getString("label.index_digits"));
2057 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2058 suffixDigitsLabel.setFont(LABEL_FONT);
2061 ChangeListener c = new ChangeListener()
2064 public void stateChanged(ChangeEvent e)
2066 updateBackupFilesExampleLabel();
2070 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
2072 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2073 MessageManager.getString("label.increment_index"));
2074 suffixReverse.addActionListener(new ActionListener()
2077 public void actionPerformed(ActionEvent e)
2079 boolean okay = true;
2080 if (warnAboutSuffixReverseChange())
2083 okay = confirmSuffixReverseChange();
2087 updateBackupFilesExampleLabel();
2091 boolean savedSuffixReverse = Cache
2092 .getDefault(BackupFiles.REVERSE_ORDER, false);
2093 suffixReverse.setSelected(savedSuffixReverse);
2098 GridBagConstraints sgbc = new GridBagConstraints();
2100 // first row (template text box)
2101 sgbc.anchor = GridBagConstraints.WEST;
2105 sgbc.gridheight = 1;
2108 sgbc.fill = GridBagConstraints.NONE;
2109 suffixPanel.add(suffixTemplateLabel, sgbc);
2112 sgbc.fill = GridBagConstraints.HORIZONTAL;
2113 suffixPanel.add(suffixTemplate, sgbc);
2115 // second row (number of digits spinner)
2119 sgbc.fill = GridBagConstraints.NONE;
2120 suffixPanel.add(suffixDigitsLabel, sgbc);
2123 sgbc.fill = GridBagConstraints.HORIZONTAL;
2124 suffixPanel.add(suffixDigitsSpinner, sgbc);
2126 // third row (forward order radio selection)
2129 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2130 sgbc.fill = GridBagConstraints.HORIZONTAL;
2131 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2133 // fourth row (reverse order radio selection)
2135 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2139 private boolean confirmSuffixReverseChange()
2141 boolean ret = false;
2142 String warningMessage = MessageManager
2143 .getString("label.warning_confirm_change_reverse");
2144 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2146 MessageManager.getString("label.change_increment_decrement"),
2147 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2149 ret = (confirm == JvOptionPane.YES_OPTION);
2153 private JPanel initBackupsTabKeepFilesPanel()
2155 keepfilesPanel.setBorder(
2156 new TitledBorder(MessageManager.getString("label.keep_files")));
2157 keepfilesPanel.setLayout(new GridBagLayout());
2159 backupfilesKeepAll.setLabels(
2160 MessageManager.getString("label.keep_all_backup_files"),
2161 MessageManager.getString(
2162 "label.keep_only_this_number_of_backup_files"));
2163 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2166 public void actionPerformed(ActionEvent e)
2168 updateBackupFilesExampleLabel();
2171 backupfilesKeepAll.addActionListener(new ActionListener()
2174 public void actionPerformed(ActionEvent e)
2176 keepRollMaxOptionsEnabled();
2177 updateBackupFilesExampleLabel();
2181 ChangeListener c = new ChangeListener()
2184 public void stateChanged(ChangeEvent e)
2186 updateBackupFilesExampleLabel();
2190 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
2192 backupfilesConfirmDelete.setLabels(
2193 MessageManager.getString("label.always_ask"),
2194 MessageManager.getString("label.auto_delete"));
2195 // update the enabled section
2196 keepRollMaxOptionsEnabled();
2198 GridBagConstraints kgbc = new GridBagConstraints();
2200 // first row (template text box)
2201 kgbc.anchor = GridBagConstraints.WEST;
2204 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2205 kgbc.gridheight = 1;
2208 kgbc.fill = GridBagConstraints.HORIZONTAL;
2209 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2215 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2216 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2219 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2220 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2222 // third row (indented)
2224 kgbc.insets = new Insets(0, 20, 0, 0);
2227 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2228 kgbc.fill = GridBagConstraints.HORIZONTAL;
2231 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2233 // fourth row (indented)
2235 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2238 JPanel jp = new JPanel();
2239 jp.setLayout(new FlowLayout());
2241 .setText(MessageManager
2242 .getString("label.autodelete_old_backup_files"));
2243 oldBackupFilesLabel.setFont(LABEL_FONT);
2244 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2245 jp.add(oldBackupFilesLabel);
2246 jp.add(backupfilesConfirmDelete.getTrueButton());
2247 jp.add(backupfilesConfirmDelete.getFalseButton());
2248 keepfilesPanel.add(jp, kgbc);
2250 return keepfilesPanel;
2253 protected void updateBackupFilesExampleLabel()
2255 int exampleindex = 12;
2256 String base = MessageManager.getString("label.filename") + ".fa";
2257 if (base == null || base.length() == 0)
2259 base = "file_name.fa";
2262 boolean reverse = suffixReverse.isSelected();
2263 boolean keepAll = backupfilesKeepAll.isSelected();
2265 String suffix = suffixTemplate.getText();
2268 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2269 if (suffix == null || suffix.length() == 0)
2271 backupfilesExampleLabel
2272 .setText(MessageManager.getString("label.no_backup_files"));
2273 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2277 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2278 rollMax = rollMax < 1 ? 1 : rollMax;
2280 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2285 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2286 digits = digits < 1 ? 1 : digits;
2288 int lowersurround = 2;
2289 int uppersurround = 0;
2290 StringBuilder exampleSB = new StringBuilder();
2291 boolean firstLine = true;
2296 int max = keepAll ? exampleindex : rollMax;
2297 for (int index = min; index <= max; index++)
2299 if (index == min + lowersurround && index < max - uppersurround - 1)
2301 exampleSB.append("\n...");
2303 else if (index > min + lowersurround && index < max - uppersurround)
2315 exampleSB.append("\n");
2317 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2318 base, suffix, digits));
2321 // no extra text needed
2323 else if (index == min)
2325 String newest = MessageManager.getString("label.braced_newest");
2326 if (newest != null && newest.length() > 0)
2328 exampleSB.append(" " + newest);
2331 else if (index == max)
2333 String oldest = MessageManager.getString("label.braced_oldest");
2334 if (oldest != null && oldest.length() > 0)
2336 exampleSB.append(" " + oldest);
2345 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2346 : exampleindex - rollMax + 1;
2347 int max = exampleindex;
2349 for (int index = min; index <= max; index++)
2352 if (index == min + lowersurround && index < max - uppersurround - 1)
2354 exampleSB.append("\n...");
2356 else if (index > min + lowersurround && index < max - uppersurround)
2368 exampleSB.append("\n");
2370 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2371 base, suffix, digits));
2374 // no extra text needed
2376 else if (index == min)
2378 String oldest = MessageManager.getString("label.braced_oldest");
2379 if (oldest != null && oldest.length() > 0)
2381 exampleSB.append(" " + oldest);
2384 else if (index == max)
2386 String newest = MessageManager.getString("label.braced_newest");
2387 if (newest != null && newest.length() > 0)
2389 exampleSB.append(" " + newest);
2397 backupfilesExampleLabel.setText(exampleSB.toString());
2400 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2401 boolean useExistingVal, ChangeListener c)
2408 i = Integer.parseInt((String) s.getValue());
2409 } catch (Exception e)
2412 "Exception casting the initial value of s.getValue()");
2416 setIntegerSpinner(s, min, max, i, c);
2419 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2422 // integer spinner for number of digits
2427 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2430 s.addChangeListener(c);
2434 protected static int getSpinnerInt(JSpinner s, int def)
2440 i = (Integer) s.getValue();
2441 } catch (Exception e)
2443 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2448 private void keepRollMaxOptionsEnabled()
2450 boolean enabled = backupfilesKeepAll.isEnabled()
2451 && !backupfilesKeepAll.isSelected();
2452 oldBackupFilesLabel.setEnabled(enabled);
2453 backupfilesRollMaxSpinner.setEnabled(enabled);
2454 backupfilesConfirmDelete.setEnabled(enabled);
2457 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2459 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2460 && getComboIntStringKey(backupfilesPresetsCombo) == 0
2461 && suffixTemplate.getText()
2462 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2463 keepfilesPanel.setEnabled(enabled);
2464 backupfilesKeepAll.setEnabled(enabled);
2465 oldBackupFilesLabel.setEnabled(enabled);
2466 keepRollMaxOptionsEnabled();
2469 private void backupfilesSuffixTemplateDigitsSetEnabled()
2471 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2472 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2473 suffixDigitsLabel.setEnabled(enabled);
2474 suffixDigitsSpinner.setEnabled(enabled);
2475 suffixReverse.setEnabled(enabled);
2478 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2480 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2481 && getComboIntStringKey(backupfilesPresetsCombo) == 0;
2482 suffixPanel.setEnabled(enabled);
2483 suffixTemplateLabel.setEnabled(enabled);
2484 suffixTemplate.setEnabled(enabled);
2485 backupfilesSuffixTemplateDigitsSetEnabled();
2488 protected void backupfilesCustomOptionsSetEnabled()
2490 int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2491 boolean enabled = scheme == 0 && enableBackupFiles.isSelected();
2493 backupfilesSuffixTemplateSetEnabled(enabled);
2494 backupfilesKeepAllSetEnabled(enabled);
2497 private void backupfilesSummarySetEnabled()
2499 boolean enabled = enableBackupFiles.isSelected();
2500 backupfilesExampleLabel.setEnabled(enabled);
2501 exampleFilesPanel.setEnabled(enabled);
2504 private void backupfilesPresetsSetEnabled()
2506 boolean enabled = enableBackupFiles.isSelected();
2507 presetsPanel.setEnabled(enabled);
2508 presetsComboLabel.setEnabled(enabled);
2509 backupfilesPresetsCombo.setEnabled(enabled);
2510 revertButton.setEnabled(enabled);
2513 protected void backupsOptionsSetEnabled()
2515 backupfilesPresetsSetEnabled();
2516 backupfilesSummarySetEnabled();
2517 backupfilesCustomOptionsSetEnabled();
2520 protected void backupsSetOptions(String suffix, int digits,
2521 boolean reverse, boolean keepAll, int rollMax,
2522 boolean confirmDelete)
2524 suffixTemplate.setText(suffix);
2525 suffixDigitsSpinner.setValue(digits);
2526 suffixReverse.setSelected(reverse);
2527 backupfilesKeepAll.setSelected(keepAll);
2528 backupfilesRollMaxSpinner.setValue(rollMax);
2529 backupfilesConfirmDelete.setSelected(confirmDelete);
2532 protected void backupsSetOptions(BackupFilesPresetEntry p)
2534 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2538 protected void autoIdWidth_actionPerformed()
2540 // TODO Auto-generated method stub
2544 protected void userIdWidth_actionPerformed()
2546 // TODO Auto-generated method stub
2550 protected void maxColour_actionPerformed(JPanel panel)
2554 protected void minColour_actionPerformed(JPanel panel)
2558 protected void gapColour_actionPerformed(JPanel panel)
2562 protected void hiddenColour_actionPerformed(JPanel panel)
2566 protected void showunconserved_actionPerformed(ActionEvent e)
2568 // TODO Auto-generated method stub
2572 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2576 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2586 public void ok_actionPerformed(ActionEvent e)
2596 public void cancel_actionPerformed(ActionEvent e)
2606 public void annotations_actionPerformed(ActionEvent e)
2613 public void startupFileTextfield_mouseClicked()
2617 public void newLink_actionPerformed(ActionEvent e)
2622 public void editLink_actionPerformed(ActionEvent e)
2627 public void deleteLink_actionPerformed(ActionEvent e)
2632 public void defaultBrowser_mouseClicked(MouseEvent e)
2637 public void linkURLList_keyTyped(KeyEvent e)
2642 public void useProxy_actionPerformed()
2644 boolean enabled = useProxy.isSelected();
2645 portLabel.setEnabled(enabled);
2646 serverLabel.setEnabled(enabled);
2647 proxyServerTB.setEnabled(enabled);
2648 proxyPortTB.setEnabled(enabled);
2652 * Customer renderer for JTable: supports column of radio buttons
2654 public class RadioButtonRenderer extends JRadioButton
2655 implements TableCellRenderer
2657 public RadioButtonRenderer()
2659 setHorizontalAlignment(CENTER);
2660 setToolTipText(MessageManager.getString("label.urltooltip"));
2664 public Component getTableCellRendererComponent(JTable table,
2665 Object value, boolean isSelected, boolean hasFocus, int row,
2668 setSelected((boolean) value);
2670 // set colours to match rest of table
2673 setBackground(table.getSelectionBackground());
2674 setForeground(table.getSelectionForeground());
2678 setBackground(table.getBackground());
2679 setForeground(table.getForeground());
2686 * Customer cell editor for JTable: supports column of radio buttons in
2687 * conjunction with renderer
2689 public class RadioButtonEditor extends AbstractCellEditor
2690 implements TableCellEditor
2692 private JRadioButton button = new JRadioButton();
2694 public RadioButtonEditor()
2696 button.setHorizontalAlignment(SwingConstants.CENTER);
2697 this.button.addActionListener(new ActionListener()
2700 public void actionPerformed(ActionEvent e)
2702 fireEditingStopped();
2708 public Component getTableCellEditorComponent(JTable table, Object value,
2709 boolean isSelected, int row, int column)
2711 button.setSelected((boolean) value);
2716 public Object getCellEditorValue()
2718 return button.isSelected();
2724 class IntKeyStringValueEntry
2730 public IntKeyStringValueEntry(int k, String v)
2737 public String toString()
2739 return this.getValue();
2747 public String getValue()
2753 class BackupFilesPresetEntry
2765 boolean confirmDelete;
2767 public BackupFilesPresetEntry(String suffix, int digits, boolean reverse,
2768 boolean keepAll, int rollMax, boolean confirmDelete)
2770 this.suffix = suffix;
2771 this.digits = digits;
2772 this.reverse = reverse;
2773 this.keepAll = keepAll;
2774 this.rollMax = rollMax;
2775 this.confirmDelete = confirmDelete;
2779 class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer
2784 private static final long serialVersionUID = 88L;
2787 public Component getListCellRendererComponent(JList list, Object value,
2788 int index, boolean isSelected, boolean cellHasFocus)
2790 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2793 IntKeyStringValueEntry e = (IntKeyStringValueEntry) value;
2794 if (e.getKey() == GPreferences.BACKUPFILESSCHEMECUSTOMISE)
2797 this.setFont(this.getFont().deriveFont(Font.BOLD));
2799 } catch (Exception e) {