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.JalviewBooleanRadioButtons;
28 import jalview.gui.JvSwingUtils;
29 import jalview.gui.StructureViewer.ViewerType;
30 import jalview.io.BackupFilenameFilter;
31 import jalview.io.BackupFiles;
32 import jalview.util.MessageManager;
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Component;
37 import java.awt.Dimension;
38 import java.awt.FlowLayout;
40 import java.awt.GridBagConstraints;
41 import java.awt.GridBagLayout;
42 import java.awt.GridLayout;
43 import java.awt.Insets;
44 import java.awt.Rectangle;
45 import java.awt.event.ActionEvent;
46 import java.awt.event.ActionListener;
47 import java.awt.event.FocusEvent;
48 import java.awt.event.KeyEvent;
49 import java.awt.event.KeyListener;
50 import java.awt.event.MouseAdapter;
51 import java.awt.event.MouseEvent;
53 import javax.swing.AbstractCellEditor;
54 import javax.swing.BorderFactory;
55 import javax.swing.ButtonGroup;
56 import javax.swing.DefaultListCellRenderer;
57 import javax.swing.JButton;
58 import javax.swing.JCheckBox;
59 import javax.swing.JComboBox;
60 import javax.swing.JFileChooser;
61 import javax.swing.JLabel;
62 import javax.swing.JPanel;
63 import javax.swing.JRadioButton;
64 import javax.swing.JScrollPane;
65 import javax.swing.JSpinner;
66 import javax.swing.JTabbedPane;
67 import javax.swing.JTable;
68 import javax.swing.JTextArea;
69 import javax.swing.JTextField;
70 import javax.swing.ListSelectionModel;
71 import javax.swing.SpinnerModel;
72 import javax.swing.SpinnerNumberModel;
73 import javax.swing.SwingConstants;
74 import javax.swing.border.Border;
75 import javax.swing.border.EmptyBorder;
76 import javax.swing.border.EtchedBorder;
77 import javax.swing.border.TitledBorder;
78 import javax.swing.event.ChangeEvent;
79 import javax.swing.event.ChangeListener;
80 import javax.swing.table.TableCellEditor;
81 import javax.swing.table.TableCellRenderer;
84 * Base class for the Preferences panel.
89 public class GPreferences extends JPanel
91 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
93 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
94 .getLabelFont(false, true);
97 * Visual tab components
99 protected JCheckBox fullScreen = new JCheckBox();
101 protected JCheckBox openoverv = new JCheckBox();
103 protected JCheckBox seqLimit = new JCheckBox();
105 protected JCheckBox rightAlign = new JCheckBox();
107 protected JComboBox<String> fontSizeCB = new JComboBox<>();
109 protected JComboBox<String> fontStyleCB = new JComboBox<>();
111 protected JComboBox<String> fontNameCB = new JComboBox<>();
113 protected JCheckBox showOccupancy = new JCheckBox();
115 protected JCheckBox showUnconserved = new JCheckBox();
117 protected JCheckBox idItalics = new JCheckBox();
119 protected JCheckBox smoothFont = new JCheckBox();
121 protected JCheckBox scaleProteinToCdna = new JCheckBox();
123 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
125 protected JCheckBox wrap = new JCheckBox();
127 protected JComboBox<String> sortby = new JComboBox<>();
129 protected JComboBox<String> sortAnnBy = new JComboBox<>();
131 protected JComboBox<String> sortAutocalc = new JComboBox<>();
133 protected JCheckBox startupCheckbox = new JCheckBox();
135 protected JTextField startupFileTextfield = new JTextField();
137 // below are in the 'second column'
138 protected JCheckBox annotations = new JCheckBox();
140 protected JCheckBox quality = new JCheckBox();
142 protected JCheckBox conservation = new JCheckBox();
144 protected JCheckBox identity = new JCheckBox();
146 protected JCheckBox showGroupConsensus = new JCheckBox();
148 protected JCheckBox showGroupConservation = new JCheckBox();
150 protected JCheckBox showConsensHistogram = new JCheckBox();
152 protected JCheckBox showConsensLogo = new JCheckBox();
154 protected JCheckBox showDbRefTooltip = new JCheckBox();
156 protected JCheckBox showNpTooltip = new JCheckBox();
159 * Structure tab and components
161 protected JPanel structureTab;
163 protected JCheckBox structFromPdb = new JCheckBox();
165 protected JCheckBox useRnaView = new JCheckBox();
167 protected JCheckBox addSecondaryStructure = new JCheckBox();
169 protected JCheckBox addTempFactor = new JCheckBox();
171 protected JComboBox<String> structViewer = new JComboBox<>();
173 protected JTextField chimeraPath = new JTextField();
175 protected ButtonGroup mappingMethod = new ButtonGroup();
177 protected JRadioButton siftsMapping = new JRadioButton();
179 protected JRadioButton nwMapping = new JRadioButton();
182 * Colours tab components
184 protected JPanel minColour = new JPanel();
186 protected JPanel maxColour = new JPanel();
188 protected JComboBox<String> protColour = new JComboBox<>();
190 protected JComboBox<String> nucColour = new JComboBox<>();
193 * Overview tab components
195 protected JPanel gapColour = new JPanel();
197 protected JPanel hiddenColour = new JPanel();
199 protected JCheckBox useLegacyGap;
201 protected JCheckBox showHiddenAtStart;
203 protected JLabel gapLabel;
206 * Connections tab components
208 protected JTable linkUrlTable = new JTable();
210 protected JButton editLink = new JButton();
212 protected JButton deleteLink = new JButton();
214 protected JTextField filterTB = new JTextField();
216 protected JButton doReset = new JButton();
218 protected JButton userOnly = new JButton();
220 protected JLabel portLabel = new JLabel();
222 protected JLabel serverLabel = new JLabel();
224 protected JTextField proxyServerTB = new JTextField();
226 protected JTextField proxyPortTB = new JTextField();
228 protected JTextField defaultBrowser = new JTextField();
230 protected JCheckBox useProxy = new JCheckBox();
232 protected JCheckBox usagestats = new JCheckBox();
234 protected JCheckBox questionnaire = new JCheckBox();
236 protected JCheckBox versioncheck = new JCheckBox();
239 * Output tab components
241 protected JComboBox<Object> epsRendering = new JComboBox<>();
243 protected JLabel userIdWidthlabel = new JLabel();
245 protected JCheckBox autoIdWidth = new JCheckBox();
247 protected JTextField userIdWidth = new JTextField();
249 protected JCheckBox blcjv = new JCheckBox();
251 protected JCheckBox pileupjv = new JCheckBox();
253 protected JCheckBox clustaljv = new JCheckBox();
255 protected JCheckBox msfjv = new JCheckBox();
257 protected JCheckBox fastajv = new JCheckBox();
259 protected JCheckBox pfamjv = new JCheckBox();
261 protected JCheckBox pirjv = new JCheckBox();
263 protected JCheckBox modellerOutput = new JCheckBox();
265 protected JCheckBox embbedBioJSON = new JCheckBox();
268 * Editing tab components
270 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
272 protected JCheckBox padGaps = new JCheckBox();
274 protected JCheckBox sortByTree = new JCheckBox();
280 protected JPanel wsTab = new JPanel();
283 * Backups tab components
284 * a lot of these are member variables instead of local variables only so that they
285 * can be enabled/disabled easily
288 protected JCheckBox enableBackupFiles = new JCheckBox();
290 protected JPanel suffixPanel = new JPanel();
292 protected JPanel keepfilesPanel = new JPanel();
294 protected JPanel exampleFilesPanel = new JPanel();
296 protected JTextField suffixTemplate = new JTextField(null, 8);
298 protected JLabel suffixTemplateLabel = new JLabel();
300 protected JLabel suffixDigitsLabel = new JLabel();
302 protected JSpinner suffixDigitsSpinner = new JSpinner();
304 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
306 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
308 protected JSpinner backupfilesRollMaxSpinner = new JSpinner();
310 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
312 protected JLabel exampleLabel = new JLabel();
314 protected JScrollPane exampleScrollPane = new JScrollPane();
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 enableBackupFiles.setFont(LABEL_FONT);
1700 enableBackupFiles.setText(
1701 MessageManager.getString("label.enable_backupfiles"));
1703 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1704 enableBackupFiles.addActionListener(new ActionListener()
1707 public void actionPerformed(ActionEvent e)
1709 boolean selected = enableBackupFiles.isSelected();
1710 // enable other options only when the first is checked
1711 backupsOptionsSetEnabled(selected);
1715 GridBagConstraints gbc = new GridBagConstraints();
1718 gbc.anchor = GridBagConstraints.NORTHWEST;
1720 // enable checkbox 1 row
1723 backupsTab.add(enableBackupFiles, gbc);
1725 // whole suffix panel next row
1726 initBackupsTabSuffixPanel();
1728 backupsTab.add(suffixPanel, gbc);
1731 initBackupsTabKeepFilesPanel();
1733 backupsTab.add(keepfilesPanel, gbc);
1735 // whole examples panel next row
1736 initBackupsTabFilenameExamplesPanel();
1738 backupsTab.add(exampleFilesPanel, gbc);
1744 public JPanel initBackupsTabSuffixPanel()
1746 suffixPanel.setBorder(new TitledBorder(
1747 MessageManager.getString("label.suffix_format")));
1748 suffixPanel.setLayout(new GridBagLayout());
1751 .setText(MessageManager.getString("label.suffix_template"));
1752 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
1753 suffixTemplateLabel.setFont(LABEL_FONT);
1755 String suffix = Cache.getDefault(BackupFiles.SUFFIX, BackupFiles.getNumPlaceHolder());
1756 suffixTemplate.setText(suffix);
1757 final String tooltip = JvSwingUtils.wrapTooltip(true, MessageManager
1758 .getString("label.suffix_template_tooltip"));
1759 suffixTemplate.setToolTipText(tooltip);
1760 suffixTemplate.addActionListener(new ActionListener()
1763 public void actionPerformed(ActionEvent e)
1765 updateBackupFilesExampleLabel();
1769 KeyListener kl = new KeyListener()
1772 public void keyReleased(KeyEvent e)
1774 updateBackupFilesExampleLabel();
1778 public void keyPressed(KeyEvent e)
1782 // disable use of ':'
1784 public void keyTyped(KeyEvent e)
1786 char c = e.getKeyChar();
1789 // don't process ':'
1795 suffixTemplate.addKeyListener(kl);
1799 .setText(MessageManager.getString("label.index_digits"));
1800 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1801 suffixDigitsLabel.setFont(LABEL_FONT);
1805 defaultmin = Integer.parseInt(
1806 MessageManager.getString("default.suffix_index_digits_min"));
1807 } catch (Exception e)
1811 "Exception setting suffix digits min from default.suffix_index_digits_min label, setting to "
1816 defaultmax = Integer.parseInt(
1817 MessageManager.getString("default.suffix_index_digits_max"));
1818 } catch (Exception e) {
1821 "Exception setting suffix digits max from default.suffix_index_digits_max label, setting to "
1824 setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax,
1825 Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
1827 suffixReverse.setSelected(
1828 Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
1829 suffixReverse.setLabels(
1830 MessageManager.getString("label.reverse_roll"),
1831 MessageManager.getString("label.increment_index"));
1832 suffixReverse.addActionListener(new ActionListener()
1835 public void actionPerformed(ActionEvent e)
1837 updateBackupFilesExampleLabel();
1841 GridBagConstraints sgbc = new GridBagConstraints();
1843 // first row (template text box)
1844 sgbc.anchor = GridBagConstraints.WEST;
1848 sgbc.gridheight = 1;
1851 sgbc.fill = GridBagConstraints.NONE;
1852 suffixPanel.add(suffixTemplateLabel,sgbc);
1855 sgbc.fill = GridBagConstraints.HORIZONTAL;
1856 suffixPanel.add(suffixTemplate, sgbc);
1858 // second row (number of digits spinner)
1862 sgbc.fill = GridBagConstraints.NONE;
1863 suffixPanel.add(suffixDigitsLabel, sgbc);
1866 sgbc.fill = GridBagConstraints.HORIZONTAL;
1867 suffixPanel.add(suffixDigitsSpinner, sgbc);
1869 // third row (forward order radio selection)
1872 sgbc.gridwidth = GridBagConstraints.REMAINDER;
1873 sgbc.fill = GridBagConstraints.HORIZONTAL;
1874 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
1876 // fourth row (reverse order radio selection)
1878 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
1882 private JPanel initBackupsTabKeepFilesPanel()
1884 keepfilesPanel.setBorder(
1885 new TitledBorder(MessageManager.getString("label.keep_files")));
1886 keepfilesPanel.setLayout(new GridBagLayout());
1889 .setSelected(Cache.getDefault(BackupFiles.NO_MAX, true));
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 setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999,
1914 Cache.getDefault(BackupFiles.ROLL_MAX, 3));
1916 backupfilesConfirmDelete.setSelected(
1917 Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
1918 backupfilesConfirmDelete.setLabels(
1919 MessageManager.getString("label.confirm_delete"),
1920 MessageManager.getString("label.auto_delete"));
1921 // update the enabled section
1922 keepRollMaxOptionsEnabled(!backupfilesKeepAll.isSelected());
1924 GridBagConstraints kgbc = new GridBagConstraints();
1926 // first row (template text box)
1927 kgbc.anchor = GridBagConstraints.WEST;
1930 kgbc.gridwidth = GridBagConstraints.REMAINDER;
1931 kgbc.gridheight = 1;
1934 kgbc.fill = GridBagConstraints.HORIZONTAL;
1935 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
1941 kgbc.gridwidth = GridBagConstraints.RELATIVE;
1942 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
1945 // kgbc.fill = GridBagConstraints.HORIZONTAL;
1946 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
1948 // third row (indented)
1950 kgbc.insets = new Insets(0, 20, 0, 0);
1953 kgbc.gridwidth = GridBagConstraints.REMAINDER;
1954 kgbc.fill = GridBagConstraints.HORIZONTAL;
1956 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
1958 // fourth row (indented)
1960 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
1961 return keepfilesPanel;
1964 private JPanel initBackupsTabFilenameExamplesPanel()
1966 exampleFilesPanel.setBorder(new TitledBorder(
1967 MessageManager.getString("label.examples")));
1968 exampleFilesPanel.setLayout(new GridBagLayout());
1970 exampleLabel.setText(
1971 MessageManager.getString("label.suffix_example_filenames"));
1972 exampleLabel.setFont(LABEL_FONT);
1973 exampleLabel.setHorizontalAlignment(SwingConstants.LEFT);
1975 backupfilesExampleLabel.setEditable(false);
1976 backupfilesExampleLabel.setPreferredSize(new Dimension(300, 100));
1977 backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
1978 backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
1980 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
1981 backupfilesExampleLabel.setBackground(exampleLabel.getBackground());
1984 exampleScrollPane.setBounds(0, 0, 200, 100);
1985 exampleScrollPane.setPreferredSize(new Dimension(800, 800));
1986 exampleScrollPane.add(backupfilesExampleLabel);
1988 updateBackupFilesExampleLabel();
1990 GridBagConstraints gbc = new GridBagConstraints();
1991 gbc.anchor = GridBagConstraints.WEST;
1994 exampleFilesPanel.add(exampleLabel, gbc);
1996 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1997 // exampleFilesPanel.add(exampleScrollPane, gbc);
1998 return exampleFilesPanel;
2001 private void updateBackupFilesExampleLabel()
2003 int exampleindex = 12;
2004 String base = "filename";
2005 String extension = ".fa";
2007 String suffix = suffixTemplate.getText();
2010 suffixDigitsSpinner.commitEdit();
2011 digits = (Integer) suffixDigitsSpinner.getValue();
2012 digits = digits < 1 ? 1 : digits;
2013 } catch (Exception e)
2015 System.out.println("Failed casting (Integer) suffixTemplateSpinner.getValue()");
2017 boolean reverse = suffixReverse.isSelected();
2018 boolean keepAll = backupfilesKeepAll.isSelected();
2022 backupfilesRollMaxSpinner.commitEdit();
2023 rollMax = (Integer) backupfilesRollMaxSpinner.getValue();
2024 rollMax = rollMax < 1 ? 1 : rollMax;
2025 } catch (Exception e)
2028 "Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
2032 StringBuilder exampleSB = new StringBuilder();
2033 boolean firstLine = true;
2038 int max = keepAll ? exampleindex : rollMax;
2039 for (int index = min; index <= max; index++)
2041 if (index == min + surround && index <= max - surround)
2043 exampleSB.append("\n...");
2045 else if (index > min + surround && index <= max - surround)
2057 exampleSB.append("\n");
2059 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2060 base, suffix, digits, extension));
2063 // no extra text needed
2065 else if (index == min)
2067 exampleSB.append(" (most recent)");
2069 else if (index == max)
2071 exampleSB.append(" (oldest)");
2079 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2080 : exampleindex - rollMax + 1;
2081 int max = exampleindex;
2083 for (int index = min; index <= max; index++)
2086 if (index == min + surround && index <= max - surround)
2088 exampleSB.append("\n...");
2090 else if (index > min + surround && index <= max - surround)
2102 exampleSB.append("\n");
2104 exampleSB.append(BackupFilenameFilter.getBackupFilename(index,
2105 base, suffix, digits, extension));
2108 // no extra text needed
2110 else if (index == min)
2112 exampleSB.append(" (oldest)");
2114 else if (index == max)
2116 exampleSB.append(" (most recent)");
2123 backupfilesExampleLabel.setText(exampleSB.toString());
2126 protected void setIntegerSpinner(JSpinner s, int min,
2129 // integer spinner for number of digits
2134 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2137 s.addChangeListener(new ChangeListener()
2140 public void stateChanged(ChangeEvent e)
2142 updateBackupFilesExampleLabel();
2149 public static int getSpinnerInt(JSpinner s, int def)
2155 i = (Integer) s.getValue();
2156 } catch (Exception e)
2158 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2163 private void keepRollMaxOptionsEnabled(boolean enabled)
2165 backupfilesRollMaxSpinner.setEnabled(enabled);
2166 backupfilesConfirmDelete.setEnabled(enabled);
2169 private void backupsOptionsSetEnabled(boolean enabled)
2171 suffixPanel.setEnabled(enabled);
2172 keepfilesPanel.setEnabled(enabled);
2173 exampleFilesPanel.setEnabled(enabled);
2175 suffixTemplate.setEnabled(enabled);
2176 suffixTemplateLabel.setEnabled(enabled);
2177 suffixDigitsLabel.setEnabled(enabled);
2178 suffixDigitsSpinner.setEnabled(enabled);
2179 suffixReverse.setEnabled(enabled);
2180 backupfilesKeepAll.setEnabled(enabled);
2181 backupfilesRollMaxSpinner.setEnabled(enabled);
2182 backupfilesConfirmDelete.setEnabled(enabled);
2183 exampleLabel.setEnabled(enabled);
2184 exampleScrollPane.setEnabled(enabled);
2185 backupfilesExampleLabel.setEnabled(enabled);
2187 keepRollMaxOptionsEnabled(enabled && !backupfilesKeepAll.isSelected());
2190 protected void autoIdWidth_actionPerformed()
2192 // TODO Auto-generated method stub
2196 protected void userIdWidth_actionPerformed()
2198 // TODO Auto-generated method stub
2202 protected void maxColour_actionPerformed(JPanel panel)
2206 protected void minColour_actionPerformed(JPanel panel)
2210 protected void gapColour_actionPerformed(JPanel panel)
2214 protected void hiddenColour_actionPerformed(JPanel panel)
2218 protected void showunconserved_actionPerformed(ActionEvent e)
2220 // TODO Auto-generated method stub
2224 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2228 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2238 public void ok_actionPerformed(ActionEvent e)
2248 public void cancel_actionPerformed(ActionEvent e)
2258 public void annotations_actionPerformed(ActionEvent e)
2265 public void startupFileTextfield_mouseClicked()
2269 public void newLink_actionPerformed(ActionEvent e)
2274 public void editLink_actionPerformed(ActionEvent e)
2279 public void deleteLink_actionPerformed(ActionEvent e)
2284 public void defaultBrowser_mouseClicked(MouseEvent e)
2289 public void linkURLList_keyTyped(KeyEvent e)
2294 public void useProxy_actionPerformed()
2296 boolean enabled = useProxy.isSelected();
2297 portLabel.setEnabled(enabled);
2298 serverLabel.setEnabled(enabled);
2299 proxyServerTB.setEnabled(enabled);
2300 proxyPortTB.setEnabled(enabled);
2304 * Customer renderer for JTable: supports column of radio buttons
2306 public class RadioButtonRenderer extends JRadioButton
2307 implements TableCellRenderer
2309 public RadioButtonRenderer()
2311 setHorizontalAlignment(CENTER);
2312 setToolTipText(MessageManager.getString("label.urltooltip"));
2316 public Component getTableCellRendererComponent(JTable table,
2317 Object value, boolean isSelected, boolean hasFocus, int row,
2320 setSelected((boolean) value);
2322 // set colours to match rest of table
2325 setBackground(table.getSelectionBackground());
2326 setForeground(table.getSelectionForeground());
2330 setBackground(table.getBackground());
2331 setForeground(table.getForeground());
2338 * Customer cell editor for JTable: supports column of radio buttons in
2339 * conjunction with renderer
2341 public class RadioButtonEditor extends AbstractCellEditor
2342 implements TableCellEditor
2344 private JRadioButton button = new JRadioButton();
2346 public RadioButtonEditor()
2348 button.setHorizontalAlignment(SwingConstants.CENTER);
2349 this.button.addActionListener(new ActionListener()
2352 public void actionPerformed(ActionEvent e)
2354 fireEditingStopped();
2360 public Component getTableCellEditorComponent(JTable table, Object value,
2361 boolean isSelected, int row, int column)
2363 button.setSelected((boolean) value);
2368 public Object getCellEditorValue()
2370 return button.isSelected();