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 JLabel chimeraPathLabel;
184 protected JTextField chimeraPath = new JTextField();
186 protected ButtonGroup mappingMethod = new ButtonGroup();
188 protected JRadioButton siftsMapping = new JRadioButton();
190 protected JRadioButton nwMapping = new JRadioButton();
193 * Colours tab components
195 protected JPanel minColour = new JPanel();
197 protected JPanel maxColour = new JPanel();
199 protected JComboBox<String> protColour = new JComboBox<>();
201 protected JComboBox<String> nucColour = new JComboBox<>();
204 * Overview tab components
206 protected JPanel gapColour = new JPanel();
208 protected JPanel hiddenColour = new JPanel();
210 protected JCheckBox useLegacyGap;
212 protected JCheckBox showHiddenAtStart;
214 protected JLabel gapLabel;
217 * Connections tab components
219 protected JTable linkUrlTable = new JTable();
221 protected JButton editLink = new JButton();
223 protected JButton deleteLink = new JButton();
225 protected JTextField filterTB = new JTextField();
227 protected JButton doReset = new JButton();
229 protected JButton userOnly = new JButton();
231 protected JLabel portLabel = new JLabel();
233 protected JLabel serverLabel = new JLabel();
235 protected JTextField proxyServerTB = new JTextField();
237 protected JTextField proxyPortTB = new JTextField();
239 protected JTextField defaultBrowser = new JTextField();
241 protected JCheckBox useProxy = new JCheckBox();
243 protected JCheckBox usagestats = new JCheckBox();
245 protected JCheckBox questionnaire = new JCheckBox();
247 protected JCheckBox versioncheck = new JCheckBox();
250 * Output tab components
252 protected JComboBox<Object> epsRendering = new JComboBox<>();
254 protected JLabel userIdWidthlabel = new JLabel();
256 protected JCheckBox autoIdWidth = new JCheckBox();
258 protected JTextField userIdWidth = new JTextField();
260 protected JCheckBox blcjv = new JCheckBox();
262 protected JCheckBox pileupjv = new JCheckBox();
264 protected JCheckBox clustaljv = new JCheckBox();
266 protected JCheckBox msfjv = new JCheckBox();
268 protected JCheckBox fastajv = new JCheckBox();
270 protected JCheckBox pfamjv = new JCheckBox();
272 protected JCheckBox pirjv = new JCheckBox();
274 protected JCheckBox modellerOutput = new JCheckBox();
276 protected JCheckBox embbedBioJSON = new JCheckBox();
279 * Editing tab components
281 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
283 protected JCheckBox padGaps = new JCheckBox();
285 protected JCheckBox sortByTree = new JCheckBox();
290 protected JPanel wsTab = new JPanel();
293 * Backups tab components
294 * a lot of these are member variables instead of local variables only so that they
295 * can be enabled/disabled easily in one go
298 protected JCheckBox enableBackupFiles = new JCheckBox();
300 protected JPanel presetsPanel = new JPanel();
302 protected JLabel presetsComboLabel = new JLabel();
304 protected JCheckBox customiseCheckbox = new JCheckBox();
306 protected JButton revertButton = new JButton();
308 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
310 private int backupfilesPresetsComboLastSelected = 0;
312 protected JPanel suffixPanel = new JPanel();
314 protected JPanel keepfilesPanel = new JPanel();
316 protected JPanel exampleFilesPanel = new JPanel();
318 protected JTextField suffixTemplate = new JTextField(null, 8);
320 protected JLabel suffixTemplateLabel = new JLabel();
322 protected JLabel suffixDigitsLabel = new JLabel();
324 protected JSpinner suffixDigitsSpinner = new JSpinner();
326 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
328 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
330 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
332 protected JLabel oldBackupFilesLabel = new JLabel();
334 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
336 protected JTextArea backupfilesExampleLabel = new JTextArea();
339 * Creates a new GPreferences object.
341 public GPreferences()
346 } catch (Exception ex)
348 ex.printStackTrace();
353 * Construct the panel and its tabbed sub-panels.
357 private void jbInit() throws Exception
359 final JTabbedPane tabbedPane = new JTabbedPane();
360 this.setLayout(new BorderLayout());
361 JPanel okCancelPanel = initOkCancelPanel();
362 this.add(tabbedPane, BorderLayout.CENTER);
363 this.add(okCancelPanel, BorderLayout.SOUTH);
365 tabbedPane.add(initVisualTab(),
366 MessageManager.getString("label.visual"));
368 tabbedPane.add(initColoursTab(),
369 MessageManager.getString("label.colours"));
371 tabbedPane.add(initOverviewTab(),
372 MessageManager.getString("label.overview"));
374 tabbedPane.add(initStructureTab(),
375 MessageManager.getString("label.structure"));
377 tabbedPane.add(initConnectionsTab(),
378 MessageManager.getString("label.connections"));
380 tabbedPane.add(initBackupsTab(),
381 MessageManager.getString("label.backups"));
383 tabbedPane.add(initLinksTab(),
384 MessageManager.getString("label.urllinks"));
386 tabbedPane.add(initOutputTab(),
387 MessageManager.getString("label.output"));
389 tabbedPane.add(initEditingTab(),
390 MessageManager.getString("label.editing"));
393 * See WsPreferences for the real work of configuring this tab.
395 wsTab.setLayout(new BorderLayout());
396 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
399 * Handler to validate a tab before leaving it - currently only for
402 tabbedPane.addChangeListener(new ChangeListener()
404 private Component lastTab;
407 public void stateChanged(ChangeEvent e)
409 if (lastTab == structureTab
410 && tabbedPane.getSelectedComponent() != structureTab)
412 if (!validateStructure())
414 tabbedPane.setSelectedComponent(structureTab);
418 lastTab = tabbedPane.getSelectedComponent();
425 * Initialises the Editing tabbed panel.
429 private JPanel initEditingTab()
431 JPanel editingTab = new JPanel();
432 editingTab.setLayout(null);
433 autoCalculateConsCheck.setFont(LABEL_FONT);
434 autoCalculateConsCheck.setText(
435 MessageManager.getString("label.autocalculate_consensus"));
436 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
437 padGaps.setFont(LABEL_FONT);
439 MessageManager.getString("label.pad_gaps_when_editing"));
440 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
441 sortByTree.setFont(LABEL_FONT);
443 .setText(MessageManager.getString("label.sort_with_new_tree"));
444 sortByTree.setToolTipText(MessageManager.getString(
445 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
446 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
447 editingTab.add(autoCalculateConsCheck);
448 editingTab.add(padGaps);
449 editingTab.add(sortByTree);
454 * Initialises the Output tabbed panel.
458 private JPanel initOutputTab()
460 JPanel outputTab = new JPanel();
461 outputTab.setLayout(null);
462 JLabel epsLabel = new JLabel();
463 epsLabel.setFont(LABEL_FONT);
464 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
465 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
466 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
467 epsRendering.setFont(LABEL_FONT);
468 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
469 JLabel jLabel1 = new JLabel();
470 jLabel1.setFont(LABEL_FONT);
471 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
472 jLabel1.setText(MessageManager.getString("label.append_start_end"));
473 jLabel1.setFont(LABEL_FONT);
474 fastajv.setFont(LABEL_FONT);
475 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
476 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
477 blcjv.setText(MessageManager.getString("label.blc") + " ");
478 fastajv.setText(MessageManager.getString("label.fasta") + " ");
479 msfjv.setText(MessageManager.getString("label.msf") + " ");
480 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
481 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
482 msfjv.setFont(LABEL_FONT);
483 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
484 pirjv.setText(MessageManager.getString("label.pir") + " ");
485 JPanel jPanel11 = new JPanel();
486 jPanel11.setFont(LABEL_FONT);
487 TitledBorder titledBorder2 = new TitledBorder(
488 MessageManager.getString("label.file_output"));
489 jPanel11.setBorder(titledBorder2);
490 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
491 GridLayout gridLayout3 = new GridLayout();
492 jPanel11.setLayout(gridLayout3);
493 gridLayout3.setRows(8);
494 blcjv.setFont(LABEL_FONT);
495 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
496 clustaljv.setFont(LABEL_FONT);
497 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
498 pfamjv.setFont(LABEL_FONT);
499 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
500 pileupjv.setFont(LABEL_FONT);
501 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
502 pirjv.setFont(LABEL_FONT);
503 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
504 autoIdWidth.setFont(LABEL_FONT);
506 MessageManager.getString("label.automatically_set_id_width"));
507 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
508 .getString("label.adjusts_width_generated_eps_png")));
509 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
510 autoIdWidth.addActionListener(new ActionListener()
514 public void actionPerformed(ActionEvent e)
516 autoIdWidth_actionPerformed();
519 userIdWidthlabel.setFont(LABEL_FONT);
520 userIdWidthlabel.setText(
521 MessageManager.getString("label.figure_id_column_width"));
522 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
523 .getString("label.manually_specify_width_left_column")));
524 userIdWidthlabel.setToolTipText(
525 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
526 "label.manually_specify_width_left_column")));
527 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
528 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
529 userIdWidth.setText("");
530 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
531 userIdWidth.addActionListener(new ActionListener()
535 public void actionPerformed(ActionEvent e)
537 userIdWidth_actionPerformed();
540 modellerOutput.setFont(LABEL_FONT);
542 .setText(MessageManager.getString("label.use_modeller_output"));
543 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
544 embbedBioJSON.setFont(LABEL_FONT);
545 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
546 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
548 jPanel11.add(jLabel1);
550 jPanel11.add(clustaljv);
551 jPanel11.add(fastajv);
553 jPanel11.add(pfamjv);
554 jPanel11.add(pileupjv);
556 outputTab.add(autoIdWidth);
557 outputTab.add(userIdWidth);
558 outputTab.add(userIdWidthlabel);
559 outputTab.add(modellerOutput);
560 outputTab.add(embbedBioJSON);
561 outputTab.add(epsLabel);
562 outputTab.add(epsRendering);
563 outputTab.add(jPanel11);
568 * Initialises the Connections tabbed panel.
572 private JPanel initConnectionsTab()
574 JPanel connectTab = new JPanel();
575 connectTab.setLayout(new GridBagLayout());
577 // Label for browser text box
578 JLabel browserLabel = new JLabel();
579 browserLabel.setFont(LABEL_FONT);
580 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
581 browserLabel.setText(
582 MessageManager.getString("label.default_browser_unix"));
583 defaultBrowser.setFont(LABEL_FONT);
584 defaultBrowser.setText("");
585 final String tooltip = JvSwingUtils.wrapTooltip(true,
586 MessageManager.getString("label.double_click_to_browse"));
587 defaultBrowser.setToolTipText(tooltip);
588 defaultBrowser.addMouseListener(new MouseAdapter()
591 public void mouseClicked(MouseEvent e)
593 if (e.getClickCount() > 1)
595 defaultBrowser_mouseClicked(e);
600 JPanel proxyPanel = initConnTabProxyPanel();
601 initConnTabCheckboxes();
603 // Add default Browser text box
604 connectTab.add(browserLabel,
605 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
606 GridBagConstraints.WEST, GridBagConstraints.NONE,
607 new Insets(10, 0, 5, 5), 5, 1));
608 defaultBrowser.setFont(LABEL_FONT);
609 defaultBrowser.setText("");
611 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
612 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
613 new Insets(10, 0, 5, 10), 30, 1));
615 // Add proxy server panel
616 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
617 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
618 new Insets(10, 0, 5, 12), 4, 10));
620 // Add usage stats, version check and questionnaire checkboxes
621 connectTab.add(usagestats,
622 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
623 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
624 new Insets(0, 2, 5, 5), 70, 1));
625 connectTab.add(questionnaire,
626 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
627 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
628 new Insets(0, 2, 5, 10), 70, 1));
629 connectTab.add(versioncheck,
630 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
631 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
632 new Insets(0, 2, 5, 5), 70, 1));
634 versioncheck.setVisible(false);
636 // Add padding so the panel doesn't look ridiculous
637 JPanel spacePanel = new JPanel();
638 connectTab.add(spacePanel,
639 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
640 GridBagConstraints.WEST, GridBagConstraints.BOTH,
641 new Insets(0, 0, 0, 5), 70, 1));
647 * Initialises the Links tabbed panel.
651 private JPanel initLinksTab()
653 JPanel linkTab = new JPanel();
654 linkTab.setLayout(new GridBagLayout());
656 // Set up table for Url links
657 linkUrlTable.getTableHeader().setReorderingAllowed(false);
658 linkUrlTable.setFillsViewportHeight(true);
659 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
660 linkUrlTable.setAutoCreateRowSorter(true);
661 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
663 // adjust row height so radio buttons actually fit
664 // don't do this in the renderer, it causes the awt thread to activate
666 JRadioButton temp = new JRadioButton();
667 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
669 // Table in scrollpane so that the table is given a scrollbar
670 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
671 linkScrollPane.setBorder(null);
673 // Panel for links functionality
674 JPanel linkPanel = new JPanel(new GridBagLayout());
675 linkPanel.setBorder(new TitledBorder(
676 MessageManager.getString("label.url_linkfrom_sequence_id")));
678 // Put the Url links panel together
680 // Buttons go at top right, resizing only resizes the blank space vertically
681 JPanel buttonPanel = initLinkTabUrlButtons();
682 GridBagConstraints linkConstraints1 = new GridBagConstraints();
683 linkConstraints1.insets = new Insets(0, 0, 5, 0);
684 linkConstraints1.gridx = 0;
685 linkConstraints1.gridy = 0;
686 linkConstraints1.weightx = 1.0;
687 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
688 linkTab.add(buttonPanel, linkConstraints1);
690 // Links table goes at top left, resizing resizes the table
691 GridBagConstraints linkConstraints2 = new GridBagConstraints();
692 linkConstraints2.insets = new Insets(0, 0, 5, 5);
693 linkConstraints2.gridx = 0;
694 linkConstraints2.gridy = 1;
695 linkConstraints2.weightx = 1.0;
696 linkConstraints2.weighty = 1.0;
697 linkConstraints2.fill = GridBagConstraints.BOTH;
698 linkTab.add(linkScrollPane, linkConstraints2);
700 // Filter box and buttons goes at bottom left, resizing resizes the text box
701 JPanel filterPanel = initLinkTabFilterPanel();
702 GridBagConstraints linkConstraints3 = new GridBagConstraints();
703 linkConstraints3.insets = new Insets(0, 0, 0, 5);
704 linkConstraints3.gridx = 0;
705 linkConstraints3.gridy = 2;
706 linkConstraints3.weightx = 1.0;
707 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
708 linkTab.add(filterPanel, linkConstraints3);
713 private JPanel initLinkTabFilterPanel()
715 // Filter textbox and reset button
716 JLabel filterLabel = new JLabel(
717 MessageManager.getString("label.filter"));
718 filterLabel.setFont(LABEL_FONT);
719 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
720 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
722 filterTB.setFont(LABEL_FONT);
723 filterTB.setText("");
725 doReset.setText(MessageManager.getString("action.showall"));
726 userOnly.setText(MessageManager.getString("action.customfilter"));
728 // Panel for filter functionality
729 JPanel filterPanel = new JPanel(new GridBagLayout());
730 filterPanel.setBorder(new TitledBorder("Filter"));
731 GridBagConstraints gbc = new GridBagConstraints();
734 gbc.fill = GridBagConstraints.NONE;
735 gbc.anchor = GridBagConstraints.WEST;
737 filterPanel.add(filterLabel, gbc);
739 GridBagConstraints gbc1 = new GridBagConstraints();
742 gbc1.fill = GridBagConstraints.HORIZONTAL;
743 gbc1.anchor = GridBagConstraints.WEST;
745 filterPanel.add(filterTB, gbc1);
747 GridBagConstraints gbc2 = new GridBagConstraints();
749 gbc2.fill = GridBagConstraints.NONE;
750 gbc2.anchor = GridBagConstraints.WEST;
751 filterPanel.add(doReset, gbc2);
753 GridBagConstraints gbc3 = new GridBagConstraints();
755 gbc3.fill = GridBagConstraints.NONE;
756 gbc3.anchor = GridBagConstraints.WEST;
757 filterPanel.add(userOnly, gbc3);
762 private JPanel initLinkTabUrlButtons()
764 // Buttons for new / edit / delete Url links
765 JButton newLink = new JButton();
766 newLink.setText(MessageManager.getString("action.new"));
768 editLink.setText(MessageManager.getString("action.edit"));
770 deleteLink.setText(MessageManager.getString("action.delete"));
772 // no current selection, so initially disable delete/edit buttons
773 editLink.setEnabled(false);
774 deleteLink.setEnabled(false);
776 newLink.addActionListener(new java.awt.event.ActionListener()
779 public void actionPerformed(ActionEvent e)
781 newLink_actionPerformed(e);
785 editLink.setText(MessageManager.getString("action.edit"));
786 editLink.addActionListener(new java.awt.event.ActionListener()
789 public void actionPerformed(ActionEvent e)
791 editLink_actionPerformed(e);
795 deleteLink.setText(MessageManager.getString("action.delete"));
796 deleteLink.addActionListener(new java.awt.event.ActionListener()
799 public void actionPerformed(ActionEvent e)
801 deleteLink_actionPerformed(e);
805 JPanel buttonPanel = new JPanel(new GridBagLayout());
806 buttonPanel.setBorder(new TitledBorder("Edit links"));
807 GridBagConstraints gbc = new GridBagConstraints();
810 gbc.fill = GridBagConstraints.NONE;
811 buttonPanel.add(newLink, gbc);
813 GridBagConstraints gbc1 = new GridBagConstraints();
816 gbc1.fill = GridBagConstraints.NONE;
817 buttonPanel.add(editLink, gbc1);
819 GridBagConstraints gbc2 = new GridBagConstraints();
822 gbc2.fill = GridBagConstraints.NONE;
823 buttonPanel.add(deleteLink, gbc2);
825 GridBagConstraints gbc3 = new GridBagConstraints();
828 gbc3.fill = GridBagConstraints.HORIZONTAL;
830 JPanel spacePanel = new JPanel();
831 spacePanel.setBorder(null);
832 buttonPanel.add(spacePanel, gbc3);
838 * Initialises the proxy server panel in the Connections tab
840 * @return the proxy server panel
842 private JPanel initConnTabProxyPanel()
844 // Label for server text box
845 serverLabel.setText(MessageManager.getString("label.address"));
846 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
847 serverLabel.setFont(LABEL_FONT);
849 // Proxy server and port text boxes
850 proxyServerTB.setFont(LABEL_FONT);
851 proxyPortTB.setFont(LABEL_FONT);
853 // Label for Port text box
854 portLabel.setFont(LABEL_FONT);
855 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
856 portLabel.setText(MessageManager.getString("label.port"));
858 // Use proxy server checkbox
859 useProxy.setFont(LABEL_FONT);
860 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
861 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
862 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
863 useProxy.addActionListener(new ActionListener()
866 public void actionPerformed(ActionEvent e)
868 useProxy_actionPerformed();
872 // Make proxy server panel
873 JPanel proxyPanel = new JPanel();
874 TitledBorder titledBorder1 = new TitledBorder(
875 MessageManager.getString("label.proxy_server"));
876 proxyPanel.setBorder(titledBorder1);
877 proxyPanel.setLayout(new GridBagLayout());
878 proxyPanel.add(serverLabel,
879 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
880 GridBagConstraints.WEST, GridBagConstraints.NONE,
881 new Insets(0, 2, 2, 0), 5, 0));
882 proxyPanel.add(portLabel,
883 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
884 GridBagConstraints.WEST, GridBagConstraints.NONE,
885 new Insets(0, 0, 2, 0), 11, 0));
886 proxyPanel.add(useProxy,
887 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
888 GridBagConstraints.WEST, GridBagConstraints.NONE,
889 new Insets(0, 2, 5, 185), 2, -4));
890 proxyPanel.add(proxyPortTB,
891 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
892 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
893 new Insets(0, 2, 2, 2), 54, 1));
894 proxyPanel.add(proxyServerTB,
895 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
896 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
897 new Insets(0, 2, 2, 0), 263, 1));
903 * Initialises the checkboxes in the Connections tab
905 private void initConnTabCheckboxes()
907 // Usage stats checkbox label
909 MessageManager.getString("label.send_usage_statistics"));
910 usagestats.setFont(LABEL_FONT);
911 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
912 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
914 // Questionnaire checkbox label
915 questionnaire.setText(
916 MessageManager.getString("label.check_for_questionnaires"));
917 questionnaire.setFont(LABEL_FONT);
918 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
919 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
921 // Check for latest version checkbox label
922 versioncheck.setText(
923 MessageManager.getString("label.check_for_latest_version"));
924 versioncheck.setFont(LABEL_FONT);
925 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
926 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
930 * Initialises the parent panel which contains the tabbed sections.
934 private JPanel initOkCancelPanel()
936 JButton ok = new JButton();
937 ok.setText(MessageManager.getString("action.ok"));
938 ok.addActionListener(new ActionListener()
941 public void actionPerformed(ActionEvent e)
943 ok_actionPerformed(e);
946 JButton cancel = new JButton();
947 cancel.setText(MessageManager.getString("action.cancel"));
948 cancel.addActionListener(new ActionListener()
951 public void actionPerformed(ActionEvent e)
953 cancel_actionPerformed(e);
956 JPanel okCancelPanel = new JPanel();
957 okCancelPanel.add(ok);
958 okCancelPanel.add(cancel);
959 return okCancelPanel;
963 * Initialises the Colours tabbed panel.
967 private JPanel initColoursTab()
969 JPanel coloursTab = new JPanel();
970 coloursTab.setBorder(new TitledBorder(
971 MessageManager.getString("action.open_new_alignment")));
972 coloursTab.setLayout(new FlowLayout());
973 JLabel mincolourLabel = new JLabel();
974 mincolourLabel.setFont(LABEL_FONT);
975 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
976 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
977 minColour.setFont(LABEL_FONT);
978 minColour.setBorder(BorderFactory.createEtchedBorder());
979 minColour.setPreferredSize(new Dimension(40, 20));
980 minColour.addMouseListener(new MouseAdapter()
983 public void mousePressed(MouseEvent e)
985 minColour_actionPerformed(minColour);
988 JLabel maxcolourLabel = new JLabel();
989 maxcolourLabel.setFont(LABEL_FONT);
990 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
991 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
992 maxColour.setFont(LABEL_FONT);
993 maxColour.setBorder(BorderFactory.createEtchedBorder());
994 maxColour.setPreferredSize(new Dimension(40, 20));
995 maxColour.addMouseListener(new MouseAdapter()
998 public void mousePressed(MouseEvent e)
1000 maxColour_actionPerformed(maxColour);
1004 protColour.setFont(LABEL_FONT);
1005 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1006 JLabel protColourLabel = new JLabel();
1007 protColourLabel.setFont(LABEL_FONT);
1008 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1009 protColourLabel.setText(
1010 MessageManager.getString("label.prot_alignment_colour") + " ");
1011 JvSwingUtils.addtoLayout(coloursTab,
1013 .getString("label.default_colour_scheme_for_alignment"),
1014 protColourLabel, protColour);
1016 nucColour.setFont(LABEL_FONT);
1017 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1018 JLabel nucColourLabel = new JLabel();
1019 nucColourLabel.setFont(LABEL_FONT);
1020 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1021 nucColourLabel.setText(
1022 MessageManager.getString("label.nuc_alignment_colour") + " ");
1023 JvSwingUtils.addtoLayout(coloursTab,
1025 .getString("label.default_colour_scheme_for_alignment"),
1026 nucColourLabel, nucColour);
1028 JPanel annotationShding = new JPanel();
1029 annotationShding.setBorder(new TitledBorder(
1030 MessageManager.getString("label.annotation_shading_default")));
1031 annotationShding.setLayout(new GridLayout(1, 2));
1032 JvSwingUtils.addtoLayout(annotationShding,
1033 MessageManager.getString(
1034 "label.default_minimum_colour_annotation_shading"),
1035 mincolourLabel, minColour);
1036 JvSwingUtils.addtoLayout(annotationShding,
1037 MessageManager.getString(
1038 "label.default_maximum_colour_annotation_shading"),
1039 maxcolourLabel, maxColour);
1040 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1045 * Initialises the Overview tabbed panel.
1049 private JPanel initOverviewTab()
1051 JPanel overviewPanel = new JPanel();
1052 overviewPanel.setBorder(new TitledBorder(
1053 MessageManager.getString("label.overview_settings")));
1055 gapColour.setFont(LABEL_FONT);
1056 // fixing the border colours stops apparent colour bleed from the panel
1057 gapColour.setBorder(
1058 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1059 gapColour.setPreferredSize(new Dimension(40, 20));
1060 gapColour.addMouseListener(new MouseAdapter()
1063 public void mousePressed(MouseEvent e)
1065 gapColour_actionPerformed(gapColour);
1069 hiddenColour.setFont(LABEL_FONT);
1070 // fixing the border colours stops apparent colour bleed from the panel
1071 hiddenColour.setBorder(
1072 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1073 hiddenColour.setPreferredSize(new Dimension(40, 20));
1074 hiddenColour.addMouseListener(new MouseAdapter()
1077 public void mousePressed(MouseEvent e)
1079 hiddenColour_actionPerformed(hiddenColour);
1083 useLegacyGap = new JCheckBox(
1084 MessageManager.getString("label.ov_legacy_gap"));
1085 useLegacyGap.setFont(LABEL_FONT);
1086 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1087 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1088 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1089 gapLabel.setFont(LABEL_FONT);
1090 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1091 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1092 showHiddenAtStart = new JCheckBox(
1093 MessageManager.getString("label.ov_show_hide_default"));
1094 showHiddenAtStart.setFont(LABEL_FONT);
1095 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1096 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1097 JLabel hiddenLabel = new JLabel(
1098 MessageManager.getString("label.hidden_colour"));
1099 hiddenLabel.setFont(LABEL_FONT);
1100 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1101 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1103 useLegacyGap.addActionListener(new ActionListener()
1106 public void actionPerformed(ActionEvent e)
1108 useLegacyGaps_actionPerformed(e);
1112 overviewPanel.setLayout(new GridBagLayout());
1113 GridBagConstraints c1 = new GridBagConstraints();
1115 c1.fill = GridBagConstraints.HORIZONTAL;
1120 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1121 overviewPanel.add(useLegacyGap, c1);
1123 GridBagConstraints c2 = new GridBagConstraints();
1124 c2.fill = GridBagConstraints.HORIZONTAL;
1127 c2.insets = new Insets(0, 15, 0, 10);
1128 overviewPanel.add(gapLabel, c2);
1130 GridBagConstraints c3 = new GridBagConstraints();
1131 c3.fill = GridBagConstraints.HORIZONTAL;
1134 c3.insets = new Insets(0, 0, 0, 15);
1135 overviewPanel.add(gapColour, c3);
1137 GridBagConstraints c4 = new GridBagConstraints();
1138 c4.fill = GridBagConstraints.HORIZONTAL;
1142 overviewPanel.add(showHiddenAtStart, c4);
1144 GridBagConstraints c5 = new GridBagConstraints();
1145 c5.fill = GridBagConstraints.HORIZONTAL;
1148 c5.insets = new Insets(0, 15, 0, 10);
1149 overviewPanel.add(hiddenLabel, c5);
1151 GridBagConstraints c6 = new GridBagConstraints();
1152 c6.fill = GridBagConstraints.HORIZONTAL;
1155 c6.insets = new Insets(0, 0, 0, 15);
1156 overviewPanel.add(hiddenColour, c6);
1158 JButton resetButton = new JButton(
1159 MessageManager.getString("label.reset_to_defaults"));
1161 resetButton.addActionListener(new ActionListener()
1164 public void actionPerformed(ActionEvent e)
1166 resetOvDefaults_actionPerformed(e);
1170 GridBagConstraints c7 = new GridBagConstraints();
1171 c7.fill = GridBagConstraints.NONE;
1174 c7.insets = new Insets(10, 0, 0, 0);
1175 c7.anchor = GridBagConstraints.WEST;
1176 overviewPanel.add(resetButton, c7);
1178 // Add padding so the panel doesn't look ridiculous
1179 JPanel spacePanel = new JPanel();
1180 overviewPanel.add(spacePanel,
1181 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1182 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1183 new Insets(0, 0, 0, 5), 0, 0));
1185 return overviewPanel;
1189 * Initialises the Structure tabbed panel.
1193 private JPanel initStructureTab()
1195 structureTab = new JPanel();
1197 structureTab.setBorder(new TitledBorder(
1198 MessageManager.getString("label.structure_options")));
1199 structureTab.setLayout(null);
1200 final int width = 420;
1201 final int height = 22;
1202 final int lineSpacing = 25;
1205 structFromPdb.setFont(LABEL_FONT);
1207 .setText(MessageManager.getString("label.struct_from_pdb"));
1208 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1209 structFromPdb.addActionListener(new ActionListener()
1212 public void actionPerformed(ActionEvent e)
1214 boolean selected = structFromPdb.isSelected();
1215 // enable other options only when the first is checked
1216 useRnaView.setEnabled(selected);
1217 addSecondaryStructure.setEnabled(selected);
1218 addTempFactor.setEnabled(selected);
1221 structureTab.add(structFromPdb);
1223 // indent checkboxes that are conditional on the first one
1224 ypos += lineSpacing;
1225 useRnaView.setFont(LABEL_FONT);
1226 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1227 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1228 structureTab.add(useRnaView);
1230 ypos += lineSpacing;
1231 addSecondaryStructure.setFont(LABEL_FONT);
1232 addSecondaryStructure
1233 .setText(MessageManager.getString("label.autoadd_secstr"));
1234 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1235 structureTab.add(addSecondaryStructure);
1237 ypos += lineSpacing;
1238 addTempFactor.setFont(LABEL_FONT);
1239 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1240 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1241 structureTab.add(addTempFactor);
1243 ypos += lineSpacing;
1244 JLabel viewerLabel = new JLabel();
1245 viewerLabel.setFont(LABEL_FONT);
1246 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1247 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1248 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1249 structureTab.add(viewerLabel);
1251 structViewer.setFont(LABEL_FONT);
1252 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1253 structViewer.addItem(ViewerType.JMOL.name());
1254 structViewer.addItem(ViewerType.CHIMERA.name());
1255 structViewer.addItem(ViewerType.CHIMERAX.name());
1256 structViewer.addActionListener(new ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 structureViewer_actionPerformed(
1262 (String) structViewer.getSelectedItem());
1265 structureTab.add(structViewer);
1267 ypos += lineSpacing;
1268 chimeraPathLabel = new JLabel();
1269 chimeraPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
1270 chimeraPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1271 chimeraPathLabel.setText(MessageManager
1272 .formatMessage("label.chimera_path", "Chimera(X)"));
1273 chimeraPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
1274 chimeraPathLabel.setEnabled(false);
1275 structureTab.add(chimeraPathLabel);
1277 chimeraPath.setFont(LABEL_FONT);
1278 chimeraPath.setText("");
1279 chimeraPath.setEnabled(false);
1280 final String tooltip = JvSwingUtils.wrapTooltip(true,
1281 MessageManager.getString("label.chimera_path_tip"));
1282 chimeraPath.setToolTipText(tooltip);
1283 chimeraPath.setBounds(new Rectangle(190, ypos, 290, height));
1284 chimeraPath.addMouseListener(new MouseAdapter()
1287 public void mouseClicked(MouseEvent e)
1289 if (chimeraPath.isEnabled() && e.getClickCount() == 2)
1291 String chosen = openFileChooser();
1294 chimeraPath.setText(chosen);
1299 structureTab.add(chimeraPath);
1301 ypos += lineSpacing;
1302 nwMapping.setFont(LABEL_FONT);
1303 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1304 siftsMapping.setFont(LABEL_FONT);
1305 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1306 mappingMethod.add(nwMapping);
1307 mappingMethod.add(siftsMapping);
1308 JPanel mappingPanel = new JPanel();
1309 mappingPanel.setFont(LABEL_FONT);
1310 TitledBorder mmTitledBorder = new TitledBorder(
1311 MessageManager.getString("label.mapping_method"));
1312 mmTitledBorder.setTitleFont(LABEL_FONT);
1313 mappingPanel.setBorder(mmTitledBorder);
1314 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1315 // GridLayout mappingLayout = new GridLayout();
1316 mappingPanel.setLayout(new GridLayout());
1317 mappingPanel.add(nwMapping);
1318 mappingPanel.add(siftsMapping);
1319 structureTab.add(mappingPanel);
1321 ypos += lineSpacing;
1322 ypos += lineSpacing;
1323 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1324 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1325 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1326 structureTab.add(docFieldPref);
1328 return structureTab;
1332 * Action on choosing a structure viewer from combobox options.
1334 * @param selectedItem
1336 protected void structureViewer_actionPerformed(String selectedItem)
1341 * Show a dialog for the user to choose a file. Returns the chosen path, or
1346 protected String openFileChooser()
1348 String choice = null;
1349 JFileChooser chooser = new JFileChooser();
1351 // chooser.setFileView(new JalviewFileView());
1352 chooser.setDialogTitle(
1353 MessageManager.getString("label.open_local_file"));
1354 chooser.setToolTipText(MessageManager.getString("action.open"));
1356 int value = chooser.showOpenDialog(this);
1358 if (value == JFileChooser.APPROVE_OPTION)
1360 choice = chooser.getSelectedFile().getPath();
1366 * Validate the structure tab preferences; if invalid, set focus on this tab.
1370 protected boolean validateStructure(FocusEvent e)
1372 if (!validateStructure())
1374 e.getComponent().requestFocusInWindow();
1380 protected boolean validateStructure()
1386 * Initialises the Visual tabbed panel.
1390 private JPanel initVisualTab()
1392 JPanel visualTab = new JPanel();
1393 visualTab.setBorder(new TitledBorder(
1394 MessageManager.getString("action.open_new_alignment")));
1395 visualTab.setLayout(null);
1396 fullScreen.setFont(LABEL_FONT);
1397 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1398 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1399 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1400 quality.setEnabled(false);
1401 quality.setFont(LABEL_FONT);
1402 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1403 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1404 quality.setSelected(true);
1405 quality.setText(MessageManager.getString("label.quality"));
1406 conservation.setEnabled(false);
1407 conservation.setFont(LABEL_FONT);
1408 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1409 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1410 conservation.setSelected(true);
1411 conservation.setText(MessageManager.getString("label.conservation"));
1412 identity.setEnabled(false);
1413 identity.setFont(LABEL_FONT);
1414 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1415 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1416 identity.setSelected(true);
1417 identity.setText(MessageManager.getString("label.consensus"));
1418 showOccupancy.setFont(LABEL_FONT);
1419 showOccupancy.setEnabled(false);
1420 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1421 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1422 showOccupancy.setSelected(true);
1423 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1425 JLabel showGroupbits = new JLabel();
1426 showGroupbits.setFont(LABEL_FONT);
1427 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1428 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1430 .setText(MessageManager.getString("action.show_group") + ":");
1431 JLabel showConsensbits = new JLabel();
1432 showConsensbits.setFont(LABEL_FONT);
1433 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1434 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1436 .setText(MessageManager.getString("label.consensus") + ":");
1437 showConsensHistogram.setEnabled(false);
1438 showConsensHistogram.setFont(LABEL_FONT);
1439 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1440 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1441 showConsensHistogram.setSelected(true);
1442 showConsensHistogram
1443 .setText(MessageManager.getString("label.histogram"));
1444 showConsensLogo.setEnabled(false);
1445 showConsensLogo.setFont(LABEL_FONT);
1446 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1447 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1448 showConsensLogo.setSelected(true);
1449 showConsensLogo.setText(MessageManager.getString("label.logo"));
1450 showGroupConsensus.setEnabled(false);
1451 showGroupConsensus.setFont(LABEL_FONT);
1452 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1453 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1454 showGroupConsensus.setSelected(true);
1455 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1456 showGroupConservation.setEnabled(false);
1457 showGroupConservation.setFont(LABEL_FONT);
1458 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1459 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1460 showGroupConservation.setSelected(true);
1461 showGroupConservation
1462 .setText(MessageManager.getString("label.conservation"));
1463 showNpTooltip.setEnabled(true);
1464 showNpTooltip.setFont(LABEL_FONT);
1465 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1466 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1467 showNpTooltip.setSelected(true);
1468 showNpTooltip.setText(
1469 MessageManager.getString("label.non_positional_features"));
1470 showDbRefTooltip.setEnabled(true);
1471 showDbRefTooltip.setFont(LABEL_FONT);
1472 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1473 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1474 showDbRefTooltip.setSelected(true);
1476 .setText(MessageManager.getString("label.database_references"));
1477 annotations.setFont(LABEL_FONT);
1478 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1479 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1480 annotations.setSelected(true);
1481 annotations.setText(MessageManager.getString("label.show_annotations"));
1482 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1483 annotations.addActionListener(new ActionListener()
1486 public void actionPerformed(ActionEvent e)
1488 annotations_actionPerformed(e);
1491 identity.addActionListener(new ActionListener()
1494 public void actionPerformed(ActionEvent e)
1496 annotations_actionPerformed(e);
1499 showGroupConsensus.addActionListener(new ActionListener()
1502 public void actionPerformed(ActionEvent e)
1504 annotations_actionPerformed(e);
1507 showUnconserved.setFont(LABEL_FONT);
1508 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1509 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1510 showUnconserved.setSelected(true);
1512 .setText(MessageManager.getString("action.show_unconserved"));
1513 showUnconserved.addActionListener(new ActionListener()
1516 public void actionPerformed(ActionEvent e)
1518 showunconserved_actionPerformed(e);
1522 // TODO these are not yet added to / action from Preferences
1523 // JCheckBox shareSelections = new JCheckBox();
1524 // shareSelections.setFont(verdana11);
1525 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1526 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1527 // shareSelections.setSelected(true);
1528 // shareSelections.setText(MessageManager
1529 // .getString("label.share_selection_across_views"));
1530 // JCheckBox followHighlight = new JCheckBox();
1531 // followHighlight.setFont(verdana11);
1532 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1533 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1534 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1535 // followHighlight.setSelected(true);
1536 // followHighlight.setText(MessageManager
1537 // .getString("label.scroll_highlighted_regions"));
1539 seqLimit.setFont(LABEL_FONT);
1540 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1541 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1542 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1543 smoothFont.setFont(LABEL_FONT);
1544 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1545 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1546 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1547 scaleProteinToCdna.setFont(LABEL_FONT);
1548 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1549 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1550 scaleProteinToCdna.setText(
1551 MessageManager.getString("label.scale_protein_to_cdna"));
1552 scaleProteinToCdna.setToolTipText(
1553 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1554 JLabel gapLabel = new JLabel();
1555 gapLabel.setFont(LABEL_FONT);
1556 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1557 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1558 JLabel fontLabel = new JLabel();
1559 fontLabel.setFont(LABEL_FONT);
1560 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1561 fontLabel.setText(MessageManager.getString("label.font"));
1562 fontSizeCB.setFont(LABEL_FONT);
1563 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1564 fontStyleCB.setFont(LABEL_FONT);
1565 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1566 fontNameCB.setFont(LABEL_FONT);
1567 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1568 gapSymbolCB.setFont(LABEL_FONT);
1569 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1570 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1571 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1572 gapSymbolCB.setRenderer(dlcr);
1574 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1575 startupCheckbox.setFont(LABEL_FONT);
1576 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1577 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1578 startupCheckbox.setSelected(true);
1579 startupFileTextfield.setFont(LABEL_FONT);
1580 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1581 final String tooltip = JvSwingUtils.wrapTooltip(true,
1582 MessageManager.getString("label.double_click_to_browse"));
1583 startupFileTextfield.setToolTipText(tooltip);
1584 startupFileTextfield.addMouseListener(new MouseAdapter()
1587 public void mouseClicked(MouseEvent e)
1589 if (e.getClickCount() > 1)
1591 startupFileTextfield_mouseClicked();
1596 sortby.setFont(LABEL_FONT);
1597 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1598 JLabel sortLabel = new JLabel();
1599 sortLabel.setFont(LABEL_FONT);
1600 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1601 sortLabel.setText(MessageManager.getString("label.sort_by"));
1602 sortAnnBy.setFont(LABEL_FONT);
1603 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1604 JLabel sortAnnLabel = new JLabel();
1605 sortAnnLabel.setFont(LABEL_FONT);
1606 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1607 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1608 sortAutocalc.setFont(LABEL_FONT);
1609 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1611 JPanel annsettingsPanel = new JPanel();
1612 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1613 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1614 annsettingsPanel.setBorder(new EtchedBorder());
1615 visualTab.add(annsettingsPanel);
1616 Border jb = new EmptyBorder(1, 1, 4, 5);
1617 annotations.setBorder(jb);
1618 showOccupancy.setBorder(jb);
1619 quality.setBorder(jb);
1620 conservation.setBorder(jb);
1621 identity.setBorder(jb);
1622 showConsensbits.setBorder(jb);
1623 showGroupbits.setBorder(jb);
1624 showGroupConsensus.setBorder(jb);
1625 showGroupConservation.setBorder(jb);
1626 showConsensHistogram.setBorder(jb);
1627 showConsensLogo.setBorder(jb);
1629 JPanel autoAnnotSettings = new JPanel();
1630 annsettingsPanel.add(autoAnnotSettings);
1631 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1632 autoAnnotSettings.add(annotations);
1633 autoAnnotSettings.add(quality);
1634 // second row of autoannotation box
1635 autoAnnotSettings = new JPanel();
1636 annsettingsPanel.add(autoAnnotSettings);
1638 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1639 autoAnnotSettings.add(conservation);
1640 autoAnnotSettings.add(identity);
1641 autoAnnotSettings.add(showOccupancy);
1642 autoAnnotSettings.add(showGroupbits);
1643 autoAnnotSettings.add(showGroupConservation);
1644 autoAnnotSettings.add(showGroupConsensus);
1645 autoAnnotSettings.add(showConsensbits);
1646 autoAnnotSettings.add(showConsensHistogram);
1647 autoAnnotSettings.add(showConsensLogo);
1649 JPanel tooltipSettings = new JPanel();
1650 tooltipSettings.setBorder(new TitledBorder(
1651 MessageManager.getString("label.sequence_id_tooltip")));
1652 tooltipSettings.setBounds(173, 140, 220, 62);
1653 tooltipSettings.setLayout(new GridLayout(2, 1));
1654 tooltipSettings.add(showDbRefTooltip);
1655 tooltipSettings.add(showNpTooltip);
1656 visualTab.add(tooltipSettings);
1658 wrap.setFont(LABEL_FONT);
1659 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1660 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1661 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1662 rightAlign.setFont(LABEL_FONT);
1663 rightAlign.setForeground(Color.black);
1664 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1665 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1666 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1667 idItalics.setFont(LABEL_FONT_ITALIC);
1668 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1669 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1671 MessageManager.getString("label.sequence_name_italics"));
1672 openoverv.setFont(LABEL_FONT);
1673 openoverv.setActionCommand(
1674 MessageManager.getString("label.open_overview"));
1675 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1676 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1677 openoverv.setText(MessageManager.getString("label.open_overview"));
1678 JPanel jPanel2 = new JPanel();
1679 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1680 jPanel2.setLayout(new GridLayout(14, 1));
1681 jPanel2.add(fullScreen);
1682 jPanel2.add(openoverv);
1683 jPanel2.add(seqLimit);
1684 jPanel2.add(rightAlign);
1685 jPanel2.add(fontLabel);
1686 jPanel2.add(showUnconserved);
1687 jPanel2.add(idItalics);
1688 jPanel2.add(smoothFont);
1689 jPanel2.add(scaleProteinToCdna);
1690 jPanel2.add(gapLabel);
1692 jPanel2.add(sortLabel);
1693 jPanel2.add(sortAnnLabel);
1694 jPanel2.add(startupCheckbox);
1695 visualTab.add(jPanel2);
1696 visualTab.add(startupFileTextfield);
1697 visualTab.add(sortby);
1698 visualTab.add(sortAnnBy);
1699 visualTab.add(sortAutocalc);
1700 visualTab.add(gapSymbolCB);
1701 visualTab.add(fontNameCB);
1702 visualTab.add(fontSizeCB);
1703 visualTab.add(fontStyleCB);
1708 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1711 protected void loadLastSavedBackupsOptions()
1713 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1714 .getSavedBackupEntry();
1716 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1718 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1719 .createBackupFilesPresetEntry(Cache
1720 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1721 if (backupfilesCustomEntry == null)
1723 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1724 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1726 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1727 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1728 backupfilesCustomEntry);
1730 setComboIntStringKey(backupfilesPresetsCombo,
1731 Cache.getDefault(BackupFiles.NS + "_PRESET",
1732 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1734 backupsSetOptions(savedPreset);
1736 backupsOptionsSetEnabled();
1737 updateBackupFilesExampleLabel();
1740 private boolean warnAboutSuffixReverseChange()
1742 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1743 .getSavedBackupEntry();
1744 boolean savedSuffixReverse = bfpe.reverse;
1745 int savedSuffixDigits = bfpe.digits;
1746 String savedSuffixTemplate = bfpe.suffix;
1748 boolean nowSuffixReverse = suffixReverse.isSelected();
1749 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1750 String nowSuffixTemplate = suffixTemplate.getText();
1751 return nowSuffixReverse != savedSuffixReverse
1752 && nowSuffixDigits == savedSuffixDigits
1753 && nowSuffixTemplate != null
1754 && nowSuffixTemplate.equals(savedSuffixTemplate);
1758 * Initialises the Backups tabbed panel.
1762 private JPanel initBackupsTab()
1764 JPanel backupsTab = new JPanel();
1765 backupsTab.setBorder(new TitledBorder(
1766 MessageManager.getString("label.backup_files")));
1767 backupsTab.setLayout(new GridBagLayout());
1769 GridBagConstraints gbc = new GridBagConstraints();
1772 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1773 gbc.fill = GridBagConstraints.NONE;
1775 initBackupsTabPresetsPanel();
1776 initBackupsTabSuffixPanel();
1777 initBackupsTabKeepFilesPanel();
1778 initBackupsTabFilenameExamplesPanel();
1780 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1782 .setText(MessageManager.getString("label.enable_backupfiles"));
1783 enableBackupFiles.addActionListener(new ActionListener()
1786 public void actionPerformed(ActionEvent e)
1788 // enable other options only when the first is checked
1789 backupsOptionsSetEnabled();
1794 // enable checkbox 1 col
1798 gbc.gridy = 0; // row 0
1799 backupsTab.add(enableBackupFiles, gbc);
1801 // summary of scheme box (over two rows)
1805 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1806 gbc.fill = GridBagConstraints.BOTH;
1807 backupsTab.add(exampleFilesPanel, gbc);
1809 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1810 gbc.fill = GridBagConstraints.NONE;
1812 // fill empty space on right
1815 backupsTab.add(new JPanel(), gbc);
1820 gbc.gridy++; // row 1
1821 backupsTab.add(presetsPanel, gbc);
1823 // now using whole row
1828 gbc.gridy++; // row 2
1829 backupsTab.add(keepfilesPanel, gbc);
1831 // filename strategy box
1832 gbc.gridy++; // row 3
1833 backupsTab.add(suffixPanel, gbc);
1836 gbc.gridy++; // row 4
1838 backupsTab.add(new JPanel(), gbc);
1840 backupsOptionsSetEnabled();
1844 private JPanel initBackupsTabPresetsPanel()
1847 String title = MessageManager.getString("label.schemes");
1849 presetsPanel.setLayout(new GridBagLayout());
1851 GridBagConstraints gbc = new GridBagConstraints();
1854 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1855 gbc.fill = GridBagConstraints.NONE;
1863 presetsComboLabel = new JLabel(title + ":");
1864 presetsPanel.add(presetsComboLabel, gbc);
1866 List<Object> entries = Arrays
1867 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
1868 List<String> tooltips = Arrays.asList(
1869 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
1870 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
1873 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1875 backupfilesPresetsCombo
1876 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1880 backupfilesPresetsCombo.addActionListener(new ActionListener()
1883 public void actionPerformed(ActionEvent e)
1885 int key = getComboIntStringKey(backupfilesPresetsCombo);
1886 if (!customiseCheckbox.isSelected())
1888 backupfilesPresetsComboLastSelected = key;
1890 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1892 if (customiseCheckbox.isSelected())
1894 // got here by clicking on customiseCheckbox so don't change the values
1895 backupfilesCustomOptionsSetEnabled();
1899 backupsTabUpdatePresets();
1900 backupfilesCustomOptionsSetEnabled();
1905 customiseCheckbox.setSelected(false);
1906 backupsTabUpdatePresets();
1907 backupfilesCustomOptionsSetEnabled();
1912 // dropdown list of preset schemes
1914 presetsPanel.add(backupfilesPresetsCombo, gbc);
1916 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1917 revertButton.setToolTipText(
1918 MessageManager.getString("label.cancel_changes_description"));
1919 revertButton.addActionListener(new ActionListener()
1922 public void actionPerformed(ActionEvent e)
1925 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
1926 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
1927 backupfilesCustomOptionsSetEnabled();
1931 revertButton.setFont(LABEL_FONT);
1933 customiseCheckbox.setFont(LABEL_FONT);
1934 customiseCheckbox.setText(MessageManager.getString("label.customise"));
1935 customiseCheckbox.addActionListener(new ActionListener()
1938 public void actionPerformed(ActionEvent e)
1940 int currently = getComboIntStringKey(backupfilesPresetsCombo);
1941 if (customiseCheckbox.isSelected())
1943 backupfilesPresetsComboLastSelected = currently;
1944 setComboIntStringKey(backupfilesPresetsCombo,
1945 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
1949 setComboIntStringKey(backupfilesPresetsCombo,
1950 backupfilesPresetsComboLastSelected);
1953 backupfilesCustomOptionsSetEnabled();
1956 customiseCheckbox.setToolTipText(
1957 MessageManager.getString("label.customise_description"));
1959 // customise checkbox
1962 presetsPanel.add(customiseCheckbox, gbc);
1964 // "Cancel changes" button (aligned with combo box above)
1966 presetsPanel.add(revertButton, gbc);
1968 return presetsPanel;
1971 private JPanel initBackupsTabFilenameExamplesPanel()
1973 String title = MessageManager
1974 .getString("label.scheme_examples");
1975 TitledBorder tb = new TitledBorder(title);
1976 exampleFilesPanel.setBorder(tb);
1977 exampleFilesPanel.setLayout(new GridBagLayout());
1980 backupfilesExampleLabel.setEditable(false);
1981 backupfilesExampleLabel
1982 .setBackground(exampleFilesPanel.getBackground());
1984 updateBackupFilesExampleLabel();
1986 GridBagConstraints gbc = new GridBagConstraints();
1989 gbc.fill = GridBagConstraints.NONE;
1990 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1992 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1993 return exampleFilesPanel;
1996 private void backupsTabUpdatePresets()
1998 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2001 String value = entry.v;
2003 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2007 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2013 "Preset '" + value + "' [key:" + key + "] not implemented");
2016 // Custom options will now be enabled when the customiseCheckbox is checked
2017 // (performed above)
2018 // backupfilesCustomOptionsSetEnabled();
2019 updateBackupFilesExampleLabel();
2022 protected int getComboIntStringKey(
2023 JComboBox<Object> backupfilesPresetsCombo2)
2025 IntKeyStringValueEntry e;
2028 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2030 } catch (Exception ex)
2033 "Problem casting Combo entry to IntKeyStringValueEntry.");
2036 return e != null ? e.k : 0;
2039 protected void setComboIntStringKey(
2040 JComboBox<Object> backupfilesPresetsCombo2,
2043 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2045 IntKeyStringValueEntry e;
2048 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2049 } catch (Exception ex)
2052 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2057 backupfilesPresetsCombo2.setSelectedIndex(i);
2061 // backupsTabUpdatePresets();
2064 private JPanel initBackupsTabSuffixPanel()
2066 suffixPanel.setBorder(new TitledBorder(
2067 MessageManager.getString("label.backup_filename_strategy")));
2068 suffixPanel.setLayout(new GridBagLayout());
2071 .setText(MessageManager.getString("label.append_to_filename"));
2072 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2073 suffixTemplateLabel.setFont(LABEL_FONT);
2075 final String tooltip = JvSwingUtils.wrapTooltip(true,
2076 MessageManager.getString("label.append_to_filename_tooltip"));
2077 suffixTemplate.setToolTipText(tooltip);
2078 suffixTemplate.addActionListener(new ActionListener()
2081 public void actionPerformed(ActionEvent e)
2083 updateBackupFilesExampleLabel();
2084 backupfilesCustomOptionsSetEnabled();
2085 backupfilesRevertButtonSetEnabled(true);
2089 suffixTemplate.addKeyListener(new KeyListener()
2092 public void keyReleased(KeyEvent e)
2094 updateBackupFilesExampleLabel();
2095 backupfilesCustomOptionsSetEnabled();
2096 backupfilesRevertButtonSetEnabled(true);
2100 public void keyPressed(KeyEvent e)
2104 // disable use of ':' or '/' or '\'
2106 public void keyTyped(KeyEvent e)
2108 char c = e.getKeyChar();
2109 if (c == ':' || c == '/' || c == '\\')
2111 // don't process ':' or '/' or '\'
2120 .setText(MessageManager.getString("label.index_digits"));
2121 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2122 suffixDigitsLabel.setFont(LABEL_FONT);
2123 ChangeListener c = new ChangeListener()
2126 public void stateChanged(ChangeEvent e)
2128 backupfilesRevertButtonSetEnabled(true);
2129 updateBackupFilesExampleLabel();
2133 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2134 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2136 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2137 MessageManager.getString("label.increment_index"));
2138 suffixReverse.addActionListener(new ActionListener()
2141 public void actionPerformed(ActionEvent e)
2143 boolean okay = true;
2144 if (warnAboutSuffixReverseChange())
2147 okay = confirmSuffixReverseChange();
2151 backupfilesRevertButtonSetEnabled(true);
2152 updateBackupFilesExampleLabel();
2156 boolean savedSuffixReverse = BackupFilesPresetEntry
2157 .getSavedBackupEntry().reverse;
2158 suffixReverse.setSelected(savedSuffixReverse);
2163 GridBagConstraints sgbc = new GridBagConstraints();
2165 // first row (template text box)
2166 sgbc.anchor = GridBagConstraints.WEST;
2170 sgbc.gridheight = 1;
2173 sgbc.fill = GridBagConstraints.NONE;
2174 suffixPanel.add(suffixTemplateLabel, sgbc);
2177 sgbc.fill = GridBagConstraints.HORIZONTAL;
2178 suffixPanel.add(suffixTemplate, sgbc);
2180 // second row (number of digits spinner)
2184 sgbc.fill = GridBagConstraints.NONE;
2185 suffixPanel.add(suffixDigitsLabel, sgbc);
2188 sgbc.fill = GridBagConstraints.HORIZONTAL;
2189 suffixPanel.add(suffixDigitsSpinner, sgbc);
2191 // third row (forward order radio selection)
2194 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2195 sgbc.fill = GridBagConstraints.HORIZONTAL;
2196 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2198 // fourth row (reverse order radio selection)
2200 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2204 private boolean confirmSuffixReverseChange()
2206 boolean ret = false;
2207 String warningMessage = MessageManager
2208 .getString("label.warning_confirm_change_reverse");
2209 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2211 MessageManager.getString("label.change_increment_decrement"),
2212 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2214 ret = (confirm == JvOptionPane.YES_OPTION);
2218 private JPanel initBackupsTabKeepFilesPanel()
2220 keepfilesPanel.setBorder(
2221 new TitledBorder(MessageManager.getString("label.keep_files")));
2222 keepfilesPanel.setLayout(new GridBagLayout());
2224 backupfilesKeepAll.setLabels(
2225 MessageManager.getString("label.keep_all_backup_files"),
2226 MessageManager.getString(
2227 "label.keep_only_this_number_of_backup_files"));
2228 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2231 public void actionPerformed(ActionEvent e)
2233 backupfilesRevertButtonSetEnabled(true);
2234 updateBackupFilesExampleLabel();
2237 backupfilesKeepAll.addActionListener(new ActionListener()
2240 public void actionPerformed(ActionEvent e)
2242 backupfilesRevertButtonSetEnabled(true);
2243 keepRollMaxOptionsEnabled();
2244 updateBackupFilesExampleLabel();
2248 ChangeListener c = new ChangeListener()
2251 public void stateChanged(ChangeEvent e)
2253 backupfilesRevertButtonSetEnabled(true);
2254 updateBackupFilesExampleLabel();
2258 setIntegerSpinner(backupfilesRollMaxSpinner,
2259 BackupFilesPresetEntry.ROLLMAXMIN,
2260 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2262 backupfilesConfirmDelete.setLabels(
2263 MessageManager.getString("label.always_ask"),
2264 MessageManager.getString("label.auto_delete"));
2265 backupfilesConfirmDelete.addActionListener(new ActionListener()
2268 public void actionPerformed(ActionEvent e)
2270 backupfilesRevertButtonSetEnabled(true);
2273 // update the enabled section
2274 keepRollMaxOptionsEnabled();
2276 GridBagConstraints kgbc = new GridBagConstraints();
2278 // first row (template text box)
2279 kgbc.anchor = GridBagConstraints.WEST;
2282 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2283 kgbc.gridheight = 1;
2286 kgbc.fill = GridBagConstraints.HORIZONTAL;
2287 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2293 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2294 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2297 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2298 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2300 // third row (indented)
2302 kgbc.insets = new Insets(0, 20, 0, 0);
2305 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2306 kgbc.fill = GridBagConstraints.HORIZONTAL;
2309 JPanel jp = new JPanel();
2310 jp.setLayout(new FlowLayout());
2312 .setText(MessageManager
2313 .getString("label.autodelete_old_backup_files"));
2314 oldBackupFilesLabel.setFont(LABEL_FONT);
2315 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2316 jp.add(oldBackupFilesLabel);
2317 jp.add(backupfilesConfirmDelete.getTrueButton());
2318 jp.add(backupfilesConfirmDelete.getFalseButton());
2319 keepfilesPanel.add(jp, kgbc);
2321 return keepfilesPanel;
2324 protected void updateBackupFilesExampleLabel()
2326 int exampleindex = 12;
2327 String base = MessageManager.getString("label.filename") + ".fa";
2328 if (base == null || base.length() == 0)
2330 base = "file_name.fa";
2333 boolean reverse = suffixReverse.isSelected();
2334 boolean keepAll = backupfilesKeepAll.isSelected();
2336 String suffix = suffixTemplate.getText();
2339 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2340 if (suffix == null || suffix.length() == 0)
2342 backupfilesExampleLabel
2343 .setText(MessageManager.getString("label.no_backup_files"));
2344 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2348 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2349 rollMax = rollMax < 1 ? 1 : rollMax;
2351 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2356 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2357 digits = digits < 1 ? 1 : digits;
2359 int lowersurround = 2;
2360 int uppersurround = 0;
2361 StringBuilder exampleSB = new StringBuilder();
2362 boolean firstLine = true;
2368 int max = keepAll ? exampleindex : rollMax;
2369 for (int index = min; index <= max; index++)
2371 if (index == min + lowersurround && index < max - uppersurround - 1)
2373 exampleSB.append("\n...");
2376 else if (index > min + lowersurround && index < max - uppersurround)
2388 exampleSB.append("\n");
2391 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2392 base, suffix, digits));
2395 // no extra text needed
2397 else if (index == min)
2399 String newest = MessageManager.getString("label.braced_newest");
2400 if (newest != null && newest.length() > 0)
2402 exampleSB.append(" " + newest);
2405 else if (index == max)
2407 String oldest = MessageManager.getString("label.braced_oldest");
2408 if (oldest != null && oldest.length() > 0)
2410 exampleSB.append(" " + oldest);
2419 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2420 : exampleindex - rollMax + 1;
2421 int max = exampleindex;
2423 for (int index = min; index <= max; index++)
2426 if (index == min + lowersurround && index < max - uppersurround - 1)
2428 exampleSB.append("\n...");
2431 else if (index > min + lowersurround && index < max - uppersurround)
2443 exampleSB.append("\n");
2446 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2447 base, suffix, digits));
2450 // no extra text needed
2452 else if (index == min)
2454 String oldest = MessageManager.getString("label.braced_oldest");
2455 if (oldest != null && oldest.length() > 0)
2457 exampleSB.append(" " + oldest);
2460 else if (index == max)
2462 String newest = MessageManager.getString("label.braced_newest");
2463 if (newest != null && newest.length() > 0)
2465 exampleSB.append(" " + newest);
2473 // add some extra empty lines to pad out the example files box. ugh, please tell
2474 // me how to do this better
2475 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2476 if (remainingLines > 0)
2478 for (int i = 0; i < remainingLines; i++)
2480 exampleSB.append("\n ");
2485 backupfilesExampleLabel.setText(exampleSB.toString());
2488 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2489 boolean useExistingVal, ChangeListener c)
2496 i = ((Integer) s.getValue()).intValue();
2497 } catch (Exception e)
2500 "Exception casting the initial value of s.getValue()");
2504 setIntegerSpinner(s, min, max, i, c);
2507 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2510 // integer spinner for number of digits
2515 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2518 s.addChangeListener(c);
2522 protected static int getSpinnerInt(JSpinner s, int def)
2528 i = (Integer) s.getValue();
2529 } catch (Exception e)
2531 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2536 private void keepRollMaxOptionsEnabled()
2538 boolean enabled = backupfilesKeepAll.isEnabled()
2539 && !backupfilesKeepAll.isSelected();
2540 oldBackupFilesLabel.setEnabled(enabled);
2541 backupfilesRollMaxSpinner.setEnabled(enabled);
2542 backupfilesConfirmDelete.setEnabled(enabled);
2545 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2547 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2548 && customiseCheckbox.isSelected()
2549 && suffixTemplate.getText()
2550 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2551 keepfilesPanel.setEnabled(enabled);
2552 backupfilesKeepAll.setEnabled(enabled);
2553 oldBackupFilesLabel.setEnabled(enabled);
2554 keepRollMaxOptionsEnabled();
2557 private void backupfilesSuffixTemplateDigitsSetEnabled()
2559 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2560 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2561 suffixDigitsLabel.setEnabled(enabled);
2562 suffixDigitsSpinner.setEnabled(enabled);
2563 suffixReverse.setEnabled(enabled);
2566 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2568 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2569 && customiseCheckbox.isSelected();
2570 suffixPanel.setEnabled(enabled);
2571 suffixTemplateLabel.setEnabled(enabled);
2572 suffixTemplate.setEnabled(enabled);
2573 backupfilesSuffixTemplateDigitsSetEnabled();
2576 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2578 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2579 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2580 revertButton.setEnabled(enabled);
2583 private boolean backupfilesCustomChanged()
2585 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2586 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2587 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2588 return !custom.equals(current);
2591 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2593 String suffix = suffixTemplate.getText();
2594 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2595 boolean reverse = suffixReverse.isSelected();
2596 boolean keepAll = backupfilesKeepAll.isSelected();
2597 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2598 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2600 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2601 reverse, keepAll, rollMax, confirmDelete);
2606 protected void backupfilesCustomOptionsSetEnabled()
2608 boolean enabled = customiseCheckbox.isSelected();
2610 backupfilesRevertButtonSetEnabled(enabled);
2611 backupfilesSuffixTemplateSetEnabled(enabled);
2612 backupfilesKeepAllSetEnabled(enabled);
2615 private void backupfilesSummarySetEnabled()
2617 boolean enabled = enableBackupFiles.isSelected();
2618 backupfilesExampleLabel.setEnabled(enabled);
2619 exampleFilesPanel.setEnabled(enabled);
2622 private void backupfilesPresetsSetEnabled()
2624 boolean enabled = enableBackupFiles.isSelected();
2625 presetsPanel.setEnabled(enabled);
2626 presetsComboLabel.setEnabled(enabled);
2627 backupfilesPresetsCombo.setEnabled(enabled);
2628 customiseCheckbox.setEnabled(enabled);
2629 revertButton.setEnabled(enabled);
2632 protected void backupsOptionsSetEnabled()
2634 backupfilesPresetsSetEnabled();
2635 backupfilesSummarySetEnabled();
2636 backupfilesCustomOptionsSetEnabled();
2639 protected void backupsSetOptions(String suffix, int digits,
2640 boolean reverse, boolean keepAll, int rollMax,
2641 boolean confirmDelete)
2643 suffixTemplate.setText(suffix);
2644 suffixDigitsSpinner.setValue(digits);
2645 suffixReverse.setSelected(reverse);
2646 backupfilesKeepAll.setSelected(keepAll);
2647 backupfilesRollMaxSpinner.setValue(rollMax);
2648 backupfilesConfirmDelete.setSelected(confirmDelete);
2651 protected void backupsSetOptions(BackupFilesPresetEntry p)
2653 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2657 protected void autoIdWidth_actionPerformed()
2659 // TODO Auto-generated method stub
2663 protected void userIdWidth_actionPerformed()
2665 // TODO Auto-generated method stub
2669 protected void maxColour_actionPerformed(JPanel panel)
2673 protected void minColour_actionPerformed(JPanel panel)
2677 protected void gapColour_actionPerformed(JPanel panel)
2681 protected void hiddenColour_actionPerformed(JPanel panel)
2685 protected void showunconserved_actionPerformed(ActionEvent e)
2687 // TODO Auto-generated method stub
2691 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2695 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2705 public void ok_actionPerformed(ActionEvent e)
2715 public void cancel_actionPerformed(ActionEvent e)
2725 public void annotations_actionPerformed(ActionEvent e)
2732 public void startupFileTextfield_mouseClicked()
2736 public void newLink_actionPerformed(ActionEvent e)
2741 public void editLink_actionPerformed(ActionEvent e)
2746 public void deleteLink_actionPerformed(ActionEvent e)
2751 public void defaultBrowser_mouseClicked(MouseEvent e)
2756 public void linkURLList_keyTyped(KeyEvent e)
2761 public void useProxy_actionPerformed()
2763 boolean enabled = useProxy.isSelected();
2764 portLabel.setEnabled(enabled);
2765 serverLabel.setEnabled(enabled);
2766 proxyServerTB.setEnabled(enabled);
2767 proxyPortTB.setEnabled(enabled);
2771 * Customer renderer for JTable: supports column of radio buttons
2773 public class RadioButtonRenderer extends JRadioButton
2774 implements TableCellRenderer
2776 public RadioButtonRenderer()
2778 setHorizontalAlignment(CENTER);
2779 setToolTipText(MessageManager.getString("label.urltooltip"));
2783 public Component getTableCellRendererComponent(JTable table,
2784 Object value, boolean isSelected, boolean hasFocus, int row,
2787 setSelected((boolean) value);
2789 // set colours to match rest of table
2792 setBackground(table.getSelectionBackground());
2793 setForeground(table.getSelectionForeground());
2797 setBackground(table.getBackground());
2798 setForeground(table.getForeground());
2805 * Customer cell editor for JTable: supports column of radio buttons in
2806 * conjunction with renderer
2808 public class RadioButtonEditor extends AbstractCellEditor
2809 implements TableCellEditor
2811 private JRadioButton button = new JRadioButton();
2813 public RadioButtonEditor()
2815 button.setHorizontalAlignment(SwingConstants.CENTER);
2816 this.button.addActionListener(new ActionListener()
2819 public void actionPerformed(ActionEvent e)
2821 fireEditingStopped();
2827 public Component getTableCellEditorComponent(JTable table, Object value,
2828 boolean isSelected, int row, int column)
2830 button.setSelected((boolean) value);
2835 public Object getCellEditorValue()
2837 return button.isSelected();