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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.util.Arrays;
42 import java.util.List;
44 import javax.swing.AbstractCellEditor;
45 import javax.swing.BorderFactory;
46 import javax.swing.ButtonGroup;
47 import javax.swing.DefaultListCellRenderer;
48 import javax.swing.JButton;
49 import javax.swing.JCheckBox;
50 import javax.swing.JComboBox;
51 import javax.swing.JFileChooser;
52 import javax.swing.JLabel;
53 import javax.swing.JPanel;
54 import javax.swing.JPasswordField;
55 import javax.swing.JRadioButton;
56 import javax.swing.JScrollPane;
57 import javax.swing.JSpinner;
58 import javax.swing.JTabbedPane;
59 import javax.swing.JTable;
60 import javax.swing.JTextArea;
61 import javax.swing.JTextField;
62 import javax.swing.ListSelectionModel;
63 import javax.swing.SpinnerModel;
64 import javax.swing.SpinnerNumberModel;
65 import javax.swing.SwingConstants;
66 import javax.swing.border.Border;
67 import javax.swing.border.EmptyBorder;
68 import javax.swing.border.EtchedBorder;
69 import javax.swing.border.TitledBorder;
70 import javax.swing.event.ChangeEvent;
71 import javax.swing.event.ChangeListener;
72 import javax.swing.table.TableCellEditor;
73 import javax.swing.table.TableCellRenderer;
75 import jalview.bin.Cache;
76 import jalview.fts.core.FTSDataColumnPreferences;
77 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
78 import jalview.fts.service.pdb.PDBFTSRestClient;
79 import jalview.gui.Desktop;
80 import jalview.gui.JalviewBooleanRadioButtons;
81 import jalview.gui.JvOptionPane;
82 import jalview.gui.JvSwingUtils;
83 import jalview.gui.StructureViewer.ViewerType;
84 import jalview.io.BackupFilenameParts;
85 import jalview.io.BackupFiles;
86 import jalview.io.BackupFilesPresetEntry;
87 import jalview.io.IntKeyStringValueEntry;
88 import jalview.util.MessageManager;
91 * Base class for the Preferences panel.
96 public class GPreferences extends JPanel
98 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
100 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
101 .getLabelFont(false, true);
103 private static final Font LABEL_FONT_BOLD = JvSwingUtils
104 .getLabelFont(true, false);
107 * Visual tab components
109 protected JCheckBox fullScreen = new JCheckBox();
111 protected JCheckBox openoverv = new JCheckBox();
113 protected JCheckBox seqLimit = new JCheckBox();
115 protected JCheckBox rightAlign = new JCheckBox();
117 protected JComboBox<String> fontSizeCB = new JComboBox<>();
119 protected JComboBox<String> fontStyleCB = new JComboBox<>();
121 protected JComboBox<String> fontNameCB = new JComboBox<>();
123 protected JCheckBox showOccupancy = new JCheckBox();
125 protected JCheckBox showUnconserved = new JCheckBox();
127 protected JCheckBox idItalics = new JCheckBox();
129 protected JCheckBox smoothFont = new JCheckBox();
131 protected JCheckBox scaleProteinToCdna = new JCheckBox();
133 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
135 protected JCheckBox wrap = new JCheckBox();
137 protected JComboBox<String> sortby = new JComboBox<>();
139 protected JComboBox<String> sortAnnBy = new JComboBox<>();
141 protected JComboBox<String> sortAutocalc = new JComboBox<>();
143 protected JCheckBox startupCheckbox = new JCheckBox();
145 protected JTextField startupFileTextfield = new JTextField();
147 // below are in the 'second column'
148 protected JCheckBox annotations = new JCheckBox();
150 protected JCheckBox quality = new JCheckBox();
152 protected JCheckBox conservation = new JCheckBox();
154 protected JCheckBox identity = new JCheckBox();
156 protected JCheckBox showGroupConsensus = new JCheckBox();
158 protected JCheckBox showGroupConservation = new JCheckBox();
160 protected JCheckBox showConsensHistogram = new JCheckBox();
162 protected JCheckBox showConsensLogo = new JCheckBox();
164 protected JCheckBox showDbRefTooltip = new JCheckBox();
166 protected JCheckBox showNpTooltip = new JCheckBox();
169 * Structure tab and components
171 protected JPanel structureTab;
173 protected JCheckBox structFromPdb = new JCheckBox();
175 protected JCheckBox useRnaView = new JCheckBox();
177 protected JCheckBox addSecondaryStructure = new JCheckBox();
179 protected JCheckBox addTempFactor = new JCheckBox();
181 protected JComboBox<String> structViewer = new JComboBox<>();
183 protected JTextField chimeraPath = new JTextField();
185 protected ButtonGroup mappingMethod = new ButtonGroup();
187 protected JRadioButton siftsMapping = new JRadioButton();
189 protected JRadioButton nwMapping = new JRadioButton();
192 * Colours tab components
194 protected JPanel minColour = new JPanel();
196 protected JPanel maxColour = new JPanel();
198 protected JComboBox<String> protColour = new JComboBox<>();
200 protected JComboBox<String> nucColour = new JComboBox<>();
203 * Overview tab components
205 protected JPanel gapColour = new JPanel();
207 protected JPanel hiddenColour = new JPanel();
209 protected JCheckBox useLegacyGap;
211 protected JCheckBox showHiddenAtStart;
213 protected JLabel gapLabel;
216 * Connections tab components
218 protected JPanel connectTab;
220 protected JTable linkUrlTable = new JTable();
222 protected JButton editLink = new JButton();
224 protected JButton deleteLink = new JButton();
226 protected JTextField filterTB = new JTextField();
228 protected JButton doReset = new JButton();
230 protected JButton userOnly = new JButton();
232 protected JLabel httpLabel = new JLabel();
234 protected JLabel httpsLabel = new JLabel();
236 protected JLabel portLabel = new JLabel();
238 protected JLabel serverLabel = new JLabel();
240 protected JLabel portLabel2 = new JLabel();
242 protected JLabel serverLabel2 = new JLabel();
244 protected JLabel proxyAuthUsernameLabel = new JLabel();
246 protected JLabel proxyAuthPasswordLabel = new JLabel();
248 protected JLabel passwordNotStoredLabel = new JLabel();
250 protected JTextField proxyServerHttpTB = new JTextField();
252 protected JTextField proxyPortHttpTB = new JTextField();
254 protected JTextField proxyServerHttpsTB = new JTextField();
256 protected JTextField proxyPortHttpsTB = new JTextField();
258 protected JCheckBox proxyAuth = new JCheckBox();
260 protected JTextField proxyAuthUsernameTB = new JTextField();
262 protected JPasswordField proxyAuthPasswordTB = new JPasswordField();
264 protected JTextField defaultBrowser = new JTextField();
266 protected ButtonGroup proxyType = new ButtonGroup();
268 protected JRadioButton noProxy = new JRadioButton();
270 protected JRadioButton systemProxy = new JRadioButton();
272 protected JRadioButton customProxy = new JRadioButton();
274 protected JCheckBox usagestats = new JCheckBox();
276 protected JCheckBox questionnaire = new JCheckBox();
278 protected JCheckBox versioncheck = new JCheckBox();
281 * Output tab components
283 protected JComboBox<Object> epsRendering = new JComboBox<>();
285 protected JLabel userIdWidthlabel = new JLabel();
287 protected JCheckBox autoIdWidth = new JCheckBox();
289 protected JTextField userIdWidth = new JTextField();
291 protected JCheckBox blcjv = new JCheckBox();
293 protected JCheckBox pileupjv = new JCheckBox();
295 protected JCheckBox clustaljv = new JCheckBox();
297 protected JCheckBox msfjv = new JCheckBox();
299 protected JCheckBox fastajv = new JCheckBox();
301 protected JCheckBox pfamjv = new JCheckBox();
303 protected JCheckBox pirjv = new JCheckBox();
305 protected JCheckBox modellerOutput = new JCheckBox();
307 protected JCheckBox embbedBioJSON = new JCheckBox();
310 * Editing tab components
312 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
314 protected JCheckBox padGaps = new JCheckBox();
316 protected JCheckBox sortByTree = new JCheckBox();
321 protected JPanel wsTab = new JPanel();
324 * Backups tab components
325 * a lot of these are member variables instead of local variables only so that they
326 * can be enabled/disabled easily in one go
329 protected JCheckBox enableBackupFiles = new JCheckBox();
331 protected JPanel presetsPanel = new JPanel();
333 protected JLabel presetsComboLabel = new JLabel();
335 protected JCheckBox customiseCheckbox = new JCheckBox();
337 protected JButton revertButton = new JButton();
339 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
341 private int backupfilesPresetsComboLastSelected = 0;
343 protected JPanel suffixPanel = new JPanel();
345 protected JPanel keepfilesPanel = new JPanel();
347 protected JPanel exampleFilesPanel = new JPanel();
349 protected JTextField suffixTemplate = new JTextField(null, 8);
351 protected JLabel suffixTemplateLabel = new JLabel();
353 protected JLabel suffixDigitsLabel = new JLabel();
355 protected JSpinner suffixDigitsSpinner = new JSpinner();
357 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
359 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
361 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
363 protected JLabel oldBackupFilesLabel = new JLabel();
365 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
367 protected JTextArea backupfilesExampleLabel = new JTextArea();
370 * Creates a new GPreferences object.
372 public GPreferences()
377 public GPreferences(int selectTab)
382 } catch (Exception ex)
384 ex.printStackTrace();
389 * Construct the panel and its tabbed sub-panels.
393 private void jbInit() throws Exception
398 public final static int CONNECTIONS_TAB = 5;
400 private void jbInit(int selectTab) throws Exception
402 final JTabbedPane tabbedPane = new JTabbedPane();
403 this.setLayout(new BorderLayout());
404 JPanel okCancelPanel = initOkCancelPanel();
405 this.add(tabbedPane, BorderLayout.CENTER);
406 this.add(okCancelPanel, BorderLayout.SOUTH);
408 tabbedPane.add(initVisualTab(),
409 MessageManager.getString("label.visual"));
411 tabbedPane.add(initColoursTab(),
412 MessageManager.getString("label.colours"));
414 tabbedPane.add(initOverviewTab(),
415 MessageManager.getString("label.overview"));
417 tabbedPane.add(initStructureTab(),
418 MessageManager.getString("label.structure"));
420 tabbedPane.add(initConnectionsTab(),
421 MessageManager.getString("label.connections"));
423 tabbedPane.add(initBackupsTab(),
424 MessageManager.getString("label.backups"));
426 tabbedPane.add(initLinksTab(),
427 MessageManager.getString("label.urllinks"));
429 tabbedPane.add(initOutputTab(),
430 MessageManager.getString("label.output"));
432 tabbedPane.add(initEditingTab(),
433 MessageManager.getString("label.editing"));
436 * See WsPreferences for the real work of configuring this tab.
438 wsTab.setLayout(new BorderLayout());
439 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
442 * Handler to validate a tab before leaving it - currently only for
445 tabbedPane.addChangeListener(new ChangeListener()
447 private Component lastTab;
450 public void stateChanged(ChangeEvent e)
452 if (lastTab == structureTab
453 && tabbedPane.getSelectedComponent() != structureTab)
455 if (!validateStructure())
457 tabbedPane.setSelectedComponent(structureTab);
461 lastTab = tabbedPane.getSelectedComponent();
466 // select a given tab - currently only for Connections
469 case CONNECTIONS_TAB:
470 tabbedPane.setSelectedComponent(connectTab);
478 * Initialises the Editing tabbed panel.
482 private JPanel initEditingTab()
484 JPanel editingTab = new JPanel();
485 editingTab.setLayout(null);
486 autoCalculateConsCheck.setFont(LABEL_FONT);
487 autoCalculateConsCheck.setText(
488 MessageManager.getString("label.autocalculate_consensus"));
489 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
490 padGaps.setFont(LABEL_FONT);
492 MessageManager.getString("label.pad_gaps_when_editing"));
493 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
494 sortByTree.setFont(LABEL_FONT);
496 .setText(MessageManager.getString("label.sort_with_new_tree"));
497 sortByTree.setToolTipText(MessageManager.getString(
498 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
499 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
500 editingTab.add(autoCalculateConsCheck);
501 editingTab.add(padGaps);
502 editingTab.add(sortByTree);
507 * Initialises the Output tabbed panel.
511 private JPanel initOutputTab()
513 JPanel outputTab = new JPanel();
514 outputTab.setLayout(null);
515 JLabel epsLabel = new JLabel();
516 epsLabel.setFont(LABEL_FONT);
517 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
518 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
519 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
520 epsRendering.setFont(LABEL_FONT);
521 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
522 JLabel jLabel1 = new JLabel();
523 jLabel1.setFont(LABEL_FONT);
524 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
525 jLabel1.setText(MessageManager.getString("label.append_start_end"));
526 jLabel1.setFont(LABEL_FONT);
527 fastajv.setFont(LABEL_FONT);
528 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
529 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
530 blcjv.setText(MessageManager.getString("label.blc") + " ");
531 fastajv.setText(MessageManager.getString("label.fasta") + " ");
532 msfjv.setText(MessageManager.getString("label.msf") + " ");
533 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
534 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
535 msfjv.setFont(LABEL_FONT);
536 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
537 pirjv.setText(MessageManager.getString("label.pir") + " ");
538 JPanel jPanel11 = new JPanel();
539 jPanel11.setFont(LABEL_FONT);
540 TitledBorder titledBorder2 = new TitledBorder(
541 MessageManager.getString("label.file_output"));
542 jPanel11.setBorder(titledBorder2);
543 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
544 GridLayout gridLayout3 = new GridLayout();
545 jPanel11.setLayout(gridLayout3);
546 gridLayout3.setRows(8);
547 blcjv.setFont(LABEL_FONT);
548 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
549 clustaljv.setFont(LABEL_FONT);
550 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
551 pfamjv.setFont(LABEL_FONT);
552 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
553 pileupjv.setFont(LABEL_FONT);
554 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
555 pirjv.setFont(LABEL_FONT);
556 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
557 autoIdWidth.setFont(LABEL_FONT);
559 MessageManager.getString("label.automatically_set_id_width"));
560 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
561 .getString("label.adjusts_width_generated_eps_png")));
562 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
563 autoIdWidth.addActionListener(new ActionListener()
567 public void actionPerformed(ActionEvent e)
569 autoIdWidth_actionPerformed();
572 userIdWidthlabel.setFont(LABEL_FONT);
573 userIdWidthlabel.setText(
574 MessageManager.getString("label.figure_id_column_width"));
575 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
576 .getString("label.manually_specify_width_left_column")));
577 userIdWidthlabel.setToolTipText(
578 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
579 "label.manually_specify_width_left_column")));
580 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
581 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
582 userIdWidth.setText("");
583 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
584 userIdWidth.addActionListener(new ActionListener()
588 public void actionPerformed(ActionEvent e)
590 userIdWidth_actionPerformed();
593 modellerOutput.setFont(LABEL_FONT);
595 .setText(MessageManager.getString("label.use_modeller_output"));
596 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
597 embbedBioJSON.setFont(LABEL_FONT);
598 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
599 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
601 jPanel11.add(jLabel1);
603 jPanel11.add(clustaljv);
604 jPanel11.add(fastajv);
606 jPanel11.add(pfamjv);
607 jPanel11.add(pileupjv);
609 outputTab.add(autoIdWidth);
610 outputTab.add(userIdWidth);
611 outputTab.add(userIdWidthlabel);
612 outputTab.add(modellerOutput);
613 outputTab.add(embbedBioJSON);
614 outputTab.add(epsLabel);
615 outputTab.add(epsRendering);
616 outputTab.add(jPanel11);
621 * Initialises the Connections tabbed panel.
625 private JPanel initConnectionsTab()
627 connectTab = new JPanel();
628 connectTab.setLayout(new GridBagLayout());
630 // Label for browser text box
631 JLabel browserLabel = new JLabel();
632 browserLabel.setFont(LABEL_FONT);
633 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
634 browserLabel.setText(
635 MessageManager.getString("label.default_browser_unix"));
636 defaultBrowser.setFont(LABEL_FONT);
637 defaultBrowser.setText("");
638 final String tooltip = JvSwingUtils.wrapTooltip(true,
639 MessageManager.getString("label.double_click_to_browse"));
640 defaultBrowser.setToolTipText(tooltip);
641 defaultBrowser.addMouseListener(new MouseAdapter()
644 public void mouseClicked(MouseEvent e)
646 if (e.getClickCount() > 1)
648 defaultBrowser_mouseClicked(e);
653 JPanel proxyPanel = initConnTabProxyPanel();
654 initConnTabCheckboxes();
656 // Add default Browser text box
657 connectTab.add(browserLabel,
658 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
659 GridBagConstraints.WEST, GridBagConstraints.NONE,
660 new Insets(10, 0, 5, 5), 5, 1));
661 defaultBrowser.setFont(LABEL_FONT);
662 defaultBrowser.setText("");
664 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
665 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
666 new Insets(10, 0, 5, 10), 30, 1));
668 // Add proxy server panel
669 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
670 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
671 new Insets(10, 0, 5, 12), 4, 10));
673 // Add usage stats, version check and questionnaire checkboxes
674 connectTab.add(usagestats,
675 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
676 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
677 new Insets(0, 2, 5, 5), 70, 1));
678 connectTab.add(questionnaire,
679 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
680 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
681 new Insets(0, 2, 5, 10), 70, 1));
682 connectTab.add(versioncheck,
683 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
684 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
685 new Insets(0, 2, 5, 5), 70, 1));
687 versioncheck.setVisible(false);
689 // Add padding so the panel doesn't look ridiculous
690 JPanel spacePanel = new JPanel();
691 connectTab.add(spacePanel,
692 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
693 GridBagConstraints.WEST, GridBagConstraints.BOTH,
694 new Insets(0, 0, 0, 5), 70, 1));
700 * Initialises the Links tabbed panel.
704 private JPanel initLinksTab()
706 JPanel linkTab = new JPanel();
707 linkTab.setLayout(new GridBagLayout());
709 // Set up table for Url links
710 linkUrlTable.getTableHeader().setReorderingAllowed(false);
711 linkUrlTable.setFillsViewportHeight(true);
712 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
713 linkUrlTable.setAutoCreateRowSorter(true);
714 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
716 // adjust row height so radio buttons actually fit
717 // don't do this in the renderer, it causes the awt thread to activate
719 JRadioButton temp = new JRadioButton();
720 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
722 // Table in scrollpane so that the table is given a scrollbar
723 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
724 linkScrollPane.setBorder(null);
726 // Panel for links functionality
727 JPanel linkPanel = new JPanel(new GridBagLayout());
728 linkPanel.setBorder(new TitledBorder(
729 MessageManager.getString("label.url_linkfrom_sequence_id")));
731 // Put the Url links panel together
733 // Buttons go at top right, resizing only resizes the blank space vertically
734 JPanel buttonPanel = initLinkTabUrlButtons();
735 GridBagConstraints linkConstraints1 = new GridBagConstraints();
736 linkConstraints1.insets = new Insets(0, 0, 5, 0);
737 linkConstraints1.gridx = 0;
738 linkConstraints1.gridy = 0;
739 linkConstraints1.weightx = 1.0;
740 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
741 linkTab.add(buttonPanel, linkConstraints1);
743 // Links table goes at top left, resizing resizes the table
744 GridBagConstraints linkConstraints2 = new GridBagConstraints();
745 linkConstraints2.insets = new Insets(0, 0, 5, 5);
746 linkConstraints2.gridx = 0;
747 linkConstraints2.gridy = 1;
748 linkConstraints2.weightx = 1.0;
749 linkConstraints2.weighty = 1.0;
750 linkConstraints2.fill = GridBagConstraints.BOTH;
751 linkTab.add(linkScrollPane, linkConstraints2);
753 // Filter box and buttons goes at bottom left, resizing resizes the text box
754 JPanel filterPanel = initLinkTabFilterPanel();
755 GridBagConstraints linkConstraints3 = new GridBagConstraints();
756 linkConstraints3.insets = new Insets(0, 0, 0, 5);
757 linkConstraints3.gridx = 0;
758 linkConstraints3.gridy = 2;
759 linkConstraints3.weightx = 1.0;
760 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
761 linkTab.add(filterPanel, linkConstraints3);
766 private JPanel initLinkTabFilterPanel()
768 // Filter textbox and reset button
769 JLabel filterLabel = new JLabel(
770 MessageManager.getString("label.filter"));
771 filterLabel.setFont(LABEL_FONT);
772 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
773 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
775 filterTB.setFont(LABEL_FONT);
776 filterTB.setText("");
778 doReset.setText(MessageManager.getString("action.showall"));
779 userOnly.setText(MessageManager.getString("action.customfilter"));
781 // Panel for filter functionality
782 JPanel filterPanel = new JPanel(new GridBagLayout());
783 filterPanel.setBorder(new TitledBorder("Filter"));
784 GridBagConstraints gbc = new GridBagConstraints();
787 gbc.fill = GridBagConstraints.NONE;
788 gbc.anchor = GridBagConstraints.WEST;
790 filterPanel.add(filterLabel, gbc);
792 GridBagConstraints gbc1 = new GridBagConstraints();
795 gbc1.fill = GridBagConstraints.HORIZONTAL;
796 gbc1.anchor = GridBagConstraints.WEST;
798 filterPanel.add(filterTB, gbc1);
800 GridBagConstraints gbc2 = new GridBagConstraints();
802 gbc2.fill = GridBagConstraints.NONE;
803 gbc2.anchor = GridBagConstraints.WEST;
804 filterPanel.add(doReset, gbc2);
806 GridBagConstraints gbc3 = new GridBagConstraints();
808 gbc3.fill = GridBagConstraints.NONE;
809 gbc3.anchor = GridBagConstraints.WEST;
810 filterPanel.add(userOnly, gbc3);
815 private JPanel initLinkTabUrlButtons()
817 // Buttons for new / edit / delete Url links
818 JButton newLink = new JButton();
819 newLink.setText(MessageManager.getString("action.new"));
821 editLink.setText(MessageManager.getString("action.edit"));
823 deleteLink.setText(MessageManager.getString("action.delete"));
825 // no current selection, so initially disable delete/edit buttons
826 editLink.setEnabled(false);
827 deleteLink.setEnabled(false);
829 newLink.addActionListener(new java.awt.event.ActionListener()
832 public void actionPerformed(ActionEvent e)
834 newLink_actionPerformed(e);
838 editLink.setText(MessageManager.getString("action.edit"));
839 editLink.addActionListener(new java.awt.event.ActionListener()
842 public void actionPerformed(ActionEvent e)
844 editLink_actionPerformed(e);
848 deleteLink.setText(MessageManager.getString("action.delete"));
849 deleteLink.addActionListener(new java.awt.event.ActionListener()
852 public void actionPerformed(ActionEvent e)
854 deleteLink_actionPerformed(e);
858 JPanel buttonPanel = new JPanel(new GridBagLayout());
859 buttonPanel.setBorder(new TitledBorder("Edit links"));
860 GridBagConstraints gbc = new GridBagConstraints();
863 gbc.fill = GridBagConstraints.NONE;
864 buttonPanel.add(newLink, gbc);
866 GridBagConstraints gbc1 = new GridBagConstraints();
869 gbc1.fill = GridBagConstraints.NONE;
870 buttonPanel.add(editLink, gbc1);
872 GridBagConstraints gbc2 = new GridBagConstraints();
875 gbc2.fill = GridBagConstraints.NONE;
876 buttonPanel.add(deleteLink, gbc2);
878 GridBagConstraints gbc3 = new GridBagConstraints();
881 gbc3.fill = GridBagConstraints.HORIZONTAL;
883 JPanel spacePanel = new JPanel();
884 spacePanel.setBorder(null);
885 buttonPanel.add(spacePanel, gbc3);
891 * Initialises the proxy server panel in the Connections tab
893 * @return the proxy server panel
895 private JPanel initConnTabProxyPanel()
897 // Label for server text box
898 serverLabel.setText(MessageManager.getString("label.host") + ": ");
899 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
900 serverLabel.setFont(LABEL_FONT);
901 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
902 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
903 serverLabel2.setFont(LABEL_FONT);
905 // Proxy server and port text boxes
906 proxyServerHttpTB.setFont(LABEL_FONT);
907 proxyServerHttpTB.setColumns(40);
908 proxyPortHttpTB.setFont(LABEL_FONT);
909 proxyPortHttpTB.setColumns(4);
910 proxyServerHttpsTB.setFont(LABEL_FONT);
911 proxyServerHttpsTB.setColumns(40);
912 proxyPortHttpsTB.setFont(LABEL_FONT);
913 proxyPortHttpsTB.setColumns(4);
914 proxyAuthUsernameTB.setFont(LABEL_FONT);
915 proxyAuthUsernameTB.setColumns(30);
916 proxyAuthPasswordTB.setFont(LABEL_FONT);
917 proxyAuthPasswordTB.setColumns(30);
919 // Label for Port text box
920 portLabel.setFont(LABEL_FONT);
921 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
922 portLabel.setText(MessageManager.getString("label.port") + ": ");
923 portLabel2.setFont(LABEL_FONT);
924 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
925 portLabel2.setText(MessageManager.getString("label.port") + ": ");
927 httpLabel.setText("HTTP");
928 httpLabel.setFont(LABEL_FONT_BOLD);
929 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
930 httpsLabel.setText("HTTPS");
931 httpsLabel.setFont(LABEL_FONT_BOLD);
932 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
934 proxyAuthUsernameLabel
935 .setText(MessageManager.getString("label.username") + ": ");
936 proxyAuthUsernameLabel.setFont(LABEL_FONT);
937 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
938 proxyAuthPasswordLabel
939 .setText(MessageManager.getString("label.password") + ": ");
940 proxyAuthPasswordLabel.setFont(LABEL_FONT);
941 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
942 passwordNotStoredLabel.setText(
943 "(" + MessageManager.getString("label.not_stored") + ")");
944 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
945 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
947 // Proxy type radio buttons
948 noProxy.setFont(LABEL_FONT);
949 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
950 noProxy.setText(MessageManager.getString("label.no_proxy"));
951 systemProxy.setFont(LABEL_FONT);
952 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
953 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
954 displayUserHostPort(Cache.startupProxyProperties[4],
955 Cache.startupProxyProperties[0],
956 Cache.startupProxyProperties[1]),
957 displayUserHostPort(Cache.startupProxyProperties[6],
958 Cache.startupProxyProperties[2],
959 Cache.startupProxyProperties[3])));
960 customProxy.setFont(LABEL_FONT);
961 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
963 MessageManager.getString("label.use_proxy_server") + ":");
964 ActionListener al = new ActionListener()
967 public void actionPerformed(ActionEvent e)
969 proxyType_actionPerformed();
972 noProxy.addActionListener(al);
973 systemProxy.addActionListener(al);
974 customProxy.addActionListener(al);
975 proxyType.add(noProxy);
976 proxyType.add(systemProxy);
977 proxyType.add(customProxy);
979 proxyAuth.setFont(LABEL_FONT);
980 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
981 proxyAuth.setText(MessageManager.getString("label.auth_required"));
982 proxyAuth.addActionListener(new ActionListener()
985 public void actionPerformed(ActionEvent e)
987 proxyAuth_actionPerformed();
991 setCustomProxyEnabled();
993 // Make proxy server panel
994 JPanel proxyPanel = new JPanel();
995 TitledBorder titledBorder1 = new TitledBorder(
996 MessageManager.getString("label.proxy_servers"));
997 proxyPanel.setBorder(titledBorder1);
998 proxyPanel.setLayout(new GridBagLayout());
999 GridBagConstraints gbc = new GridBagConstraints();
1000 gbc.fill = GridBagConstraints.HORIZONTAL;
1003 GridBagConstraints c = new GridBagConstraints();
1004 // Proxy type radio buttons (3)
1005 JPanel ptPanel = new JPanel();
1006 ptPanel.setLayout(new GridBagLayout());
1011 c.fill = GridBagConstraints.HORIZONTAL;
1012 ptPanel.add(noProxy, c);
1014 ptPanel.add(systemProxy, c);
1016 ptPanel.add(customProxy, c);
1019 proxyPanel.add(ptPanel, gbc);
1021 // host and port text boxes
1022 JPanel hpPanel = new JPanel();
1023 hpPanel.setLayout(new GridBagLayout());
1024 // HTTP host port row
1029 c.anchor = GridBagConstraints.LINE_START;
1030 hpPanel.add(httpLabel, c);
1034 c.anchor = GridBagConstraints.LINE_END;
1035 hpPanel.add(serverLabel, c);
1039 c.anchor = GridBagConstraints.LINE_START;
1040 hpPanel.add(proxyServerHttpTB, c);
1044 c.anchor = GridBagConstraints.LINE_END;
1045 hpPanel.add(portLabel, c);
1049 c.anchor = GridBagConstraints.LINE_START;
1050 hpPanel.add(proxyPortHttpTB, c);
1052 // HTTPS host port row
1057 c.anchor = GridBagConstraints.LINE_START;
1058 hpPanel.add(httpsLabel, c);
1061 c.anchor = GridBagConstraints.LINE_END;
1062 hpPanel.add(serverLabel2, c);
1065 c.anchor = GridBagConstraints.LINE_START;
1066 hpPanel.add(proxyServerHttpsTB, c);
1069 c.anchor = GridBagConstraints.LINE_END;
1070 hpPanel.add(portLabel2, c);
1073 c.anchor = GridBagConstraints.LINE_START;
1074 hpPanel.add(proxyPortHttpsTB, c);
1077 proxyPanel.add(hpPanel, gbc);
1079 // Require authentication checkbox
1081 proxyPanel.add(proxyAuth, gbc);
1083 // username and password
1084 JPanel upPanel = new JPanel();
1085 upPanel.setLayout(new GridBagLayout());
1091 c.anchor = GridBagConstraints.LINE_END;
1092 upPanel.add(proxyAuthUsernameLabel, c);
1096 c.anchor = GridBagConstraints.LINE_START;
1097 upPanel.add(proxyAuthUsernameTB, c);
1103 c.anchor = GridBagConstraints.LINE_END;
1104 upPanel.add(proxyAuthPasswordLabel, c);
1108 c.anchor = GridBagConstraints.LINE_START;
1109 upPanel.add(proxyAuthPasswordTB, c);
1113 c.anchor = GridBagConstraints.LINE_START;
1114 upPanel.add(passwordNotStoredLabel, c);
1117 proxyPanel.add(upPanel, gbc);
1122 private String displayUserHostPort(String user, String host, String port)
1124 boolean hostBlank = (host == null || host.isEmpty());
1125 boolean portBlank = (port == null || port.isEmpty());
1126 if (hostBlank && portBlank)
1128 return MessageManager.getString("label.none");
1131 StringBuilder sb = new StringBuilder();
1134 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1138 sb.append(hostBlank ? "" : host);
1144 return sb.toString();
1148 * Initialises the checkboxes in the Connections tab
1150 private void initConnTabCheckboxes()
1152 // Usage stats checkbox label
1154 MessageManager.getString("label.send_usage_statistics"));
1155 usagestats.setFont(LABEL_FONT);
1156 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1157 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1159 // Questionnaire checkbox label
1160 questionnaire.setText(
1161 MessageManager.getString("label.check_for_questionnaires"));
1162 questionnaire.setFont(LABEL_FONT);
1163 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1164 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1166 // Check for latest version checkbox label
1167 versioncheck.setText(
1168 MessageManager.getString("label.check_for_latest_version"));
1169 versioncheck.setFont(LABEL_FONT);
1170 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1171 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1175 * Initialises the parent panel which contains the tabbed sections.
1179 private JPanel initOkCancelPanel()
1181 JButton ok = new JButton();
1182 ok.setText(MessageManager.getString("action.ok"));
1183 ok.addActionListener(new ActionListener()
1186 public void actionPerformed(ActionEvent e)
1188 ok_actionPerformed(e);
1191 JButton cancel = new JButton();
1192 cancel.setText(MessageManager.getString("action.cancel"));
1193 cancel.addActionListener(new ActionListener()
1196 public void actionPerformed(ActionEvent e)
1198 cancel_actionPerformed(e);
1201 JPanel okCancelPanel = new JPanel();
1202 okCancelPanel.add(ok);
1203 okCancelPanel.add(cancel);
1204 return okCancelPanel;
1208 * Initialises the Colours tabbed panel.
1212 private JPanel initColoursTab()
1214 JPanel coloursTab = new JPanel();
1215 coloursTab.setBorder(new TitledBorder(
1216 MessageManager.getString("action.open_new_alignment")));
1217 coloursTab.setLayout(new FlowLayout());
1218 JLabel mincolourLabel = new JLabel();
1219 mincolourLabel.setFont(LABEL_FONT);
1220 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1221 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1222 minColour.setFont(LABEL_FONT);
1223 minColour.setBorder(BorderFactory.createEtchedBorder());
1224 minColour.setPreferredSize(new Dimension(40, 20));
1225 minColour.addMouseListener(new MouseAdapter()
1228 public void mousePressed(MouseEvent e)
1230 minColour_actionPerformed(minColour);
1233 JLabel maxcolourLabel = new JLabel();
1234 maxcolourLabel.setFont(LABEL_FONT);
1235 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1236 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1237 maxColour.setFont(LABEL_FONT);
1238 maxColour.setBorder(BorderFactory.createEtchedBorder());
1239 maxColour.setPreferredSize(new Dimension(40, 20));
1240 maxColour.addMouseListener(new MouseAdapter()
1243 public void mousePressed(MouseEvent e)
1245 maxColour_actionPerformed(maxColour);
1249 protColour.setFont(LABEL_FONT);
1250 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1251 JLabel protColourLabel = new JLabel();
1252 protColourLabel.setFont(LABEL_FONT);
1253 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1254 protColourLabel.setText(
1255 MessageManager.getString("label.prot_alignment_colour") + " ");
1256 JvSwingUtils.addtoLayout(coloursTab,
1258 .getString("label.default_colour_scheme_for_alignment"),
1259 protColourLabel, protColour);
1261 nucColour.setFont(LABEL_FONT);
1262 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1263 JLabel nucColourLabel = new JLabel();
1264 nucColourLabel.setFont(LABEL_FONT);
1265 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1266 nucColourLabel.setText(
1267 MessageManager.getString("label.nuc_alignment_colour") + " ");
1268 JvSwingUtils.addtoLayout(coloursTab,
1270 .getString("label.default_colour_scheme_for_alignment"),
1271 nucColourLabel, nucColour);
1273 JPanel annotationShding = new JPanel();
1274 annotationShding.setBorder(new TitledBorder(
1275 MessageManager.getString("label.annotation_shading_default")));
1276 annotationShding.setLayout(new GridLayout(1, 2));
1277 JvSwingUtils.addtoLayout(annotationShding,
1278 MessageManager.getString(
1279 "label.default_minimum_colour_annotation_shading"),
1280 mincolourLabel, minColour);
1281 JvSwingUtils.addtoLayout(annotationShding,
1282 MessageManager.getString(
1283 "label.default_maximum_colour_annotation_shading"),
1284 maxcolourLabel, maxColour);
1285 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1290 * Initialises the Overview tabbed panel.
1294 private JPanel initOverviewTab()
1296 JPanel overviewPanel = new JPanel();
1297 overviewPanel.setBorder(new TitledBorder(
1298 MessageManager.getString("label.overview_settings")));
1300 gapColour.setFont(LABEL_FONT);
1301 // fixing the border colours stops apparent colour bleed from the panel
1302 gapColour.setBorder(
1303 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1304 gapColour.setPreferredSize(new Dimension(40, 20));
1305 gapColour.addMouseListener(new MouseAdapter()
1308 public void mousePressed(MouseEvent e)
1310 gapColour_actionPerformed(gapColour);
1314 hiddenColour.setFont(LABEL_FONT);
1315 // fixing the border colours stops apparent colour bleed from the panel
1316 hiddenColour.setBorder(
1317 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1318 hiddenColour.setPreferredSize(new Dimension(40, 20));
1319 hiddenColour.addMouseListener(new MouseAdapter()
1322 public void mousePressed(MouseEvent e)
1324 hiddenColour_actionPerformed(hiddenColour);
1328 useLegacyGap = new JCheckBox(
1329 MessageManager.getString("label.ov_legacy_gap"));
1330 useLegacyGap.setFont(LABEL_FONT);
1331 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1332 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1333 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1334 gapLabel.setFont(LABEL_FONT);
1335 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1336 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1337 showHiddenAtStart = new JCheckBox(
1338 MessageManager.getString("label.ov_show_hide_default"));
1339 showHiddenAtStart.setFont(LABEL_FONT);
1340 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1341 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1342 JLabel hiddenLabel = new JLabel(
1343 MessageManager.getString("label.hidden_colour"));
1344 hiddenLabel.setFont(LABEL_FONT);
1345 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1346 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1348 useLegacyGap.addActionListener(new ActionListener()
1351 public void actionPerformed(ActionEvent e)
1353 useLegacyGaps_actionPerformed(e);
1357 overviewPanel.setLayout(new GridBagLayout());
1358 GridBagConstraints c1 = new GridBagConstraints();
1360 c1.fill = GridBagConstraints.HORIZONTAL;
1365 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1366 overviewPanel.add(useLegacyGap, c1);
1368 GridBagConstraints c2 = new GridBagConstraints();
1369 c2.fill = GridBagConstraints.HORIZONTAL;
1372 c2.insets = new Insets(0, 15, 0, 10);
1373 overviewPanel.add(gapLabel, c2);
1375 GridBagConstraints c3 = new GridBagConstraints();
1376 c3.fill = GridBagConstraints.HORIZONTAL;
1379 c3.insets = new Insets(0, 0, 0, 15);
1380 overviewPanel.add(gapColour, c3);
1382 GridBagConstraints c4 = new GridBagConstraints();
1383 c4.fill = GridBagConstraints.HORIZONTAL;
1387 overviewPanel.add(showHiddenAtStart, c4);
1389 GridBagConstraints c5 = new GridBagConstraints();
1390 c5.fill = GridBagConstraints.HORIZONTAL;
1393 c5.insets = new Insets(0, 15, 0, 10);
1394 overviewPanel.add(hiddenLabel, c5);
1396 GridBagConstraints c6 = new GridBagConstraints();
1397 c6.fill = GridBagConstraints.HORIZONTAL;
1400 c6.insets = new Insets(0, 0, 0, 15);
1401 overviewPanel.add(hiddenColour, c6);
1403 JButton resetButton = new JButton(
1404 MessageManager.getString("label.reset_to_defaults"));
1406 resetButton.addActionListener(new ActionListener()
1409 public void actionPerformed(ActionEvent e)
1411 resetOvDefaults_actionPerformed(e);
1415 GridBagConstraints c7 = new GridBagConstraints();
1416 c7.fill = GridBagConstraints.NONE;
1419 c7.insets = new Insets(10, 0, 0, 0);
1420 c7.anchor = GridBagConstraints.WEST;
1421 overviewPanel.add(resetButton, c7);
1423 // Add padding so the panel doesn't look ridiculous
1424 JPanel spacePanel = new JPanel();
1425 overviewPanel.add(spacePanel,
1426 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1427 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1428 new Insets(0, 0, 0, 5), 0, 0));
1430 return overviewPanel;
1434 * Initialises the Structure tabbed panel.
1438 private JPanel initStructureTab()
1440 structureTab = new JPanel();
1442 structureTab.setBorder(new TitledBorder(
1443 MessageManager.getString("label.structure_options")));
1444 structureTab.setLayout(null);
1445 final int width = 400;
1446 final int height = 22;
1447 final int lineSpacing = 25;
1450 structFromPdb.setFont(LABEL_FONT);
1452 .setText(MessageManager.getString("label.struct_from_pdb"));
1453 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1454 structFromPdb.addActionListener(new ActionListener()
1457 public void actionPerformed(ActionEvent e)
1459 boolean selected = structFromPdb.isSelected();
1460 // enable other options only when the first is checked
1461 useRnaView.setEnabled(selected);
1462 addSecondaryStructure.setEnabled(selected);
1463 addTempFactor.setEnabled(selected);
1466 structureTab.add(structFromPdb);
1468 // indent checkboxes that are conditional on the first one
1469 ypos += lineSpacing;
1470 useRnaView.setFont(LABEL_FONT);
1471 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1472 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1473 structureTab.add(useRnaView);
1475 ypos += lineSpacing;
1476 addSecondaryStructure.setFont(LABEL_FONT);
1477 addSecondaryStructure
1478 .setText(MessageManager.getString("label.autoadd_secstr"));
1479 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1480 structureTab.add(addSecondaryStructure);
1482 ypos += lineSpacing;
1483 addTempFactor.setFont(LABEL_FONT);
1484 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1485 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1486 structureTab.add(addTempFactor);
1488 ypos += lineSpacing;
1489 JLabel viewerLabel = new JLabel();
1490 viewerLabel.setFont(LABEL_FONT);
1491 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1492 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1493 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1494 structureTab.add(viewerLabel);
1496 structViewer.setFont(LABEL_FONT);
1497 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1498 structViewer.addItem(ViewerType.JMOL.name());
1499 structViewer.addItem(ViewerType.CHIMERA.name());
1500 structViewer.addActionListener(new ActionListener()
1503 public void actionPerformed(ActionEvent e)
1505 structureViewer_actionPerformed(
1506 (String) structViewer.getSelectedItem());
1509 structureTab.add(structViewer);
1511 ypos += lineSpacing;
1512 JLabel pathLabel = new JLabel();
1513 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1514 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1515 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1516 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1517 structureTab.add(pathLabel);
1519 chimeraPath.setFont(LABEL_FONT);
1520 chimeraPath.setText("");
1521 final String tooltip = JvSwingUtils.wrapTooltip(true,
1522 MessageManager.getString("label.chimera_path_tip"));
1523 chimeraPath.setToolTipText(tooltip);
1524 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1525 chimeraPath.addMouseListener(new MouseAdapter()
1528 public void mouseClicked(MouseEvent e)
1530 if (e.getClickCount() == 2)
1532 String chosen = openFileChooser();
1535 chimeraPath.setText(chosen);
1540 structureTab.add(chimeraPath);
1542 ypos += lineSpacing;
1543 nwMapping.setFont(LABEL_FONT);
1544 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1545 siftsMapping.setFont(LABEL_FONT);
1546 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1547 mappingMethod.add(nwMapping);
1548 mappingMethod.add(siftsMapping);
1549 JPanel mappingPanel = new JPanel();
1550 mappingPanel.setFont(LABEL_FONT);
1551 TitledBorder mmTitledBorder = new TitledBorder(
1552 MessageManager.getString("label.mapping_method"));
1553 mmTitledBorder.setTitleFont(LABEL_FONT);
1554 mappingPanel.setBorder(mmTitledBorder);
1555 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1556 // GridLayout mappingLayout = new GridLayout();
1557 mappingPanel.setLayout(new GridLayout());
1558 mappingPanel.add(nwMapping);
1559 mappingPanel.add(siftsMapping);
1560 structureTab.add(mappingPanel);
1562 ypos += lineSpacing;
1563 ypos += lineSpacing;
1564 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1565 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1566 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1567 structureTab.add(docFieldPref);
1569 return structureTab;
1573 * Action on choosing a structure viewer from combobox options.
1575 * @param selectedItem
1577 protected void structureViewer_actionPerformed(String selectedItem)
1582 * Show a dialog for the user to choose a file. Returns the chosen path, or
1587 protected String openFileChooser()
1589 String choice = null;
1590 JFileChooser chooser = new JFileChooser();
1592 // chooser.setFileView(new JalviewFileView());
1593 chooser.setDialogTitle(
1594 MessageManager.getString("label.open_local_file"));
1595 chooser.setToolTipText(MessageManager.getString("action.open"));
1597 int value = chooser.showOpenDialog(this);
1599 if (value == JFileChooser.APPROVE_OPTION)
1601 choice = chooser.getSelectedFile().getPath();
1607 * Validate the structure tab preferences; if invalid, set focus on this tab.
1611 protected boolean validateStructure(FocusEvent e)
1613 if (!validateStructure())
1615 e.getComponent().requestFocusInWindow();
1621 protected boolean validateStructure()
1627 * Initialises the Visual tabbed panel.
1631 private JPanel initVisualTab()
1633 JPanel visualTab = new JPanel();
1634 visualTab.setBorder(new TitledBorder(
1635 MessageManager.getString("action.open_new_alignment")));
1636 visualTab.setLayout(null);
1637 fullScreen.setFont(LABEL_FONT);
1638 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1639 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1640 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1641 quality.setEnabled(false);
1642 quality.setFont(LABEL_FONT);
1643 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1644 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1645 quality.setSelected(true);
1646 quality.setText(MessageManager.getString("label.quality"));
1647 conservation.setEnabled(false);
1648 conservation.setFont(LABEL_FONT);
1649 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1650 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1651 conservation.setSelected(true);
1652 conservation.setText(MessageManager.getString("label.conservation"));
1653 identity.setEnabled(false);
1654 identity.setFont(LABEL_FONT);
1655 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1656 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1657 identity.setSelected(true);
1658 identity.setText(MessageManager.getString("label.consensus"));
1659 showOccupancy.setFont(LABEL_FONT);
1660 showOccupancy.setEnabled(false);
1661 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1662 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1663 showOccupancy.setSelected(true);
1664 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1666 JLabel showGroupbits = new JLabel();
1667 showGroupbits.setFont(LABEL_FONT);
1668 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1669 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1671 .setText(MessageManager.getString("action.show_group") + ":");
1672 JLabel showConsensbits = new JLabel();
1673 showConsensbits.setFont(LABEL_FONT);
1674 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1675 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1677 .setText(MessageManager.getString("label.consensus") + ":");
1678 showConsensHistogram.setEnabled(false);
1679 showConsensHistogram.setFont(LABEL_FONT);
1680 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1681 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1682 showConsensHistogram.setSelected(true);
1683 showConsensHistogram
1684 .setText(MessageManager.getString("label.histogram"));
1685 showConsensLogo.setEnabled(false);
1686 showConsensLogo.setFont(LABEL_FONT);
1687 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1688 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1689 showConsensLogo.setSelected(true);
1690 showConsensLogo.setText(MessageManager.getString("label.logo"));
1691 showGroupConsensus.setEnabled(false);
1692 showGroupConsensus.setFont(LABEL_FONT);
1693 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1694 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1695 showGroupConsensus.setSelected(true);
1696 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1697 showGroupConservation.setEnabled(false);
1698 showGroupConservation.setFont(LABEL_FONT);
1699 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1700 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1701 showGroupConservation.setSelected(true);
1702 showGroupConservation
1703 .setText(MessageManager.getString("label.conservation"));
1704 showNpTooltip.setEnabled(true);
1705 showNpTooltip.setFont(LABEL_FONT);
1706 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1707 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1708 showNpTooltip.setSelected(true);
1709 showNpTooltip.setText(
1710 MessageManager.getString("label.non_positional_features"));
1711 showDbRefTooltip.setEnabled(true);
1712 showDbRefTooltip.setFont(LABEL_FONT);
1713 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1714 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1715 showDbRefTooltip.setSelected(true);
1717 .setText(MessageManager.getString("label.database_references"));
1718 annotations.setFont(LABEL_FONT);
1719 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1720 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1721 annotations.setSelected(true);
1722 annotations.setText(MessageManager.getString("label.show_annotations"));
1723 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1724 annotations.addActionListener(new ActionListener()
1727 public void actionPerformed(ActionEvent e)
1729 annotations_actionPerformed(e);
1732 identity.addActionListener(new ActionListener()
1735 public void actionPerformed(ActionEvent e)
1737 annotations_actionPerformed(e);
1740 showGroupConsensus.addActionListener(new ActionListener()
1743 public void actionPerformed(ActionEvent e)
1745 annotations_actionPerformed(e);
1748 showUnconserved.setFont(LABEL_FONT);
1749 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1750 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1751 showUnconserved.setSelected(true);
1753 .setText(MessageManager.getString("action.show_unconserved"));
1754 showUnconserved.addActionListener(new ActionListener()
1757 public void actionPerformed(ActionEvent e)
1759 showunconserved_actionPerformed(e);
1763 // TODO these are not yet added to / action from Preferences
1764 // JCheckBox shareSelections = new JCheckBox();
1765 // shareSelections.setFont(verdana11);
1766 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1767 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1768 // shareSelections.setSelected(true);
1769 // shareSelections.setText(MessageManager
1770 // .getString("label.share_selection_across_views"));
1771 // JCheckBox followHighlight = new JCheckBox();
1772 // followHighlight.setFont(verdana11);
1773 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1774 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1775 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1776 // followHighlight.setSelected(true);
1777 // followHighlight.setText(MessageManager
1778 // .getString("label.scroll_highlighted_regions"));
1780 seqLimit.setFont(LABEL_FONT);
1781 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1782 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1783 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1784 smoothFont.setFont(LABEL_FONT);
1785 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1786 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1787 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1788 scaleProteinToCdna.setFont(LABEL_FONT);
1789 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1790 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1791 scaleProteinToCdna.setText(
1792 MessageManager.getString("label.scale_protein_to_cdna"));
1793 scaleProteinToCdna.setToolTipText(
1794 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1795 JLabel gapLabel = new JLabel();
1796 gapLabel.setFont(LABEL_FONT);
1797 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1798 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1799 JLabel fontLabel = new JLabel();
1800 fontLabel.setFont(LABEL_FONT);
1801 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1802 fontLabel.setText(MessageManager.getString("label.font"));
1803 fontSizeCB.setFont(LABEL_FONT);
1804 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1805 fontStyleCB.setFont(LABEL_FONT);
1806 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1807 fontNameCB.setFont(LABEL_FONT);
1808 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1809 gapSymbolCB.setFont(LABEL_FONT);
1810 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1811 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1812 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1813 gapSymbolCB.setRenderer(dlcr);
1815 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1816 startupCheckbox.setFont(LABEL_FONT);
1817 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1818 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1819 startupCheckbox.setSelected(true);
1820 startupFileTextfield.setFont(LABEL_FONT);
1821 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1822 final String tooltip = JvSwingUtils.wrapTooltip(true,
1823 MessageManager.getString("label.double_click_to_browse"));
1824 startupFileTextfield.setToolTipText(tooltip);
1825 startupFileTextfield.addMouseListener(new MouseAdapter()
1828 public void mouseClicked(MouseEvent e)
1830 if (e.getClickCount() > 1)
1832 startupFileTextfield_mouseClicked();
1837 sortby.setFont(LABEL_FONT);
1838 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1839 JLabel sortLabel = new JLabel();
1840 sortLabel.setFont(LABEL_FONT);
1841 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1842 sortLabel.setText(MessageManager.getString("label.sort_by"));
1843 sortAnnBy.setFont(LABEL_FONT);
1844 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1845 JLabel sortAnnLabel = new JLabel();
1846 sortAnnLabel.setFont(LABEL_FONT);
1847 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1848 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1849 sortAutocalc.setFont(LABEL_FONT);
1850 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1852 JPanel annsettingsPanel = new JPanel();
1853 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1854 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1855 annsettingsPanel.setBorder(new EtchedBorder());
1856 visualTab.add(annsettingsPanel);
1857 Border jb = new EmptyBorder(1, 1, 4, 5);
1858 annotations.setBorder(jb);
1859 showOccupancy.setBorder(jb);
1860 quality.setBorder(jb);
1861 conservation.setBorder(jb);
1862 identity.setBorder(jb);
1863 showConsensbits.setBorder(jb);
1864 showGroupbits.setBorder(jb);
1865 showGroupConsensus.setBorder(jb);
1866 showGroupConservation.setBorder(jb);
1867 showConsensHistogram.setBorder(jb);
1868 showConsensLogo.setBorder(jb);
1870 JPanel autoAnnotSettings = new JPanel();
1871 annsettingsPanel.add(autoAnnotSettings);
1872 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1873 autoAnnotSettings.add(annotations);
1874 autoAnnotSettings.add(quality);
1875 // second row of autoannotation box
1876 autoAnnotSettings = new JPanel();
1877 annsettingsPanel.add(autoAnnotSettings);
1879 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1880 autoAnnotSettings.add(conservation);
1881 autoAnnotSettings.add(identity);
1882 autoAnnotSettings.add(showOccupancy);
1883 autoAnnotSettings.add(showGroupbits);
1884 autoAnnotSettings.add(showGroupConservation);
1885 autoAnnotSettings.add(showGroupConsensus);
1886 autoAnnotSettings.add(showConsensbits);
1887 autoAnnotSettings.add(showConsensHistogram);
1888 autoAnnotSettings.add(showConsensLogo);
1890 JPanel tooltipSettings = new JPanel();
1891 tooltipSettings.setBorder(new TitledBorder(
1892 MessageManager.getString("label.sequence_id_tooltip")));
1893 tooltipSettings.setBounds(173, 140, 220, 62);
1894 tooltipSettings.setLayout(new GridLayout(2, 1));
1895 tooltipSettings.add(showDbRefTooltip);
1896 tooltipSettings.add(showNpTooltip);
1897 visualTab.add(tooltipSettings);
1899 wrap.setFont(LABEL_FONT);
1900 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1901 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1902 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1903 rightAlign.setFont(LABEL_FONT);
1904 rightAlign.setForeground(Color.black);
1905 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1906 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1907 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1908 idItalics.setFont(LABEL_FONT_ITALIC);
1909 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1910 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1912 MessageManager.getString("label.sequence_name_italics"));
1913 openoverv.setFont(LABEL_FONT);
1914 openoverv.setActionCommand(
1915 MessageManager.getString("label.open_overview"));
1916 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1917 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1918 openoverv.setText(MessageManager.getString("label.open_overview"));
1919 JPanel jPanel2 = new JPanel();
1920 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1921 jPanel2.setLayout(new GridLayout(14, 1));
1922 jPanel2.add(fullScreen);
1923 jPanel2.add(openoverv);
1924 jPanel2.add(seqLimit);
1925 jPanel2.add(rightAlign);
1926 jPanel2.add(fontLabel);
1927 jPanel2.add(showUnconserved);
1928 jPanel2.add(idItalics);
1929 jPanel2.add(smoothFont);
1930 jPanel2.add(scaleProteinToCdna);
1931 jPanel2.add(gapLabel);
1933 jPanel2.add(sortLabel);
1934 jPanel2.add(sortAnnLabel);
1935 jPanel2.add(startupCheckbox);
1936 visualTab.add(jPanel2);
1937 visualTab.add(startupFileTextfield);
1938 visualTab.add(sortby);
1939 visualTab.add(sortAnnBy);
1940 visualTab.add(sortAutocalc);
1941 visualTab.add(gapSymbolCB);
1942 visualTab.add(fontNameCB);
1943 visualTab.add(fontSizeCB);
1944 visualTab.add(fontStyleCB);
1949 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1952 protected void loadLastSavedBackupsOptions()
1954 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1955 .getSavedBackupEntry();
1957 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1959 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1960 .createBackupFilesPresetEntry(Cache
1961 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1962 if (backupfilesCustomEntry == null)
1964 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1965 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1967 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1968 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1969 backupfilesCustomEntry);
1971 setComboIntStringKey(backupfilesPresetsCombo,
1972 Cache.getDefault(BackupFiles.NS + "_PRESET",
1973 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1975 backupsSetOptions(savedPreset);
1977 backupsOptionsSetEnabled();
1978 updateBackupFilesExampleLabel();
1981 private boolean warnAboutSuffixReverseChange()
1983 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1984 .getSavedBackupEntry();
1985 boolean savedSuffixReverse = bfpe.reverse;
1986 int savedSuffixDigits = bfpe.digits;
1987 String savedSuffixTemplate = bfpe.suffix;
1989 boolean nowSuffixReverse = suffixReverse.isSelected();
1990 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1991 String nowSuffixTemplate = suffixTemplate.getText();
1992 return nowSuffixReverse != savedSuffixReverse
1993 && nowSuffixDigits == savedSuffixDigits
1994 && nowSuffixTemplate != null
1995 && nowSuffixTemplate.equals(savedSuffixTemplate);
1999 * Initialises the Backups tabbed panel.
2003 private JPanel initBackupsTab()
2005 JPanel backupsTab = new JPanel();
2006 backupsTab.setBorder(new TitledBorder(
2007 MessageManager.getString("label.backup_files")));
2008 backupsTab.setLayout(new GridBagLayout());
2010 GridBagConstraints gbc = new GridBagConstraints();
2013 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2014 gbc.fill = GridBagConstraints.NONE;
2016 initBackupsTabPresetsPanel();
2017 initBackupsTabSuffixPanel();
2018 initBackupsTabKeepFilesPanel();
2019 initBackupsTabFilenameExamplesPanel();
2021 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2023 .setText(MessageManager.getString("label.enable_backupfiles"));
2024 enableBackupFiles.addActionListener(new ActionListener()
2027 public void actionPerformed(ActionEvent e)
2029 // enable other options only when the first is checked
2030 backupsOptionsSetEnabled();
2034 // enable checkbox 1 col
2038 gbc.gridy = 0; // row 0
2039 backupsTab.add(enableBackupFiles, gbc);
2041 // summary of scheme box (over two rows)
2045 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2046 gbc.fill = GridBagConstraints.BOTH;
2047 backupsTab.add(exampleFilesPanel, gbc);
2049 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2050 gbc.fill = GridBagConstraints.NONE;
2052 // fill empty space on right
2055 backupsTab.add(new JPanel(), gbc);
2060 gbc.gridy++; // row 1
2061 backupsTab.add(presetsPanel, gbc);
2063 // now using whole row
2068 gbc.gridy++; // row 2
2069 backupsTab.add(keepfilesPanel, gbc);
2071 // filename strategy box
2072 gbc.gridy++; // row 3
2073 backupsTab.add(suffixPanel, gbc);
2076 gbc.gridy++; // row 4
2078 backupsTab.add(new JPanel(), gbc);
2080 backupsOptionsSetEnabled();
2084 private JPanel initBackupsTabPresetsPanel()
2087 String title = MessageManager.getString("label.schemes");
2089 presetsPanel.setLayout(new GridBagLayout());
2091 GridBagConstraints gbc = new GridBagConstraints();
2094 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2095 gbc.fill = GridBagConstraints.NONE;
2103 presetsComboLabel = new JLabel(title + ":");
2104 presetsPanel.add(presetsComboLabel, gbc);
2106 List<Object> entries = Arrays.asList(
2107 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2108 List<String> tooltips = Arrays.asList(
2109 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2110 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2113 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2115 backupfilesPresetsCombo
2116 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2120 backupfilesPresetsCombo.addActionListener(new ActionListener()
2123 public void actionPerformed(ActionEvent e)
2125 int key = getComboIntStringKey(backupfilesPresetsCombo);
2126 if (!customiseCheckbox.isSelected())
2128 backupfilesPresetsComboLastSelected = key;
2130 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2132 if (customiseCheckbox.isSelected())
2134 // got here by clicking on customiseCheckbox so don't change the
2136 backupfilesCustomOptionsSetEnabled();
2140 backupsTabUpdatePresets();
2141 backupfilesCustomOptionsSetEnabled();
2146 customiseCheckbox.setSelected(false);
2147 backupsTabUpdatePresets();
2148 backupfilesCustomOptionsSetEnabled();
2153 // dropdown list of preset schemes
2155 presetsPanel.add(backupfilesPresetsCombo, gbc);
2157 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2158 revertButton.setToolTipText(
2159 MessageManager.getString("label.cancel_changes_description"));
2160 revertButton.addActionListener(new ActionListener()
2163 public void actionPerformed(ActionEvent e)
2166 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2167 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2168 backupfilesCustomOptionsSetEnabled();
2172 revertButton.setFont(LABEL_FONT);
2174 customiseCheckbox.setFont(LABEL_FONT);
2175 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2176 customiseCheckbox.addActionListener(new ActionListener()
2179 public void actionPerformed(ActionEvent e)
2181 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2182 if (customiseCheckbox.isSelected())
2184 backupfilesPresetsComboLastSelected = currently;
2185 setComboIntStringKey(backupfilesPresetsCombo,
2186 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2190 setComboIntStringKey(backupfilesPresetsCombo,
2191 backupfilesPresetsComboLastSelected);
2194 backupfilesCustomOptionsSetEnabled();
2197 customiseCheckbox.setToolTipText(
2198 MessageManager.getString("label.customise_description"));
2200 // customise checkbox
2203 presetsPanel.add(customiseCheckbox, gbc);
2205 // "Cancel changes" button (aligned with combo box above)
2207 presetsPanel.add(revertButton, gbc);
2209 return presetsPanel;
2212 private JPanel initBackupsTabFilenameExamplesPanel()
2214 String title = MessageManager.getString("label.scheme_examples");
2215 TitledBorder tb = new TitledBorder(title);
2216 exampleFilesPanel.setBorder(tb);
2217 exampleFilesPanel.setLayout(new GridBagLayout());
2219 backupfilesExampleLabel.setEditable(false);
2220 backupfilesExampleLabel
2221 .setBackground(exampleFilesPanel.getBackground());
2223 updateBackupFilesExampleLabel();
2225 GridBagConstraints gbc = new GridBagConstraints();
2228 gbc.fill = GridBagConstraints.NONE;
2229 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2231 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2232 return exampleFilesPanel;
2235 private void backupsTabUpdatePresets()
2237 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2240 String value = entry.v;
2242 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2246 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2252 "Preset '" + value + "' [key:" + key + "] not implemented");
2255 // Custom options will now be enabled when the customiseCheckbox is checked
2256 // (performed above)
2257 // backupfilesCustomOptionsSetEnabled();
2258 updateBackupFilesExampleLabel();
2261 protected int getComboIntStringKey(
2262 JComboBox<Object> backupfilesPresetsCombo2)
2264 IntKeyStringValueEntry e;
2267 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2269 } catch (Exception ex)
2272 "Problem casting Combo entry to IntKeyStringValueEntry.");
2275 return e != null ? e.k : 0;
2278 protected void setComboIntStringKey(
2279 JComboBox<Object> backupfilesPresetsCombo2, int key)
2281 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2283 IntKeyStringValueEntry e;
2286 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2287 } catch (Exception ex)
2290 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2295 backupfilesPresetsCombo2.setSelectedIndex(i);
2299 // backupsTabUpdatePresets();
2302 private JPanel initBackupsTabSuffixPanel()
2304 suffixPanel.setBorder(new TitledBorder(
2305 MessageManager.getString("label.backup_filename_strategy")));
2306 suffixPanel.setLayout(new GridBagLayout());
2309 .setText(MessageManager.getString("label.append_to_filename"));
2310 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2311 suffixTemplateLabel.setFont(LABEL_FONT);
2313 final String tooltip = JvSwingUtils.wrapTooltip(true,
2314 MessageManager.getString("label.append_to_filename_tooltip"));
2315 suffixTemplate.setToolTipText(tooltip);
2316 suffixTemplate.addActionListener(new ActionListener()
2319 public void actionPerformed(ActionEvent e)
2321 updateBackupFilesExampleLabel();
2322 backupfilesCustomOptionsSetEnabled();
2323 backupfilesRevertButtonSetEnabled(true);
2327 suffixTemplate.addKeyListener(new KeyListener()
2330 public void keyReleased(KeyEvent e)
2332 updateBackupFilesExampleLabel();
2333 backupfilesCustomOptionsSetEnabled();
2334 backupfilesRevertButtonSetEnabled(true);
2338 public void keyPressed(KeyEvent e)
2342 // disable use of ':' or '/' or '\'
2344 public void keyTyped(KeyEvent e)
2346 char c = e.getKeyChar();
2347 if (c == ':' || c == '/' || c == '\\')
2349 // don't process ':' or '/' or '\'
2358 .setText(MessageManager.getString("label.index_digits"));
2359 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2360 suffixDigitsLabel.setFont(LABEL_FONT);
2361 ChangeListener c = new ChangeListener()
2364 public void stateChanged(ChangeEvent e)
2366 backupfilesRevertButtonSetEnabled(true);
2367 updateBackupFilesExampleLabel();
2371 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2372 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2374 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2375 MessageManager.getString("label.increment_index"));
2376 suffixReverse.addActionListener(new ActionListener()
2379 public void actionPerformed(ActionEvent e)
2381 boolean okay = true;
2382 if (warnAboutSuffixReverseChange())
2385 okay = confirmSuffixReverseChange();
2389 backupfilesRevertButtonSetEnabled(true);
2390 updateBackupFilesExampleLabel();
2394 boolean savedSuffixReverse = BackupFilesPresetEntry
2395 .getSavedBackupEntry().reverse;
2396 suffixReverse.setSelected(savedSuffixReverse);
2401 GridBagConstraints sgbc = new GridBagConstraints();
2403 // first row (template text box)
2404 sgbc.anchor = GridBagConstraints.WEST;
2408 sgbc.gridheight = 1;
2411 sgbc.fill = GridBagConstraints.NONE;
2412 suffixPanel.add(suffixTemplateLabel, sgbc);
2415 sgbc.fill = GridBagConstraints.HORIZONTAL;
2416 suffixPanel.add(suffixTemplate, sgbc);
2418 // second row (number of digits spinner)
2422 sgbc.fill = GridBagConstraints.NONE;
2423 suffixPanel.add(suffixDigitsLabel, sgbc);
2426 sgbc.fill = GridBagConstraints.HORIZONTAL;
2427 suffixPanel.add(suffixDigitsSpinner, sgbc);
2429 // third row (forward order radio selection)
2432 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2433 sgbc.fill = GridBagConstraints.HORIZONTAL;
2434 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2436 // fourth row (reverse order radio selection)
2438 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2442 private boolean confirmSuffixReverseChange()
2444 boolean ret = false;
2445 String warningMessage = MessageManager
2446 .getString("label.warning_confirm_change_reverse");
2447 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2449 MessageManager.getString("label.change_increment_decrement"),
2450 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2452 ret = (confirm == JvOptionPane.YES_OPTION);
2456 private JPanel initBackupsTabKeepFilesPanel()
2458 keepfilesPanel.setBorder(
2459 new TitledBorder(MessageManager.getString("label.keep_files")));
2460 keepfilesPanel.setLayout(new GridBagLayout());
2462 backupfilesKeepAll.setLabels(
2463 MessageManager.getString("label.keep_all_backup_files"),
2464 MessageManager.getString(
2465 "label.keep_only_this_number_of_backup_files"));
2466 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2469 public void actionPerformed(ActionEvent e)
2471 backupfilesRevertButtonSetEnabled(true);
2472 updateBackupFilesExampleLabel();
2475 backupfilesKeepAll.addActionListener(new ActionListener()
2478 public void actionPerformed(ActionEvent e)
2480 backupfilesRevertButtonSetEnabled(true);
2481 keepRollMaxOptionsEnabled();
2482 updateBackupFilesExampleLabel();
2486 ChangeListener c = new ChangeListener()
2489 public void stateChanged(ChangeEvent e)
2491 backupfilesRevertButtonSetEnabled(true);
2492 updateBackupFilesExampleLabel();
2496 setIntegerSpinner(backupfilesRollMaxSpinner,
2497 BackupFilesPresetEntry.ROLLMAXMIN,
2498 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2500 backupfilesConfirmDelete.setLabels(
2501 MessageManager.getString("label.always_ask"),
2502 MessageManager.getString("label.auto_delete"));
2503 backupfilesConfirmDelete.addActionListener(new ActionListener()
2506 public void actionPerformed(ActionEvent e)
2508 backupfilesRevertButtonSetEnabled(true);
2511 // update the enabled section
2512 keepRollMaxOptionsEnabled();
2514 GridBagConstraints kgbc = new GridBagConstraints();
2516 // first row (template text box)
2517 kgbc.anchor = GridBagConstraints.WEST;
2520 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2521 kgbc.gridheight = 1;
2524 kgbc.fill = GridBagConstraints.HORIZONTAL;
2525 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2531 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2532 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2535 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2536 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2538 // third row (indented)
2540 kgbc.insets = new Insets(0, 20, 0, 0);
2543 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2544 kgbc.fill = GridBagConstraints.HORIZONTAL;
2547 JPanel jp = new JPanel();
2548 jp.setLayout(new FlowLayout());
2549 oldBackupFilesLabel.setText(
2550 MessageManager.getString("label.autodelete_old_backup_files"));
2551 oldBackupFilesLabel.setFont(LABEL_FONT);
2552 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2553 jp.add(oldBackupFilesLabel);
2554 jp.add(backupfilesConfirmDelete.getTrueButton());
2555 jp.add(backupfilesConfirmDelete.getFalseButton());
2556 keepfilesPanel.add(jp, kgbc);
2558 return keepfilesPanel;
2561 protected void updateBackupFilesExampleLabel()
2563 int exampleindex = 12;
2564 String base = MessageManager.getString("label.filename") + ".fa";
2565 if (base == null || base.length() == 0)
2567 base = "file_name.fa";
2570 boolean reverse = suffixReverse.isSelected();
2571 boolean keepAll = backupfilesKeepAll.isSelected();
2573 String suffix = suffixTemplate.getText();
2576 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2577 if (suffix == null || suffix.length() == 0)
2579 backupfilesExampleLabel
2580 .setText(MessageManager.getString("label.no_backup_files"));
2581 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2585 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2586 rollMax = rollMax < 1 ? 1 : rollMax;
2588 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2593 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2594 digits = digits < 1 ? 1 : digits;
2596 int lowersurround = 2;
2597 int uppersurround = 0;
2598 StringBuilder exampleSB = new StringBuilder();
2599 boolean firstLine = true;
2605 int max = keepAll ? exampleindex : rollMax;
2606 for (int index = min; index <= max; index++)
2608 if (index == min + lowersurround && index < max - uppersurround - 1)
2610 exampleSB.append("\n...");
2613 else if (index > min + lowersurround && index < max - uppersurround)
2625 exampleSB.append("\n");
2628 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2629 base, suffix, digits));
2632 // no extra text needed
2634 else if (index == min)
2636 String newest = MessageManager.getString("label.braced_newest");
2637 if (newest != null && newest.length() > 0)
2639 exampleSB.append(" " + newest);
2642 else if (index == max)
2644 String oldest = MessageManager.getString("label.braced_oldest");
2645 if (oldest != null && oldest.length() > 0)
2647 exampleSB.append(" " + oldest);
2656 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2657 : exampleindex - rollMax + 1;
2658 int max = exampleindex;
2660 for (int index = min; index <= max; index++)
2663 if (index == min + lowersurround && index < max - uppersurround - 1)
2665 exampleSB.append("\n...");
2668 else if (index > min + lowersurround && index < max - uppersurround)
2680 exampleSB.append("\n");
2683 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2684 base, suffix, digits));
2687 // no extra text needed
2689 else if (index == min)
2691 String oldest = MessageManager.getString("label.braced_oldest");
2692 if (oldest != null && oldest.length() > 0)
2694 exampleSB.append(" " + oldest);
2697 else if (index == max)
2699 String newest = MessageManager.getString("label.braced_newest");
2700 if (newest != null && newest.length() > 0)
2702 exampleSB.append(" " + newest);
2710 // add some extra empty lines to pad out the example files box. ugh, please
2712 // me how to do this better
2713 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2714 if (remainingLines > 0)
2716 for (int i = 0; i < remainingLines; i++)
2718 exampleSB.append("\n ");
2723 backupfilesExampleLabel.setText(exampleSB.toString());
2726 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2727 boolean useExistingVal, ChangeListener c)
2734 i = ((Integer) s.getValue()).intValue();
2735 } catch (Exception e)
2738 "Exception casting the initial value of s.getValue()");
2742 setIntegerSpinner(s, min, max, i, c);
2745 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2748 // integer spinner for number of digits
2757 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2760 s.addChangeListener(c);
2764 protected static int getSpinnerInt(JSpinner s, int def)
2770 i = (Integer) s.getValue();
2771 } catch (Exception e)
2773 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2778 private void keepRollMaxOptionsEnabled()
2780 boolean enabled = backupfilesKeepAll.isEnabled()
2781 && !backupfilesKeepAll.isSelected();
2782 oldBackupFilesLabel.setEnabled(enabled);
2783 backupfilesRollMaxSpinner.setEnabled(enabled);
2784 backupfilesConfirmDelete.setEnabled(enabled);
2787 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2789 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2790 && customiseCheckbox.isSelected() && suffixTemplate.getText()
2791 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2792 keepfilesPanel.setEnabled(enabled);
2793 backupfilesKeepAll.setEnabled(enabled);
2794 oldBackupFilesLabel.setEnabled(enabled);
2795 keepRollMaxOptionsEnabled();
2798 private void backupfilesSuffixTemplateDigitsSetEnabled()
2800 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2801 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2802 suffixDigitsLabel.setEnabled(enabled);
2803 suffixDigitsSpinner.setEnabled(enabled);
2804 suffixReverse.setEnabled(enabled);
2807 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2809 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2810 && customiseCheckbox.isSelected();
2811 suffixPanel.setEnabled(enabled);
2812 suffixTemplateLabel.setEnabled(enabled);
2813 suffixTemplate.setEnabled(enabled);
2814 backupfilesSuffixTemplateDigitsSetEnabled();
2817 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2819 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2820 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2821 revertButton.setEnabled(enabled);
2824 private boolean backupfilesCustomChanged()
2826 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2827 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2828 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2829 return !custom.equals(current);
2832 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2834 String suffix = suffixTemplate.getText();
2835 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2836 boolean reverse = suffixReverse.isSelected();
2837 boolean keepAll = backupfilesKeepAll.isSelected();
2838 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2839 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2841 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2842 reverse, keepAll, rollMax, confirmDelete);
2847 protected void backupfilesCustomOptionsSetEnabled()
2849 boolean enabled = customiseCheckbox.isSelected();
2851 backupfilesRevertButtonSetEnabled(enabled);
2852 backupfilesSuffixTemplateSetEnabled(enabled);
2853 backupfilesKeepAllSetEnabled(enabled);
2856 private void backupfilesSummarySetEnabled()
2858 boolean enabled = enableBackupFiles.isSelected();
2859 backupfilesExampleLabel.setEnabled(enabled);
2860 exampleFilesPanel.setEnabled(enabled);
2863 private void backupfilesPresetsSetEnabled()
2865 boolean enabled = enableBackupFiles.isSelected();
2866 presetsPanel.setEnabled(enabled);
2867 presetsComboLabel.setEnabled(enabled);
2868 backupfilesPresetsCombo.setEnabled(enabled);
2869 customiseCheckbox.setEnabled(enabled);
2870 revertButton.setEnabled(enabled);
2873 protected void backupsOptionsSetEnabled()
2875 backupfilesPresetsSetEnabled();
2876 backupfilesSummarySetEnabled();
2877 backupfilesCustomOptionsSetEnabled();
2880 protected void backupsSetOptions(String suffix, int digits,
2881 boolean reverse, boolean keepAll, int rollMax,
2882 boolean confirmDelete)
2884 suffixTemplate.setText(suffix);
2885 suffixDigitsSpinner.setValue(digits);
2886 suffixReverse.setSelected(reverse);
2887 backupfilesKeepAll.setSelected(keepAll);
2888 backupfilesRollMaxSpinner.setValue(rollMax);
2889 backupfilesConfirmDelete.setSelected(confirmDelete);
2892 protected void backupsSetOptions(BackupFilesPresetEntry p)
2894 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2898 protected void autoIdWidth_actionPerformed()
2900 // TODO Auto-generated method stub
2904 protected void userIdWidth_actionPerformed()
2906 // TODO Auto-generated method stub
2910 protected void maxColour_actionPerformed(JPanel panel)
2914 protected void minColour_actionPerformed(JPanel panel)
2918 protected void gapColour_actionPerformed(JPanel panel)
2922 protected void hiddenColour_actionPerformed(JPanel panel)
2926 protected void showunconserved_actionPerformed(ActionEvent e)
2928 // TODO Auto-generated method stub
2932 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2936 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2946 public void ok_actionPerformed(ActionEvent e)
2956 public void cancel_actionPerformed(ActionEvent e)
2966 public void annotations_actionPerformed(ActionEvent e)
2973 public void startupFileTextfield_mouseClicked()
2977 public void newLink_actionPerformed(ActionEvent e)
2982 public void editLink_actionPerformed(ActionEvent e)
2987 public void deleteLink_actionPerformed(ActionEvent e)
2992 public void defaultBrowser_mouseClicked(MouseEvent e)
2997 public void linkURLList_keyTyped(KeyEvent e)
3002 public void setProxyAuthEnabled()
3004 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3005 proxyAuthUsernameLabel.setEnabled(enabled);
3006 proxyAuthPasswordLabel.setEnabled(enabled);
3007 passwordNotStoredLabel.setEnabled(enabled);
3008 proxyAuthUsernameTB.setEnabled(enabled);
3009 proxyAuthPasswordTB.setEnabled(enabled);
3012 public void setCustomProxyEnabled()
3014 boolean enabled = customProxy.isSelected();
3015 portLabel.setEnabled(enabled);
3016 serverLabel.setEnabled(enabled);
3017 portLabel2.setEnabled(enabled);
3018 serverLabel2.setEnabled(enabled);
3019 httpLabel.setEnabled(enabled);
3020 httpsLabel.setEnabled(enabled);
3021 proxyServerHttpTB.setEnabled(enabled);
3022 proxyPortHttpTB.setEnabled(enabled);
3023 proxyServerHttpsTB.setEnabled(enabled);
3024 proxyPortHttpsTB.setEnabled(enabled);
3025 proxyAuth.setEnabled(enabled);
3026 setProxyAuthEnabled();
3029 public void proxyType_actionPerformed()
3031 setCustomProxyEnabled();
3034 public void proxyAuth_actionPerformed()
3036 setProxyAuthEnabled();
3040 * Customer renderer for JTable: supports column of radio buttons
3042 public class RadioButtonRenderer extends JRadioButton
3043 implements TableCellRenderer
3045 public RadioButtonRenderer()
3047 setHorizontalAlignment(CENTER);
3048 setToolTipText(MessageManager.getString("label.urltooltip"));
3052 public Component getTableCellRendererComponent(JTable table,
3053 Object value, boolean isSelected, boolean hasFocus, int row,
3056 setSelected((boolean) value);
3058 // set colours to match rest of table
3061 setBackground(table.getSelectionBackground());
3062 setForeground(table.getSelectionForeground());
3066 setBackground(table.getBackground());
3067 setForeground(table.getForeground());
3074 * Customer cell editor for JTable: supports column of radio buttons in
3075 * conjunction with renderer
3077 public class RadioButtonEditor extends AbstractCellEditor
3078 implements TableCellEditor
3080 private JRadioButton button = new JRadioButton();
3082 public RadioButtonEditor()
3084 button.setHorizontalAlignment(SwingConstants.CENTER);
3085 this.button.addActionListener(new ActionListener()
3088 public void actionPerformed(ActionEvent e)
3090 fireEditingStopped();
3096 public Component getTableCellEditorComponent(JTable table, Object value,
3097 boolean isSelected, int row, int column)
3099 button.setSelected((boolean) value);
3104 public Object getCellEditorValue()
3106 return button.isSelected();