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.fts.core.FTSDataColumnPreferences;
24 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
25 import jalview.fts.service.pdb.PDBFTSRestClient;
26 import jalview.gui.JalviewBooleanRadioButtons;
27 import jalview.gui.JvSwingUtils;
28 import jalview.gui.StructureViewer.ViewerType;
29 import jalview.io.BackupFilenameFilter;
30 import jalview.util.MessageManager;
32 import java.awt.BorderLayout;
33 import java.awt.Color;
34 import java.awt.Component;
35 import java.awt.Dimension;
36 import java.awt.FlowLayout;
38 import java.awt.FontMetrics;
39 import java.awt.GridBagConstraints;
40 import java.awt.GridBagLayout;
41 import java.awt.GridLayout;
42 import java.awt.Insets;
43 import java.awt.Rectangle;
44 import java.awt.event.ActionEvent;
45 import java.awt.event.ActionListener;
46 import java.awt.event.FocusEvent;
47 import java.awt.event.KeyEvent;
48 import java.awt.event.KeyListener;
49 import java.awt.event.MouseAdapter;
50 import java.awt.event.MouseEvent;
52 import javax.swing.AbstractCellEditor;
53 import javax.swing.BorderFactory;
54 import javax.swing.ButtonGroup;
55 import javax.swing.DefaultListCellRenderer;
56 import javax.swing.JButton;
57 import javax.swing.JCheckBox;
58 import javax.swing.JComboBox;
59 import javax.swing.JFileChooser;
60 import javax.swing.JLabel;
61 import javax.swing.JPanel;
62 import javax.swing.JRadioButton;
63 import javax.swing.JScrollPane;
64 import javax.swing.JSpinner;
65 import javax.swing.JTabbedPane;
66 import javax.swing.JTable;
67 import javax.swing.JTextArea;
68 import javax.swing.JTextField;
69 import javax.swing.ListSelectionModel;
70 import javax.swing.SpinnerModel;
71 import javax.swing.SpinnerNumberModel;
72 import javax.swing.SwingConstants;
73 import javax.swing.border.Border;
74 import javax.swing.border.EmptyBorder;
75 import javax.swing.border.EtchedBorder;
76 import javax.swing.border.TitledBorder;
77 import javax.swing.event.ChangeEvent;
78 import javax.swing.event.ChangeListener;
79 import javax.swing.table.TableCellEditor;
80 import javax.swing.table.TableCellRenderer;
83 * Base class for the Preferences panel.
88 public class GPreferences extends JPanel
90 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
92 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
93 .getLabelFont(false, true);
95 private static final Font LABEL_FONT_BOLD = JvSwingUtils
96 .getLabelFont(true, false);
99 * Visual tab components
101 protected JCheckBox fullScreen = new JCheckBox();
103 protected JCheckBox openoverv = new JCheckBox();
105 protected JCheckBox seqLimit = new JCheckBox();
107 protected JCheckBox rightAlign = new JCheckBox();
109 protected JComboBox<String> fontSizeCB = new JComboBox<>();
111 protected JComboBox<String> fontStyleCB = new JComboBox<>();
113 protected JComboBox<String> fontNameCB = new JComboBox<>();
115 protected JCheckBox showOccupancy = new JCheckBox();
117 protected JCheckBox showUnconserved = new JCheckBox();
119 protected JCheckBox idItalics = new JCheckBox();
121 protected JCheckBox smoothFont = new JCheckBox();
123 protected JCheckBox scaleProteinToCdna = new JCheckBox();
125 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
127 protected JCheckBox wrap = new JCheckBox();
129 protected JComboBox<String> sortby = new JComboBox<>();
131 protected JComboBox<String> sortAnnBy = new JComboBox<>();
133 protected JComboBox<String> sortAutocalc = new JComboBox<>();
135 protected JCheckBox startupCheckbox = new JCheckBox();
137 protected JTextField startupFileTextfield = new JTextField();
139 // below are in the 'second column'
140 protected JCheckBox annotations = new JCheckBox();
142 protected JCheckBox quality = new JCheckBox();
144 protected JCheckBox conservation = new JCheckBox();
146 protected JCheckBox identity = new JCheckBox();
148 protected JCheckBox showGroupConsensus = new JCheckBox();
150 protected JCheckBox showGroupConservation = new JCheckBox();
152 protected JCheckBox showConsensHistogram = new JCheckBox();
154 protected JCheckBox showConsensLogo = new JCheckBox();
156 protected JCheckBox showDbRefTooltip = new JCheckBox();
158 protected JCheckBox showNpTooltip = new JCheckBox();
161 * Structure tab and components
163 protected JPanel structureTab;
165 protected JCheckBox structFromPdb = new JCheckBox();
167 protected JCheckBox useRnaView = new JCheckBox();
169 protected JCheckBox addSecondaryStructure = new JCheckBox();
171 protected JCheckBox addTempFactor = new JCheckBox();
173 protected JComboBox<String> structViewer = new JComboBox<>();
175 protected JTextField chimeraPath = new JTextField();
177 protected ButtonGroup mappingMethod = new ButtonGroup();
179 protected JRadioButton siftsMapping = new JRadioButton();
181 protected JRadioButton nwMapping = new JRadioButton();
184 * Colours tab components
186 protected JPanel minColour = new JPanel();
188 protected JPanel maxColour = new JPanel();
190 protected JComboBox<String> protColour = new JComboBox<>();
192 protected JComboBox<String> nucColour = new JComboBox<>();
195 * Overview tab components
197 protected JPanel gapColour = new JPanel();
199 protected JPanel hiddenColour = new JPanel();
201 protected JCheckBox useLegacyGap;
203 protected JCheckBox showHiddenAtStart;
205 protected JLabel gapLabel;
208 * Connections tab components
210 protected JTable linkUrlTable = new JTable();
212 protected JButton editLink = new JButton();
214 protected JButton deleteLink = new JButton();
216 protected JTextField filterTB = new JTextField();
218 protected JButton doReset = new JButton();
220 protected JButton userOnly = new JButton();
222 protected JLabel portLabel = new JLabel();
224 protected JLabel serverLabel = new JLabel();
226 protected JTextField proxyServerTB = new JTextField();
228 protected JTextField proxyPortTB = new JTextField();
230 protected JTextField defaultBrowser = new JTextField();
232 protected JCheckBox useProxy = new JCheckBox();
234 protected JCheckBox usagestats = new JCheckBox();
236 protected JCheckBox questionnaire = new JCheckBox();
238 protected JCheckBox versioncheck = new JCheckBox();
241 * Output tab components
243 protected JComboBox<Object> epsRendering = new JComboBox<>();
245 protected JLabel userIdWidthlabel = new JLabel();
247 protected JCheckBox autoIdWidth = new JCheckBox();
249 protected JTextField userIdWidth = new JTextField();
251 protected JCheckBox blcjv = new JCheckBox();
253 protected JCheckBox pileupjv = new JCheckBox();
255 protected JCheckBox clustaljv = new JCheckBox();
257 protected JCheckBox msfjv = new JCheckBox();
259 protected JCheckBox fastajv = new JCheckBox();
261 protected JCheckBox pfamjv = new JCheckBox();
263 protected JCheckBox pirjv = new JCheckBox();
265 protected JCheckBox modellerOutput = new JCheckBox();
267 protected JCheckBox embbedBioJSON = new JCheckBox();
270 * Editing tab components
272 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
274 protected JCheckBox padGaps = new JCheckBox();
276 protected JCheckBox sortByTree = new JCheckBox();
282 protected JPanel wsTab = new JPanel();
285 * Backups tab components
286 * a lot of these are member variables instead of local variables only so that they
287 * can be enabled/disabled easily in one go
290 protected JCheckBox enableBackupFiles = new JCheckBox();
292 protected JPanel suffixPanel = new JPanel();
294 protected JPanel keepfilesPanel = new JPanel();
296 protected JPanel exampleFilesPanel = new JPanel();
298 protected JTextField suffixTemplate = new JTextField(null, 8);
300 protected JLabel suffixTemplateLabel = new JLabel();
302 protected JLabel suffixDigitsLabel = new JLabel();
304 protected JSpinner suffixDigitsSpinner = new JSpinner();
306 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
308 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
310 protected JSpinner backupfilesRollMaxSpinner = new JSpinner();
312 protected JLabel oldBackupFilesLabel = new JLabel();
314 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
316 protected JTextArea backupfilesExampleLabel = new JTextArea();
319 * Creates a new GPreferences object.
321 public GPreferences()
326 } catch (Exception ex)
328 ex.printStackTrace();
333 * Construct the panel and its tabbed sub-panels.
337 private void jbInit() throws Exception
339 final JTabbedPane tabbedPane = new JTabbedPane();
340 this.setLayout(new BorderLayout());
341 JPanel okCancelPanel = initOkCancelPanel();
342 this.add(tabbedPane, BorderLayout.CENTER);
343 this.add(okCancelPanel, BorderLayout.SOUTH);
345 tabbedPane.add(initVisualTab(),
346 MessageManager.getString("label.visual"));
348 tabbedPane.add(initColoursTab(),
349 MessageManager.getString("label.colours"));
351 tabbedPane.add(initOverviewTab(),
352 MessageManager.getString("label.overview"));
354 tabbedPane.add(initStructureTab(),
355 MessageManager.getString("label.structure"));
357 tabbedPane.add(initConnectionsTab(),
358 MessageManager.getString("label.connections"));
360 tabbedPane.add(initBackupsTab(),
361 MessageManager.getString("label.backups"));
363 tabbedPane.add(initLinksTab(),
364 MessageManager.getString("label.urllinks"));
366 tabbedPane.add(initOutputTab(),
367 MessageManager.getString("label.output"));
369 tabbedPane.add(initEditingTab(),
370 MessageManager.getString("label.editing"));
373 * See WsPreferences for the real work of configuring this tab.
375 wsTab.setLayout(new BorderLayout());
376 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
379 * Handler to validate a tab before leaving it - currently only for
382 tabbedPane.addChangeListener(new ChangeListener()
384 private Component lastTab;
387 public void stateChanged(ChangeEvent e)
389 if (lastTab == structureTab
390 && tabbedPane.getSelectedComponent() != structureTab)
392 if (!validateStructure())
394 tabbedPane.setSelectedComponent(structureTab);
398 lastTab = tabbedPane.getSelectedComponent();
405 * Initialises the Editing tabbed panel.
409 private JPanel initEditingTab()
411 JPanel editingTab = new JPanel();
412 editingTab.setLayout(null);
413 autoCalculateConsCheck.setFont(LABEL_FONT);
414 autoCalculateConsCheck.setText(
415 MessageManager.getString("label.autocalculate_consensus"));
416 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
417 padGaps.setFont(LABEL_FONT);
419 MessageManager.getString("label.pad_gaps_when_editing"));
420 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
421 sortByTree.setFont(LABEL_FONT);
423 .setText(MessageManager.getString("label.sort_with_new_tree"));
424 sortByTree.setToolTipText(MessageManager.getString(
425 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
426 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
427 editingTab.add(autoCalculateConsCheck);
428 editingTab.add(padGaps);
429 editingTab.add(sortByTree);
434 * Initialises the Output tabbed panel.
438 private JPanel initOutputTab()
440 JPanel outputTab = new JPanel();
441 outputTab.setLayout(null);
442 JLabel epsLabel = new JLabel();
443 epsLabel.setFont(LABEL_FONT);
444 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
445 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
446 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
447 epsRendering.setFont(LABEL_FONT);
448 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
449 JLabel jLabel1 = new JLabel();
450 jLabel1.setFont(LABEL_FONT);
451 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
452 jLabel1.setText(MessageManager.getString("label.append_start_end"));
453 jLabel1.setFont(LABEL_FONT);
454 fastajv.setFont(LABEL_FONT);
455 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
456 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
457 blcjv.setText(MessageManager.getString("label.blc") + " ");
458 fastajv.setText(MessageManager.getString("label.fasta") + " ");
459 msfjv.setText(MessageManager.getString("label.msf") + " ");
460 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
461 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
462 msfjv.setFont(LABEL_FONT);
463 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
464 pirjv.setText(MessageManager.getString("label.pir") + " ");
465 JPanel jPanel11 = new JPanel();
466 jPanel11.setFont(LABEL_FONT);
467 TitledBorder titledBorder2 = new TitledBorder(
468 MessageManager.getString("label.file_output"));
469 jPanel11.setBorder(titledBorder2);
470 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
471 GridLayout gridLayout3 = new GridLayout();
472 jPanel11.setLayout(gridLayout3);
473 gridLayout3.setRows(8);
474 blcjv.setFont(LABEL_FONT);
475 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
476 clustaljv.setFont(LABEL_FONT);
477 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
478 pfamjv.setFont(LABEL_FONT);
479 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
480 pileupjv.setFont(LABEL_FONT);
481 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
482 pirjv.setFont(LABEL_FONT);
483 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
484 autoIdWidth.setFont(LABEL_FONT);
486 MessageManager.getString("label.automatically_set_id_width"));
487 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
488 .getString("label.adjusts_width_generated_eps_png")));
489 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
490 autoIdWidth.addActionListener(new ActionListener()
494 public void actionPerformed(ActionEvent e)
496 autoIdWidth_actionPerformed();
499 userIdWidthlabel.setFont(LABEL_FONT);
500 userIdWidthlabel.setText(
501 MessageManager.getString("label.figure_id_column_width"));
502 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
503 .getString("label.manually_specify_width_left_column")));
504 userIdWidthlabel.setToolTipText(
505 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
506 "label.manually_specify_width_left_column")));
507 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
508 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
509 userIdWidth.setText("");
510 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
511 userIdWidth.addActionListener(new ActionListener()
515 public void actionPerformed(ActionEvent e)
517 userIdWidth_actionPerformed();
520 modellerOutput.setFont(LABEL_FONT);
522 .setText(MessageManager.getString("label.use_modeller_output"));
523 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
524 embbedBioJSON.setFont(LABEL_FONT);
525 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
526 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
529 TitledBorder backupFilesBorder = new TitledBorder(
531 .getString("label.backup_files"));
534 jPanel11.add(jLabel1);
536 jPanel11.add(clustaljv);
537 jPanel11.add(fastajv);
539 jPanel11.add(pfamjv);
540 jPanel11.add(pileupjv);
542 outputTab.add(autoIdWidth);
543 outputTab.add(userIdWidth);
544 outputTab.add(userIdWidthlabel);
545 outputTab.add(modellerOutput);
546 outputTab.add(embbedBioJSON);
547 outputTab.add(epsLabel);
548 outputTab.add(epsRendering);
549 outputTab.add(jPanel11);
554 * Initialises the Connections tabbed panel.
558 private JPanel initConnectionsTab()
560 JPanel connectTab = new JPanel();
561 connectTab.setLayout(new GridBagLayout());
563 // Label for browser text box
564 JLabel browserLabel = new JLabel();
565 browserLabel.setFont(LABEL_FONT);
566 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
567 browserLabel.setText(
568 MessageManager.getString("label.default_browser_unix"));
569 defaultBrowser.setFont(LABEL_FONT);
570 defaultBrowser.setText("");
571 final String tooltip = JvSwingUtils.wrapTooltip(true,
572 MessageManager.getString("label.double_click_to_browse"));
573 defaultBrowser.setToolTipText(tooltip);
574 defaultBrowser.addMouseListener(new MouseAdapter()
577 public void mouseClicked(MouseEvent e)
579 if (e.getClickCount() > 1)
581 defaultBrowser_mouseClicked(e);
586 JPanel proxyPanel = initConnTabProxyPanel();
587 initConnTabCheckboxes();
589 // Add default Browser text box
590 connectTab.add(browserLabel,
591 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
592 GridBagConstraints.WEST, GridBagConstraints.NONE,
593 new Insets(10, 0, 5, 5), 5, 1));
594 defaultBrowser.setFont(LABEL_FONT);
595 defaultBrowser.setText("");
597 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
598 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
599 new Insets(10, 0, 5, 10), 30, 1));
601 // Add proxy server panel
602 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
603 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
604 new Insets(10, 0, 5, 12), 4, 10));
606 // Add usage stats, version check and questionnaire checkboxes
607 connectTab.add(usagestats,
608 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
609 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
610 new Insets(0, 2, 5, 5), 70, 1));
611 connectTab.add(questionnaire,
612 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
613 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
614 new Insets(0, 2, 5, 10), 70, 1));
615 connectTab.add(versioncheck,
616 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
617 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
618 new Insets(0, 2, 5, 5), 70, 1));
620 // Add padding so the panel doesn't look ridiculous
621 JPanel spacePanel = new JPanel();
622 connectTab.add(spacePanel,
623 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
624 GridBagConstraints.WEST, GridBagConstraints.BOTH,
625 new Insets(0, 0, 0, 5), 70, 1));
631 * Initialises the Links tabbed panel.
635 private JPanel initLinksTab()
637 JPanel linkTab = new JPanel();
638 linkTab.setLayout(new GridBagLayout());
640 // Set up table for Url links
641 linkUrlTable.setFillsViewportHeight(true);
642 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
643 linkUrlTable.setAutoCreateRowSorter(true);
644 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
646 // adjust row height so radio buttons actually fit
647 // don't do this in the renderer, it causes the awt thread to activate
649 JRadioButton temp = new JRadioButton();
650 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
652 // Table in scrollpane so that the table is given a scrollbar
653 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
654 linkScrollPane.setBorder(null);
656 // Panel for links functionality
657 JPanel linkPanel = new JPanel(new GridBagLayout());
658 linkPanel.setBorder(new TitledBorder(
659 MessageManager.getString("label.url_linkfrom_sequence_id")));
661 // Put the Url links panel together
663 // Buttons go at top right, resizing only resizes the blank space vertically
664 JPanel buttonPanel = initLinkTabUrlButtons();
665 GridBagConstraints linkConstraints1 = new GridBagConstraints();
666 linkConstraints1.insets = new Insets(0, 0, 5, 0);
667 linkConstraints1.gridx = 0;
668 linkConstraints1.gridy = 0;
669 linkConstraints1.weightx = 1.0;
670 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
671 linkTab.add(buttonPanel, linkConstraints1);
673 // Links table goes at top left, resizing resizes the table
674 GridBagConstraints linkConstraints2 = new GridBagConstraints();
675 linkConstraints2.insets = new Insets(0, 0, 5, 5);
676 linkConstraints2.gridx = 0;
677 linkConstraints2.gridy = 1;
678 linkConstraints2.weightx = 1.0;
679 linkConstraints2.weighty = 1.0;
680 linkConstraints2.fill = GridBagConstraints.BOTH;
681 linkTab.add(linkScrollPane, linkConstraints2);
683 // Filter box and buttons goes at bottom left, resizing resizes the text box
684 JPanel filterPanel = initLinkTabFilterPanel();
685 GridBagConstraints linkConstraints3 = new GridBagConstraints();
686 linkConstraints3.insets = new Insets(0, 0, 0, 5);
687 linkConstraints3.gridx = 0;
688 linkConstraints3.gridy = 2;
689 linkConstraints3.weightx = 1.0;
690 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
691 linkTab.add(filterPanel, linkConstraints3);
696 private JPanel initLinkTabFilterPanel()
698 // Filter textbox and reset button
699 JLabel filterLabel = new JLabel(
700 MessageManager.getString("label.filter"));
701 filterLabel.setFont(LABEL_FONT);
702 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
703 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
705 filterTB.setFont(LABEL_FONT);
706 filterTB.setText("");
708 doReset.setText(MessageManager.getString("action.showall"));
709 userOnly.setText(MessageManager.getString("action.customfilter"));
711 // Panel for filter functionality
712 JPanel filterPanel = new JPanel(new GridBagLayout());
713 filterPanel.setBorder(new TitledBorder("Filter"));
714 GridBagConstraints gbc = new GridBagConstraints();
717 gbc.fill = GridBagConstraints.NONE;
718 gbc.anchor = GridBagConstraints.WEST;
720 filterPanel.add(filterLabel, gbc);
722 GridBagConstraints gbc1 = new GridBagConstraints();
725 gbc1.fill = GridBagConstraints.HORIZONTAL;
726 gbc1.anchor = GridBagConstraints.WEST;
728 filterPanel.add(filterTB, gbc1);
730 GridBagConstraints gbc2 = new GridBagConstraints();
732 gbc2.fill = GridBagConstraints.NONE;
733 gbc2.anchor = GridBagConstraints.WEST;
734 filterPanel.add(doReset, gbc2);
736 GridBagConstraints gbc3 = new GridBagConstraints();
738 gbc3.fill = GridBagConstraints.NONE;
739 gbc3.anchor = GridBagConstraints.WEST;
740 filterPanel.add(userOnly, gbc3);
745 private JPanel initLinkTabUrlButtons()
747 // Buttons for new / edit / delete Url links
748 JButton newLink = new JButton();
749 newLink.setText(MessageManager.getString("action.new"));
751 editLink.setText(MessageManager.getString("action.edit"));
753 deleteLink.setText(MessageManager.getString("action.delete"));
755 // no current selection, so initially disable delete/edit buttons
756 editLink.setEnabled(false);
757 deleteLink.setEnabled(false);
759 newLink.addActionListener(new java.awt.event.ActionListener()
762 public void actionPerformed(ActionEvent e)
764 newLink_actionPerformed(e);
768 editLink.setText(MessageManager.getString("action.edit"));
769 editLink.addActionListener(new java.awt.event.ActionListener()
772 public void actionPerformed(ActionEvent e)
774 editLink_actionPerformed(e);
778 deleteLink.setText(MessageManager.getString("action.delete"));
779 deleteLink.addActionListener(new java.awt.event.ActionListener()
782 public void actionPerformed(ActionEvent e)
784 deleteLink_actionPerformed(e);
788 JPanel buttonPanel = new JPanel(new GridBagLayout());
789 buttonPanel.setBorder(new TitledBorder("Edit links"));
790 GridBagConstraints gbc = new GridBagConstraints();
793 gbc.fill = GridBagConstraints.NONE;
794 buttonPanel.add(newLink, gbc);
796 GridBagConstraints gbc1 = new GridBagConstraints();
799 gbc1.fill = GridBagConstraints.NONE;
800 buttonPanel.add(editLink, gbc1);
802 GridBagConstraints gbc2 = new GridBagConstraints();
805 gbc2.fill = GridBagConstraints.NONE;
806 buttonPanel.add(deleteLink, gbc2);
808 GridBagConstraints gbc3 = new GridBagConstraints();
811 gbc3.fill = GridBagConstraints.HORIZONTAL;
813 JPanel spacePanel = new JPanel();
814 spacePanel.setBorder(null);
815 buttonPanel.add(spacePanel, gbc3);
821 * Initialises the proxy server panel in the Connections tab
823 * @return the proxy server panel
825 private JPanel initConnTabProxyPanel()
827 // Label for server text box
828 serverLabel.setText(MessageManager.getString("label.address"));
829 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
830 serverLabel.setFont(LABEL_FONT);
832 // Proxy server and port text boxes
833 proxyServerTB.setFont(LABEL_FONT);
834 proxyPortTB.setFont(LABEL_FONT);
836 // Label for Port text box
837 portLabel.setFont(LABEL_FONT);
838 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
839 portLabel.setText(MessageManager.getString("label.port"));
841 // Use proxy server checkbox
842 useProxy.setFont(LABEL_FONT);
843 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
844 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
845 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
846 useProxy.addActionListener(new ActionListener()
849 public void actionPerformed(ActionEvent e)
851 useProxy_actionPerformed();
855 // Make proxy server panel
856 JPanel proxyPanel = new JPanel();
857 TitledBorder titledBorder1 = new TitledBorder(
858 MessageManager.getString("label.proxy_server"));
859 proxyPanel.setBorder(titledBorder1);
860 proxyPanel.setLayout(new GridBagLayout());
861 proxyPanel.add(serverLabel,
862 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
863 GridBagConstraints.WEST, GridBagConstraints.NONE,
864 new Insets(0, 2, 2, 0), 5, 0));
865 proxyPanel.add(portLabel,
866 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
867 GridBagConstraints.WEST, GridBagConstraints.NONE,
868 new Insets(0, 0, 2, 0), 11, 0));
869 proxyPanel.add(useProxy,
870 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
871 GridBagConstraints.WEST, GridBagConstraints.NONE,
872 new Insets(0, 2, 5, 185), 2, -4));
873 proxyPanel.add(proxyPortTB,
874 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
875 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
876 new Insets(0, 2, 2, 2), 54, 1));
877 proxyPanel.add(proxyServerTB,
878 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
879 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
880 new Insets(0, 2, 2, 0), 263, 1));
886 * Initialises the checkboxes in the Connections tab
888 private void initConnTabCheckboxes()
890 // Usage stats checkbox label
892 MessageManager.getString("label.send_usage_statistics"));
893 usagestats.setFont(LABEL_FONT);
894 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
895 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
897 // Questionnaire checkbox label
898 questionnaire.setText(
899 MessageManager.getString("label.check_for_questionnaires"));
900 questionnaire.setFont(LABEL_FONT);
901 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
902 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
904 // Check for latest version checkbox label
905 versioncheck.setText(
906 MessageManager.getString("label.check_for_latest_version"));
907 versioncheck.setFont(LABEL_FONT);
908 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
909 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
913 * Initialises the parent panel which contains the tabbed sections.
917 private JPanel initOkCancelPanel()
919 JButton ok = new JButton();
920 ok.setText(MessageManager.getString("action.ok"));
921 ok.addActionListener(new ActionListener()
924 public void actionPerformed(ActionEvent e)
926 ok_actionPerformed(e);
929 JButton cancel = new JButton();
930 cancel.setText(MessageManager.getString("action.cancel"));
931 cancel.addActionListener(new ActionListener()
934 public void actionPerformed(ActionEvent e)
936 cancel_actionPerformed(e);
939 JPanel okCancelPanel = new JPanel();
940 okCancelPanel.add(ok);
941 okCancelPanel.add(cancel);
942 return okCancelPanel;
946 * Initialises the Colours tabbed panel.
950 private JPanel initColoursTab()
952 JPanel coloursTab = new JPanel();
953 coloursTab.setBorder(new TitledBorder(
954 MessageManager.getString("action.open_new_alignment")));
955 coloursTab.setLayout(new FlowLayout());
956 JLabel mincolourLabel = new JLabel();
957 mincolourLabel.setFont(LABEL_FONT);
958 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
959 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
960 minColour.setFont(LABEL_FONT);
961 minColour.setBorder(BorderFactory.createEtchedBorder());
962 minColour.setPreferredSize(new Dimension(40, 20));
963 minColour.addMouseListener(new MouseAdapter()
966 public void mousePressed(MouseEvent e)
968 minColour_actionPerformed(minColour);
971 JLabel maxcolourLabel = new JLabel();
972 maxcolourLabel.setFont(LABEL_FONT);
973 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
974 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
975 maxColour.setFont(LABEL_FONT);
976 maxColour.setBorder(BorderFactory.createEtchedBorder());
977 maxColour.setPreferredSize(new Dimension(40, 20));
978 maxColour.addMouseListener(new MouseAdapter()
981 public void mousePressed(MouseEvent e)
983 maxColour_actionPerformed(maxColour);
987 protColour.setFont(LABEL_FONT);
988 protColour.setBounds(new Rectangle(172, 225, 155, 21));
989 JLabel protColourLabel = new JLabel();
990 protColourLabel.setFont(LABEL_FONT);
991 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
992 protColourLabel.setText(
993 MessageManager.getString("label.prot_alignment_colour") + " ");
994 JvSwingUtils.addtoLayout(coloursTab,
996 .getString("label.default_colour_scheme_for_alignment"),
997 protColourLabel, protColour);
999 nucColour.setFont(LABEL_FONT);
1000 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1001 JLabel nucColourLabel = new JLabel();
1002 nucColourLabel.setFont(LABEL_FONT);
1003 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1004 nucColourLabel.setText(
1005 MessageManager.getString("label.nuc_alignment_colour") + " ");
1006 JvSwingUtils.addtoLayout(coloursTab,
1008 .getString("label.default_colour_scheme_for_alignment"),
1009 nucColourLabel, nucColour);
1011 JPanel annotationShding = new JPanel();
1012 annotationShding.setBorder(new TitledBorder(
1013 MessageManager.getString("label.annotation_shading_default")));
1014 annotationShding.setLayout(new GridLayout(1, 2));
1015 JvSwingUtils.addtoLayout(annotationShding,
1016 MessageManager.getString(
1017 "label.default_minimum_colour_annotation_shading"),
1018 mincolourLabel, minColour);
1019 JvSwingUtils.addtoLayout(annotationShding,
1020 MessageManager.getString(
1021 "label.default_maximum_colour_annotation_shading"),
1022 maxcolourLabel, maxColour);
1023 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1028 * Initialises the Overview tabbed panel.
1032 private JPanel initOverviewTab()
1034 JPanel overviewPanel = new JPanel();
1035 overviewPanel.setBorder(new TitledBorder(
1036 MessageManager.getString("label.overview_settings")));
1038 gapColour.setFont(LABEL_FONT);
1039 // fixing the border colours stops apparent colour bleed from the panel
1040 gapColour.setBorder(
1041 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1042 gapColour.setPreferredSize(new Dimension(40, 20));
1043 gapColour.addMouseListener(new MouseAdapter()
1046 public void mousePressed(MouseEvent e)
1048 gapColour_actionPerformed(gapColour);
1052 hiddenColour.setFont(LABEL_FONT);
1053 // fixing the border colours stops apparent colour bleed from the panel
1054 hiddenColour.setBorder(
1055 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1056 hiddenColour.setPreferredSize(new Dimension(40, 20));
1057 hiddenColour.addMouseListener(new MouseAdapter()
1060 public void mousePressed(MouseEvent e)
1062 hiddenColour_actionPerformed(hiddenColour);
1066 useLegacyGap = new JCheckBox(
1067 MessageManager.getString("label.ov_legacy_gap"));
1068 useLegacyGap.setFont(LABEL_FONT);
1069 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1070 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1071 gapLabel = new JLabel(
1072 MessageManager.getString("label.gap_colour"));
1073 gapLabel.setFont(LABEL_FONT);
1074 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1075 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1076 showHiddenAtStart = new JCheckBox(
1077 MessageManager.getString("label.ov_show_hide_default"));
1078 showHiddenAtStart.setFont(LABEL_FONT);
1079 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1080 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1081 JLabel hiddenLabel = new JLabel(
1082 MessageManager.getString("label.hidden_colour"));
1083 hiddenLabel.setFont(LABEL_FONT);
1084 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1085 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1087 useLegacyGap.addActionListener(new ActionListener()
1090 public void actionPerformed(ActionEvent e)
1092 useLegacyGaps_actionPerformed(e);
1096 overviewPanel.setLayout(new GridBagLayout());
1097 GridBagConstraints c1 = new GridBagConstraints();
1099 c1.fill = GridBagConstraints.HORIZONTAL;
1104 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1105 overviewPanel.add(useLegacyGap, c1);
1107 GridBagConstraints c2 = new GridBagConstraints();
1108 c2.fill = GridBagConstraints.HORIZONTAL;
1111 c2.insets = new Insets(0, 15, 0, 10);
1112 overviewPanel.add(gapLabel, c2);
1114 GridBagConstraints c3 = new GridBagConstraints();
1115 c3.fill = GridBagConstraints.HORIZONTAL;
1118 c3.insets = new Insets(0, 0, 0, 15);
1119 overviewPanel.add(gapColour, c3);
1121 GridBagConstraints c4 = new GridBagConstraints();
1122 c4.fill = GridBagConstraints.HORIZONTAL;
1126 overviewPanel.add(showHiddenAtStart, c4);
1128 GridBagConstraints c5 = new GridBagConstraints();
1129 c5.fill = GridBagConstraints.HORIZONTAL;
1132 c5.insets = new Insets(0, 15, 0, 10);
1133 overviewPanel.add(hiddenLabel, c5);
1135 GridBagConstraints c6 = new GridBagConstraints();
1136 c6.fill = GridBagConstraints.HORIZONTAL;
1139 c6.insets = new Insets(0, 0, 0, 15);
1140 overviewPanel.add(hiddenColour, c6);
1142 JButton resetButton = new JButton(
1143 MessageManager.getString("label.reset_to_defaults"));
1145 resetButton.addActionListener(new ActionListener()
1148 public void actionPerformed(ActionEvent e)
1150 resetOvDefaults_actionPerformed(e);
1154 GridBagConstraints c7 = new GridBagConstraints();
1155 c7.fill = GridBagConstraints.NONE;
1158 c7.insets = new Insets(10, 0, 0, 0);
1159 c7.anchor = GridBagConstraints.WEST;
1160 overviewPanel.add(resetButton, c7);
1162 // Add padding so the panel doesn't look ridiculous
1163 JPanel spacePanel = new JPanel();
1164 overviewPanel.add(spacePanel,
1165 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1166 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1167 new Insets(0, 0, 0, 5), 0, 0));
1169 return overviewPanel;
1173 * Initialises the Structure tabbed panel.
1177 private JPanel initStructureTab()
1179 structureTab = new JPanel();
1181 structureTab.setBorder(new TitledBorder(
1182 MessageManager.getString("label.structure_options")));
1183 structureTab.setLayout(null);
1184 final int width = 400;
1185 final int height = 22;
1186 final int lineSpacing = 25;
1189 structFromPdb.setFont(LABEL_FONT);
1191 .setText(MessageManager.getString("label.struct_from_pdb"));
1192 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1193 structFromPdb.addActionListener(new ActionListener()
1196 public void actionPerformed(ActionEvent e)
1198 boolean selected = structFromPdb.isSelected();
1199 // enable other options only when the first is checked
1200 useRnaView.setEnabled(selected);
1201 addSecondaryStructure.setEnabled(selected);
1202 addTempFactor.setEnabled(selected);
1205 structureTab.add(structFromPdb);
1207 // indent checkboxes that are conditional on the first one
1208 ypos += lineSpacing;
1209 useRnaView.setFont(LABEL_FONT);
1210 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1211 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1212 structureTab.add(useRnaView);
1214 ypos += lineSpacing;
1215 addSecondaryStructure.setFont(LABEL_FONT);
1216 addSecondaryStructure
1217 .setText(MessageManager.getString("label.autoadd_secstr"));
1218 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1219 structureTab.add(addSecondaryStructure);
1221 ypos += lineSpacing;
1222 addTempFactor.setFont(LABEL_FONT);
1223 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1224 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1225 structureTab.add(addTempFactor);
1227 ypos += lineSpacing;
1228 JLabel viewerLabel = new JLabel();
1229 viewerLabel.setFont(LABEL_FONT);
1230 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1231 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1232 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1233 structureTab.add(viewerLabel);
1235 structViewer.setFont(LABEL_FONT);
1236 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1237 structViewer.addItem(ViewerType.JMOL.name());
1238 structViewer.addItem(ViewerType.CHIMERA.name());
1239 structViewer.addActionListener(new ActionListener()
1242 public void actionPerformed(ActionEvent e)
1244 structureViewer_actionPerformed(
1245 (String) structViewer.getSelectedItem());
1248 structureTab.add(structViewer);
1250 ypos += lineSpacing;
1251 JLabel pathLabel = new JLabel();
1252 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1253 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1254 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1255 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1256 structureTab.add(pathLabel);
1258 chimeraPath.setFont(LABEL_FONT);
1259 chimeraPath.setText("");
1260 final String tooltip = JvSwingUtils.wrapTooltip(true,
1261 MessageManager.getString("label.chimera_path_tip"));
1262 chimeraPath.setToolTipText(tooltip);
1263 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1264 chimeraPath.addMouseListener(new MouseAdapter()
1267 public void mouseClicked(MouseEvent e)
1269 if (e.getClickCount() == 2)
1271 String chosen = openFileChooser();
1274 chimeraPath.setText(chosen);
1279 structureTab.add(chimeraPath);
1281 ypos += lineSpacing;
1282 nwMapping.setFont(LABEL_FONT);
1283 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1284 siftsMapping.setFont(LABEL_FONT);
1285 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1286 mappingMethod.add(nwMapping);
1287 mappingMethod.add(siftsMapping);
1288 JPanel mappingPanel = new JPanel();
1289 mappingPanel.setFont(LABEL_FONT);
1290 TitledBorder mmTitledBorder = new TitledBorder(
1291 MessageManager.getString("label.mapping_method"));
1292 mmTitledBorder.setTitleFont(LABEL_FONT);
1293 mappingPanel.setBorder(mmTitledBorder);
1294 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1295 // GridLayout mappingLayout = new GridLayout();
1296 mappingPanel.setLayout(new GridLayout());
1297 mappingPanel.add(nwMapping);
1298 mappingPanel.add(siftsMapping);
1299 structureTab.add(mappingPanel);
1301 ypos += lineSpacing;
1302 ypos += lineSpacing;
1303 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1304 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1305 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1306 structureTab.add(docFieldPref);
1308 return structureTab;
1312 * Action on choosing a structure viewer from combobox options.
1314 * @param selectedItem
1316 protected void structureViewer_actionPerformed(String selectedItem)
1321 * Show a dialog for the user to choose a file. Returns the chosen path, or
1326 protected String openFileChooser()
1328 String choice = null;
1329 JFileChooser chooser = new JFileChooser();
1331 // chooser.setFileView(new JalviewFileView());
1332 chooser.setDialogTitle(
1333 MessageManager.getString("label.open_local_file"));
1334 chooser.setToolTipText(MessageManager.getString("action.open"));
1336 int value = chooser.showOpenDialog(this);
1338 if (value == JFileChooser.APPROVE_OPTION)
1340 choice = chooser.getSelectedFile().getPath();
1346 * Validate the structure tab preferences; if invalid, set focus on this tab.
1350 protected boolean validateStructure(FocusEvent e)
1352 if (!validateStructure())
1354 e.getComponent().requestFocusInWindow();
1360 protected boolean validateStructure()
1366 * Initialises the Visual tabbed panel.
1370 private JPanel initVisualTab()
1372 JPanel visualTab = new JPanel();
1373 visualTab.setBorder(new TitledBorder(
1374 MessageManager.getString("action.open_new_alignment")));
1375 visualTab.setLayout(null);
1376 fullScreen.setFont(LABEL_FONT);
1377 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1378 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1379 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1380 quality.setEnabled(false);
1381 quality.setFont(LABEL_FONT);
1382 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1383 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1384 quality.setSelected(true);
1385 quality.setText(MessageManager.getString("label.quality"));
1386 conservation.setEnabled(false);
1387 conservation.setFont(LABEL_FONT);
1388 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1389 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1390 conservation.setSelected(true);
1391 conservation.setText(MessageManager.getString("label.conservation"));
1392 identity.setEnabled(false);
1393 identity.setFont(LABEL_FONT);
1394 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1395 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1396 identity.setSelected(true);
1397 identity.setText(MessageManager.getString("label.consensus"));
1398 showOccupancy.setFont(LABEL_FONT);
1399 showOccupancy.setEnabled(false);
1400 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1401 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1402 showOccupancy.setSelected(true);
1403 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1405 JLabel showGroupbits = new JLabel();
1406 showGroupbits.setFont(LABEL_FONT);
1407 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1408 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1410 .setText(MessageManager.getString("action.show_group") + ":");
1411 JLabel showConsensbits = new JLabel();
1412 showConsensbits.setFont(LABEL_FONT);
1413 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1414 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1416 .setText(MessageManager.getString("label.consensus") + ":");
1417 showConsensHistogram.setEnabled(false);
1418 showConsensHistogram.setFont(LABEL_FONT);
1419 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1420 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1421 showConsensHistogram.setSelected(true);
1422 showConsensHistogram
1423 .setText(MessageManager.getString("label.histogram"));
1424 showConsensLogo.setEnabled(false);
1425 showConsensLogo.setFont(LABEL_FONT);
1426 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1427 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1428 showConsensLogo.setSelected(true);
1429 showConsensLogo.setText(MessageManager.getString("label.logo"));
1430 showGroupConsensus.setEnabled(false);
1431 showGroupConsensus.setFont(LABEL_FONT);
1432 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1433 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1434 showGroupConsensus.setSelected(true);
1435 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1436 showGroupConservation.setEnabled(false);
1437 showGroupConservation.setFont(LABEL_FONT);
1438 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1439 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1440 showGroupConservation.setSelected(true);
1441 showGroupConservation
1442 .setText(MessageManager.getString("label.conservation"));
1443 showNpTooltip.setEnabled(true);
1444 showNpTooltip.setFont(LABEL_FONT);
1445 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1446 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1447 showNpTooltip.setSelected(true);
1448 showNpTooltip.setText(
1449 MessageManager.getString("label.non_positional_features"));
1450 showDbRefTooltip.setEnabled(true);
1451 showDbRefTooltip.setFont(LABEL_FONT);
1452 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1453 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1454 showDbRefTooltip.setSelected(true);
1456 .setText(MessageManager.getString("label.database_references"));
1457 annotations.setFont(LABEL_FONT);
1458 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1459 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1460 annotations.setSelected(true);
1461 annotations.setText(MessageManager.getString("label.show_annotations"));
1462 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1463 annotations.addActionListener(new ActionListener()
1466 public void actionPerformed(ActionEvent e)
1468 annotations_actionPerformed(e);
1471 identity.addActionListener(new ActionListener()
1474 public void actionPerformed(ActionEvent e)
1476 annotations_actionPerformed(e);
1479 showGroupConsensus.addActionListener(new ActionListener()
1482 public void actionPerformed(ActionEvent e)
1484 annotations_actionPerformed(e);
1487 showUnconserved.setFont(LABEL_FONT);
1488 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1489 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1490 showUnconserved.setSelected(true);
1492 .setText(MessageManager.getString("action.show_unconserved"));
1493 showUnconserved.addActionListener(new ActionListener()
1496 public void actionPerformed(ActionEvent e)
1498 showunconserved_actionPerformed(e);
1502 // TODO these are not yet added to / action from Preferences
1503 // JCheckBox shareSelections = new JCheckBox();
1504 // shareSelections.setFont(verdana11);
1505 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1506 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1507 // shareSelections.setSelected(true);
1508 // shareSelections.setText(MessageManager
1509 // .getString("label.share_selection_across_views"));
1510 // JCheckBox followHighlight = new JCheckBox();
1511 // followHighlight.setFont(verdana11);
1512 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1513 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1514 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1515 // followHighlight.setSelected(true);
1516 // followHighlight.setText(MessageManager
1517 // .getString("label.scroll_highlighted_regions"));
1519 seqLimit.setFont(LABEL_FONT);
1520 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1521 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1522 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1523 smoothFont.setFont(LABEL_FONT);
1524 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1525 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1526 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1527 scaleProteinToCdna.setFont(LABEL_FONT);
1528 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1529 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1530 scaleProteinToCdna.setText(
1531 MessageManager.getString("label.scale_protein_to_cdna"));
1532 scaleProteinToCdna.setToolTipText(
1533 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1534 JLabel gapLabel = new JLabel();
1535 gapLabel.setFont(LABEL_FONT);
1536 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1537 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1538 JLabel fontLabel = new JLabel();
1539 fontLabel.setFont(LABEL_FONT);
1540 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1541 fontLabel.setText(MessageManager.getString("label.font"));
1542 fontSizeCB.setFont(LABEL_FONT);
1543 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1544 fontStyleCB.setFont(LABEL_FONT);
1545 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1546 fontNameCB.setFont(LABEL_FONT);
1547 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1548 gapSymbolCB.setFont(LABEL_FONT);
1549 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1550 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1551 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1552 gapSymbolCB.setRenderer(dlcr);
1554 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1555 startupCheckbox.setFont(LABEL_FONT);
1556 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1557 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1558 startupCheckbox.setSelected(true);
1559 startupFileTextfield.setFont(LABEL_FONT);
1560 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1561 final String tooltip = JvSwingUtils.wrapTooltip(true,
1562 MessageManager.getString("label.double_click_to_browse"));
1563 startupFileTextfield.setToolTipText(tooltip);
1564 startupFileTextfield.addMouseListener(new MouseAdapter()
1567 public void mouseClicked(MouseEvent e)
1569 if (e.getClickCount() > 1)
1571 startupFileTextfield_mouseClicked();
1576 sortby.setFont(LABEL_FONT);
1577 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1578 JLabel sortLabel = new JLabel();
1579 sortLabel.setFont(LABEL_FONT);
1580 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1581 sortLabel.setText(MessageManager.getString("label.sort_by"));
1582 sortAnnBy.setFont(LABEL_FONT);
1583 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1584 JLabel sortAnnLabel = new JLabel();
1585 sortAnnLabel.setFont(LABEL_FONT);
1586 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1587 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1588 sortAutocalc.setFont(LABEL_FONT);
1589 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1591 JPanel annsettingsPanel = new JPanel();
1592 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1593 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1594 annsettingsPanel.setBorder(new EtchedBorder());
1595 visualTab.add(annsettingsPanel);
1596 Border jb = new EmptyBorder(1, 1, 4, 5);
1597 annotations.setBorder(jb);
1598 showOccupancy.setBorder(jb);
1599 quality.setBorder(jb);
1600 conservation.setBorder(jb);
1601 identity.setBorder(jb);
1602 showConsensbits.setBorder(jb);
1603 showGroupbits.setBorder(jb);
1604 showGroupConsensus.setBorder(jb);
1605 showGroupConservation.setBorder(jb);
1606 showConsensHistogram.setBorder(jb);
1607 showConsensLogo.setBorder(jb);
1609 JPanel autoAnnotSettings = new JPanel();
1610 annsettingsPanel.add(autoAnnotSettings);
1611 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1612 autoAnnotSettings.add(annotations);
1613 autoAnnotSettings.add(quality);
1614 // second row of autoannotation box
1615 autoAnnotSettings = new JPanel();
1616 annsettingsPanel.add(autoAnnotSettings);
1618 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1619 autoAnnotSettings.add(conservation);
1620 autoAnnotSettings.add(identity);
1621 autoAnnotSettings.add(showOccupancy);
1622 autoAnnotSettings.add(showGroupbits);
1623 autoAnnotSettings.add(showGroupConservation);
1624 autoAnnotSettings.add(showGroupConsensus);
1625 autoAnnotSettings.add(showConsensbits);
1626 autoAnnotSettings.add(showConsensHistogram);
1627 autoAnnotSettings.add(showConsensLogo);
1629 JPanel tooltipSettings = new JPanel();
1630 tooltipSettings.setBorder(new TitledBorder(
1631 MessageManager.getString("label.sequence_id_tooltip")));
1632 tooltipSettings.setBounds(173, 140, 220, 62);
1633 tooltipSettings.setLayout(new GridLayout(2, 1));
1634 tooltipSettings.add(showDbRefTooltip);
1635 tooltipSettings.add(showNpTooltip);
1636 visualTab.add(tooltipSettings);
1638 wrap.setFont(LABEL_FONT);
1639 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1640 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1641 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1642 rightAlign.setFont(LABEL_FONT);
1643 rightAlign.setForeground(Color.black);
1644 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1645 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1646 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1647 idItalics.setFont(LABEL_FONT_ITALIC);
1648 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1649 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1651 MessageManager.getString("label.sequence_name_italics"));
1652 openoverv.setFont(LABEL_FONT);
1653 openoverv.setActionCommand(
1654 MessageManager.getString("label.open_overview"));
1655 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1656 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1657 openoverv.setText(MessageManager.getString("label.open_overview"));
1658 JPanel jPanel2 = new JPanel();
1659 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1660 jPanel2.setLayout(new GridLayout(14, 1));
1661 jPanel2.add(fullScreen);
1662 jPanel2.add(openoverv);
1663 jPanel2.add(seqLimit);
1664 jPanel2.add(rightAlign);
1665 jPanel2.add(fontLabel);
1666 jPanel2.add(showUnconserved);
1667 jPanel2.add(idItalics);
1668 jPanel2.add(smoothFont);
1669 jPanel2.add(scaleProteinToCdna);
1670 jPanel2.add(gapLabel);
1672 jPanel2.add(sortLabel);
1673 jPanel2.add(sortAnnLabel);
1674 jPanel2.add(startupCheckbox);
1675 visualTab.add(jPanel2);
1676 visualTab.add(startupFileTextfield);
1677 visualTab.add(sortby);
1678 visualTab.add(sortAnnBy);
1679 visualTab.add(sortAutocalc);
1680 visualTab.add(gapSymbolCB);
1681 visualTab.add(fontNameCB);
1682 visualTab.add(fontSizeCB);
1683 visualTab.add(fontStyleCB);
1688 * Initialises the Backups tabbed panel.
1692 private JPanel initBackupsTab()
1694 JPanel backupsTab = new JPanel();
1695 backupsTab.setBorder(new TitledBorder(MessageManager
1696 .getString("label.backup_files")));
1697 backupsTab.setLayout(new GridBagLayout());
1699 GridBagConstraints gbc = new GridBagConstraints();
1702 gbc.anchor = GridBagConstraints.NORTHWEST;
1703 gbc.fill = GridBagConstraints.NONE;
1705 initBackupsTabSuffixPanel();
1706 initBackupsTabKeepFilesPanel();
1707 initBackupsTabFilenameExamplesPanel();
1710 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1711 enableBackupFiles.setText(
1712 MessageManager.getString("label.enable_backupfiles"));
1713 enableBackupFiles.addActionListener(new ActionListener()
1716 public void actionPerformed(ActionEvent e)
1718 boolean selected = enableBackupFiles.isSelected();
1719 // enable other options only when the first is checked
1720 backupsOptionsSetEnabled(selected);
1724 // enable checkbox 1 row
1727 backupsTab.add(enableBackupFiles, gbc);
1730 //gbc.anchor = GridBagConstraints.NORTHEAST;
1731 //gbc.fill = GridBagConstraints.HORIZONTAL;
1732 backupsTab.add(exampleFilesPanel, gbc);
1734 gbc.anchor = GridBagConstraints.NORTHWEST;
1735 gbc.fill = GridBagConstraints.NONE;
1737 // whole suffix panel next row
1740 backupsTab.add(suffixPanel, gbc);
1744 backupsTab.add(keepfilesPanel, gbc);
1747 // whole examples panel next row
1749 backupsTab.add(exampleFilesPanel, gbc);
1754 backupsTab.add(new JPanel(), gbc);
1757 backupsOptionsSetEnabled(enableBackupFiles.isSelected());
1762 public JPanel initBackupsTabSuffixPanel()
1764 suffixPanel.setBorder(new TitledBorder(
1765 MessageManager.getString("label.suffix_format")));
1766 suffixPanel.setLayout(new GridBagLayout());
1769 .setText(MessageManager.getString("label.suffix_template"));
1770 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
1771 suffixTemplateLabel.setFont(LABEL_FONT);
1773 final String tooltip = JvSwingUtils.wrapTooltip(true, MessageManager
1774 .getString("label.suffix_template_tooltip"));
1775 suffixTemplate.setToolTipText(tooltip);
1776 suffixTemplate.addActionListener(new ActionListener()
1779 public void actionPerformed(ActionEvent e)
1781 updateBackupFilesExampleLabel();
1785 KeyListener kl = new KeyListener()
1788 public void keyReleased(KeyEvent e)
1790 updateBackupFilesExampleLabel();
1794 public void keyPressed(KeyEvent e)
1798 // disable use of ':'
1800 public void keyTyped(KeyEvent e)
1802 char c = e.getKeyChar();
1805 // don't process ':'
1811 suffixTemplate.addKeyListener(kl);
1815 .setText(MessageManager.getString("label.index_digits"));
1816 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1817 suffixDigitsLabel.setFont(LABEL_FONT);
1820 ChangeListener c = new ChangeListener()
1823 public void stateChanged(ChangeEvent e)
1825 updateBackupFilesExampleLabel();
1829 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
1831 suffixReverse.setLabels(
1832 MessageManager.getString("label.reverse_roll"),
1833 MessageManager.getString("label.increment_index"));
1834 suffixReverse.addActionListener(new ActionListener()
1837 public void actionPerformed(ActionEvent e)
1839 updateBackupFilesExampleLabel();
1843 GridBagConstraints sgbc = new GridBagConstraints();
1845 // first row (template text box)
1846 sgbc.anchor = GridBagConstraints.WEST;
1850 sgbc.gridheight = 1;
1853 sgbc.fill = GridBagConstraints.NONE;
1854 suffixPanel.add(suffixTemplateLabel,sgbc);
1857 sgbc.fill = GridBagConstraints.HORIZONTAL;
1858 suffixPanel.add(suffixTemplate, sgbc);
1860 // second row (number of digits spinner)
1864 sgbc.fill = GridBagConstraints.NONE;
1865 suffixPanel.add(suffixDigitsLabel, sgbc);
1868 sgbc.fill = GridBagConstraints.HORIZONTAL;
1869 suffixPanel.add(suffixDigitsSpinner, sgbc);
1871 // third row (forward order radio selection)
1874 sgbc.gridwidth = GridBagConstraints.REMAINDER;
1875 sgbc.fill = GridBagConstraints.HORIZONTAL;
1876 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
1878 // fourth row (reverse order radio selection)
1880 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
1884 private JPanel initBackupsTabKeepFilesPanel()
1886 keepfilesPanel.setBorder(
1887 new TitledBorder(MessageManager.getString("label.keep_files")));
1888 keepfilesPanel.setLayout(new GridBagLayout());
1890 backupfilesKeepAll.setLabels(
1891 MessageManager.getString("label.keep_all_backup_files"),
1892 MessageManager.getString(
1893 "label.keep_only_this_number_of_backup_files"));
1894 backupfilesKeepAll.addTrueActionListener(new ActionListener()
1897 public void actionPerformed(ActionEvent e)
1899 updateBackupFilesExampleLabel();
1902 backupfilesKeepAll.addActionListener(new ActionListener()
1905 public void actionPerformed(ActionEvent e)
1907 boolean selected = backupfilesKeepAll.isSelected();
1908 keepRollMaxOptionsEnabled(!selected);
1909 updateBackupFilesExampleLabel();
1913 ChangeListener c = new ChangeListener()
1916 public void stateChanged(ChangeEvent e)
1918 updateBackupFilesExampleLabel();
1922 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
1924 backupfilesConfirmDelete.setLabels(
1925 MessageManager.getString("label.confirm_delete"),
1926 MessageManager.getString("label.auto_delete"));
1927 // update the enabled section
1928 keepRollMaxOptionsEnabled(!backupfilesKeepAll.isSelected());
1930 GridBagConstraints kgbc = new GridBagConstraints();
1932 // first row (template text box)
1933 kgbc.anchor = GridBagConstraints.WEST;
1936 kgbc.gridwidth = GridBagConstraints.REMAINDER;
1937 kgbc.gridheight = 1;
1940 kgbc.fill = GridBagConstraints.HORIZONTAL;
1941 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
1947 kgbc.gridwidth = GridBagConstraints.RELATIVE;
1948 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
1951 kgbc.gridwidth = GridBagConstraints.REMAINDER;
1952 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
1954 // third row (indented)
1956 kgbc.insets = new Insets(0, 20, 0, 0);
1959 kgbc.gridwidth = GridBagConstraints.REMAINDER;
1960 kgbc.fill = GridBagConstraints.HORIZONTAL;
1963 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
1965 // fourth row (indented)
1967 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
1970 JPanel jp = new JPanel();
1971 jp.setLayout(new FlowLayout());
1973 .setText(MessageManager.getString("label.old_backup_files"));
1974 oldBackupFilesLabel.setFont(LABEL_FONT);
1975 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
1976 jp.add(oldBackupFilesLabel);
1977 jp.add(backupfilesConfirmDelete.getTrueButton());
1978 jp.add(backupfilesConfirmDelete.getFalseButton());
1979 keepfilesPanel.add(jp, kgbc);
1981 return keepfilesPanel;
1984 private JPanel initBackupsTabFilenameExamplesPanel()
1986 String title = MessageManager.getString("label.example_filenames");
1987 TitledBorder tb = new TitledBorder(title);
1988 //tb.setTitleFont(LABEL_FONT);
1989 exampleFilesPanel.setBorder(tb);
1990 exampleFilesPanel.setLayout(new GridBagLayout());
1992 //inordinately difficult to get this titledborder the right size for the title
1994 backupfilesExampleLabel.setEditable(false);
1995 backupfilesExampleLabel.setPreferredSize(new Dimension(280, 85));
1996 backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
1997 backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
1999 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2000 backupfilesExampleLabel
2001 .setBackground(exampleFilesPanel.getBackground());
2003 updateBackupFilesExampleLabel();
2004 exampleFilesPanel.setMinimumSize(new Dimension(280, 85));
2006 GridBagConstraints gbc = new GridBagConstraints();
2007 gbc.anchor = GridBagConstraints.EAST;
2010 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2011 return exampleFilesPanel;
2014 protected void updateBackupFilesExampleLabel()
2016 int exampleindex = 12;
2017 String base = MessageManager.getString("label.filename");
2018 if (base == null || base.length() > 0)
2020 base = "filename.fa";
2023 String suffix = suffixTemplate.getText();
2026 suffixDigitsSpinner.commitEdit();
2027 digits = (Integer) suffixDigitsSpinner.getValue();
2028 digits = digits < 1 ? 1 : digits;
2029 } catch (Exception e)
2031 System.out.println("Failed casting (Integer) suffixTemplateSpinner.getValue()");
2033 boolean reverse = suffixReverse.isSelected();
2034 boolean keepAll = backupfilesKeepAll.isSelected();
2038 backupfilesRollMaxSpinner.commitEdit();
2039 rollMax = (Integer) backupfilesRollMaxSpinner.getValue();
2040 rollMax = rollMax < 1 ? 1 : rollMax;
2041 } catch (Exception e)
2044 "Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
2047 int lowersurround = 2;
2048 int uppersurround = 0;
2049 StringBuilder exampleSB = new StringBuilder();
2050 boolean firstLine = true;
2055 int max = keepAll ? exampleindex : rollMax;
2056 for (int index = min; index <= max; index++)
2058 if (index == min + lowersurround && index < max - uppersurround - 1)
2060 exampleSB.append("\n...");
2062 else if (index > min + lowersurround && index < max - uppersurround)
2074 exampleSB.append("\n");
2076 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2077 base, suffix, digits));
2080 // no extra text needed
2082 else if (index == min)
2084 String newest = MessageManager.getString("label.braced_newest");
2085 if (newest != null && newest.length() > 0)
2087 exampleSB.append(" "+newest);
2090 else if (index == max)
2092 String oldest = MessageManager.getString("label.braced_oldest");
2093 if (oldest != null && oldest.length() > 0)
2095 exampleSB.append(" "+oldest);
2104 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2105 : exampleindex - rollMax + 1;
2106 int max = exampleindex;
2108 for (int index = min; index <= max; index++)
2111 if (index == min + lowersurround && index < max - uppersurround - 1)
2113 exampleSB.append("\n...");
2115 else if (index > min + lowersurround && index < max - uppersurround)
2127 exampleSB.append("\n");
2129 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2130 base, suffix, digits));
2133 // no extra text needed
2135 else if (index == min)
2137 String oldest = MessageManager.getString("label.braced_oldest");
2138 if (oldest != null && oldest.length() > 0)
2140 exampleSB.append(" "+oldest);
2143 else if (index == max)
2145 String newest = MessageManager.getString("label.braced_newest");
2146 if (newest != null && newest.length() > 0)
2148 exampleSB.append(" "+newest);
2156 backupfilesExampleLabel.setText(exampleSB.toString());
2159 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2160 boolean useExistingVal, ChangeListener c)
2167 i = Integer.parseInt((String) s.getValue());
2168 } catch (Exception e)
2171 "Exception casting the initial value of s.getValue()");
2175 setIntegerSpinner(s, min, max, i, c);
2178 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2181 // integer spinner for number of digits
2186 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2189 s.addChangeListener(c);
2193 public static int getSpinnerInt(JSpinner s, int def)
2199 i = (Integer) s.getValue();
2200 } catch (Exception e)
2202 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2207 private void keepRollMaxOptionsEnabled(boolean enabled)
2209 oldBackupFilesLabel.setEnabled(enabled);
2210 backupfilesRollMaxSpinner.setEnabled(enabled);
2211 backupfilesConfirmDelete.setEnabled(enabled);
2215 protected void backupsOptionsSetEnabled(boolean enabled)
2217 suffixPanel.setEnabled(enabled);
2218 keepfilesPanel.setEnabled(enabled);
2219 exampleFilesPanel.setEnabled(enabled);
2221 suffixTemplate.setEnabled(enabled);
2222 suffixTemplateLabel.setEnabled(enabled);
2223 suffixDigitsLabel.setEnabled(enabled);
2224 suffixDigitsSpinner.setEnabled(enabled);
2225 suffixReverse.setEnabled(enabled);
2226 backupfilesKeepAll.setEnabled(enabled);
2227 backupfilesRollMaxSpinner.setEnabled(enabled);
2228 oldBackupFilesLabel.setEnabled(enabled);
2229 backupfilesConfirmDelete.setEnabled(enabled);
2230 backupfilesExampleLabel.setEnabled(enabled);
2232 keepRollMaxOptionsEnabled(enabled && !backupfilesKeepAll.isSelected());
2235 protected void autoIdWidth_actionPerformed()
2237 // TODO Auto-generated method stub
2241 protected void userIdWidth_actionPerformed()
2243 // TODO Auto-generated method stub
2247 protected void maxColour_actionPerformed(JPanel panel)
2251 protected void minColour_actionPerformed(JPanel panel)
2255 protected void gapColour_actionPerformed(JPanel panel)
2259 protected void hiddenColour_actionPerformed(JPanel panel)
2263 protected void showunconserved_actionPerformed(ActionEvent e)
2265 // TODO Auto-generated method stub
2269 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2273 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2283 public void ok_actionPerformed(ActionEvent e)
2293 public void cancel_actionPerformed(ActionEvent e)
2303 public void annotations_actionPerformed(ActionEvent e)
2310 public void startupFileTextfield_mouseClicked()
2314 public void newLink_actionPerformed(ActionEvent e)
2319 public void editLink_actionPerformed(ActionEvent e)
2324 public void deleteLink_actionPerformed(ActionEvent e)
2329 public void defaultBrowser_mouseClicked(MouseEvent e)
2334 public void linkURLList_keyTyped(KeyEvent e)
2339 public void useProxy_actionPerformed()
2341 boolean enabled = useProxy.isSelected();
2342 portLabel.setEnabled(enabled);
2343 serverLabel.setEnabled(enabled);
2344 proxyServerTB.setEnabled(enabled);
2345 proxyPortTB.setEnabled(enabled);
2349 * Customer renderer for JTable: supports column of radio buttons
2351 public class RadioButtonRenderer extends JRadioButton
2352 implements TableCellRenderer
2354 public RadioButtonRenderer()
2356 setHorizontalAlignment(CENTER);
2357 setToolTipText(MessageManager.getString("label.urltooltip"));
2361 public Component getTableCellRendererComponent(JTable table,
2362 Object value, boolean isSelected, boolean hasFocus, int row,
2365 setSelected((boolean) value);
2367 // set colours to match rest of table
2370 setBackground(table.getSelectionBackground());
2371 setForeground(table.getSelectionForeground());
2375 setBackground(table.getBackground());
2376 setForeground(table.getForeground());
2383 * Customer cell editor for JTable: supports column of radio buttons in
2384 * conjunction with renderer
2386 public class RadioButtonEditor extends AbstractCellEditor
2387 implements TableCellEditor
2389 private JRadioButton button = new JRadioButton();
2391 public RadioButtonEditor()
2393 button.setHorizontalAlignment(SwingConstants.CENTER);
2394 this.button.addActionListener(new ActionListener()
2397 public void actionPerformed(ActionEvent e)
2399 fireEditingStopped();
2405 public Component getTableCellEditorComponent(JTable table, Object value,
2406 boolean isSelected, int row, int column)
2408 button.setSelected((boolean) value);
2413 public Object getCellEditorValue()
2415 return button.isSelected();