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)
379 new GPreferences(selectTab, null);
382 public GPreferences(int selectTab, String message)
386 jbInit(selectTab, message);
387 } catch (Exception ex)
389 ex.printStackTrace();
394 * Construct the panel and its tabbed sub-panels.
398 private void jbInit() throws Exception
403 private void jbInit(int selectTab) throws Exception
405 jbInit(selectTab, null);
408 public final static int CONNECTIONS_TAB = 5;
410 private void jbInit(int selectTab, String message) throws Exception
412 final JTabbedPane tabbedPane = new JTabbedPane();
413 this.setLayout(new BorderLayout());
417 JLabel messageLabel = new JLabel(message, JLabel.CENTER);
418 messageLabel.setFont(LABEL_FONT_BOLD);
419 messageLabel.setForeground(Color.RED.darker());
420 this.add(messageLabel, BorderLayout.NORTH);
423 JPanel okCancelPanel = initOkCancelPanel();
424 this.add(tabbedPane, BorderLayout.CENTER);
425 this.add(okCancelPanel, BorderLayout.SOUTH);
427 tabbedPane.add(initVisualTab(),
428 MessageManager.getString("label.visual"));
430 tabbedPane.add(initColoursTab(),
431 MessageManager.getString("label.colours"));
433 tabbedPane.add(initOverviewTab(),
434 MessageManager.getString("label.overview"));
436 tabbedPane.add(initStructureTab(),
437 MessageManager.getString("label.structure"));
439 tabbedPane.add(initConnectionsTab(),
440 MessageManager.getString("label.connections"));
442 tabbedPane.add(initBackupsTab(),
443 MessageManager.getString("label.backups"));
445 tabbedPane.add(initLinksTab(),
446 MessageManager.getString("label.urllinks"));
448 tabbedPane.add(initOutputTab(),
449 MessageManager.getString("label.output"));
451 tabbedPane.add(initEditingTab(),
452 MessageManager.getString("label.editing"));
455 * See WsPreferences for the real work of configuring this tab.
457 wsTab.setLayout(new BorderLayout());
458 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
461 * Handler to validate a tab before leaving it - currently only for
464 tabbedPane.addChangeListener(new ChangeListener()
466 private Component lastTab;
469 public void stateChanged(ChangeEvent e)
471 if (lastTab == structureTab
472 && tabbedPane.getSelectedComponent() != structureTab)
474 if (!validateStructure())
476 tabbedPane.setSelectedComponent(structureTab);
480 lastTab = tabbedPane.getSelectedComponent();
485 // select a given tab - currently only for Connections
488 case CONNECTIONS_TAB:
489 tabbedPane.setSelectedComponent(connectTab);
497 * Initialises the Editing tabbed panel.
501 private JPanel initEditingTab()
503 JPanel editingTab = new JPanel();
504 editingTab.setLayout(null);
505 autoCalculateConsCheck.setFont(LABEL_FONT);
506 autoCalculateConsCheck.setText(
507 MessageManager.getString("label.autocalculate_consensus"));
508 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
509 padGaps.setFont(LABEL_FONT);
511 MessageManager.getString("label.pad_gaps_when_editing"));
512 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
513 sortByTree.setFont(LABEL_FONT);
515 .setText(MessageManager.getString("label.sort_with_new_tree"));
516 sortByTree.setToolTipText(MessageManager.getString(
517 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
518 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
519 editingTab.add(autoCalculateConsCheck);
520 editingTab.add(padGaps);
521 editingTab.add(sortByTree);
526 * Initialises the Output tabbed panel.
530 private JPanel initOutputTab()
532 JPanel outputTab = new JPanel();
533 outputTab.setLayout(null);
534 JLabel epsLabel = new JLabel();
535 epsLabel.setFont(LABEL_FONT);
536 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
537 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
538 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
539 epsRendering.setFont(LABEL_FONT);
540 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
541 JLabel jLabel1 = new JLabel();
542 jLabel1.setFont(LABEL_FONT);
543 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
544 jLabel1.setText(MessageManager.getString("label.append_start_end"));
545 jLabel1.setFont(LABEL_FONT);
546 fastajv.setFont(LABEL_FONT);
547 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
548 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
549 blcjv.setText(MessageManager.getString("label.blc") + " ");
550 fastajv.setText(MessageManager.getString("label.fasta") + " ");
551 msfjv.setText(MessageManager.getString("label.msf") + " ");
552 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
553 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
554 msfjv.setFont(LABEL_FONT);
555 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
556 pirjv.setText(MessageManager.getString("label.pir") + " ");
557 JPanel jPanel11 = new JPanel();
558 jPanel11.setFont(LABEL_FONT);
559 TitledBorder titledBorder2 = new TitledBorder(
560 MessageManager.getString("label.file_output"));
561 jPanel11.setBorder(titledBorder2);
562 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
563 GridLayout gridLayout3 = new GridLayout();
564 jPanel11.setLayout(gridLayout3);
565 gridLayout3.setRows(8);
566 blcjv.setFont(LABEL_FONT);
567 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
568 clustaljv.setFont(LABEL_FONT);
569 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
570 pfamjv.setFont(LABEL_FONT);
571 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
572 pileupjv.setFont(LABEL_FONT);
573 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
574 pirjv.setFont(LABEL_FONT);
575 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
576 autoIdWidth.setFont(LABEL_FONT);
578 MessageManager.getString("label.automatically_set_id_width"));
579 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
580 .getString("label.adjusts_width_generated_eps_png")));
581 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
582 autoIdWidth.addActionListener(new ActionListener()
586 public void actionPerformed(ActionEvent e)
588 autoIdWidth_actionPerformed();
591 userIdWidthlabel.setFont(LABEL_FONT);
592 userIdWidthlabel.setText(
593 MessageManager.getString("label.figure_id_column_width"));
594 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
595 .getString("label.manually_specify_width_left_column")));
596 userIdWidthlabel.setToolTipText(
597 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
598 "label.manually_specify_width_left_column")));
599 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
600 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
601 userIdWidth.setText("");
602 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
603 userIdWidth.addActionListener(new ActionListener()
607 public void actionPerformed(ActionEvent e)
609 userIdWidth_actionPerformed();
612 modellerOutput.setFont(LABEL_FONT);
614 .setText(MessageManager.getString("label.use_modeller_output"));
615 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
616 embbedBioJSON.setFont(LABEL_FONT);
617 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
618 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
620 jPanel11.add(jLabel1);
622 jPanel11.add(clustaljv);
623 jPanel11.add(fastajv);
625 jPanel11.add(pfamjv);
626 jPanel11.add(pileupjv);
628 outputTab.add(autoIdWidth);
629 outputTab.add(userIdWidth);
630 outputTab.add(userIdWidthlabel);
631 outputTab.add(modellerOutput);
632 outputTab.add(embbedBioJSON);
633 outputTab.add(epsLabel);
634 outputTab.add(epsRendering);
635 outputTab.add(jPanel11);
640 * Initialises the Connections tabbed panel.
644 private JPanel initConnectionsTab()
646 connectTab = new JPanel();
647 connectTab.setLayout(new GridBagLayout());
649 // Label for browser text box
650 JLabel browserLabel = new JLabel();
651 browserLabel.setFont(LABEL_FONT);
652 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
653 browserLabel.setText(
654 MessageManager.getString("label.default_browser_unix"));
655 defaultBrowser.setFont(LABEL_FONT);
656 defaultBrowser.setText("");
657 final String tooltip = JvSwingUtils.wrapTooltip(true,
658 MessageManager.getString("label.double_click_to_browse"));
659 defaultBrowser.setToolTipText(tooltip);
660 defaultBrowser.addMouseListener(new MouseAdapter()
663 public void mouseClicked(MouseEvent e)
665 if (e.getClickCount() > 1)
667 defaultBrowser_mouseClicked(e);
672 JPanel proxyPanel = initConnTabProxyPanel();
673 initConnTabCheckboxes();
675 // Add default Browser text box
676 connectTab.add(browserLabel,
677 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
678 GridBagConstraints.WEST, GridBagConstraints.NONE,
679 new Insets(10, 0, 5, 5), 5, 1));
680 defaultBrowser.setFont(LABEL_FONT);
681 defaultBrowser.setText("");
683 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
684 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
685 new Insets(10, 0, 5, 10), 30, 1));
687 // Add proxy server panel
688 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
689 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
690 new Insets(10, 0, 5, 12), 4, 10));
692 // Add usage stats, version check and questionnaire checkboxes
693 connectTab.add(usagestats,
694 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
695 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
696 new Insets(0, 2, 5, 5), 70, 1));
697 connectTab.add(questionnaire,
698 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
699 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
700 new Insets(0, 2, 5, 10), 70, 1));
701 connectTab.add(versioncheck,
702 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
703 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
704 new Insets(0, 2, 5, 5), 70, 1));
706 versioncheck.setVisible(false);
708 // Add padding so the panel doesn't look ridiculous
709 JPanel spacePanel = new JPanel();
710 connectTab.add(spacePanel,
711 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
712 GridBagConstraints.WEST, GridBagConstraints.BOTH,
713 new Insets(0, 0, 0, 5), 70, 1));
719 * Initialises the Links tabbed panel.
723 private JPanel initLinksTab()
725 JPanel linkTab = new JPanel();
726 linkTab.setLayout(new GridBagLayout());
728 // Set up table for Url links
729 linkUrlTable.getTableHeader().setReorderingAllowed(false);
730 linkUrlTable.setFillsViewportHeight(true);
731 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
732 linkUrlTable.setAutoCreateRowSorter(true);
733 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
735 // adjust row height so radio buttons actually fit
736 // don't do this in the renderer, it causes the awt thread to activate
738 JRadioButton temp = new JRadioButton();
739 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
741 // Table in scrollpane so that the table is given a scrollbar
742 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
743 linkScrollPane.setBorder(null);
745 // Panel for links functionality
746 JPanel linkPanel = new JPanel(new GridBagLayout());
747 linkPanel.setBorder(new TitledBorder(
748 MessageManager.getString("label.url_linkfrom_sequence_id")));
750 // Put the Url links panel together
752 // Buttons go at top right, resizing only resizes the blank space vertically
753 JPanel buttonPanel = initLinkTabUrlButtons();
754 GridBagConstraints linkConstraints1 = new GridBagConstraints();
755 linkConstraints1.insets = new Insets(0, 0, 5, 0);
756 linkConstraints1.gridx = 0;
757 linkConstraints1.gridy = 0;
758 linkConstraints1.weightx = 1.0;
759 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
760 linkTab.add(buttonPanel, linkConstraints1);
762 // Links table goes at top left, resizing resizes the table
763 GridBagConstraints linkConstraints2 = new GridBagConstraints();
764 linkConstraints2.insets = new Insets(0, 0, 5, 5);
765 linkConstraints2.gridx = 0;
766 linkConstraints2.gridy = 1;
767 linkConstraints2.weightx = 1.0;
768 linkConstraints2.weighty = 1.0;
769 linkConstraints2.fill = GridBagConstraints.BOTH;
770 linkTab.add(linkScrollPane, linkConstraints2);
772 // Filter box and buttons goes at bottom left, resizing resizes the text box
773 JPanel filterPanel = initLinkTabFilterPanel();
774 GridBagConstraints linkConstraints3 = new GridBagConstraints();
775 linkConstraints3.insets = new Insets(0, 0, 0, 5);
776 linkConstraints3.gridx = 0;
777 linkConstraints3.gridy = 2;
778 linkConstraints3.weightx = 1.0;
779 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
780 linkTab.add(filterPanel, linkConstraints3);
785 private JPanel initLinkTabFilterPanel()
787 // Filter textbox and reset button
788 JLabel filterLabel = new JLabel(
789 MessageManager.getString("label.filter"));
790 filterLabel.setFont(LABEL_FONT);
791 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
792 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
794 filterTB.setFont(LABEL_FONT);
795 filterTB.setText("");
797 doReset.setText(MessageManager.getString("action.showall"));
798 userOnly.setText(MessageManager.getString("action.customfilter"));
800 // Panel for filter functionality
801 JPanel filterPanel = new JPanel(new GridBagLayout());
802 filterPanel.setBorder(new TitledBorder("Filter"));
803 GridBagConstraints gbc = new GridBagConstraints();
806 gbc.fill = GridBagConstraints.NONE;
807 gbc.anchor = GridBagConstraints.WEST;
809 filterPanel.add(filterLabel, gbc);
811 GridBagConstraints gbc1 = new GridBagConstraints();
814 gbc1.fill = GridBagConstraints.HORIZONTAL;
815 gbc1.anchor = GridBagConstraints.WEST;
817 filterPanel.add(filterTB, gbc1);
819 GridBagConstraints gbc2 = new GridBagConstraints();
821 gbc2.fill = GridBagConstraints.NONE;
822 gbc2.anchor = GridBagConstraints.WEST;
823 filterPanel.add(doReset, gbc2);
825 GridBagConstraints gbc3 = new GridBagConstraints();
827 gbc3.fill = GridBagConstraints.NONE;
828 gbc3.anchor = GridBagConstraints.WEST;
829 filterPanel.add(userOnly, gbc3);
834 private JPanel initLinkTabUrlButtons()
836 // Buttons for new / edit / delete Url links
837 JButton newLink = new JButton();
838 newLink.setText(MessageManager.getString("action.new"));
840 editLink.setText(MessageManager.getString("action.edit"));
842 deleteLink.setText(MessageManager.getString("action.delete"));
844 // no current selection, so initially disable delete/edit buttons
845 editLink.setEnabled(false);
846 deleteLink.setEnabled(false);
848 newLink.addActionListener(new java.awt.event.ActionListener()
851 public void actionPerformed(ActionEvent e)
853 newLink_actionPerformed(e);
857 editLink.setText(MessageManager.getString("action.edit"));
858 editLink.addActionListener(new java.awt.event.ActionListener()
861 public void actionPerformed(ActionEvent e)
863 editLink_actionPerformed(e);
867 deleteLink.setText(MessageManager.getString("action.delete"));
868 deleteLink.addActionListener(new java.awt.event.ActionListener()
871 public void actionPerformed(ActionEvent e)
873 deleteLink_actionPerformed(e);
877 JPanel buttonPanel = new JPanel(new GridBagLayout());
878 buttonPanel.setBorder(new TitledBorder("Edit links"));
879 GridBagConstraints gbc = new GridBagConstraints();
882 gbc.fill = GridBagConstraints.NONE;
883 buttonPanel.add(newLink, gbc);
885 GridBagConstraints gbc1 = new GridBagConstraints();
888 gbc1.fill = GridBagConstraints.NONE;
889 buttonPanel.add(editLink, gbc1);
891 GridBagConstraints gbc2 = new GridBagConstraints();
894 gbc2.fill = GridBagConstraints.NONE;
895 buttonPanel.add(deleteLink, gbc2);
897 GridBagConstraints gbc3 = new GridBagConstraints();
900 gbc3.fill = GridBagConstraints.HORIZONTAL;
902 JPanel spacePanel = new JPanel();
903 spacePanel.setBorder(null);
904 buttonPanel.add(spacePanel, gbc3);
910 * Initialises the proxy server panel in the Connections tab
912 * @return the proxy server panel
914 private JPanel initConnTabProxyPanel()
916 // Label for server text box
917 serverLabel.setText(MessageManager.getString("label.host") + ": ");
918 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
919 serverLabel.setFont(LABEL_FONT);
920 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
921 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
922 serverLabel2.setFont(LABEL_FONT);
924 // Proxy server and port text boxes
925 proxyServerHttpTB.setFont(LABEL_FONT);
926 proxyServerHttpTB.setColumns(40);
927 proxyPortHttpTB.setFont(LABEL_FONT);
928 proxyPortHttpTB.setColumns(4);
929 proxyServerHttpsTB.setFont(LABEL_FONT);
930 proxyServerHttpsTB.setColumns(40);
931 proxyPortHttpsTB.setFont(LABEL_FONT);
932 proxyPortHttpsTB.setColumns(4);
933 proxyAuthUsernameTB.setFont(LABEL_FONT);
934 proxyAuthUsernameTB.setColumns(30);
935 proxyAuthPasswordTB.setFont(LABEL_FONT);
936 proxyAuthPasswordTB.setColumns(30);
938 // Label for Port text box
939 portLabel.setFont(LABEL_FONT);
940 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
941 portLabel.setText(MessageManager.getString("label.port") + ": ");
942 portLabel2.setFont(LABEL_FONT);
943 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
944 portLabel2.setText(MessageManager.getString("label.port") + ": ");
946 httpLabel.setText("HTTP");
947 httpLabel.setFont(LABEL_FONT_BOLD);
948 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
949 httpsLabel.setText("HTTPS");
950 httpsLabel.setFont(LABEL_FONT_BOLD);
951 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
953 proxyAuthUsernameLabel
954 .setText(MessageManager.getString("label.username") + ": ");
955 proxyAuthUsernameLabel.setFont(LABEL_FONT);
956 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
957 proxyAuthPasswordLabel
958 .setText(MessageManager.getString("label.password") + ": ");
959 proxyAuthPasswordLabel.setFont(LABEL_FONT);
960 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
961 passwordNotStoredLabel.setText(
962 "(" + MessageManager.getString("label.not_stored") + ")");
963 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
964 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
966 // Proxy type radio buttons
967 noProxy.setFont(LABEL_FONT);
968 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
969 noProxy.setText(MessageManager.getString("label.no_proxy"));
970 systemProxy.setFont(LABEL_FONT);
971 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
972 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
973 displayUserHostPort(Cache.startupProxyProperties[4],
974 Cache.startupProxyProperties[0],
975 Cache.startupProxyProperties[1]),
976 displayUserHostPort(Cache.startupProxyProperties[6],
977 Cache.startupProxyProperties[2],
978 Cache.startupProxyProperties[3])));
979 customProxy.setFont(LABEL_FONT);
980 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
982 MessageManager.getString("label.use_proxy_server") + ":");
983 ActionListener al = new ActionListener()
986 public void actionPerformed(ActionEvent e)
988 proxyType_actionPerformed();
991 noProxy.addActionListener(al);
992 systemProxy.addActionListener(al);
993 customProxy.addActionListener(al);
994 proxyType.add(noProxy);
995 proxyType.add(systemProxy);
996 proxyType.add(customProxy);
998 proxyAuth.setFont(LABEL_FONT);
999 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1000 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1001 proxyAuth.addActionListener(new ActionListener()
1004 public void actionPerformed(ActionEvent e)
1006 proxyAuth_actionPerformed();
1010 setCustomProxyEnabled();
1012 // Make proxy server panel
1013 JPanel proxyPanel = new JPanel();
1014 TitledBorder titledBorder1 = new TitledBorder(
1015 MessageManager.getString("label.proxy_servers"));
1016 proxyPanel.setBorder(titledBorder1);
1017 proxyPanel.setLayout(new GridBagLayout());
1018 GridBagConstraints gbc = new GridBagConstraints();
1019 gbc.fill = GridBagConstraints.HORIZONTAL;
1022 GridBagConstraints c = new GridBagConstraints();
1023 // Proxy type radio buttons (3)
1024 JPanel ptPanel = new JPanel();
1025 ptPanel.setLayout(new GridBagLayout());
1030 c.fill = GridBagConstraints.HORIZONTAL;
1031 ptPanel.add(noProxy, c);
1033 ptPanel.add(systemProxy, c);
1035 ptPanel.add(customProxy, c);
1038 proxyPanel.add(ptPanel, gbc);
1040 // host and port text boxes
1041 JPanel hpPanel = new JPanel();
1042 hpPanel.setLayout(new GridBagLayout());
1043 // HTTP host port row
1048 c.anchor = GridBagConstraints.LINE_START;
1049 hpPanel.add(httpLabel, c);
1053 c.anchor = GridBagConstraints.LINE_END;
1054 hpPanel.add(serverLabel, c);
1058 c.anchor = GridBagConstraints.LINE_START;
1059 hpPanel.add(proxyServerHttpTB, c);
1063 c.anchor = GridBagConstraints.LINE_END;
1064 hpPanel.add(portLabel, c);
1068 c.anchor = GridBagConstraints.LINE_START;
1069 hpPanel.add(proxyPortHttpTB, c);
1071 // HTTPS host port row
1076 c.anchor = GridBagConstraints.LINE_START;
1077 hpPanel.add(httpsLabel, c);
1080 c.anchor = GridBagConstraints.LINE_END;
1081 hpPanel.add(serverLabel2, c);
1084 c.anchor = GridBagConstraints.LINE_START;
1085 hpPanel.add(proxyServerHttpsTB, c);
1088 c.anchor = GridBagConstraints.LINE_END;
1089 hpPanel.add(portLabel2, c);
1092 c.anchor = GridBagConstraints.LINE_START;
1093 hpPanel.add(proxyPortHttpsTB, c);
1096 proxyPanel.add(hpPanel, gbc);
1098 // Require authentication checkbox
1100 proxyPanel.add(proxyAuth, gbc);
1102 // username and password
1103 JPanel upPanel = new JPanel();
1104 upPanel.setLayout(new GridBagLayout());
1110 c.anchor = GridBagConstraints.LINE_END;
1111 upPanel.add(proxyAuthUsernameLabel, c);
1115 c.anchor = GridBagConstraints.LINE_START;
1116 upPanel.add(proxyAuthUsernameTB, c);
1122 c.anchor = GridBagConstraints.LINE_END;
1123 upPanel.add(proxyAuthPasswordLabel, c);
1127 c.anchor = GridBagConstraints.LINE_START;
1128 upPanel.add(proxyAuthPasswordTB, c);
1132 c.anchor = GridBagConstraints.LINE_START;
1133 upPanel.add(passwordNotStoredLabel, c);
1136 proxyPanel.add(upPanel, gbc);
1141 private String displayUserHostPort(String user, String host, String port)
1143 boolean hostBlank = (host == null || host.isEmpty());
1144 boolean portBlank = (port == null || port.isEmpty());
1145 if (hostBlank && portBlank)
1147 return MessageManager.getString("label.none");
1150 StringBuilder sb = new StringBuilder();
1153 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1157 sb.append(hostBlank ? "" : host);
1163 return sb.toString();
1167 * Initialises the checkboxes in the Connections tab
1169 private void initConnTabCheckboxes()
1171 // Usage stats checkbox label
1173 MessageManager.getString("label.send_usage_statistics"));
1174 usagestats.setFont(LABEL_FONT);
1175 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1176 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1178 // Questionnaire checkbox label
1179 questionnaire.setText(
1180 MessageManager.getString("label.check_for_questionnaires"));
1181 questionnaire.setFont(LABEL_FONT);
1182 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1183 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1185 // Check for latest version checkbox label
1186 versioncheck.setText(
1187 MessageManager.getString("label.check_for_latest_version"));
1188 versioncheck.setFont(LABEL_FONT);
1189 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1190 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1194 * Initialises the parent panel which contains the tabbed sections.
1198 private JPanel initOkCancelPanel()
1200 JButton ok = new JButton();
1201 ok.setText(MessageManager.getString("action.ok"));
1202 ok.addActionListener(new ActionListener()
1205 public void actionPerformed(ActionEvent e)
1207 ok_actionPerformed(e);
1210 JButton cancel = new JButton();
1211 cancel.setText(MessageManager.getString("action.cancel"));
1212 cancel.addActionListener(new ActionListener()
1215 public void actionPerformed(ActionEvent e)
1217 cancel_actionPerformed(e);
1220 JPanel okCancelPanel = new JPanel();
1221 okCancelPanel.add(ok);
1222 okCancelPanel.add(cancel);
1223 return okCancelPanel;
1227 * Initialises the Colours tabbed panel.
1231 private JPanel initColoursTab()
1233 JPanel coloursTab = new JPanel();
1234 coloursTab.setBorder(new TitledBorder(
1235 MessageManager.getString("action.open_new_alignment")));
1236 coloursTab.setLayout(new FlowLayout());
1237 JLabel mincolourLabel = new JLabel();
1238 mincolourLabel.setFont(LABEL_FONT);
1239 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1240 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1241 minColour.setFont(LABEL_FONT);
1242 minColour.setBorder(BorderFactory.createEtchedBorder());
1243 minColour.setPreferredSize(new Dimension(40, 20));
1244 minColour.addMouseListener(new MouseAdapter()
1247 public void mousePressed(MouseEvent e)
1249 minColour_actionPerformed(minColour);
1252 JLabel maxcolourLabel = new JLabel();
1253 maxcolourLabel.setFont(LABEL_FONT);
1254 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1255 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1256 maxColour.setFont(LABEL_FONT);
1257 maxColour.setBorder(BorderFactory.createEtchedBorder());
1258 maxColour.setPreferredSize(new Dimension(40, 20));
1259 maxColour.addMouseListener(new MouseAdapter()
1262 public void mousePressed(MouseEvent e)
1264 maxColour_actionPerformed(maxColour);
1268 protColour.setFont(LABEL_FONT);
1269 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1270 JLabel protColourLabel = new JLabel();
1271 protColourLabel.setFont(LABEL_FONT);
1272 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1273 protColourLabel.setText(
1274 MessageManager.getString("label.prot_alignment_colour") + " ");
1275 JvSwingUtils.addtoLayout(coloursTab,
1277 .getString("label.default_colour_scheme_for_alignment"),
1278 protColourLabel, protColour);
1280 nucColour.setFont(LABEL_FONT);
1281 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1282 JLabel nucColourLabel = new JLabel();
1283 nucColourLabel.setFont(LABEL_FONT);
1284 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1285 nucColourLabel.setText(
1286 MessageManager.getString("label.nuc_alignment_colour") + " ");
1287 JvSwingUtils.addtoLayout(coloursTab,
1289 .getString("label.default_colour_scheme_for_alignment"),
1290 nucColourLabel, nucColour);
1292 JPanel annotationShding = new JPanel();
1293 annotationShding.setBorder(new TitledBorder(
1294 MessageManager.getString("label.annotation_shading_default")));
1295 annotationShding.setLayout(new GridLayout(1, 2));
1296 JvSwingUtils.addtoLayout(annotationShding,
1297 MessageManager.getString(
1298 "label.default_minimum_colour_annotation_shading"),
1299 mincolourLabel, minColour);
1300 JvSwingUtils.addtoLayout(annotationShding,
1301 MessageManager.getString(
1302 "label.default_maximum_colour_annotation_shading"),
1303 maxcolourLabel, maxColour);
1304 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1309 * Initialises the Overview tabbed panel.
1313 private JPanel initOverviewTab()
1315 JPanel overviewPanel = new JPanel();
1316 overviewPanel.setBorder(new TitledBorder(
1317 MessageManager.getString("label.overview_settings")));
1319 gapColour.setFont(LABEL_FONT);
1320 // fixing the border colours stops apparent colour bleed from the panel
1321 gapColour.setBorder(
1322 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1323 gapColour.setPreferredSize(new Dimension(40, 20));
1324 gapColour.addMouseListener(new MouseAdapter()
1327 public void mousePressed(MouseEvent e)
1329 gapColour_actionPerformed(gapColour);
1333 hiddenColour.setFont(LABEL_FONT);
1334 // fixing the border colours stops apparent colour bleed from the panel
1335 hiddenColour.setBorder(
1336 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1337 hiddenColour.setPreferredSize(new Dimension(40, 20));
1338 hiddenColour.addMouseListener(new MouseAdapter()
1341 public void mousePressed(MouseEvent e)
1343 hiddenColour_actionPerformed(hiddenColour);
1347 useLegacyGap = new JCheckBox(
1348 MessageManager.getString("label.ov_legacy_gap"));
1349 useLegacyGap.setFont(LABEL_FONT);
1350 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1351 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1352 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1353 gapLabel.setFont(LABEL_FONT);
1354 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1355 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1356 showHiddenAtStart = new JCheckBox(
1357 MessageManager.getString("label.ov_show_hide_default"));
1358 showHiddenAtStart.setFont(LABEL_FONT);
1359 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1360 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1361 JLabel hiddenLabel = new JLabel(
1362 MessageManager.getString("label.hidden_colour"));
1363 hiddenLabel.setFont(LABEL_FONT);
1364 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1365 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1367 useLegacyGap.addActionListener(new ActionListener()
1370 public void actionPerformed(ActionEvent e)
1372 useLegacyGaps_actionPerformed(e);
1376 overviewPanel.setLayout(new GridBagLayout());
1377 GridBagConstraints c1 = new GridBagConstraints();
1379 c1.fill = GridBagConstraints.HORIZONTAL;
1384 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1385 overviewPanel.add(useLegacyGap, c1);
1387 GridBagConstraints c2 = new GridBagConstraints();
1388 c2.fill = GridBagConstraints.HORIZONTAL;
1391 c2.insets = new Insets(0, 15, 0, 10);
1392 overviewPanel.add(gapLabel, c2);
1394 GridBagConstraints c3 = new GridBagConstraints();
1395 c3.fill = GridBagConstraints.HORIZONTAL;
1398 c3.insets = new Insets(0, 0, 0, 15);
1399 overviewPanel.add(gapColour, c3);
1401 GridBagConstraints c4 = new GridBagConstraints();
1402 c4.fill = GridBagConstraints.HORIZONTAL;
1406 overviewPanel.add(showHiddenAtStart, c4);
1408 GridBagConstraints c5 = new GridBagConstraints();
1409 c5.fill = GridBagConstraints.HORIZONTAL;
1412 c5.insets = new Insets(0, 15, 0, 10);
1413 overviewPanel.add(hiddenLabel, c5);
1415 GridBagConstraints c6 = new GridBagConstraints();
1416 c6.fill = GridBagConstraints.HORIZONTAL;
1419 c6.insets = new Insets(0, 0, 0, 15);
1420 overviewPanel.add(hiddenColour, c6);
1422 JButton resetButton = new JButton(
1423 MessageManager.getString("label.reset_to_defaults"));
1425 resetButton.addActionListener(new ActionListener()
1428 public void actionPerformed(ActionEvent e)
1430 resetOvDefaults_actionPerformed(e);
1434 GridBagConstraints c7 = new GridBagConstraints();
1435 c7.fill = GridBagConstraints.NONE;
1438 c7.insets = new Insets(10, 0, 0, 0);
1439 c7.anchor = GridBagConstraints.WEST;
1440 overviewPanel.add(resetButton, c7);
1442 // Add padding so the panel doesn't look ridiculous
1443 JPanel spacePanel = new JPanel();
1444 overviewPanel.add(spacePanel,
1445 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1446 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1447 new Insets(0, 0, 0, 5), 0, 0));
1449 return overviewPanel;
1453 * Initialises the Structure tabbed panel.
1457 private JPanel initStructureTab()
1459 structureTab = new JPanel();
1461 structureTab.setBorder(new TitledBorder(
1462 MessageManager.getString("label.structure_options")));
1463 structureTab.setLayout(null);
1464 final int width = 400;
1465 final int height = 22;
1466 final int lineSpacing = 25;
1469 structFromPdb.setFont(LABEL_FONT);
1471 .setText(MessageManager.getString("label.struct_from_pdb"));
1472 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1473 structFromPdb.addActionListener(new ActionListener()
1476 public void actionPerformed(ActionEvent e)
1478 boolean selected = structFromPdb.isSelected();
1479 // enable other options only when the first is checked
1480 useRnaView.setEnabled(selected);
1481 addSecondaryStructure.setEnabled(selected);
1482 addTempFactor.setEnabled(selected);
1485 structureTab.add(structFromPdb);
1487 // indent checkboxes that are conditional on the first one
1488 ypos += lineSpacing;
1489 useRnaView.setFont(LABEL_FONT);
1490 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1491 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1492 structureTab.add(useRnaView);
1494 ypos += lineSpacing;
1495 addSecondaryStructure.setFont(LABEL_FONT);
1496 addSecondaryStructure
1497 .setText(MessageManager.getString("label.autoadd_secstr"));
1498 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1499 structureTab.add(addSecondaryStructure);
1501 ypos += lineSpacing;
1502 addTempFactor.setFont(LABEL_FONT);
1503 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1504 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1505 structureTab.add(addTempFactor);
1507 ypos += lineSpacing;
1508 JLabel viewerLabel = new JLabel();
1509 viewerLabel.setFont(LABEL_FONT);
1510 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1511 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1512 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1513 structureTab.add(viewerLabel);
1515 structViewer.setFont(LABEL_FONT);
1516 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1517 structViewer.addItem(ViewerType.JMOL.name());
1518 structViewer.addItem(ViewerType.CHIMERA.name());
1519 structViewer.addActionListener(new ActionListener()
1522 public void actionPerformed(ActionEvent e)
1524 structureViewer_actionPerformed(
1525 (String) structViewer.getSelectedItem());
1528 structureTab.add(structViewer);
1530 ypos += lineSpacing;
1531 JLabel pathLabel = new JLabel();
1532 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1533 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1534 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1535 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1536 structureTab.add(pathLabel);
1538 chimeraPath.setFont(LABEL_FONT);
1539 chimeraPath.setText("");
1540 final String tooltip = JvSwingUtils.wrapTooltip(true,
1541 MessageManager.getString("label.chimera_path_tip"));
1542 chimeraPath.setToolTipText(tooltip);
1543 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1544 chimeraPath.addMouseListener(new MouseAdapter()
1547 public void mouseClicked(MouseEvent e)
1549 if (e.getClickCount() == 2)
1551 String chosen = openFileChooser();
1554 chimeraPath.setText(chosen);
1559 structureTab.add(chimeraPath);
1561 ypos += lineSpacing;
1562 nwMapping.setFont(LABEL_FONT);
1563 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1564 siftsMapping.setFont(LABEL_FONT);
1565 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1566 mappingMethod.add(nwMapping);
1567 mappingMethod.add(siftsMapping);
1568 JPanel mappingPanel = new JPanel();
1569 mappingPanel.setFont(LABEL_FONT);
1570 TitledBorder mmTitledBorder = new TitledBorder(
1571 MessageManager.getString("label.mapping_method"));
1572 mmTitledBorder.setTitleFont(LABEL_FONT);
1573 mappingPanel.setBorder(mmTitledBorder);
1574 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1575 // GridLayout mappingLayout = new GridLayout();
1576 mappingPanel.setLayout(new GridLayout());
1577 mappingPanel.add(nwMapping);
1578 mappingPanel.add(siftsMapping);
1579 structureTab.add(mappingPanel);
1581 ypos += lineSpacing;
1582 ypos += lineSpacing;
1583 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1584 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1585 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1586 structureTab.add(docFieldPref);
1588 return structureTab;
1592 * Action on choosing a structure viewer from combobox options.
1594 * @param selectedItem
1596 protected void structureViewer_actionPerformed(String selectedItem)
1601 * Show a dialog for the user to choose a file. Returns the chosen path, or
1606 protected String openFileChooser()
1608 String choice = null;
1609 JFileChooser chooser = new JFileChooser();
1611 // chooser.setFileView(new JalviewFileView());
1612 chooser.setDialogTitle(
1613 MessageManager.getString("label.open_local_file"));
1614 chooser.setToolTipText(MessageManager.getString("action.open"));
1616 int value = chooser.showOpenDialog(this);
1618 if (value == JFileChooser.APPROVE_OPTION)
1620 choice = chooser.getSelectedFile().getPath();
1626 * Validate the structure tab preferences; if invalid, set focus on this tab.
1630 protected boolean validateStructure(FocusEvent e)
1632 if (!validateStructure())
1634 e.getComponent().requestFocusInWindow();
1640 protected boolean validateStructure()
1646 * Initialises the Visual tabbed panel.
1650 private JPanel initVisualTab()
1652 JPanel visualTab = new JPanel();
1653 visualTab.setBorder(new TitledBorder(
1654 MessageManager.getString("action.open_new_alignment")));
1655 visualTab.setLayout(null);
1656 fullScreen.setFont(LABEL_FONT);
1657 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1658 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1659 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1660 quality.setEnabled(false);
1661 quality.setFont(LABEL_FONT);
1662 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1663 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1664 quality.setSelected(true);
1665 quality.setText(MessageManager.getString("label.quality"));
1666 conservation.setEnabled(false);
1667 conservation.setFont(LABEL_FONT);
1668 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1669 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1670 conservation.setSelected(true);
1671 conservation.setText(MessageManager.getString("label.conservation"));
1672 identity.setEnabled(false);
1673 identity.setFont(LABEL_FONT);
1674 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1675 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1676 identity.setSelected(true);
1677 identity.setText(MessageManager.getString("label.consensus"));
1678 showOccupancy.setFont(LABEL_FONT);
1679 showOccupancy.setEnabled(false);
1680 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1681 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1682 showOccupancy.setSelected(true);
1683 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1685 JLabel showGroupbits = new JLabel();
1686 showGroupbits.setFont(LABEL_FONT);
1687 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1688 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1690 .setText(MessageManager.getString("action.show_group") + ":");
1691 JLabel showConsensbits = new JLabel();
1692 showConsensbits.setFont(LABEL_FONT);
1693 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1694 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1696 .setText(MessageManager.getString("label.consensus") + ":");
1697 showConsensHistogram.setEnabled(false);
1698 showConsensHistogram.setFont(LABEL_FONT);
1699 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1700 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1701 showConsensHistogram.setSelected(true);
1702 showConsensHistogram
1703 .setText(MessageManager.getString("label.histogram"));
1704 showConsensLogo.setEnabled(false);
1705 showConsensLogo.setFont(LABEL_FONT);
1706 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1707 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1708 showConsensLogo.setSelected(true);
1709 showConsensLogo.setText(MessageManager.getString("label.logo"));
1710 showGroupConsensus.setEnabled(false);
1711 showGroupConsensus.setFont(LABEL_FONT);
1712 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1713 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1714 showGroupConsensus.setSelected(true);
1715 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1716 showGroupConservation.setEnabled(false);
1717 showGroupConservation.setFont(LABEL_FONT);
1718 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1719 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1720 showGroupConservation.setSelected(true);
1721 showGroupConservation
1722 .setText(MessageManager.getString("label.conservation"));
1723 showNpTooltip.setEnabled(true);
1724 showNpTooltip.setFont(LABEL_FONT);
1725 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1726 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1727 showNpTooltip.setSelected(true);
1728 showNpTooltip.setText(
1729 MessageManager.getString("label.non_positional_features"));
1730 showDbRefTooltip.setEnabled(true);
1731 showDbRefTooltip.setFont(LABEL_FONT);
1732 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1733 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1734 showDbRefTooltip.setSelected(true);
1736 .setText(MessageManager.getString("label.database_references"));
1737 annotations.setFont(LABEL_FONT);
1738 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1739 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1740 annotations.setSelected(true);
1741 annotations.setText(MessageManager.getString("label.show_annotations"));
1742 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1743 annotations.addActionListener(new ActionListener()
1746 public void actionPerformed(ActionEvent e)
1748 annotations_actionPerformed(e);
1751 identity.addActionListener(new ActionListener()
1754 public void actionPerformed(ActionEvent e)
1756 annotations_actionPerformed(e);
1759 showGroupConsensus.addActionListener(new ActionListener()
1762 public void actionPerformed(ActionEvent e)
1764 annotations_actionPerformed(e);
1767 showUnconserved.setFont(LABEL_FONT);
1768 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1769 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1770 showUnconserved.setSelected(true);
1772 .setText(MessageManager.getString("action.show_unconserved"));
1773 showUnconserved.addActionListener(new ActionListener()
1776 public void actionPerformed(ActionEvent e)
1778 showunconserved_actionPerformed(e);
1782 // TODO these are not yet added to / action from Preferences
1783 // JCheckBox shareSelections = new JCheckBox();
1784 // shareSelections.setFont(verdana11);
1785 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1786 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1787 // shareSelections.setSelected(true);
1788 // shareSelections.setText(MessageManager
1789 // .getString("label.share_selection_across_views"));
1790 // JCheckBox followHighlight = new JCheckBox();
1791 // followHighlight.setFont(verdana11);
1792 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1793 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1794 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1795 // followHighlight.setSelected(true);
1796 // followHighlight.setText(MessageManager
1797 // .getString("label.scroll_highlighted_regions"));
1799 seqLimit.setFont(LABEL_FONT);
1800 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1801 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1802 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1803 smoothFont.setFont(LABEL_FONT);
1804 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1805 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1806 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1807 scaleProteinToCdna.setFont(LABEL_FONT);
1808 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1809 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1810 scaleProteinToCdna.setText(
1811 MessageManager.getString("label.scale_protein_to_cdna"));
1812 scaleProteinToCdna.setToolTipText(
1813 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1814 JLabel gapLabel = new JLabel();
1815 gapLabel.setFont(LABEL_FONT);
1816 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1817 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1818 JLabel fontLabel = new JLabel();
1819 fontLabel.setFont(LABEL_FONT);
1820 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1821 fontLabel.setText(MessageManager.getString("label.font"));
1822 fontSizeCB.setFont(LABEL_FONT);
1823 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1824 fontStyleCB.setFont(LABEL_FONT);
1825 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1826 fontNameCB.setFont(LABEL_FONT);
1827 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1828 gapSymbolCB.setFont(LABEL_FONT);
1829 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1830 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1831 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1832 gapSymbolCB.setRenderer(dlcr);
1834 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1835 startupCheckbox.setFont(LABEL_FONT);
1836 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1837 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1838 startupCheckbox.setSelected(true);
1839 startupFileTextfield.setFont(LABEL_FONT);
1840 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1841 final String tooltip = JvSwingUtils.wrapTooltip(true,
1842 MessageManager.getString("label.double_click_to_browse"));
1843 startupFileTextfield.setToolTipText(tooltip);
1844 startupFileTextfield.addMouseListener(new MouseAdapter()
1847 public void mouseClicked(MouseEvent e)
1849 if (e.getClickCount() > 1)
1851 startupFileTextfield_mouseClicked();
1856 sortby.setFont(LABEL_FONT);
1857 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1858 JLabel sortLabel = new JLabel();
1859 sortLabel.setFont(LABEL_FONT);
1860 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1861 sortLabel.setText(MessageManager.getString("label.sort_by"));
1862 sortAnnBy.setFont(LABEL_FONT);
1863 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1864 JLabel sortAnnLabel = new JLabel();
1865 sortAnnLabel.setFont(LABEL_FONT);
1866 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1867 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1868 sortAutocalc.setFont(LABEL_FONT);
1869 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1871 JPanel annsettingsPanel = new JPanel();
1872 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1873 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1874 annsettingsPanel.setBorder(new EtchedBorder());
1875 visualTab.add(annsettingsPanel);
1876 Border jb = new EmptyBorder(1, 1, 4, 5);
1877 annotations.setBorder(jb);
1878 showOccupancy.setBorder(jb);
1879 quality.setBorder(jb);
1880 conservation.setBorder(jb);
1881 identity.setBorder(jb);
1882 showConsensbits.setBorder(jb);
1883 showGroupbits.setBorder(jb);
1884 showGroupConsensus.setBorder(jb);
1885 showGroupConservation.setBorder(jb);
1886 showConsensHistogram.setBorder(jb);
1887 showConsensLogo.setBorder(jb);
1889 JPanel autoAnnotSettings = new JPanel();
1890 annsettingsPanel.add(autoAnnotSettings);
1891 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1892 autoAnnotSettings.add(annotations);
1893 autoAnnotSettings.add(quality);
1894 // second row of autoannotation box
1895 autoAnnotSettings = new JPanel();
1896 annsettingsPanel.add(autoAnnotSettings);
1898 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1899 autoAnnotSettings.add(conservation);
1900 autoAnnotSettings.add(identity);
1901 autoAnnotSettings.add(showOccupancy);
1902 autoAnnotSettings.add(showGroupbits);
1903 autoAnnotSettings.add(showGroupConservation);
1904 autoAnnotSettings.add(showGroupConsensus);
1905 autoAnnotSettings.add(showConsensbits);
1906 autoAnnotSettings.add(showConsensHistogram);
1907 autoAnnotSettings.add(showConsensLogo);
1909 JPanel tooltipSettings = new JPanel();
1910 tooltipSettings.setBorder(new TitledBorder(
1911 MessageManager.getString("label.sequence_id_tooltip")));
1912 tooltipSettings.setBounds(173, 140, 220, 62);
1913 tooltipSettings.setLayout(new GridLayout(2, 1));
1914 tooltipSettings.add(showDbRefTooltip);
1915 tooltipSettings.add(showNpTooltip);
1916 visualTab.add(tooltipSettings);
1918 wrap.setFont(LABEL_FONT);
1919 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1920 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1921 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1922 rightAlign.setFont(LABEL_FONT);
1923 rightAlign.setForeground(Color.black);
1924 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1925 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1926 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1927 idItalics.setFont(LABEL_FONT_ITALIC);
1928 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1929 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1931 MessageManager.getString("label.sequence_name_italics"));
1932 openoverv.setFont(LABEL_FONT);
1933 openoverv.setActionCommand(
1934 MessageManager.getString("label.open_overview"));
1935 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1936 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1937 openoverv.setText(MessageManager.getString("label.open_overview"));
1938 JPanel jPanel2 = new JPanel();
1939 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1940 jPanel2.setLayout(new GridLayout(14, 1));
1941 jPanel2.add(fullScreen);
1942 jPanel2.add(openoverv);
1943 jPanel2.add(seqLimit);
1944 jPanel2.add(rightAlign);
1945 jPanel2.add(fontLabel);
1946 jPanel2.add(showUnconserved);
1947 jPanel2.add(idItalics);
1948 jPanel2.add(smoothFont);
1949 jPanel2.add(scaleProteinToCdna);
1950 jPanel2.add(gapLabel);
1952 jPanel2.add(sortLabel);
1953 jPanel2.add(sortAnnLabel);
1954 jPanel2.add(startupCheckbox);
1955 visualTab.add(jPanel2);
1956 visualTab.add(startupFileTextfield);
1957 visualTab.add(sortby);
1958 visualTab.add(sortAnnBy);
1959 visualTab.add(sortAutocalc);
1960 visualTab.add(gapSymbolCB);
1961 visualTab.add(fontNameCB);
1962 visualTab.add(fontSizeCB);
1963 visualTab.add(fontStyleCB);
1968 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1971 protected void loadLastSavedBackupsOptions()
1973 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1974 .getSavedBackupEntry();
1976 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1978 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1979 .createBackupFilesPresetEntry(Cache
1980 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1981 if (backupfilesCustomEntry == null)
1983 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1984 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1986 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1987 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1988 backupfilesCustomEntry);
1990 setComboIntStringKey(backupfilesPresetsCombo,
1991 Cache.getDefault(BackupFiles.NS + "_PRESET",
1992 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1994 backupsSetOptions(savedPreset);
1996 backupsOptionsSetEnabled();
1997 updateBackupFilesExampleLabel();
2000 private boolean warnAboutSuffixReverseChange()
2002 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2003 .getSavedBackupEntry();
2004 boolean savedSuffixReverse = bfpe.reverse;
2005 int savedSuffixDigits = bfpe.digits;
2006 String savedSuffixTemplate = bfpe.suffix;
2008 boolean nowSuffixReverse = suffixReverse.isSelected();
2009 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2010 String nowSuffixTemplate = suffixTemplate.getText();
2011 return nowSuffixReverse != savedSuffixReverse
2012 && nowSuffixDigits == savedSuffixDigits
2013 && nowSuffixTemplate != null
2014 && nowSuffixTemplate.equals(savedSuffixTemplate);
2018 * Initialises the Backups tabbed panel.
2022 private JPanel initBackupsTab()
2024 JPanel backupsTab = new JPanel();
2025 backupsTab.setBorder(new TitledBorder(
2026 MessageManager.getString("label.backup_files")));
2027 backupsTab.setLayout(new GridBagLayout());
2029 GridBagConstraints gbc = new GridBagConstraints();
2032 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2033 gbc.fill = GridBagConstraints.NONE;
2035 initBackupsTabPresetsPanel();
2036 initBackupsTabSuffixPanel();
2037 initBackupsTabKeepFilesPanel();
2038 initBackupsTabFilenameExamplesPanel();
2040 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2042 .setText(MessageManager.getString("label.enable_backupfiles"));
2043 enableBackupFiles.addActionListener(new ActionListener()
2046 public void actionPerformed(ActionEvent e)
2048 // enable other options only when the first is checked
2049 backupsOptionsSetEnabled();
2053 // enable checkbox 1 col
2057 gbc.gridy = 0; // row 0
2058 backupsTab.add(enableBackupFiles, gbc);
2060 // summary of scheme box (over two rows)
2064 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2065 gbc.fill = GridBagConstraints.BOTH;
2066 backupsTab.add(exampleFilesPanel, gbc);
2068 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2069 gbc.fill = GridBagConstraints.NONE;
2071 // fill empty space on right
2074 backupsTab.add(new JPanel(), gbc);
2079 gbc.gridy++; // row 1
2080 backupsTab.add(presetsPanel, gbc);
2082 // now using whole row
2087 gbc.gridy++; // row 2
2088 backupsTab.add(keepfilesPanel, gbc);
2090 // filename strategy box
2091 gbc.gridy++; // row 3
2092 backupsTab.add(suffixPanel, gbc);
2095 gbc.gridy++; // row 4
2097 backupsTab.add(new JPanel(), gbc);
2099 backupsOptionsSetEnabled();
2103 private JPanel initBackupsTabPresetsPanel()
2106 String title = MessageManager.getString("label.schemes");
2108 presetsPanel.setLayout(new GridBagLayout());
2110 GridBagConstraints gbc = new GridBagConstraints();
2113 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2114 gbc.fill = GridBagConstraints.NONE;
2122 presetsComboLabel = new JLabel(title + ":");
2123 presetsPanel.add(presetsComboLabel, gbc);
2125 List<Object> entries = Arrays.asList(
2126 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2127 List<String> tooltips = Arrays.asList(
2128 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2129 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2132 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2134 backupfilesPresetsCombo
2135 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2139 backupfilesPresetsCombo.addActionListener(new ActionListener()
2142 public void actionPerformed(ActionEvent e)
2144 int key = getComboIntStringKey(backupfilesPresetsCombo);
2145 if (!customiseCheckbox.isSelected())
2147 backupfilesPresetsComboLastSelected = key;
2149 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2151 if (customiseCheckbox.isSelected())
2153 // got here by clicking on customiseCheckbox so don't change the
2155 backupfilesCustomOptionsSetEnabled();
2159 backupsTabUpdatePresets();
2160 backupfilesCustomOptionsSetEnabled();
2165 customiseCheckbox.setSelected(false);
2166 backupsTabUpdatePresets();
2167 backupfilesCustomOptionsSetEnabled();
2172 // dropdown list of preset schemes
2174 presetsPanel.add(backupfilesPresetsCombo, gbc);
2176 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2177 revertButton.setToolTipText(
2178 MessageManager.getString("label.cancel_changes_description"));
2179 revertButton.addActionListener(new ActionListener()
2182 public void actionPerformed(ActionEvent e)
2185 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2186 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2187 backupfilesCustomOptionsSetEnabled();
2191 revertButton.setFont(LABEL_FONT);
2193 customiseCheckbox.setFont(LABEL_FONT);
2194 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2195 customiseCheckbox.addActionListener(new ActionListener()
2198 public void actionPerformed(ActionEvent e)
2200 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2201 if (customiseCheckbox.isSelected())
2203 backupfilesPresetsComboLastSelected = currently;
2204 setComboIntStringKey(backupfilesPresetsCombo,
2205 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2209 setComboIntStringKey(backupfilesPresetsCombo,
2210 backupfilesPresetsComboLastSelected);
2213 backupfilesCustomOptionsSetEnabled();
2216 customiseCheckbox.setToolTipText(
2217 MessageManager.getString("label.customise_description"));
2219 // customise checkbox
2222 presetsPanel.add(customiseCheckbox, gbc);
2224 // "Cancel changes" button (aligned with combo box above)
2226 presetsPanel.add(revertButton, gbc);
2228 return presetsPanel;
2231 private JPanel initBackupsTabFilenameExamplesPanel()
2233 String title = MessageManager.getString("label.scheme_examples");
2234 TitledBorder tb = new TitledBorder(title);
2235 exampleFilesPanel.setBorder(tb);
2236 exampleFilesPanel.setLayout(new GridBagLayout());
2238 backupfilesExampleLabel.setEditable(false);
2239 backupfilesExampleLabel
2240 .setBackground(exampleFilesPanel.getBackground());
2242 updateBackupFilesExampleLabel();
2244 GridBagConstraints gbc = new GridBagConstraints();
2247 gbc.fill = GridBagConstraints.NONE;
2248 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2250 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2251 return exampleFilesPanel;
2254 private void backupsTabUpdatePresets()
2256 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2259 String value = entry.v;
2261 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2265 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2271 "Preset '" + value + "' [key:" + key + "] not implemented");
2274 // Custom options will now be enabled when the customiseCheckbox is checked
2275 // (performed above)
2276 // backupfilesCustomOptionsSetEnabled();
2277 updateBackupFilesExampleLabel();
2280 protected int getComboIntStringKey(
2281 JComboBox<Object> backupfilesPresetsCombo2)
2283 IntKeyStringValueEntry e;
2286 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2288 } catch (Exception ex)
2291 "Problem casting Combo entry to IntKeyStringValueEntry.");
2294 return e != null ? e.k : 0;
2297 protected void setComboIntStringKey(
2298 JComboBox<Object> backupfilesPresetsCombo2, int key)
2300 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2302 IntKeyStringValueEntry e;
2305 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2306 } catch (Exception ex)
2309 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2314 backupfilesPresetsCombo2.setSelectedIndex(i);
2318 // backupsTabUpdatePresets();
2321 private JPanel initBackupsTabSuffixPanel()
2323 suffixPanel.setBorder(new TitledBorder(
2324 MessageManager.getString("label.backup_filename_strategy")));
2325 suffixPanel.setLayout(new GridBagLayout());
2328 .setText(MessageManager.getString("label.append_to_filename"));
2329 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2330 suffixTemplateLabel.setFont(LABEL_FONT);
2332 final String tooltip = JvSwingUtils.wrapTooltip(true,
2333 MessageManager.getString("label.append_to_filename_tooltip"));
2334 suffixTemplate.setToolTipText(tooltip);
2335 suffixTemplate.addActionListener(new ActionListener()
2338 public void actionPerformed(ActionEvent e)
2340 updateBackupFilesExampleLabel();
2341 backupfilesCustomOptionsSetEnabled();
2342 backupfilesRevertButtonSetEnabled(true);
2346 suffixTemplate.addKeyListener(new KeyListener()
2349 public void keyReleased(KeyEvent e)
2351 updateBackupFilesExampleLabel();
2352 backupfilesCustomOptionsSetEnabled();
2353 backupfilesRevertButtonSetEnabled(true);
2357 public void keyPressed(KeyEvent e)
2361 // disable use of ':' or '/' or '\'
2363 public void keyTyped(KeyEvent e)
2365 char c = e.getKeyChar();
2366 if (c == ':' || c == '/' || c == '\\')
2368 // don't process ':' or '/' or '\'
2377 .setText(MessageManager.getString("label.index_digits"));
2378 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2379 suffixDigitsLabel.setFont(LABEL_FONT);
2380 ChangeListener c = new ChangeListener()
2383 public void stateChanged(ChangeEvent e)
2385 backupfilesRevertButtonSetEnabled(true);
2386 updateBackupFilesExampleLabel();
2390 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2391 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2393 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2394 MessageManager.getString("label.increment_index"));
2395 suffixReverse.addActionListener(new ActionListener()
2398 public void actionPerformed(ActionEvent e)
2400 boolean okay = true;
2401 if (warnAboutSuffixReverseChange())
2404 okay = confirmSuffixReverseChange();
2408 backupfilesRevertButtonSetEnabled(true);
2409 updateBackupFilesExampleLabel();
2413 boolean savedSuffixReverse = BackupFilesPresetEntry
2414 .getSavedBackupEntry().reverse;
2415 suffixReverse.setSelected(savedSuffixReverse);
2420 GridBagConstraints sgbc = new GridBagConstraints();
2422 // first row (template text box)
2423 sgbc.anchor = GridBagConstraints.WEST;
2427 sgbc.gridheight = 1;
2430 sgbc.fill = GridBagConstraints.NONE;
2431 suffixPanel.add(suffixTemplateLabel, sgbc);
2434 sgbc.fill = GridBagConstraints.HORIZONTAL;
2435 suffixPanel.add(suffixTemplate, sgbc);
2437 // second row (number of digits spinner)
2441 sgbc.fill = GridBagConstraints.NONE;
2442 suffixPanel.add(suffixDigitsLabel, sgbc);
2445 sgbc.fill = GridBagConstraints.HORIZONTAL;
2446 suffixPanel.add(suffixDigitsSpinner, sgbc);
2448 // third row (forward order radio selection)
2451 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2452 sgbc.fill = GridBagConstraints.HORIZONTAL;
2453 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2455 // fourth row (reverse order radio selection)
2457 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2461 private boolean confirmSuffixReverseChange()
2463 boolean ret = false;
2464 String warningMessage = MessageManager
2465 .getString("label.warning_confirm_change_reverse");
2466 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2468 MessageManager.getString("label.change_increment_decrement"),
2469 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2471 ret = (confirm == JvOptionPane.YES_OPTION);
2475 private JPanel initBackupsTabKeepFilesPanel()
2477 keepfilesPanel.setBorder(
2478 new TitledBorder(MessageManager.getString("label.keep_files")));
2479 keepfilesPanel.setLayout(new GridBagLayout());
2481 backupfilesKeepAll.setLabels(
2482 MessageManager.getString("label.keep_all_backup_files"),
2483 MessageManager.getString(
2484 "label.keep_only_this_number_of_backup_files"));
2485 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2488 public void actionPerformed(ActionEvent e)
2490 backupfilesRevertButtonSetEnabled(true);
2491 updateBackupFilesExampleLabel();
2494 backupfilesKeepAll.addActionListener(new ActionListener()
2497 public void actionPerformed(ActionEvent e)
2499 backupfilesRevertButtonSetEnabled(true);
2500 keepRollMaxOptionsEnabled();
2501 updateBackupFilesExampleLabel();
2505 ChangeListener c = new ChangeListener()
2508 public void stateChanged(ChangeEvent e)
2510 backupfilesRevertButtonSetEnabled(true);
2511 updateBackupFilesExampleLabel();
2515 setIntegerSpinner(backupfilesRollMaxSpinner,
2516 BackupFilesPresetEntry.ROLLMAXMIN,
2517 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2519 backupfilesConfirmDelete.setLabels(
2520 MessageManager.getString("label.always_ask"),
2521 MessageManager.getString("label.auto_delete"));
2522 backupfilesConfirmDelete.addActionListener(new ActionListener()
2525 public void actionPerformed(ActionEvent e)
2527 backupfilesRevertButtonSetEnabled(true);
2530 // update the enabled section
2531 keepRollMaxOptionsEnabled();
2533 GridBagConstraints kgbc = new GridBagConstraints();
2535 // first row (template text box)
2536 kgbc.anchor = GridBagConstraints.WEST;
2539 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2540 kgbc.gridheight = 1;
2543 kgbc.fill = GridBagConstraints.HORIZONTAL;
2544 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2550 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2551 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2554 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2555 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2557 // third row (indented)
2559 kgbc.insets = new Insets(0, 20, 0, 0);
2562 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2563 kgbc.fill = GridBagConstraints.HORIZONTAL;
2566 JPanel jp = new JPanel();
2567 jp.setLayout(new FlowLayout());
2568 oldBackupFilesLabel.setText(
2569 MessageManager.getString("label.autodelete_old_backup_files"));
2570 oldBackupFilesLabel.setFont(LABEL_FONT);
2571 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2572 jp.add(oldBackupFilesLabel);
2573 jp.add(backupfilesConfirmDelete.getTrueButton());
2574 jp.add(backupfilesConfirmDelete.getFalseButton());
2575 keepfilesPanel.add(jp, kgbc);
2577 return keepfilesPanel;
2580 protected void updateBackupFilesExampleLabel()
2582 int exampleindex = 12;
2583 String base = MessageManager.getString("label.filename") + ".fa";
2584 if (base == null || base.length() == 0)
2586 base = "file_name.fa";
2589 boolean reverse = suffixReverse.isSelected();
2590 boolean keepAll = backupfilesKeepAll.isSelected();
2592 String suffix = suffixTemplate.getText();
2595 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2596 if (suffix == null || suffix.length() == 0)
2598 backupfilesExampleLabel
2599 .setText(MessageManager.getString("label.no_backup_files"));
2600 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2604 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2605 rollMax = rollMax < 1 ? 1 : rollMax;
2607 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2612 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2613 digits = digits < 1 ? 1 : digits;
2615 int lowersurround = 2;
2616 int uppersurround = 0;
2617 StringBuilder exampleSB = new StringBuilder();
2618 boolean firstLine = true;
2624 int max = keepAll ? exampleindex : rollMax;
2625 for (int index = min; index <= max; index++)
2627 if (index == min + lowersurround && index < max - uppersurround - 1)
2629 exampleSB.append("\n...");
2632 else if (index > min + lowersurround && index < max - uppersurround)
2644 exampleSB.append("\n");
2647 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2648 base, suffix, digits));
2651 // no extra text needed
2653 else if (index == min)
2655 String newest = MessageManager.getString("label.braced_newest");
2656 if (newest != null && newest.length() > 0)
2658 exampleSB.append(" " + newest);
2661 else if (index == max)
2663 String oldest = MessageManager.getString("label.braced_oldest");
2664 if (oldest != null && oldest.length() > 0)
2666 exampleSB.append(" " + oldest);
2675 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2676 : exampleindex - rollMax + 1;
2677 int max = exampleindex;
2679 for (int index = min; index <= max; index++)
2682 if (index == min + lowersurround && index < max - uppersurround - 1)
2684 exampleSB.append("\n...");
2687 else if (index > min + lowersurround && index < max - uppersurround)
2699 exampleSB.append("\n");
2702 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2703 base, suffix, digits));
2706 // no extra text needed
2708 else if (index == min)
2710 String oldest = MessageManager.getString("label.braced_oldest");
2711 if (oldest != null && oldest.length() > 0)
2713 exampleSB.append(" " + oldest);
2716 else if (index == max)
2718 String newest = MessageManager.getString("label.braced_newest");
2719 if (newest != null && newest.length() > 0)
2721 exampleSB.append(" " + newest);
2729 // add some extra empty lines to pad out the example files box. ugh, please
2731 // me how to do this better
2732 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2733 if (remainingLines > 0)
2735 for (int i = 0; i < remainingLines; i++)
2737 exampleSB.append("\n ");
2742 backupfilesExampleLabel.setText(exampleSB.toString());
2745 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2746 boolean useExistingVal, ChangeListener c)
2753 i = ((Integer) s.getValue()).intValue();
2754 } catch (Exception e)
2757 "Exception casting the initial value of s.getValue()");
2761 setIntegerSpinner(s, min, max, i, c);
2764 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2767 // integer spinner for number of digits
2776 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2779 s.addChangeListener(c);
2783 protected static int getSpinnerInt(JSpinner s, int def)
2789 i = (Integer) s.getValue();
2790 } catch (Exception e)
2792 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2797 private void keepRollMaxOptionsEnabled()
2799 boolean enabled = backupfilesKeepAll.isEnabled()
2800 && !backupfilesKeepAll.isSelected();
2801 oldBackupFilesLabel.setEnabled(enabled);
2802 backupfilesRollMaxSpinner.setEnabled(enabled);
2803 backupfilesConfirmDelete.setEnabled(enabled);
2806 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2808 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2809 && customiseCheckbox.isSelected() && suffixTemplate.getText()
2810 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2811 keepfilesPanel.setEnabled(enabled);
2812 backupfilesKeepAll.setEnabled(enabled);
2813 oldBackupFilesLabel.setEnabled(enabled);
2814 keepRollMaxOptionsEnabled();
2817 private void backupfilesSuffixTemplateDigitsSetEnabled()
2819 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2820 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2821 suffixDigitsLabel.setEnabled(enabled);
2822 suffixDigitsSpinner.setEnabled(enabled);
2823 suffixReverse.setEnabled(enabled);
2826 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2828 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2829 && customiseCheckbox.isSelected();
2830 suffixPanel.setEnabled(enabled);
2831 suffixTemplateLabel.setEnabled(enabled);
2832 suffixTemplate.setEnabled(enabled);
2833 backupfilesSuffixTemplateDigitsSetEnabled();
2836 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2838 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2839 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2840 revertButton.setEnabled(enabled);
2843 private boolean backupfilesCustomChanged()
2845 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2846 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2847 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2848 return !custom.equals(current);
2851 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2853 String suffix = suffixTemplate.getText();
2854 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2855 boolean reverse = suffixReverse.isSelected();
2856 boolean keepAll = backupfilesKeepAll.isSelected();
2857 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2858 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2860 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2861 reverse, keepAll, rollMax, confirmDelete);
2866 protected void backupfilesCustomOptionsSetEnabled()
2868 boolean enabled = customiseCheckbox.isSelected();
2870 backupfilesRevertButtonSetEnabled(enabled);
2871 backupfilesSuffixTemplateSetEnabled(enabled);
2872 backupfilesKeepAllSetEnabled(enabled);
2875 private void backupfilesSummarySetEnabled()
2877 boolean enabled = enableBackupFiles.isSelected();
2878 backupfilesExampleLabel.setEnabled(enabled);
2879 exampleFilesPanel.setEnabled(enabled);
2882 private void backupfilesPresetsSetEnabled()
2884 boolean enabled = enableBackupFiles.isSelected();
2885 presetsPanel.setEnabled(enabled);
2886 presetsComboLabel.setEnabled(enabled);
2887 backupfilesPresetsCombo.setEnabled(enabled);
2888 customiseCheckbox.setEnabled(enabled);
2889 revertButton.setEnabled(enabled);
2892 protected void backupsOptionsSetEnabled()
2894 backupfilesPresetsSetEnabled();
2895 backupfilesSummarySetEnabled();
2896 backupfilesCustomOptionsSetEnabled();
2899 protected void backupsSetOptions(String suffix, int digits,
2900 boolean reverse, boolean keepAll, int rollMax,
2901 boolean confirmDelete)
2903 suffixTemplate.setText(suffix);
2904 suffixDigitsSpinner.setValue(digits);
2905 suffixReverse.setSelected(reverse);
2906 backupfilesKeepAll.setSelected(keepAll);
2907 backupfilesRollMaxSpinner.setValue(rollMax);
2908 backupfilesConfirmDelete.setSelected(confirmDelete);
2911 protected void backupsSetOptions(BackupFilesPresetEntry p)
2913 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2917 protected void autoIdWidth_actionPerformed()
2919 // TODO Auto-generated method stub
2923 protected void userIdWidth_actionPerformed()
2925 // TODO Auto-generated method stub
2929 protected void maxColour_actionPerformed(JPanel panel)
2933 protected void minColour_actionPerformed(JPanel panel)
2937 protected void gapColour_actionPerformed(JPanel panel)
2941 protected void hiddenColour_actionPerformed(JPanel panel)
2945 protected void showunconserved_actionPerformed(ActionEvent e)
2947 // TODO Auto-generated method stub
2951 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2955 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2965 public void ok_actionPerformed(ActionEvent e)
2975 public void cancel_actionPerformed(ActionEvent e)
2985 public void annotations_actionPerformed(ActionEvent e)
2992 public void startupFileTextfield_mouseClicked()
2996 public void newLink_actionPerformed(ActionEvent e)
3001 public void editLink_actionPerformed(ActionEvent e)
3006 public void deleteLink_actionPerformed(ActionEvent e)
3011 public void defaultBrowser_mouseClicked(MouseEvent e)
3016 public void linkURLList_keyTyped(KeyEvent e)
3021 public void setProxyAuthEnabled()
3023 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3024 proxyAuthUsernameLabel.setEnabled(enabled);
3025 proxyAuthPasswordLabel.setEnabled(enabled);
3026 passwordNotStoredLabel.setEnabled(enabled);
3027 proxyAuthUsernameTB.setEnabled(enabled);
3028 proxyAuthPasswordTB.setEnabled(enabled);
3031 public void setCustomProxyEnabled()
3033 boolean enabled = customProxy.isSelected();
3034 portLabel.setEnabled(enabled);
3035 serverLabel.setEnabled(enabled);
3036 portLabel2.setEnabled(enabled);
3037 serverLabel2.setEnabled(enabled);
3038 httpLabel.setEnabled(enabled);
3039 httpsLabel.setEnabled(enabled);
3040 proxyServerHttpTB.setEnabled(enabled);
3041 proxyPortHttpTB.setEnabled(enabled);
3042 proxyServerHttpsTB.setEnabled(enabled);
3043 proxyPortHttpsTB.setEnabled(enabled);
3044 proxyAuth.setEnabled(enabled);
3045 setProxyAuthEnabled();
3048 public void proxyType_actionPerformed()
3050 setCustomProxyEnabled();
3053 public void proxyAuth_actionPerformed()
3055 setProxyAuthEnabled();
3059 * Customer renderer for JTable: supports column of radio buttons
3061 public class RadioButtonRenderer extends JRadioButton
3062 implements TableCellRenderer
3064 public RadioButtonRenderer()
3066 setHorizontalAlignment(CENTER);
3067 setToolTipText(MessageManager.getString("label.urltooltip"));
3071 public Component getTableCellRendererComponent(JTable table,
3072 Object value, boolean isSelected, boolean hasFocus, int row,
3075 setSelected((boolean) value);
3077 // set colours to match rest of table
3080 setBackground(table.getSelectionBackground());
3081 setForeground(table.getSelectionForeground());
3085 setBackground(table.getBackground());
3086 setForeground(table.getForeground());
3093 * Customer cell editor for JTable: supports column of radio buttons in
3094 * conjunction with renderer
3096 public class RadioButtonEditor extends AbstractCellEditor
3097 implements TableCellEditor
3099 private JRadioButton button = new JRadioButton();
3101 public RadioButtonEditor()
3103 button.setHorizontalAlignment(SwingConstants.CENTER);
3104 this.button.addActionListener(new ActionListener()
3107 public void actionPerformed(ActionEvent e)
3109 fireEditingStopped();
3115 public Component getTableCellEditorComponent(JTable table, Object value,
3116 boolean isSelected, int row, int column)
3118 button.setSelected((boolean) value);
3123 public Object getCellEditorValue()
3125 return button.isSelected();